TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_Cl_dis_base.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 <Cond_lim_utilisateur_base.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Frontiere_dis_base.h>
19#include <Schema_Temps_base.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22
23Implemente_base(Domaine_Cl_dis_base,"Domaine_Cl_dis_base",Objet_U);
24
26{
27 return os;
28}
29
30/*! @brief Overrides Objet_U::readOn(Sortie&) Reads the discretized boundary conditions from an input stream
31 *
32 * The expected format is as follows:
33 * {
34 * Name Cond_lim [REPEAT READ AS MANY TIMES AS NECESSARY]
35 * }
36 *
37 * @param (Entree& is) an input stream
38 * @return (Entree&) the modified input stream
39 * @throws opening brace expected
40 * @throws invalid number of boundary conditions read
41 */
43{
44 assert(mon_equation);
45 const Domaine& ledomaine=equation().domaine_dis().domaine();
46 Motcle accolade_ouverte("{");
47 Motcle accolade_fermee("}");
48 Nom nomlu;
49 Motcle motlu;
50 is >> motlu;
51 if (motlu != accolade_ouverte)
52 {
53 Cerr << "Error while reading the boundaries conditions\n";
54 Cerr << "We expected a " << accolade_ouverte << " instead of \n"
55 << motlu;
56 exit();
57 }
58
59 int n = ledomaine.nb_front_Cl();
60 IntTab front_deja_lu(n);
61 front_deja_lu = 0;
62 les_conditions_limites().dimensionner(n);
63 int nb_clim=0;
64
65 while(1)
66 {
67
68 // Reading a boundary name or }
69 is >> nomlu;
70 motlu=nomlu;
71 if (motlu == accolade_fermee)
72 break;
73
74 Cerr << "Reading the " << nomlu << " boundary condition of the " << equation().que_suis_je() << " equation from the problem " << equation().probleme().le_nom() << finl;
75 Journal()<< "Reading the boundary condition " << nomlu <<finl;
76
77 int rang=ledomaine.rang_frontiere(nomlu);
78
79 // Additional test on boundary conditions that have been read:
80 // we test if two boundaries have the same name
81 if (front_deja_lu(rang) == 0)
82 front_deja_lu(rang) = 1;
83 else
84 {
85 Cerr <<finl;
86 Cerr <<"Error in the data set "<<finl;
87 Cerr <<"the boundary condition associated"<<finl;
88 Cerr <<"to the boundary "<< nomlu <<"is read twice !!"<<finl;
89 exit();
90 }
91 // const Frontiere& frontiere=domaine.frontiere(rang);
92 is >> les_conditions_limites(rang);
93 // If we had a condition_limite_utilisateur
94 // We must retrieve the bc stored in it
95 // copy it and destroy the one contained in the cond_utilisateur
96 if (sub_type(Cond_lim_utilisateur_base,les_conditions_limites(rang).valeur()))
97 {
98 Cond_lim_utilisateur_base& la_cl=ref_cast(Cond_lim_utilisateur_base,les_conditions_limites(rang).valeur());
99 la_cl.lire(is,equation(),nomlu);
100 Cond_lim* sa=&(la_cl.la_cl());
101
102 // WEC: The new formulation avoids copying the Cond_lim_base object.
103 // This copy can cause problems for fields that register themselves in a vector
104 // (Champ_Inputs). The vector would then point to garbage...
105 // Adopt the new one and destroy the old one (Cond_lim_utilisateur)
106 les_conditions_limites(rang).adopt(*sa);
107 //les_conditions_limites(rang)=(*sa);
108 delete sa;
109 }
110 les_conditions_limites(rang)->associer_fr_dis_base(domaine_dis().frontiere_dis(rang));
111
112 // Test to prevent the use of 'Raccord_distant_homogene' in sequential computation
113 const Frontiere& frontiere=ledomaine.frontiere(rang);
114 if ((frontiere.que_suis_je()=="Raccord_distant_homogene") && Process::is_sequential())
115 {
116 Cerr<<"At least one connection (adjacent boundary on two domains) is of type 'Raccord distant homogene'." << finl;
117 Cerr<<"Use 'Raccord local homogene' to define the connections in sequential computing"<<finl;
118 Cerr<<"And 'Raccord distant homogene' for the connections in parallel computing." << finl;
119 exit();
120 }
121
122 nb_clim++;
123 }
124 if (nb_clim!=n)
125 {
127 Cerr << "It misses " << n-nb_clim << " boundaries conditions " << finl;
128 Cerr << "We read " << nb_clim << " boundaries conditions " << finl;
129 Cerr << "We waited " << n << " boundary conditions " << finl;
130 exit();
131 }
132 for (int num_cl=0; num_cl<nb_clim; num_cl++)
133 {
134 les_conditions_limites(num_cl)->associer_domaine_cl_dis_base(*this);
135 les_conditions_limites(num_cl)->verifie_ch_init_nb_comp();
136 // const Frontiere_dis_base& la_fr_dis = les_conditions_limites(num_cl).frontiere_dis();
137 // const Frontiere& frontiere=la_fr_dis.frontiere();
138 // const Domaine& domaine2=frontiere.domaine();
139 }
140
141 return is;
142}
143
144/*! @brief Returns 1 if the object contains a boundary condition with the specified Name.
145 *
146 * Returns 0 otherwise.
147 *
148 * @param (Nom& type) the name of the boundary condition to search for
149 * @return (int) 1 if the boundary condition with the specified name was found, 0 otherwise.
150 */
152{
153 for (auto& itr : les_conditions_limites_)
154 if (itr.get_info()->has_base(type)) return 1;
155 return 0;
156}
157
158/*! @brief Returns a reference to the discretized domain associated with the boundary conditions.
159 *
160 * This Domaine_dis is associated through the associated equation
161 * and not directly with the Domaine_Cl_dis_base object.
162 *
163 * @return (Domaine_dis_base&) the discretized domain associated with the equation associated with the boundary conditions.
164 */
169
170/*! @brief Returns a reference to the discretized domain associated with the boundary conditions.
171 *
172 * This Domaine_dis is associated through the associated equation
173 * and not directly with the Domaine_Cl_dis_base object.
174 * (const version)
175 *
176 * @return (Domaine_dis_base&) the discretized domain associated with the equation associated with the boundary conditions.
177 */
182
183/*! @brief Changes the i-th future time of all BCs.
184 *
185 */
187{
188 for (int j=0; j<nb_cond_lim(); j++)
190}
191
192/*! @brief Changes the i-th future time of all BCs.
193 *
194 */
196{
197 for (int j=0; j<nb_cond_lim(); j++)
199}
200
201/*! @brief Rotates the wheel of all BCs up to the given time
202 *
203 */
205{
206 int ok=1;
207 for (int j=0; j<nb_cond_lim(); j++)
208 ok = ok && les_conditions_limites_[j]->avancer(temps);
209 return ok;
210}
211
212/*! @brief Rotates the wheel of all BCs back to the given time
213 *
214 */
216{
217 int ok=1;
218 for (int j=0; j<nb_cond_lim(); j++)
219 ok = ok && les_conditions_limites_[j]->reculer(temps);
220 return ok;
221}
222
223/*! @brief Performs a time update of all boundary conditions.
224 *
225 * @param (double temps) the time step for update
226 */
228{
229 les_conditions_limites_.mettre_a_jour(temps);
230}
231
232/* @brief See ICoCo::ProblemTrio::resetTime()
233 */
235{
236 les_conditions_limites_.resetTime(temps);
237}
238
239/*! @brief Performs a time update for sub-time-steps of a time scheme (e.g. in RungeKutta)
240 *
241 * for all boundary conditions returning 1 through the method
242 * int Cond_Lim_base::a_mettre_a_jour_ss_pas_dt();
243 *
244 * @param (double temps) the time step for update
245 */
247{
248 for (auto &itr : les_conditions_limites_)
249 {
250 Cond_lim_base& la_cl = itr.valeur();
251 if (la_cl.a_mettre_a_jour_ss_pas_dt() == 1)
252 la_cl.mettre_a_jour(temps);
253 }
254}
255
256/*! @brief Initializes the BCs. Unlike the update methods, the
257 *
258 * initialize methods of BCs cannot depend on the outside
259 * (it may not be initialized itself)
260 *
261 * @return (int) 1 if OK, 0 otherwise
262 */
264{
265 return les_conditions_limites_.initialiser(temps);
266}
267
268/*! @brief Computes the exchange coefficients for thermally coupled problems
269 *
270 * @return (int) always returns 1
271 */
273{
274 les_conditions_limites_.calculer_coeffs_echange(temps);
275 return 1;
276}
277
278/*! @brief Calls Cond_lim_base::completer() on each boundary condition
279 *
280 */
286
287/*! @brief Returns the boundary condition associated with a given real face.
288 *
289 * Stores in face_locale the face number within the boundary.
290 * Triggers an error if the face does not have a BC.
291 *
292 */
293const Cond_lim_base& Domaine_Cl_dis_base::condition_limite_de_la_face_reelle(int face_globale, int& face_locale) const
294{
295 for (int i=0; i<nb_cond_lim(); i++)
296 {
297 const Frontiere& fr=les_conditions_limites(i)->frontiere_dis().frontiere();
298 if (face_globale>=fr.num_premiere_face() && face_globale < fr.num_premiere_face()+fr.nb_faces())
299 {
300 face_locale=face_globale-fr.num_premiere_face();
301 return les_conditions_limites(i).valeur();
302 }
303 }
304 assert(0); // the face does not have a BC
305 return les_conditions_limites(0).valeur(); // For compilation
306}
307
308/*! @brief Returns the boundary condition associated with a given virtual face.
309 *
310 * Stores in face_locale the face number within the boundary.
311 * Triggers an error if the face does not have a BC.
312 *
313 */
314const Cond_lim_base& Domaine_Cl_dis_base::condition_limite_de_la_face_virtuelle(int face_globale, int& face_locale) const
315{
316 for (int i=0; i<nb_cond_lim(); i++)
317 {
318 const Frontiere& fr=les_conditions_limites(i)->frontiere_dis().frontiere();
319 const ArrOfInt& faces_virt=fr.get_faces_virt();
320 for (int j=0; j<faces_virt.size_array(); j++)
321 if (face_globale==faces_virt[j])
322 {
323 face_locale=fr.nb_faces()+j;
324 return les_conditions_limites(i).valeur();
325 }
326 }
327 assert(0); // the face does not have a BC
328 return les_conditions_limites(0).valeur(); // For compilation
329}
330
331/*! @brief Returns the boundary condition associated with a boundary of the given name.
332 *
333 * Triggers an error if no boundary has this name.
334 *
335 */
337{
338 for (int i=0; i<nb_cond_lim(); i++)
339 {
340 const Frontiere& fr=les_conditions_limites(i)->frontiere_dis().frontiere();
341 if (fr.le_nom()==frontiere)
342 return les_conditions_limites(i).valeur();
343 }
344 assert(0); // No boundary with this name
345 exit();
346 return les_conditions_limites(0).valeur(); // For compilation
347}
348
349/*! @brief Returns the boundary condition associated with a boundary of the given name.
350 *
351 * Triggers an error if no boundary has this name.
352 *
353 */
355{
356 for (int i=0; i<nb_cond_lim(); i++)
357 {
358 const Frontiere& fr=les_conditions_limites(i)->frontiere_dis().frontiere();
359 if (fr.le_nom()==frontiere)
360 return les_conditions_limites(i).valeur();
361 }
362 assert(0); // No boundary with this name
363 exit();
364 return les_conditions_limites(0).valeur(); // For compilation
365}
366
367/*! @brief Computes the growth rate of unsteady BCs between t1 and t2.
368 *
369 */
371{
372 for (int i=0; i<nb_cond_lim(); i++)
373 {
374 Champ_front_base& champ=les_conditions_limites(i)->champ_front();
375 if (champ.instationnaire()) champ.calculer_derivee_en_temps(t1,t2);
376 }
377}
378
379/*! @brief Returns the i-th boundary condition.
380 *
381 * (const version)
382 *
383 * @param (int i) the rank of the i-th boundary condition
384 * @return (Cond_lim&) the i-th boundary condition
385 */
390
391/*! @brief Returns the i-th boundary condition.
392 *
393 * @param (int i) the rank of the i-th boundary condition
394 * @return (Cond_lim&) the i-th boundary condition
395 */
400
401/*! @brief Returns the array of boundary conditions.
402 *
403 * @return (Conds_lim&) the array of boundary conditions
404 */
409
410/*! @brief Returns the array of boundary conditions.
411 *
412 * (const version)
413 *
414 * @return (Conds_lim&) the array of boundary conditions
415 */
420
421/*! @brief Returns the number of boundary conditions.
422 *
423 * @return (int) the number of boundary conditions
424 */
426{
427 return les_conditions_limites_.size();
428}
429
431{
432 return domaine().nb_faces_frontiere();
433}
434
436{
437 return domaine_dis().domaine();
438}
439const Domaine& Domaine_Cl_dis_base::domaine() const
440{
441 return domaine_dis().domaine();
442}
443
444/*! @brief Given a boundary face index in the Domaine_VF, returns the boundary condition to which this face
445 *
446 * belongs, for 0 <= num_face < nb_faces_Cl().
447 *
448 */
450{
451 // Generic algorithm: we iterate over the boundaries until we find
452 // the one that contains the face.
453 // The faces of boundary 0, then those of boundary 1, etc., follow
454 // each other in the Domaine_VF.
455 assert(num_face >= 0);
456 int i = 0;
457 const int nb_cl = les_conditions_limites_.size();
458 for (i = 0; i < nb_cl; i++)
459 {
460 const Cond_lim_base& cl = les_conditions_limites_[i].valeur();
461 const Frontiere& fr = cl.frontiere_dis().frontiere();
462 int num_premiere_face = fr.num_premiere_face();
463 int nb_faces = fr.nb_faces();
464
465 if (num_face >= num_premiere_face && num_face < num_premiere_face + nb_faces)
466 break;
467 }
468 if (i == nb_cl)
469 {
470 Cerr << "Error in Domaine_Cl_dis_base::la_cl_de_la_face(num_face="
471 << num_face << ")\n This face is not on a boundary of cond_lim."
472 << finl;
473 exit();
474 }
475 return les_conditions_limites_[i];
476}
477
479{
480 nom_ = un_nom;
481}
482
484{
485 mon_inconnue=inco;
486}
487
489{
490 return mon_inconnue;
491}
492
494{
495 return mon_inconnue;
496}
Class Champ_Inc_base.
class Champ_front_base Base class for the hierarchy of boundary fields.
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
virtual void mettre_a_jour(double temps)
Performs a time update of the boundary condition.
virtual int a_mettre_a_jour_ss_pas_dt()
Indicates whether this boundary condition must be updated during sub-time steps of a time scheme such...
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
void lire(Entree &, Equation_base &, const Nom &nom_bord)
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
int nb_front_Cl() const
Definition Domaine.h:236
int_t nb_faces_frontiere() const
Returns the number of boundary faces of the domain (sum of boundaries, connections,...
Definition Domaine.h:488
int rang_frontiere(const Nom &) const
Definition Domaine.cpp:1051
const Frontiere_t & frontiere(int i) const
Definition Domaine.h:539
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
virtual void mettre_a_jour_ss_pas_dt(double temps)
Performs a time update for sub-time-steps of a time scheme (e.g. in RungeKutta).
virtual int calculer_coeffs_echange(double temps)
Computes the exchange coefficients for thermally coupled problems.
void calculer_derivee_en_temps(double t1, double t2)
Computes the growth rate of unsteady BCs between t1 and t2.
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
virtual int initialiser(double temps)
Initializes the BCs. Unlike the update methods, the.
virtual const Champ_Inc_base & inconnue() const
const Cond_lim_base & condition_limite_de_la_frontiere(Nom frontiere) const
Returns the boundary condition associated with a boundary of the given name.
int reculer(double temps)
Rotates the wheel of all BCs back to the given time.
int nb_cond_lim() const
Returns the number of boundary conditions.
virtual const Cond_lim & la_cl_de_la_face(int num_face) const
Given a boundary face index in the Domaine_VF, returns the boundary condition to which this face.
void completer()
Calls Cond_lim_base::completer() on each boundary condition.
Conds_lim & les_conditions_limites()
Returns the array of boundary conditions.
void resetTime(double time)
Domaine_dis_base & domaine_dis()
Returns a reference to the discretized domain associated with the boundary conditions.
virtual void associer_inconnue(const Champ_Inc_base &)
void set_temps_defaut(double temps)
Changes the i-th future time of all BCs.
virtual void mettre_a_jour(double temps)
Performs a time update of all boundary conditions.
int avancer(double temps)
Rotates the wheel of all BCs up to the given time.
int contient_Cl(const Nom &)
Returns 1 if the object contains a boundary condition with the specified Name.
const Cond_lim_base & condition_limite_de_la_face_reelle(int face_globale, int &face_locale) const
Returns the boundary condition associated with a given real face.
const Cond_lim_base & condition_limite_de_la_face_virtuelle(int face_globale, int &face_locale) const
Returns the boundary condition associated with a given virtual face.
void changer_temps_futur(double temps, int i)
Changes the i-th future time of all BCs.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
void ecrire_noms_bords(Sortie &) const
Writes the boundary names to an output stream.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Returns the problem associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const ArrOfInt_t & get_faces_virt() const
Definition Frontiere.h:69
int_t num_premiere_face() const
Definition Frontiere.h:67
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Returns the number of faces of the boundary.
Definition Frontiere.h:59
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
Definition Process.cpp:592
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static bool is_sequential()
Definition Process.cpp:113
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const