TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Rappel_T_VEF_Face.cpp
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#include <Terme_Source_Rappel_T_VEF_Face.h>
17#include <Champ_Uniforme.h>
18#include <Domaine_VEF.h>
19#include <Domaine_Cl_VEF.h>
20#include <Probleme_base.h>
21#include <Equation_base.h>
22#include <Schema_Temps_base.h>
23#include <EFichier.h>
24#include <Interprete.h>
25#include <TRUSTTab.h>
26
27Implemente_instanciable(Terme_Source_Rappel_T_VEF_Face,"Source_Rappel_T_VEF_P1NC",Source_base);
28
30{
31 return s << que_suis_je() ;
32}
33
35{
36 Motcle mot_lu;
37 Motcle acc_ouverte("{");
38 Motcle acc_fermee("}");
39
40 Motcles les_mots(3);
41 {
42 les_mots[0]="alpha_tau"; //source term relaxation coefficient
43 les_mots[1]="force_rappel"; // Expression for the restoring force
44 les_mots[2]="probleme"; // Expression for the restoring force
45 }
46 is >> mot_lu;
47 if(mot_lu != acc_ouverte)
48 {
49 Cerr << "Expected { instead of " << mot_lu
50 << " while reading wall law parameters " << finl;
51 }
52 is >> mot_lu;
53 while(mot_lu != acc_fermee)
54 {
55 int rang=les_mots.search(mot_lu);
56 switch(rang)
57 {
58 case 0:
59 is >> alpha_tau;
60 break;
61 case 1:
62 {
63 Nom tmp;
64 is >> tmp;
65 force_rappel.setNbVar(dimension);
66 force_rappel.setString(tmp);
67 force_rappel.addVar("x");
68 force_rappel.addVar("y");
69 if (dimension>2)
70 force_rappel.addVar("z");
71 force_rappel.parseString();
72 fct_ok=1;
73 break;
74 }
75 case 2:
76 fct_ok=0;
77 is >> nom_autre_pb >> nom_inco;
78 break;
79 default :
80 {
81 Cerr << mot_lu << " is not a keyword understood by Source_Canal_RANS_LES_VEF_P1NC" << finl;
82 Cerr << "The understood keywords are: " << les_mots << finl;
83 exit();
84 }
85 }
86 is >> mot_lu;
87 }
88
89 return is;
90
91}
92
94 const Domaine_Cl_dis_base& domaine_Cl_dis)
95{
96 le_dom_VEF = ref_cast(Domaine_VEF, domaine_dis);
97 le_dom_Cl_VEF = ref_cast(Domaine_Cl_VEF, domaine_Cl_dis);
98}
99
105{
107 if (fct_ok == 0)
108 {
109 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF,equation().domaine_dis());
110 const Domaine& domaine = domaine_VEF.domaine();
111 const int nb_elem = domaine_VEF.nb_elem();
112
113 Objet_U& ob1=Interprete::objet(nom_autre_pb);
115 if( sub_type(Probleme_base, ob1) )
116 pb = ref_cast(Probleme_base, ob1);
117 else
118 {
119 Cerr << "Cannot find a problem named " << nom_autre_pb << finl;
120 exit();
121 }
122
123 OBS_PTR(Champ_base) rch;
124 rch = pb->get_champ(nom_inco);
125 l_inconnue=ref_cast(Champ_Inc_base, rch.valeur()) ;
126
127 domaine_VEF_autre_pb = ref_cast(Domaine_VEF,pb->domaine_dis());
128 const int nb_elem_autre_pb = domaine_VEF_autre_pb->nb_elem();
129 const DoubleTab& xp_autre_pb = domaine_VEF_autre_pb->xp() ;
130 const DoubleVect& volumes = domaine_VEF_autre_pb->volumes();
131
132 // Array dimensioning
133 nb_fin.resize_array(nb_elem);
134 corresp_fin_gros.resize_array(nb_elem_autre_pb);
135 nb_fin=0;
136 corresp_fin_gros=0;
137 vol_fin_tot.resize_array(nb_elem);
138 vol_fin_tot=0.;
139
140 // Compute connectivities between the meshes of the two problems
141 domaine.chercher_elements(xp_autre_pb, corresp_fin_gros);
142 for (int i=0; i<nb_elem_autre_pb; i++)
143 {
144 assert(corresp_fin_gros[i]>0);
145 nb_fin[corresp_fin_gros[i]]++;
146 vol_fin_tot[corresp_fin_gros[i]] += volumes(i);
147 }
148 }
149
150}
151
152
153
154DoubleTab& Terme_Source_Rappel_T_VEF_Face::ajouter(DoubleTab& resu) const
155{
156 const Domaine_VEF& domaine_VEF = le_dom_VEF.valeur();
157 const int nb_faces = domaine_VEF.nb_faces();
158 const int premiere_face_std=domaine_VEF.premiere_face_std();
159 const int ndeb = domaine_VEF.premiere_face_int();
160
161 const int nb_elem = domaine_VEF.nb_elem();
162 const DoubleTab& temperature = mon_equation->inconnue().valeurs();
163 const DoubleVect& volumes_entrelaces = domaine_VEF.volumes_entrelaces();
164 const DoubleVect& volumes_entrelaces_Cl = le_dom_Cl_VEF->volumes_entrelaces_Cl();
165 const DoubleTab& xv=domaine_VEF.xv() ;
166 const double dt = mon_equation->schema_temps().pas_de_temps();
167
168 const DoubleVect& volumes_autre_pb = domaine_VEF_autre_pb->volumes();
169
170 double vol;
171 double force=0.;
172
173 if (fct_ok == 1)
174 {
175 for(int num_face = 0 ; num_face<premiere_face_std ; num_face++)
176 {
177 vol = volumes_entrelaces_Cl(num_face);
178
179 for (int i=0; i<dimension; i++)
180 force_rappel.setVar(i,xv(num_face,i));
181
182 force = force_rappel.eval();
183 resu(num_face) += (force-temperature(num_face))/(alpha_tau*dt)*vol;
184 }
185
186 for(int num_face = 0 ; num_face<nb_faces ; num_face++)
187 {
188 vol = volumes_entrelaces(num_face);
189
190 for (int i=0; i<dimension; i++)
191 force_rappel.setVar(i,xv(num_face,i));
192
193 force = force_rappel.eval();
194 resu(num_face) += (force-temperature(num_face))/(alpha_tau*dt)*vol;
195 }
196 }
197 else
198 {
199 const Domaine_VEF& domaineVEF_autre_pb = ref_cast(Domaine_VEF,l_inconnue->domaine_dis_base());
200 const int nb_elem_autre_pb = domaineVEF_autre_pb.nb_elem();
201 const DoubleTab& xp=domaineVEF_autre_pb.xp() ;
202
203 const IntTab& face_voisins=domaine_VEF.face_voisins() ;
204 ArrOfDouble val_elem(nb_elem); // values on elements of the current pb from the field of the other pb.
205
206 DoubleTab valeurs(nb_elem_autre_pb,l_inconnue->nb_comp()); //values on the other pb
207 IntTab elems(nb_elem_autre_pb);
208 for (int i=0; i<nb_elem_autre_pb; i++)
209 elems(i)=i;
210 l_inconnue->valeur_aux_elems(xp, elems, valeurs);
211
212 val_elem=0.;
213 for (int i=0; i<nb_elem_autre_pb; i++)
214 {
215 val_elem[corresp_fin_gros[i]] += valeurs(i,0)*volumes_autre_pb(i)/vol_fin_tot[corresp_fin_gros[i]] ; ///nb_fin(corresp_fin_gros(i));
216 }
217
218
219 for(int num_face = 0 ; num_face<ndeb ; num_face++)
220 {
221 vol = volumes_entrelaces_Cl(num_face);
222
223 force = val_elem[face_voisins(num_face,0)];
224 resu(num_face) += (force-temperature(num_face))/(alpha_tau*dt)*vol;
225 }
226 for(int num_face = ndeb ; num_face<premiere_face_std ; num_face++)
227 {
228 vol = volumes_entrelaces_Cl(num_face);
229
230 force = 0.5*(val_elem[face_voisins(num_face,0)]+val_elem[face_voisins(num_face,1)]);
231 if ((force!=0.))//&& (force-temperature(num_face)>0.))
232 resu(num_face) += (force-temperature(num_face))/(alpha_tau*dt)*vol;
233 }
234
235 for(int num_face = premiere_face_std ; num_face<nb_faces ; num_face++)
236 {
237 vol = volumes_entrelaces(num_face);
238
239 if ((val_elem[face_voisins(num_face,0)] !=0.) && (val_elem[face_voisins(num_face,1)] !=0.))
240 force = 0.5*(val_elem[face_voisins(num_face,0)]+val_elem[face_voisins(num_face,1)]);
241 else
242 force = val_elem[face_voisins(num_face,0)]+val_elem[face_voisins(num_face,1)];
243 if ((force!=0.))//&& (force-temperature(num_face)>0.))
244 {
245 //Cout << "force = " << force << finl;
246 resu(num_face) += (force-temperature(num_face))/(alpha_tau*dt)*vol;
247 }
248 //Cout << "force-temperature(num_face) = " << force-temperature(num_face) << finl;
249 }
250
251
252
253 }
254
255
256 return resu;
257}
258
259DoubleTab& Terme_Source_Rappel_T_VEF_Face::calculer(DoubleTab& resu) const
260{
261 resu = 0;
262 return ajouter(resu);
263}
264
Class Champ_Inc_base.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VEF
Definition Domaine_VEF.h:53
int premiere_face_std() const
Definition Domaine_VEF.h:79
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
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
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
static int dimension
Definition Objet_U.h:94
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
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
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 void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
virtual void completer()
Updates internal references of the Source_base object.
void completer() override
Updates internal references of the Source_base object.
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void associer_pb(const Probleme_base &) override
OBS_PTR(Domaine_VEF) le_dom_VEF
DoubleTab & ajouter(DoubleTab &) const override
DoubleTab & calculer(DoubleTab &) const override