TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sondes.cpp
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#include <LecFicDiffuse_JDD.h>
17#include <Postraitement.h>
18#include <Sondes.h>
19
20Implemente_instanciable(Sondes, "Sondes|Probes", LIST(OWN_PTR(Sonde)));
21// XD sondes listobj nul BRACE sonde NO_COMMA List of probes.
22
23
24Sortie& Sondes::printOn(Sortie& s ) const { return s ; }
25
26/*! @brief Reads a list of probes from an input stream. Format:
27 *
28 * {
29 * [READ A PROBE AS MANY TIMES AS NEEDED]
30 * }
31 *
32 * @param s an input stream
33 * @return the modified input stream
34 * @throws opening brace expected
35 */
36Entree& Sondes::readOn(Entree& s )
37{
38 assert(mon_post);
39
40 Motcle motlu;
41 Motcle accolade_ouverte("{");
42 Motcle accolade_fermee("}");
43
44 s >> motlu;
45
46 if (motlu != accolade_ouverte)
47 {
48 Cerr << "Error while reading the probes in the postprocessing" << finl;
49 Cerr << "We expected { to start to read the probes" << finl;
50 exit();
51 }
52 s >> motlu;
53
54 if (motlu == "FICHIER")
55 {
56 Cerr<<"Error: Sondes { " << motlu << " .... } no more allowed, use Sondes_fichier { " << motlu << " .... }" <<finl;
58 }
59 else if (motlu == accolade_fermee)
60 {
61 Cerr << "Error while reading the probes in the postprocessing" << finl;
62 Cerr << "You have not defined any probe" << finl;
63 exit();
64 }
66
67 const bool is_ijk = mon_post->que_suis_je() == "Postprocessing_IJK";
68 while (motlu != accolade_fermee)
69 {
70 OWN_PTR(Sonde) une_sonde;
71 if(is_ijk)
72 une_sonde.typer("Sonde_IJK");
73 else
74 une_sonde.typer("Sonde");
75 une_sonde->nommer(motlu);
76 une_sonde->associer_post(mon_post.valeur());
77 s >> une_sonde.valeur();
78 add(une_sonde);
79 s >> motlu;
80 }
81 Cerr << "End of reading probes " << finl;
82 return s;
83}
84
86{
87 // Reconstruit noms_champs_postraitables_
88 if (mon_post)
89 {
90 Noms noms;
91 mon_post->probleme().get_noms_champs_postraitables(noms);
92 noms_champs_postraitables_.dimensionner_force(noms.size());
93 for (int i = 0; i < noms.size(); i++)
94 noms_champs_postraitables_[i] = noms[i];
95 }
96}
97
99{
101 for (auto &itr : *this) itr->completer();
102}
103
104/*! @brief Performs post-processing on each probe in the list.
105 *
106 */
108{
109 for (auto &itr : *this) itr->postraiter();
110
111 clear_cache();
112}
113
115{
116 sourceList.vide();
117 espaceStockageList.vide();
118 sourceNoms.reset();
119}
120
121OBS_PTR(Champ_base) Sondes::get_from_cache(OBS_PTR(Champ_Generique_base)& mon_champ, const Nom& nom_champ_lu_)
122{
124 int num = sourceNoms.rang(nom_champ_lu_);
125 if (num < 0)
126 {
127 OWN_PTR(Champ_base) espace_stockage;
128 const Champ_base& ma_source = mon_champ->get_champ(espace_stockage);
129 sourceList.add(ma_source);
130 espaceStockageList.add(espace_stockage);
131 sourceNoms.add(nom_champ_lu_);
132 // See Champ_Generique_base for the definition of the storage space
133 return espace_stockage ? espaceStockageList.dernier().valeur() : ma_source;
134 }
135 else if (espaceStockageList(num))
136 return espaceStockageList(num).valeur();
137 else
138 return sourceList(num);
139}
140
141/*! @brief Updates each probe in the list in time.
142 *
143 * @param temps the update time
144 * @param tinit the initial time of the probes
145 */
146void Sondes::mettre_a_jour(double temps, double tinit)
147{
148 for (auto &itr : *this) itr->mettre_a_jour(temps, tinit);
149
150 clear_cache();
151}
152
153/*! @brief Associates a post-processing object with the probe list.
154 *
155 */
157{
158 mon_post = post;
159}
160
161/*! @brief Modifies the update-positions setting for mobile probes.
162 *
163 */
164void Sondes::set_update_positions(bool update_positions_)
165{
166 update_positions=update_positions_;
167}
168
169/*! @brief Returns the update-positions setting for mobile probes.
170 *
171 * @return true if probe positions are updated at each time step, false otherwise.
172 */
class Champ_Generique_base
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
void fixer_identifiant_appel(const Nom &identifiant)
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
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
int rang(const char *const ch) const
Definition Noms.cpp:65
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Sonde. This class allows tracking the evolution of a field over time.
Definition Sonde.h:41
class Sondes
Definition Sondes.h:32
void set_update_positions(bool update_positions)
Modifies the update-positions setting for mobile probes.
Definition Sondes.cpp:164
void mettre_a_jour(double temps, double tinit)
Updates each probe in the list in time.
Definition Sondes.cpp:146
void postraiter()
Performs post-processing on each probe in the list.
Definition Sondes.cpp:107
void clear_cache()
Definition Sondes.cpp:114
void set_noms_champs_postraitables()
Definition Sondes.cpp:85
void completer()
Definition Sondes.cpp:98
void associer_post(const Postraitement &)
Associates a post-processing object with the probe list.
Definition Sondes.cpp:156
const Nom & nom_champ_lu_
Definition Sondes.h:42
bool get_update_positions()
Returns the update-positions setting for mobile probes.
Definition Sondes.cpp:173
bool update_positions
Definition Sondes.h:46
Base class for output streams.
Definition Sortie.h:52