TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Conv_PolyMAC_CDO_iterateur_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 <Op_Conv_PolyMAC_CDO_iterateur_base.h>
17#include <Modifier_pour_fluide_dilatable.h>
18#include <Discretisation_base.h>
19#include <Probleme_base.h>
20#include <TRUSTTrav.h>
21
22
23Implemente_base(Op_Conv_PolyMAC_CDO_iterateur_base, "Op_Conv_PolyMAC_CDO_iterateur_base", Operateur_Conv_base);
24
26{
27 return s << que_suis_je();
28}
29
31{
32 return s;
33}
34
35inline void eval_fluent(const double psc, const int num1, const int num2, DoubleVect& fluent)
36{
37 if (psc >= 0)
38 fluent[num2] += psc;
39 else
40 fluent[num1] -= psc;
41}
42
44{
45 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = iter_->domaine();
46 const Domaine_Cl_PolyMAC_family& Domaine_Cl_PolyMAC_family = iter_->domaine_Cl();
47 const IntTab& face_voisins = domaine_PolyMAC_CDO.face_voisins();
48 const DoubleVect& volumes = domaine_PolyMAC_CDO.volumes();
49 const DoubleVect& face_surfaces = domaine_PolyMAC_CDO.face_surfaces();
50 const DoubleVect& vit_associe = vitesse().valeurs();
51 const DoubleVect& vit = (vitesse_pour_pas_de_temps_ ? vitesse_pour_pas_de_temps_->valeurs() : vit_associe);
52 DoubleTab fluent;
53 // fluent is initialized to zero by default:
54 domaine_PolyMAC_CDO.domaine().creer_tableau_elements(fluent);
55
56 // Fill the fluent array
57 double psc;
58 int num1, num2, face;
59 int elem1;
60
61 // Process boundaries
62 for (int n_bord = 0; n_bord < domaine_PolyMAC_CDO.nb_front_Cl(); n_bord++)
63 {
64
66
67 if ( sub_type(Dirichlet_entree_fluide,la_cl.valeur()) || sub_type(Neumann_sortie_libre, la_cl.valeur()))
68
69 {
70 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
71 num1 = le_bord.num_premiere_face();
72 num2 = num1 + le_bord.nb_faces();
73 for (face = num1; face < num2; face++)
74 {
75 psc = vit[face] * face_surfaces(face);
76 if ((elem1 = face_voisins(face, 0)) != -1)
77 {
78 if (psc < 0)
79 fluent[elem1] -= psc;
80 }
81 else // (elem2 != -1)
82 if (psc > 0)
83 fluent[face_voisins(face, 1)] += psc;
84 }
85 }
86 }
87
88 // Loop over internal faces to fill fluent
89 int domaine_PolyMAC_CDO_nb_faces = domaine_PolyMAC_CDO.nb_faces();
90 int premiere_face = domaine_PolyMAC_CDO.premiere_face_int();
91 for (face = premiere_face; face < domaine_PolyMAC_CDO_nb_faces; face++)
92 {
93 psc = vit[face] * face_surfaces(face);
94 eval_fluent(psc, face_voisins(face, 0), face_voisins(face, 1), fluent);
95 }
96
97 // Compute the stability time step from the fluent array
98 if (vitesse().le_nom() == "rho_u" && equation().probleme().is_dilatable())
99 diviser_par_rho_si_dilatable(fluent, equation().milieu());
100 double dt_stab = 1.e30;
101 int domaine_PolyMAC_CDO_nb_elem = domaine_PolyMAC_CDO.nb_elem();
102 // dt_stab = min ( 1 / ( |U|/dx + |V|/dy + |W|/dz ) )
103 for (int num_poly = 0; num_poly < domaine_PolyMAC_CDO_nb_elem; num_poly++)
104 {
105 double dt_elem = volumes(num_poly) / (fluent[num_poly] + DMINFLOAT);
106 if (dt_elem < dt_stab)
107 dt_stab = dt_elem;
108 }
109 dt_stab = Process::mp_min(dt_stab);
110
111 // trick to work around the const type of the method
113 op.fixer_dt_stab_conv(dt_stab);
114 return dt_stab;
115}
116
117// cf Op_Conv_PolyMAC_CDO_iterateur_base::calculer_dt_stab() for the choice of dt_stab computation
119{
120 if (Motcle(option) == "stabilite")
121 {
122 DoubleTab& es_valeurs = espace_stockage.valeurs();
123 es_valeurs = 1.e30;
124
125 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = iter_->domaine();
126 const Domaine_Cl_PolyMAC_family& Domaine_Cl_PolyMAC_family = iter_->domaine_Cl();
127 const IntTab& face_voisins = domaine_PolyMAC_CDO.face_voisins();
128 const DoubleVect& volumes = domaine_PolyMAC_CDO.volumes();
129 const DoubleVect& face_surfaces = domaine_PolyMAC_CDO.face_surfaces();
130 const DoubleVect& vit = vitesse().valeurs();
131 DoubleTrav fluent(domaine_PolyMAC_CDO.domaine().nb_elem_tot());
132
133 // Fill the fluent array
134
135 fluent = 0;
136 double psc;
137 int num1, num2, face;
138 int elem1;
139
140 // Process boundaries
141
142 for (int n_bord = 0; n_bord < domaine_PolyMAC_CDO.nb_front_Cl(); n_bord++)
143 {
144
146
147 if ( sub_type(Dirichlet_entree_fluide,la_cl.valeur()) || sub_type(Neumann_sortie_libre, la_cl.valeur()))
148
149 {
150 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
151 num1 = le_bord.num_premiere_face();
152 num2 = num1 + le_bord.nb_faces();
153 for (face = num1; face < num2; face++)
154 {
155 psc = vit[face] * face_surfaces(face);
156 if ((elem1 = face_voisins(face, 0)) != -1)
157 {
158 if (psc < 0)
159 fluent[elem1] -= psc;
160 }
161 else // (elem2 != -1)
162 if (psc > 0)
163 fluent[face_voisins(face, 1)] += psc;
164 }
165 }
166 }
167
168 // Loop over internal faces to fill fluent
169 int domaine_PolyMAC_CDO_nb_faces = domaine_PolyMAC_CDO.nb_faces();
170 for (face = domaine_PolyMAC_CDO.premiere_face_int(); face < domaine_PolyMAC_CDO_nb_faces; face++)
171 {
172 psc = vit[face] * face_surfaces(face);
173 eval_fluent(psc, face_voisins(face, 0), face_voisins(face, 1), fluent);
174 }
175 //fluent.echange_espace_virtuel();
176 if (vitesse().le_nom() == "rho_u" && equation().probleme().is_dilatable())
177 diviser_par_rho_si_dilatable(fluent, equation().milieu());
178
179 int domaine_PolyMAC_CDO_nb_elem = domaine_PolyMAC_CDO.nb_elem();
180 for (int num_poly = 0; num_poly < domaine_PolyMAC_CDO_nb_elem; num_poly++)
181 {
182 es_valeurs(num_poly) = volumes(num_poly) / (fluent[num_poly] + 1.e-30);
183 }
184
185 //double dt_min = mp_min_vect(es_valeurs);
186 //assert(dt_min==calculer_dt_stab());
187 }
188 else
189 Operateur_Conv_base::calculer_pour_post(espace_stockage, option, comp);
190}
191
193{
194 Motcle loc;
195 if (Motcle(option) == "stabilite")
196 loc = "elem";
197 else
199 return loc;
200}
201
203{
205 iter_->completer_();
206}
208{
209 iter_->associer_domaine_cl_dis(zcl);
210}
211
213{
214 return iter_->impr(os);
215}
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Dirichlet_entree_fluide This class represents a boundary condition imposing a quantity.
int_t nb_elem_tot() const
Definition Domaine.h:132
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates a parallel array of values at elements.
Definition Domaine.cpp:850
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
double volumes(int i) const
Definition Domaine_VF.h:113
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
int nb_front_Cl() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
virtual Motcle get_localisation_pour_post(const Nom &option) const
Definition MorEqn.cpp:43
virtual void calculer_pour_post(Champ_base &espace_stockage, const Nom &option, int comp) const
Definition MorEqn.cpp:35
A character string (Nom) in uppercase.
Definition Motcle.h:26
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Sortie
Definition Objet_U.h:70
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Op_Conv_PolyMAC_CDO_iterateur_base(const Iterateur_PolyMAC_CDO_base &iter_base)
double calculer_dt_stab() const override
Computes dt_stab.
void associer_domaine_cl_dis(const Domaine_Cl_dis_base &) override
virtual const Champ_base & vitesse() const =0
Motcle get_localisation_pour_post(const Nom &option) const override
void completer() override
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
void calculer_pour_post(Champ_base &espace_stockage, const Nom &option, int comp) const override
Operateur_Conv_base This class is the base of the hierarchy of operators representing.
void fixer_dt_stab_conv(double dt)
virtual void completer()
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
static double mp_min(double)
Definition Process.cpp:391
Base class for output streams.
Definition Sortie.h:52