TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sonde.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Sonde_included
17#define Sonde_included
18
19#include <TRUSTArrays.h>
20#include <TRUST_Ref.h>
21#include <TRUSTTab.h>
22#include <SFichier.h>
23#include <Motcle.h>
24
27class Postraitement;
28class Champ_base;
29#include <Domaine_forward.h>
30
31/*! @brief class Sonde. This class allows tracking the evolution of a field over time.
32 *
33 * The set of points at which the field is to be probed and
34 * the observation period are chosen. Postraitement objects hold
35 * probes on the fields to observe; a probe also holds a
36 * reference to a post-processing object.
37 *
38 * @sa Postraitement Sondes
39 */
40class Sonde : public Objet_U
41{
42 Declare_instanciable_sans_constructeur_ni_destructeur(Sonde);
43
44public :
45
46 Sonde();
47 Sonde(const Nom& );
48 void associer_post(const Postraitement& );
49 virtual void initialiser();
50 virtual void mettre_a_jour(double temps, double tinit);
51 virtual void postraiter();
52 void ouvrir_fichier();
53 virtual void completer();
54 inline void fermer_fichier();
55 inline const Champ_Generique_base& le_champ() const;
56 inline const DoubleTab& les_positions_sondes_initiales() const; // Initial positions
57 inline const DoubleTab& les_positions_sondes() const; // Positions after displacement
58 inline const DoubleTab& les_positions() const; // Proc-local positions
59 inline const IntVect& les_poly() const;
60 inline void fixer_periode(double);
61 inline double temps() const;
62 inline SFichier& fichier();
63 inline ~Sonde() override;
64 inline const Nom& get_nom() const { return nom_; }
65 inline const Nom& get_type() const { return type_; }
66 inline const int& get_dim() const { return dim ; }
67 inline void nommer(const Nom& n) override { nom_ = n; }
68
69 virtual void ajouter_bords(const DoubleTab& coords_bords);
70 virtual void init_bords();
71 virtual void mettre_a_jour_bords();
72 // Boundary processing (option "gravcl")
73 void resetTime(double time) { nb_bip = time/periode; };
74
75protected :
76 /** Retrieve the domain to be used for the probe */
77 virtual const Domaine& get_domaine_geom() const;
78 /** Retrieve the field names - overriden in IJK */
79 virtual const Noms get_noms_champ() const;
80 /** Retrieve the number of component for the field - overriden in IJK */
81 virtual int get_nb_compo_champ() const;
82 /** Retrieve the current time for the field - overriden in IJK */
83 virtual double get_temps_champ() const;
84 /** Should exit if invalid type for a probe - overriden for IJK */
85 virtual void validate_type(const Motcle& loc) const { }
86 /** Should exit if invalid position has been set for a probe - overriden for IJK */
87 virtual void validate_position() const { }
88 virtual void create_champ_generique(Entree& is, const Motcle& motlu);
89 /** Fix probe position - used by IJK */
90 virtual void fix_probe_position() { }
91 /** Fix probe position when keyword grav or gravcl is used */
92 virtual void fix_probe_position_grav();
93 /** Fill the array 'valeurs_locales' used by each proc to store prob local values */
94 virtual void fill_local_values();
95 /** Update the underlying field source if needed */
96 virtual void update_source(double un_temps);
97
99 Nom nom_; ///< the probe name
100 Nom nom_fichier_; ///< the name of the file containing the probe
101 int dim; ///< the dimension of the probe (point:0,segment:1,plan:2,volume:3)
103 OBS_PTR(Operateur_Statistique_tps_base) operateur_statistique_; // Reference to an optional statistical operator
104 /** Index of the component to probe. If ncomp = -1 the probe applies to all
105 * components of the field */
106 int ncomp;
107 DoubleTab les_positions_sondes_initiales_; ///< coordinates of the initial point probes
108 DoubleTab les_positions_sondes_; ///< coordinates of probes across the whole domain after displacement (master only)
109 DoubleTab les_positions_; ///< coordinates of probes local to each proc
110 int numero_elem_; ///< equals -1 if undefined, otherwise the element number on the master
111 IntVect elem_; ///< elements containing the local point probes
112 double periode; ///< sampling period
113 /** keys for probe typing (probes redefined at nodes or from values at vertices or at the center of gravity or at vertices)
114 */
115 bool nodes = false;
116 bool chsom = false;
117 bool grav = false;
118 bool gravcl = false; // Values at centers of gravity (like grav) but with optional addition of boundary values via the CL domain of the post-processed field
119 bool som = false;
120 DoubleTab valeurs_locales,valeurs_sur_maitre; ///< valeurs_locales: values on each proc, valeurs_sur_maitre: values gathered on the master
121 double nb_bip;
124 ArrsOfInt participant ; // on the master: participant[pe][i] -> the i-th point on pe corresponds to the participant[pe][i]-th position
127
128 // Boundary processing (option "gravcl")
129 ArrOfInt faces_bords_; ///< array containing the indices of the boundary faces hit by the probe
130 IntTab rang_cl_; ///< for a given face, index of the CL that this face bears
131 int nbre_points1 = -1,nbre_points2 = -1,nbre_points3 = -1; ///< used to create sonde_segment, sonde_plan, etc...
132};
133
134
135/*! @brief The elapsed time.
136 *
137 * @return (double) the elapsed time
138 */
139inline double Sonde::temps() const
140{
141 return nb_bip*periode;
142}
143
144
145
146/*! @brief Closes the file to which the probe writes.
147 *
148 */
150{
151 if (fichier().is_open()) le_fichier_.close();
152}
153
154
155/*! @brief Sets the period at which the field is probed.
156 *
157 * @param (double pe) the probing period for the field
158 */
159inline void Sonde::fixer_periode(double pe)
160{
161 periode=pe;
162}
163
164
165/*! @brief Returns the associated field.
166 *
167 * @return (Champ_base&) the associated field
168 */
170{
171 return mon_champ.valeur();
172}
173
174
175/*! @brief Returns the array of positions of the field that are probed.
176 *
177 * @return (DoubleTab&) the probed positions
178 */
179
180inline const DoubleTab& Sonde::les_positions_sondes_initiales() const
181{
183}
184
185inline const DoubleTab& Sonde::les_positions_sondes() const
186{
188}
189
190inline const DoubleTab& Sonde::les_positions() const
191{
192 return les_positions_;
193}
194
195/*! @brief Returns the array of elements that are probed.
196 *
197 * @return (IntVect&) the elements that are probed
198 */
199inline const IntVect& Sonde::les_poly() const
200{
201 return elem_;
202}
203
204
205/*! @brief Returns an output file stream pointing to the output file used by the probe.
206 *
207 * @return (SFichier&) the output file used by the probe
208 */
210{
211 return le_fichier_;
212}
213
214/*! @brief Destructor.
215 *
216 * Closes the file before destroying the object.
217 *
218 */
220{
222}
223
224
225#endif
class Champ_Generique_base
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
class Operateur_Statistique_tps_base
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
void fixer_periode(double)
Sets the period at which the field is probed.
Definition Sonde.h:159
void associer_post(const Postraitement &)
Associates the post-processing object with the probe.
Definition Sonde.cpp:723
OBS_PTR(Operateur_Statistique_tps_base) operateur_statistique_
virtual void create_champ_generique(Entree &is, const Motcle &motlu)
Definition Sonde.cpp:685
DoubleTab valeurs_locales
Definition Sonde.h:120
int orientation_faces_
Definition Sonde.h:126
double periode
sampling period
Definition Sonde.h:112
virtual void mettre_a_jour_bords()
Definition Sonde.cpp:1557
virtual int get_nb_compo_champ() const
Definition Sonde.cpp:746
IntTab rang_cl_
for a given face, index of the CL that this face bears
Definition Sonde.h:130
const DoubleTab & les_positions() const
Definition Sonde.h:190
virtual void validate_type(const Motcle &loc) const
Definition Sonde.h:85
DoubleTab les_positions_sondes_initiales_
coordinates of the initial point probes
Definition Sonde.h:107
const int & get_dim() const
Definition Sonde.h:66
void resetTime(double time)
Definition Sonde.h:73
void nommer(const Nom &n) override
Assigns a name to the Objet_U. Virtual method to override.
Definition Sonde.h:67
void fermer_fichier()
Closes the file to which the probe writes.
Definition Sonde.h:149
Nom nom_fichier_
the name of the file containing the probe
Definition Sonde.h:100
Motcle nom_champ_lu_
Definition Sonde.h:123
const DoubleTab & les_positions_sondes_initiales() const
Returns the array of positions of the field that are probed.
Definition Sonde.h:180
virtual void ajouter_bords(const DoubleTab &coords_bords)
Definition Sonde.cpp:1513
OBS_PTR(Champ_Generique_base) mon_champ
DoubleTab les_positions_
coordinates of probes local to each proc
Definition Sonde.h:109
virtual void update_source(double un_temps)
Definition Sonde.cpp:1292
virtual double get_temps_champ() const
Definition Sonde.cpp:754
const Champ_Generique_base & le_champ() const
Returns the associated field.
Definition Sonde.h:169
ArrsOfInt participant
Definition Sonde.h:124
bool som
Definition Sonde.h:119
virtual const Noms get_noms_champ() const
Definition Sonde.cpp:741
SFichier le_fichier_
Definition Sonde.h:122
int dim
the dimension of the probe (point:0,segment:1,plan:2,volume:3)
Definition Sonde.h:101
int ncomp
Definition Sonde.h:106
bool chsom
Definition Sonde.h:116
virtual void fix_probe_position()
Definition Sonde.h:90
const DoubleTab & les_positions_sondes() const
Definition Sonde.h:185
IntVect elem_
elements containing the local point probes
Definition Sonde.h:111
virtual void completer()
Definition Sonde.cpp:159
const IntVect & les_poly() const
Returns the array of elements that are probed.
Definition Sonde.h:199
int nbre_points1
Definition Sonde.h:131
virtual void validate_position() const
Definition Sonde.h:87
DoubleTab valeurs_sur_maitre
valeurs_locales: values on each proc, valeurs_sur_maitre: values gathered on the master
Definition Sonde.h:120
bool grav
Definition Sonde.h:117
const Nom & get_nom() const
Definition Sonde.h:64
virtual void initialiser()
Initialises the probe.
Definition Sonde.cpp:797
double temps() const
The elapsed time.
Definition Sonde.h:139
int nbre_points3
used to create sonde_segment, sonde_plan, etc...
Definition Sonde.h:131
ArrOfInt faces_bords_
array containing the indices of the boundary faces hit by the probe
Definition Sonde.h:129
Nom type_
Definition Sonde.h:125
int nbre_points2
Definition Sonde.h:131
int numero_elem_
equals -1 if undefined, otherwise the element number on the master
Definition Sonde.h:110
Nom nom_
the probe name
Definition Sonde.h:99
virtual void fill_local_values()
Definition Sonde.cpp:1336
~Sonde() override
Destructor.
Definition Sonde.h:219
SFichier & fichier()
Returns an output file stream pointing to the output file used by the probe.
Definition Sonde.h:209
virtual void fix_probe_position_grav()
Definition Sonde.cpp:760
virtual void postraiter()
Performs post-processing.
Definition Sonde.cpp:1363
virtual const Domaine & get_domaine_geom() const
Definition Sonde.cpp:736
const Nom & get_type() const
Definition Sonde.h:65
bool gravcl
Definition Sonde.h:118
virtual void init_bords()
Definition Sonde.cpp:1479
DoubleTab les_positions_sondes_
coordinates of probes across the whole domain after displacement (master only)
Definition Sonde.h:108
Sonde()
Default constructor for a probe.
Definition Sonde.cpp:145
bool nodes
Definition Sonde.h:115
void ouvrir_fichier()
Opens the file associated with the probe.
Definition Sonde.cpp:1123
virtual void mettre_a_jour(double temps, double tinit)
Updates the probe in time and performs the post-processing.
Definition Sonde.cpp:1305
double nb_bip
Definition Sonde.h:121
OBS_PTR(Postraitement) mon_post