TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sonde_Int.h
1/****************************************************************************
2* Copyright (c) 2024, 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_Int_included
17#define Sonde_Int_included
18
19#include <TRUST_Ref.h>
20#include <SFichier.h>
21#include <TRUSTTab.h>
22
23class Postraitement;
24#include <Domaine_forward.h>
25
26/*! @brief class Sonde_Int
27 * @brief Allows tracking the evolution of an integer array over time.
28 *
29 * A set of points at which the array is to be probed is chosen,
30 * along with the observation period. Postraitement objects hold probes
31 * for the fields to monitor; each probe in turn holds a reference to
32 * its post-processing object.
33 *
34 * @sa Postraitement Sonde_Ints
35 */
36class Sonde_Int : public Objet_U
37{
38 Declare_instanciable_sans_destructeur(Sonde_Int);
39
40public :
41
42 inline Sonde_Int(const Nom& );
43 void associer_post(const Postraitement& );
44 void initialiser(const Domaine& );
45 void mettre_a_jour(double temps, double tinit);
46 void postraiter(double );
47 void ouvrir_fichier();
48 inline void fermer_fichier();
49 inline const IntVect& le_tableau() const;
50 inline const DoubleTab& les_positions() const;
51 inline const IntVect& les_poly() const;
52 inline void fixer_periode(double);
53 inline double temps() const;
54 //int add(const DoubleTab&);
55 //int add(const double, const double);
56 //int add(const double, const double, const double);
57 inline SFichier& fichier();
58 inline ~Sonde_Int() override;
59
60private :
61
62 OBS_PTR(Postraitement) mon_post;
63 Nom nom_; // probe name
64 int dim = -1; // dimension of the probe (point:0, segment:1, plan:2, volume:3)
65 int nbre_points1= -1,nbre_points2= -1,nbre_points3= -1; // for segment, plan, etc. probes
66 OBS_PTR(IntVect) mon_tableau; // the probed array
67 DoubleTab les_positions_; // coordinates of point probes
68 IntVect elem_; // elements containing the point probes
69 IntTab valeurs; // values of mon_tableau at indices given by elem_
70 double periode= 1.e10; // sampling period
71 double nb_bip= 0.;
72 SFichier* le_fichier;
73};
74
75
76/*! @brief Constructor for a probe given its name.
77 *
78 * @param nom the name of the probe to construct
79 */
80inline Sonde_Int::Sonde_Int(const Nom& nom)
81 : nom_(nom), le_fichier(0)
82{}
83
84
85
86/*! @brief Returns the elapsed time.
87 *
88 * @return the elapsed time
89 */
90inline double Sonde_Int::temps() const
91{
92 return nb_bip*periode;
93}
94
95
96
97/*! @brief Closes the file to which the probe writes.
98 *
99 */
101{
102 if (le_fichier)
103 {
104 delete le_fichier;
105 }
106}
107
108
109/*! @brief Sets the sampling period for probing the field.
110 *
111 * @param pe the sampling period
112 */
113inline void Sonde_Int::fixer_periode(double pe)
114{
115 periode=pe;
116}
117
118
119/*! @brief Returns the associated array.
120 *
121 * @return the associated integer array
122 */
123inline const IntVect& Sonde_Int::le_tableau() const
124{
125 return mon_tableau.valeur();
126}
127
128
129/*! @brief Returns the array of probed positions.
130 *
131 * @return the probed positions
132 */
133inline const DoubleTab& Sonde_Int::les_positions() const
134{
135 return les_positions_;
136}
137
138
139/*! @brief Returns the array of elements being probed.
140 *
141 * @return the elements being probed
142 */
143inline const IntVect& Sonde_Int::les_poly() const
144{
145 return elem_;
146}
147
148
149/*! @brief Returns the output file stream used by the probe.
150 *
151 * @return the output file stream used by the probe
152 */
154{
155 return *le_fichier;
156}
157
158/*! @brief Destructor.
159 *
160 * Closes the file before destroying the object.
161 *
162 */
164{
166}
167
168
169#endif
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
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
SFichier & fichier()
Returns the output file stream used by the probe.
Definition Sonde_Int.h:153
double temps() const
Returns the elapsed time.
Definition Sonde_Int.h:90
void ouvrir_fichier()
Opens the file associated with the probe.
const IntVect & le_tableau() const
Returns the associated array.
Definition Sonde_Int.h:123
const DoubleTab & les_positions() const
Returns the array of probed positions.
Definition Sonde_Int.h:133
const IntVect & les_poly() const
Returns the array of elements being probed.
Definition Sonde_Int.h:143
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.
Definition Sonde_Int.cpp:21
void fixer_periode(double)
Sets the sampling period for probing the field.
Definition Sonde_Int.h:113
~Sonde_Int() override
Destructor.
Definition Sonde_Int.h:163
void mettre_a_jour(double temps, double tinit)
Updates the probe in time and performs post-processing.
void fermer_fichier()
Closes the file to which the probe writes.
Definition Sonde_Int.h:100
void postraiter(double)
Performs post-processing.