TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_val_tot_sur_vol_VEF.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 <Champ_val_tot_sur_vol_VEF.h>
17#include <Equation_base.h>
18#include <Domaine_Cl_VEF.h>
19#include <Dirichlet.h>
20#include <Sous_Domaine.h>
21#include <Domaine_VEF.h>
22
23Implemente_instanciable(Champ_val_tot_sur_vol_VEF,"Valeur_totale_sur_volume_VEF",Champ_val_tot_sur_vol_base);
24
25
27{
29 return os;
30}
31
33{
35 return is;
36}
37
38DoubleVect& Champ_val_tot_sur_vol_VEF::eval_contrib_loc(const Domaine_dis_base& zdis,const Domaine_Cl_dis_base& zcldis,DoubleVect& vol_glob_pond)
39{
40 const Domaine_VEF& zvef = ref_cast(Domaine_VEF,zdis);
41 const Domaine_Cl_VEF& zclvef = ref_cast(Domaine_Cl_VEF,zcldis);
42 const int nb_elem = zvef.nb_elem();
43 int size_vol = les_sous_domaines.size()+1;
44 vol_glob_pond.resize(size_vol);
45
46 const int nb_faces = zvef.nb_faces();
47 const int nb_fac_el = zvef.domaine().nb_faces_elem();
48 const IntTab& elem_faces = zvef.elem_faces();
49 const DoubleVect& vol_entrelaces = zvef.volumes_entrelaces();
50 const DoubleVect& vol_entrelaces_Cl = zclvef.volumes_entrelaces_Cl();
51 const ArrOfInt& faces_doubles = zvef.faces_doubles();
52 const DoubleVect& por_face = zclvef.equation().milieu().porosite_face();
53 int prem_face_std = zvef.premiere_face_std();
54 int face_g,face_marq;
55 double fac_pond,vol_entrelace;
56
57 int cpt=1;
58 IntVect face_fait(nb_faces);
59
60 for (auto& itr : les_sous_domaines)
61 {
62 const Sous_Domaine& sz = itr.valeur();
63 int size_sz = sz.nb_elem_tot();
64 face_fait = 0;
65 int el,elem0,elem1,elem_test;
66
67 for (int elem=0; elem<size_sz; elem++)
68 {
69 el = sz(elem);
70 // Keep only the real elements
71 if (el<nb_elem)
72 {
73 for (int fac=0; fac<nb_fac_el; fac++)
74 {
75 face_g = elem_faces(el,fac);
76
77 if (!face_fait(face_g))
78 {
79
80 // Among the two neighboring elements of the processed face, keep
81 // the one that is not the current element in the sub-domain
82 elem0 = zvef.face_voisins(face_g,0);
83 elem1 = zvef.face_voisins(face_g,1);
84 if (elem0==el)
85 elem_test = elem1;
86 else
87 elem_test = elem0;
88
89 // Four possible situations:
90 // - elem_test=-1: boundary condition
91 // - elem_test is also in the current sub-domain
92 // - elem_test is in another sub-domain
93 // - elem_test is in the default part of the domain (not in a sub-domain)
94
95 int ok_trouve_loc = 0;
96 // Check if elem_test is in the current sub-domain
97 // (1 if real element, 2 if virtual, 0 otherwise)
98 // ok_trouve_loc set to 1 if elem_test is in the current sub-domain, 0 otherwise
99 for (int poly=0; poly<size_sz; poly++)
100 {
101 if (elem_test==sz(poly))
102 {
103 ok_trouve_loc = 1;
104 if (elem_test>nb_elem-1)
105 ok_trouve_loc = 2;
106 break;
107 }
108 }
109
110 // elem_test is in the current sub-domain (as a real element) or is a boundary condition
111 if ((ok_trouve_loc==1) || (elem_test==-1))
112 fac_pond = 1.;
113 // elem_test is in another sub-domain or in the default part
114 // or in the current sub-domain but as a virtual element
115 else
116 fac_pond = 0.5;
117
118 if (face_g<prem_face_std)
119 vol_entrelace = vol_entrelaces_Cl(face_g);
120 else
121 vol_entrelace = vol_entrelaces(face_g);
122
123 vol_glob_pond(cpt) += fac_pond*vol_entrelace*por_face(face_g);
124 face_fait(face_g) = 1;
125 }
126 }
127 }
128 }
129
130 // Remove the vol_entrelaces_Cl contributions for Dirichlet faces because the power
131 // attributed to these vol_entrelaces_Cl is not effective during the computation
132 for (int n_bord=0; n_bord<zvef.nb_front_Cl(); n_bord++)
133 {
134 const Cond_lim& la_cl = zclvef.les_conditions_limites(n_bord);
135 if (sub_type(Dirichlet,la_cl.valeur()))
136 {
137 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
138 int face;
139 int num1 = 0;
140 int num2 = le_bord.nb_faces();
141 for (int ind_face=num1; ind_face<num2; ind_face++)
142 {
143 face = le_bord.num_face(ind_face);
144 if (face_fait(face)==1)
145 vol_glob_pond(cpt) -= vol_entrelaces_Cl(face)*por_face(face);
146 }
147 }
148 }
149
150 cpt++;
151 }
152
153 for (int num_face=0; num_face<prem_face_std; num_face++)
154 {
155 face_marq = faces_doubles[num_face];
156 double contrib_double = double(face_marq);
157 vol_glob_pond(0) += (1.-0.5*contrib_double)*vol_entrelaces_Cl(num_face)*por_face(num_face);
158 }
159
160
161 // Remove the vol_entrelaces_Cl contributions for Dirichlet faces because the power
162 // attributed to these vol_entrelaces_Cl is not effective during the computation
163 for (int n_bord=0; n_bord<zvef.nb_front_Cl(); n_bord++)
164 {
165 const Cond_lim& la_cl = zclvef.les_conditions_limites(n_bord);
166 if (sub_type(Dirichlet,la_cl.valeur()))
167 {
168 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
169 int face;
170 int num1 = 0;
171 int num2 = le_bord.nb_faces();
172 for (int ind_face=num1; ind_face<num2; ind_face++)
173 {
174 face = le_bord.num_face(ind_face);
175 face_marq = faces_doubles[face];
176 double contrib_double = double(face_marq);
177 vol_glob_pond(0) -= (1.-0.5*contrib_double)*vol_entrelaces_Cl(face)*por_face(face);
178 }
179 }
180 }
181
182 for (int num_face=prem_face_std; num_face<nb_faces; num_face++)
183 {
184 face_marq = faces_doubles[num_face];
185 double contrib_double = double(face_marq);
186 vol_glob_pond(0) += (1.-0.5*contrib_double)*vol_entrelaces(num_face)*por_face(num_face);
187 }
188 vol_glob_pond(0) = mp_sum(vol_glob_pond(0));
189
190 for (int i=1; i<size_vol; i++)
191 {
192 vol_glob_pond(i) = mp_sum(vol_glob_pond(i));
193 vol_glob_pond(0) -= vol_glob_pond(i);
194 }
195
196 return vol_glob_pond;
197}
class Champ_val_tot_sur_vol_VEF derived from Champ_val_tot_sur_vol_base. Evaluation Somme_vol_poro_lo...
DoubleVect & eval_contrib_loc(const Domaine_dis_base &zdis, const Domaine_Cl_dis_base &zcldis, DoubleVect &vol) override
Champ_val_tot_sur_vol_base Base class derived from Champ_Uniforme_Morceaux representing fields.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
Definition Domaine.h:484
DoubleVect & volumes_entrelaces_Cl()
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.
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
ArrOfInt & faces_doubles()
Returns 1 for faces belonging to a periodic boundary or a shared item, 0 by default.
Definition Domaine_VF.h:566
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
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.
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
virtual const Milieu_base & milieu() const =0
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_face(const int) const
Definition Front_VF.h:68
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
Base class for output streams.
Definition Sortie.h:52
int_t nb_elem_tot() const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91