TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_calc.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 <Raccord_distant_homogene.h>
17#include <Frontiere_dis_base.h>
18#include <Champ_front_calc.h>
19#include <Probleme_Couple.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22#include <Interprete.h>
23#include <Domaine.h>
24#include <Domaine_VF.h>
25
26Implemente_instanciable_sans_constructeur(Champ_front_calc,"Champ_front_calc",Ch_front_var_instationnaire_dep);
27// XD champ_front_calc front_field_base champ_front_calc NO_BRACE This keyword is used on a boundary to get a field from
28// XD_CONT another boundary. The local and remote boundaries should have the same mesh. If not, the
29// XD_CONT Champ_front_recyclage keyword could be used instead. It is used in the condition block at the limits of
30// XD_CONT equation which itself refers to a problem called pb1. We are working under the supposition that pb1 is
31// XD_CONT coupled to another problem.
32// XD attr problem_name ref_Pb_base problem_name REQ Name of the other problem to which pb1 is coupled.
33// XD attr bord chaine bord REQ Name of the side which is the boundary between the 2 domains in the domain object
34// XD_CONT description associated with the problem_name object.
35// XD attr field_name chaine field_name REQ Name of the field containing the value that the user wishes to use at the
36// XD_CONT boundary. The field_name object must be recognized by the problem_name object.
37
38
40
41Sortie& Champ_front_calc::printOn(Sortie& os) const { return os; }
42
43/*! @brief Read the name of a problem, the name of a boundary and the name of an unknown field from an input stream.
44 *
45 * Then creates the corresponding boundary field.
46 * Format:
47 * Champ_front_calc problem_name boundary_name field_name
48 *
49 * @param (Entree& is) an input stream
50 * @return (Entree&) the modified input stream
51 */
53{
55 via_readon_ = true;
56 (nom_inco_ == "VITESSE") ? fixer_nb_comp(dimension) : fixer_nb_comp(1);
57 return is;
58}
59
60/*! @brief Create the Champ_front_calc object representing the trace of an unknown field on a boundary from names:
61 *
62 * - of the problem carrying the unknown
63 * - of the concerned boundary
64 * - of the unknown
65 *
66 * @param (Nom& nom_pb) the name of the problem to which the unknown whose trace we want belongs
67 * @param (Nom& nom) the name of the boundary on which the trace of the unknown is taken
68 * @param (Motcle& nom_inco) the name of the unknown whose trace we want
69 * @throws no problem with the specified name
70 * @throws the problem does not have a field with the specified name
71 */
72void Champ_front_calc::creer(const Nom& nom_pb, const Nom& nom_bord, const Motcle& nom_inco)
73{
74 nom_autre_pb_ = nom_pb;
75 nom_autre_bord_ = nom_bord;
76 OBS_PTR(Probleme_base) autre_pb;
78 if (sub_type(Probleme_base, ob))
79 {
80 autre_pb = ref_cast(Probleme_base, ob);
81 }
82 else
83 {
84 Cerr << "We did not find problem with name " << nom_pb << finl;
85 exit();
86 }
88 rch = autre_pb->get_champ(nom_inco);
89 if (sub_type(Champ_Inc_base, rch.valeur()))
90 {
91 l_inconnue = ref_cast(Champ_Inc_base, rch.valeur());
92 fixer_nb_comp(rch->nb_comp());
93 }
94 else
95 {
96 Cerr << autre_pb->le_nom() << " did not have unknown field with name " << nom_inco << finl;
97 exit();
98 }
99}
100
101int Champ_front_calc::initialiser(double temps, const Champ_Inc_base& inco)
102{
103 // First thing to do: here it is fine! we create the field
105
107
108 // Check/initialize Raccord boundaries in parallel:
109 if (nproc() > 1)
110 {
111 const Domaine_dis_base& domaine_dis_opposee = front_dis().domaine_dis();
112 const Domaine_dis_base& domaine_dis_locale = frontiere_dis().domaine_dis();
113 const Frontiere& frontiere_opposee = front_dis().frontiere();
114 const Frontiere& frontiere_locale = frontiere_dis().frontiere();
115 if (distant_ && !sub_type(Raccord_distant_homogene, frontiere_opposee))
116 {
117 const Nom& nom_domaine_oppose = domaine_dis_opposee.domaine().le_nom();
118 Cerr << "Error, the boundary " << frontiere_opposee.le_nom() << " should be a Raccord." << finl;
119 Cerr << "Add in your data file between the definition and the partition of the domain " << nom_domaine_oppose << " :" << finl;
120 Cerr << "Modif_bord_to_raccord " << nom_domaine_oppose << " " << frontiere_opposee.le_nom() << finl;
121 exit();
122 }
123 if (distant_ == 1)
124 {
125 Raccord_distant_homogene& raccord_distant = ref_cast_non_const(Raccord_distant_homogene, frontiere_opposee);
126 if (!raccord_distant.est_initialise())
127 raccord_distant.initialise(frontiere_locale, domaine_dis_locale, domaine_dis_opposee);
128 }
129 }
130 return 1;
131}
132
133/*! @brief Associate the unknown field to the object
134 *
135 * @param (Champ_Inc_base& inco) the unknown field whose trace will be taken
136 */
138{
139 l_inconnue = inco;
140}
141
142
143/*! @brief Not implemented
144 *
145 * @param (Champ_front_base& ch)
146 * @return (Champ_front_base&)
147 */
149{
150 return *this;
151}
152
153/*! @brief Time update of the field. We simply take the trace of the unknown field at the
154 *
155 * time step at which it is located.
156 * WEC: verify that we take the unknown at the correct time!
157 *
158 */
159
160// Precondition: the boundary name must be different from "??"
161// Parameter: double
162// Meaning:
163// Default values:
164// Constraints:
165// Access:
166// Return:
167// Meaning:
168// Constraints:
169// Exception:
170// Side effects:
171// Postcondition:
173{
174 assert (nom_autre_bord_ != "??") ;
175 DoubleTab& tab=valeurs_au_temps(temps);
176 const Frontiere_dis_base& frontiere_dis_opposee = domaine_dis().frontiere_dis(nom_bord_oppose());
177 l_inconnue->trace(frontiere_dis_opposee,tab,temps,distant_ /* distant */);
178}
179
180/*! @brief Returns the associated unknown field
181 *
182 * @return (Champ_Inc_base&) the associated unknown field
183 */
185{
186 return l_inconnue.valeur();
187}
188
189/*! @brief Returns the name of the boundary on which the trace is computed.
190 *
191 * @return (Nom&) the name of the boundary on which the trace is computed
192 */
194{
195 return nom_autre_bord_;
196}
197
198/*! @brief Returns the equation associated with the unknown whose trace is taken.
199 *
200 * @return (Equation_base&) the equation associated with the unknown whose trace is taken
201 */
203{
204 if (!l_inconnue)
205 {
206 Cerr << "\nError in Champ_front_calc::equation() : not able to return the equation !" << finl;
208 }
209 return inconnue().equation();
210}
211
212/*! @brief Returns the medium associated with the equation carrying the unknown field whose trace is taken.
213 *
214 * @return (Milieu_base&) the medium associated with the equation carrying the unknown field whose trace is taken
215 */
217{
218 return equation().milieu();
219}
220
221/*! @brief Returns the discretized domain associated with the equation carrying the unknown field whose trace is taken.
222 *
223 * @return (Domaine_dis_base&) the discretized domain associated with the equation carrying the unknown field whose trace is taken
224 */
229
230/*! @brief Returns the domain of discretized boundary conditions carried by the equation carrying the unknown field
231 *
232 * whose trace is taken
233 *
234 * @return (Domaine_Cl_dis_base&) the domain of discretized boundary conditions carried by the equation carrying the unknown field whose trace is taken
235 */
240
241/*! @brief Returns the discretized boundary corresponding to the domain on which the trace is taken.
242 *
243 * @return (Frontiere_dis_base&) discretized boundary corresponding to the domain on which the trace is taken
244 * @throws boundary with the specified name not found
245 */
250
251
253{
254}
class Ch_front_var_instationnaire_dep This abstract class represents a field on a boundary,
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
Class Champ_Inc_base.
const Domaine_dis_base & domaine_dis_base() const override
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual const Frontiere_dis_base & frontiere_dis() const
Returns the discretized boundary associated with the field.
class Champ_front_calc Derived class of Champ_front_var representing
const Frontiere_dis_base & front_dis() const
Returns the discretized boundary corresponding to the domain on which the trace is taken.
void creer(const Nom &, const Nom &, const Motcle &)
Create the Champ_front_calc object representing the trace of an unknown field on a boundary from name...
const Nom & nom_bord_oppose() const
Returns the name of the boundary on which the trace is computed.
int initialiser(double, const Champ_Inc_base &) override
Initialization at the beginning of calculation.
const Domaine_Cl_dis_base & domaine_Cl_dis() const
Returns the domain of discretized boundary conditions carried by the equation carrying the unknown fi...
void set_distant(int d)
Champ_front_base & affecter_(const Champ_front_base &ch) override
Not implemented.
const Equation_base & equation() const
Returns the equation associated with the unknown whose trace is taken.
OBS_PTR(Champ_Inc_base) l_inconnue
void associer_ch_inc_base(const Champ_Inc_base &)
Associate the unknown field to the object.
void verifier(const Cond_lim_base &la_cl) const override
void mettre_a_jour(double temps) override
Time update of the field. We simply take the trace of the unknown field at the.
const Champ_Inc_base & inconnue() const
Returns the associated unknown field.
const Domaine_dis_base & domaine_dis() const override
Returns the discretized domain associated with the equation carrying the unknown field whose trace is...
const Milieu_base & milieu() const
Returns the medium associated with the equation carrying the unknown field whose trace is taken.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Frontiere_dis_base & frontiere_dis(const Nom &) const
Returns the boundary of Name nom.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
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
class Frontiere_dis_base Class representing a discretized boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Domaine_dis_base & domaine_dis() const
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
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
static int dimension
Definition Objet_U.h:94
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
class Probleme_base It is a Probleme_U that is not a coupling.
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
Definition Process.cpp:102
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
void initialise(const Frontiere_t &, const Domaine_dis_base &, const Domaine_dis_base &)
Base class for output streams.
Definition Sortie.h:52