16#include <communications.h>
17#include <Postraitement.h>
20Implemente_instanciable_sans_constructeur_ni_destructeur(
Sonde_Int,
"Sonde_Int",
Objet_U);
48 Probleme_base& pb = mon_post->probleme();
50 Motcle accolade_fermee(
"}");
59 for (
int i=0; i<liste_noms.size(); i++)
61 if (liste_noms[i]==motlu)
63 OBS_PTR(IntVect) ref_tab;
65 mon_tableau = ref_tab;
68 Cerr <<
"The problem does not have the array " << motlu << finl;
78 Motcles les_motcles(6);
80 les_motcles[0] =
"periode";
81 les_motcles[1] =
"point";
82 les_motcles[2] =
"points";
83 les_motcles[3] =
"segment";
84 les_motcles[4] =
"plan";
85 les_motcles[5] =
"volume";
88 while ((fait(0) != 1) || (fait(1) != 1))
91 if (motlu == accolade_fermee)
93 Cerr <<
"Error while reading the probe " << nom_ <<finl;
94 Cerr <<
"The data of the probe were not defined" << finl;
97 int rang=les_motcles.search(motlu);
100 Cerr <<
"Error while reading the probe " << nom_ <<finl;
101 Cerr << motlu <<
" is not understood; the keywords understood are : " << finl;
119 les_positions_.resize(nbre_points,
dimension);
121 for (
int i=0; i<nbre_points; i++)
123 is >> les_positions_(i,j);
136 les_positions_.resize(nbre_points,
dimension);
143 dx(i)=(extremite(i)-origine(i))/(nbre_points-1);
144 for (i=0; i<nbre_points; i++)
146 les_positions_(i,j)=origine(j)+i*dx(j);
161 nbre_points=nbre_points1*nbre_points2;
162 les_positions_.resize(nbre_points,
dimension);
171 dx1(i)=(extremite1(i)-origine(i))/(nbre_points1-1);
173 dx2(i)=(extremite2(i)-origine(i))/(nbre_points2-1);
174 for (i=0; i<nbre_points1; i++)
175 for (j=0; j<nbre_points2; j++)
177 les_positions_(i*nbre_points2+j,k)=origine(k)+i*dx1(k)+j*dx2(k);
195 nbre_points=nbre_points1*nbre_points2*nbre_points3;
196 les_positions_.resize(nbre_points,
dimension);
207 dx1(i)=(extremite1(i)-origine(i))/(nbre_points1-1);
209 dx2(i)=(extremite2(i)-origine(i))/(nbre_points2-1);
211 dx3(i)=(extremite3(i)-origine(i))/(nbre_points3-1);
212 for (i=0; i<nbre_points1; i++)
213 for (j=0; j<nbre_points2; j++)
214 for (
int m=0; m<nbre_points3; m++)
216 les_positions_(i*nbre_points2*nbre_points1+j*nbre_points1+m,k)=origine(k)+i*dx1(k)+j*dx2(k)+m*dx3(k);
221 Cerr << motlu <<
"is not yet understood!" << finl;
228 if ( (fait[0] == 0) || (fait[1] == 0) )
230 Cerr <<
"Error while reading the probe " << nom_ << finl;
231 Cerr <<
"The data of the probe have not been properly defined" << finl;
235 const Domaine& le_dom =pb.
domaine();
248 if (mon_post->noms_fichiers_sondes().contient(nom_)==0)
249 mon_post->noms_fichiers_sondes().add(nom_);
252 Cerr <<
"The filename " << nom_ <<
" is used several times for probes." << finl;
253 Cerr <<
"A probe must have a unique filename to avoid writing conflicts." << finl;
269 int nbre_points = les_positions_.
dimension(0);
270 elem_.resize(nbre_points);
272 for (
int i=0; i<nbre_points; i++)
275 Cerr <<
"The point number " << i+1 <<
" of probe " << nom_ << finl;
276 Cerr <<
"is outside of the computational domain" << finl;
278 if (sub_type(IntTab,mon_tableau.valeur()))
280 const IntTab& tab_val =
static_cast<const IntTab&
>(mon_tableau.valeur());
281 valeurs.resize(nbre_points,tab_val.
dimension(1));
284 valeurs.
resize(nbre_points);
306 s.
setf(ios::scientific);
310 if (dim==0 || dim==1)
313 int nbre_points = les_positions_.dimension(0);
314 s <<
"# " << nom_fich << finl;
316 for(
int i=0; i<nbre_points; i++)
318 s <<
" x=" << p(i,0) <<
" y=" << p(i,1) ;
325 s <<
"TRUST Version1 01/09/96" << finl;
327 s <<
"TRUST" << finl;
328 s <<
"GRILLE" << finl;
329 Nom nom_grille(
"Grille");
330 Nom nom_topologie(
"Topologie");
333 nom_topologie +=
"_";
334 nom_topologie += nom_;
336 int nbre_points = les_positions_.
dimension(0);
338 double xn,yn,zn,norme;
341 xn=(p(1,2)-p(0,2))*(p(nbre_points1,1)
342 -p(0,1))-(p(1,1)-p(0,1))*(p(nbre_points1,2)-p(0,2));
343 yn=(p(1,0)-p(0,0))*(p(nbre_points1,2)-p(0,2))
344 -(p(1,2)-p(0,2))*(p(nbre_points1,0)-p(0,0));
352 zn=(p(1,1)-p(0,1))*(p(nbre_points1,0)-p(0,0))
353 -(p(1,0)-p(0,0))*(p(nbre_points1,1)-p(0,1));
354 norme=std::fabs(xn)+std::fabs(yn)+std::fabs(zn);
358 s << nom_grille <<
" 3 " << 2*nbre_points << finl;
360 for(i=0; i<nbre_points; i++)
362 s << p(i,0) <<
" " << p(i,1) ;
364 else if (
dimension==2) s <<
" 0." << finl;
366 for(i=0; i<nbre_points; i++)
368 s << p(i,0)+xn <<
" " << p(i,1)+yn ;
369 if (
dimension==3) s <<
" " << p(i,2)+zn << finl;
370 else if (
dimension==2) s <<
" " << zn << finl;
372 s <<
"TOPOLOGIE" << finl;
373 s << nom_topologie <<
" " << nom_grille << finl;
374 s <<
"MAILLE" << finl;
375 s << (nbre_points1-1)*(nbre_points2-1) << finl;
376 for(
int j=0; j<nbre_points2-1; j++)
377 for(i=0; i<nbre_points1-1; i++)
379 k=j*nbre_points1+i+1;
381 s <<
"VOXEL8 " << k <<
" " << k+1 <<
" ";
382 s << k+nbre_points1 <<
" " << k+nbre_points1+1;
383 s <<
" " << kn <<
" " << kn+1 <<
" " << kn+nbre_points1;
384 s <<
" " << kn+nbre_points1+1 << finl;
391 s <<
"TRUST Version1 01/09/96" << finl;
393 s <<
"TRUST" << finl;
394 s <<
"GRILLE" << finl;
395 Nom nom_grille(
"Grille");
396 Nom nom_topologie(
"Topologie");
399 nom_topologie +=
"_";
400 nom_topologie += nom_;
402 int nbre_points = les_positions_.
dimension(0);
404 s << nom_grille <<
" 3 " << nbre_points << finl;
406 for(i=0; i<nbre_points; i++)
408 s << p(i,0) <<
" " << p(i,1) ;
409 s <<
" " << p(i,2) << finl;
411 s <<
"TOPOLOGIE" << finl;
412 s << nom_topologie <<
" " << nom_grille << finl;
413 s <<
"MAILLE" << finl;
414 s << (nbre_points1-1)*(nbre_points2-1)*(nbre_points3-1) << finl;
415 for(
int m=0; m<nbre_points3-1; m++)
416 for(
int j=0; j<nbre_points2-1; j++)
417 for(i=0; i<nbre_points1-1; i++)
419 k=m*nbre_points2*nbre_points1+j*nbre_points1+i+1;
420 kn=k+nbre_points2*nbre_points1;
421 s <<
"VOXEL8 " << k <<
" " << k+1 <<
" ";
422 s << k+nbre_points1 <<
" " << k+nbre_points1+1;
423 s <<
" " << kn <<
" " << kn+1 <<
" " << kn+nbre_points1;
424 s <<
" " << kn+nbre_points1+1 << finl;
441 modf((un_temps-tinit)/periode, &nb);
458 if (sub_type(IntTab,mon_tableau.valeur()))
460 const IntTab& val_tab=
static_cast<const IntTab&
>(mon_tableau.valeur());
464 int nbre_points = les_positions_.dimension(0);
466 for (
int i=0; i<nbre_points; i++)
467 for (
int j=0; j<nval; j++)
468 valeurs(i,j) = val_tab(elem_(i),j);
476 for(p=1; p<nbproc; p++)
478 recevoir(valeurs_pe,p,0,p);
479 int n1=valeurs.dimension(0);
480 int n2=valeurs.dimension(1);
482 for(
int i=0; i<n1; i++)
485 val_max = std::max(std::abs(valeurs(i,k)),std::abs(valeurs_pe(i,k)));
486 if(val_max==(std::abs(valeurs_pe(i,k))))
487 valeurs(i,k)=valeurs_pe(i,k);
491 if (dim==0 || dim==1)
494 for(
int i=0; i<valeurs.dimension(0); i++)
495 for(
int k=0; k<valeurs.dimension(1); k++)
496 fichier() <<
" " << valeurs(i,k);
503 else if (dim==2 || dim==3)
506 Nom nom_topologie(
"Topologie");
507 nom_topologie +=
"_";
508 nom_topologie += nom_;
509 fichier() <<
"TEMPS " << un_temps <<
"\n";
510 fichier() <<
"CHAMPOINT " << nom_ <<
" " << nom_topologie
511 <<
" " << un_temps <<
"\n";
512 fichier() << nom_ <<
" " << nval <<
" " << unite <<
"\n";
515 fichier() <<
"type1 " << nbp <<
"\n";
517 for(i=0; i<nbre_points; i++)
520 for(
int j=0; j<valeurs.dimension(1); j++)
521 fichier() <<
" " << valeurs(i,j);
528 for(i=0; i<nbre_points; i++)
531 for(
int j=0; j<valeurs.dimension(1); j++)
532 fichier() <<
" " << valeurs(i,j);
545 const IntVect& val_tab=
static_cast<const IntVect&
>(mon_tableau.valeur());
550 int nbre_points = les_positions_.dimension(0);
552 for (
int i=0; i<nbre_points; i++)
553 valeurs(i) = val_tab(elem_(i));
561 for(p=1; p<nbproc; p++)
563 recevoir(valeurs_pe,p,0,p);
565 for(
int i=0; i<valeurs.dimension(0); i++)
567 val_max = std::max(std::abs(valeurs(i)), std::abs(valeurs_pe(i)));
568 if(val_max == std::abs(valeurs_pe(i)))
569 valeurs(i)=valeurs_pe(i);
572 if (dim==0 || dim==1)
575 for(
int i=0; i<valeurs.dimension(0); i++)
576 fichier() <<
" " << valeurs(i);
583 else if (dim==2 || dim==3)
586 Nom nom_topologie(
"Topologie");
587 nom_topologie +=
"_";
588 nom_topologie += nom_;
589 fichier() <<
"TEMPS " << un_temps <<
"\n";
590 fichier() <<
"CHAMPOINT " << nom_ <<
" " << nom_topologie
591 <<
" " << un_temps <<
"\n";
592 fichier() << nom_ <<
" " << nval <<
" " << unite <<
"\n";
595 fichier() <<
"type0 " << nbp <<
"\n";
597 for(
int i=0; i<nbre_points; i++)
600 fichier() <<
" " << valeurs(i);
607 for(
int i=0; i<nbre_points; i++)
610 fichier() <<
" " << valeurs(i);
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Searches for the elements containing the points whose coordinates are specified.
Class defining operators and methods for all reading operation in an input flow (file,...
class Nom: a character string for naming TRUST objects.
Base class for TRUST objects (Objet_U).
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
const Domaine & domaine() const
Returns the domain associated with the problem.
virtual int a_pour_IntVect(const Motcle &, OBS_PTR(IntVect)&) const
static double mp_max(double)
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
SFichier & fichier()
Returns the output file stream used by the probe.
void ouvrir_fichier()
Opens the file associated with the probe.
const DoubleTab & les_positions() const
Returns the array of probed positions.
void associer_post(const Postraitement &)
Associates a post-processing object with the probe.
void initialiser(const Domaine &)
Initialises the probe.
Sonde_Int(const Nom &)
Constructor for a probe given its name.
void mettre_a_jour(double temps, double tinit)
Updates the probe in time and performs post-processing.
void postraiter(double)
Performs post-processing.
Sortie & flush() override
Forces the data in the buffer to be written to disk. Uses the ofstream class implementation.
void precision(int pre) override
void setf(IOS_FORMAT code) override
Base class for output streams.
void resize(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const