16#include <Random_process.h>
21#include <Domaine_IJK.h>
22#include <communications.h>
25#include <Interprete_bloc.h>
28#include <IJK_Lata_writer.h>
29#include <IJK_Navier_Stokes_tools.h>
30#include <LecFicDiffuse_JDD.h>
31#include <MaillerParallel.h>
34#include <Probleme_base.h>
35#include <Domaine_VF.h>
37#include <Ouvrir_fichier.h>
38#include <EcritureLectureSpecial.h>
41Implemente_instanciable_sans_constructeur_ni_destructeur(
Random_process,
"Random_process",
Objet_U ) ;
108 os <<
" semi_gen_et_modulo_reprise " << semi_gen_et_modulo_reprise_ <<
"\n";
109 os <<
" process_b " << process_flt <<
"\n";
118 param.ajouter(
"process_b",&process_flt);
132 param.ajouter(
"semi_gen_et_modulo_reprise",&semi_gen_et_modulo_reprise_,
Param::REQUIRED);
135 param.lire_avec_accolades(is);
142 semi_gen_et_modulo_reprise_[0]=0;
143 semi_gen_et_modulo_reprise_[1]=0;
154 int a_nl,
int a_nm,
int a_nn, std::string nom_fichier,
162 n_lmn = (2*nl+1)*(2*nm+1)*(2*nn+1);
164 eps_etoile = a_eps_etoile;
166 process = set_dimensions(process,2,3,n_lmn);
168 process_flt.resize(2*3*n_lmn);
169 semi_gen_et_modulo_reprise_.resize(2);
170 moke_gen_ = semi_gen_et_modulo_reprise_[0] ;
178 std::random_device rd {};
179 std::minstd_rand gen_support(rd());
182 else if (moke_gen_ >= 0)
186 long long_gen(2*semi_gen_et_modulo_reprise_[0] + semi_gen_et_modulo_reprise_[1]);
187 std::minstd_rand gen_support(long_gen);
198 Cerr <<
"moke_gen a une valeur anormale" << finl;
201 std::normal_distribution < > dist_support(0.,1.);
202 distribution = dist_support;
205 nom_sauvegarde_ = nom_sauvegarde;
206 nom_fichier_ = nom_fichier;
207 std::ofstream Detail_gen(nom_fichier_.c_str());
210 Detail_gen <<
"-------- RANDOM_PROCESS; detail de gen --------" << std::endl;
230 double Gaussian[2][3];
231 std::vector< std::vector< std:: vector < double > > > old_process;
232 int cpx, dir, l, m, n, ind;
234 old_process = process;
235 for (n=0; n<2*nn+1; n++)
236 for (m=0; m<2*nm+1; m++)
238 for (l=nl; l<2*nl+1; l++)
240 ind = (n*(2*nm+1) + m) * (2*nl+1) +l;
243 for (dir=0; dir<3; dir++)
245 for (cpx=0; cpx<2; cpx++)
247 Gaussian[cpx][dir] = distribution(gen);
248 process[cpx][dir][ind] = old_process[cpx][dir][ind]*(1-dt/tL);
249 process[cpx][dir][ind] += Gaussian[cpx][dir]*sqrt(2*eps_etoile*dt*pow(tL,2));
254 process[0][dir][n_lmn-ind] = process[0][dir][ind];
255 process[1][dir][n_lmn-ind] = - process[1][dir][ind];
268 int sorties_supplementaires(0);
269 std::ofstream Detail_gen(nom_fichier_.c_str(),std::ios_base::app);
273 double Gaussian[2][3];
276 ArrOfDouble old_process(process_flt);
281 for (
int n=0; n<2*nn+1; n++)
282 for (
int m=0; m<2*nm+1; m++)
284 for (
int l=0; l<2*nl+1; l++)
286 int ind_lmn = (n*(2*nm+1) + m) * (2*nl+1) +l;
287 for (
int dir=0; dir<3; dir++)
292 for (
int cpx=0; cpx<2; cpx++)
294 int ind_CDIlmn((cpx*n_dir+dir)*n_lmn+ind_lmn);
295 if (sorties_supplementaires)
296 Detail_gen << gen <<
" ";
297 Gaussian[cpx][dir] = distribution(gen);
298 if (sorties_supplementaires)
299 Detail_gen << gen << std::endl;
300 process_flt[ind_CDIlmn] = old_process[ind_CDIlmn]*(1-dt/tL);
301 process_flt[ind_CDIlmn] += Gaussian[cpx][dir]*sqrt(2.0*eps_etoile*(0.0+dt)/pow(tL,2));
310 if (sorties_supplementaires)
313 envoyer_broadcast(process_flt,0);
322 std::ofstream Detail_gen(nom_fichier_.c_str(),std::ios_base::app);
326 double Gaussian[2][3];
329 ArrOfDouble old_process(process_flt);
334 double coefficient_translation[2*3];
336 for (
int n=0; n<2*nn+1; n++)
337 for (
int m=0; m<2*nm+1; m++)
339 for (
int l=0; l<2*nl+1; l++)
341 int ind_lmn = (n*(2*nm+1) + m) * (2*nl+1) +l;
342 int ind_lmn_moins = (n*(2*nm+1) + m) * (2*nl+1) + (2*nl-l);
346 kappa[0] = - kmax + (l)*(2*kmax)/(2*nl);
347 kappa[1] = - kmax + (m)*(2*kmax)/(2*nm);
348 kappa[2] = - kmax + (n)*(2*kmax)/(2*nn);
351 if (!(std::fabs(kappa[0])<kmin && std::fabs(kappa[1])<kmin && std::fabs(kappa[2])<kmin))
353 for (
int dir=0; dir<3; dir++)
358 int ind_RD(0*n_dir+dir);
359 int ind_CD(1*n_dir+dir);
360 int ind_CDIlmn((1*n_dir+dir)*n_lmn+ind_lmn);
361 int ind_RDIlmn((0*n_dir+dir)*n_lmn+ind_lmn);
364 coefficient_translation[ind_RD] = cos(-1.*kappa[dir]*dt*advection_velocity[dir]);
365 coefficient_translation[ind_CD] = sin(-1.*kappa[dir]*dt*advection_velocity[dir]);
368 process_flt[ind_RDIlmn] = old_process[ind_RDIlmn]*coefficient_translation[ind_RD] - old_process[ind_CDIlmn]*coefficient_translation[ind_CD];
369 process_flt[ind_CDIlmn] = old_process[ind_RDIlmn]*coefficient_translation[ind_CD] + old_process[ind_CDIlmn]*coefficient_translation[ind_RD];
371 for (
int cpx=0; cpx<2; cpx++)
373 int ind_RCDIlmn((cpx*n_dir+dir)*n_lmn+ind_lmn);
374 Detail_gen << gen <<
" ";
375 Gaussian[cpx][dir] = distribution(gen);
376 Detail_gen << gen << std::endl;
377 process_flt[ind_RCDIlmn] = process_flt[ind_RCDIlmn]*(1-dt/tL);
378 process_flt[ind_RCDIlmn] += Gaussian[cpx][dir]*sqrt(2*eps_etoile*(0.0+dt)/pow(tL,2));
383 process_flt[(0*n_dir+dir)*n_lmn+(ind_lmn_moins)] = process_flt[(0*n_dir+dir)*n_lmn+(ind_lmn)];
384 process_flt[(1*n_dir+dir)*n_lmn+(ind_lmn_moins)] = - process_flt[(1*n_dir+dir)*n_lmn+(ind_lmn)];
390 envoyer_broadcast(process_flt,0);
396 std::ofstream Random_flux(nom_fichier_sortie.c_str(), std::ios::app);
402 Random_flux << std::endl <<
"time : " << t << std::endl << std::endl;
403 for (n=0; n<2*nn+1; n++)
404 for (m=0; m<2*nm+1; m++)
405 for (l=0; l<2*nl+1; l++)
407 ind = (n*(2*nm+1) + m) * (2*nl+1) +l;
408 Random_flux << l<<
","<<m<<
","<<n<<
"\t : ";
409 Random_flux << process[0][0][ind] <<
" + i" << process[1][0][ind]<<
", \t";
410 Random_flux << process[0][1][ind] <<
" + i" << process[1][1][ind]<<
", \t";
411 Random_flux << process[0][2][ind] <<
" + i" << process[1][2][ind]<<
", \t";
412 Random_flux << std::endl;
419 std::ofstream Random_flux(nom_fichier_sortie.c_str());
424 Random_flux << std::endl <<
"l,m,n, \t rb_x, \t cb_x, \t\t rb_y, \t cb_y, \t\t rb_z, \t cb_z \t";
425 Random_flux << std::endl;
428 for (n=0; n<2*nn+1; n++)
429 for (m=0; m<2*nm+1; m++)
430 for (l=0; l<2*nl+1; l++)
432 ind = (n*(2*nm+1) + m) * (2*nl+1) +l;
433 Random_flux << l<<
","<<m<<
","<<n<<
"\t,";
434 Random_flux << process[0][0][ind] <<
",\t" << process[1][0][ind]<<
", \t\t";
435 Random_flux << process[0][1][ind] <<
",\t" << process[1][1][ind]<<
", \t\t";
436 Random_flux << process[0][2][ind] <<
",\t" << process[1][2][ind]<<
"\t";
437 Random_flux << std::endl;
455 return semi_gen_et_modulo_reprise_[0];
Class defining operators and methods for all reading operation in an input flow (file,...
class Nom Une chaine de caractere pour nommer les objets de TRUST
classe Objet_U Cette classe est la classe de base des Objets de TRUST
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
void next_step2(double dt, int it)
void write(std::string nom_fichier_sortie, double temps)
void write_separate(std::string nom_fichier_sortie, double t)
std::vector< std::vector< std::vector< double > > > get_b()
void next_step3(ArrOfDouble &advection_velocity, double dt, int it)
ArrOfDouble & get_b_flt()
void next_step(double dt, int it)
void initialise(double eps_etoile, double tL, int nl, int nm, int nn, std::string nom_fichier_sortie, Nom nom_sauvegarde)
Classe de base des flux de sortie.