TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Eval_Conv_VDF_Elem.tpp
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#ifndef Eval_Conv_VDF_Elem_TPP_included
17#define Eval_Conv_VDF_Elem_TPP_included
18
19template <typename DERIVED_T> template <typename Type_Double>
20inline void Eval_Conv_VDF_Elem<DERIVED_T>::flux_face(const DoubleTab& inco, const DoubleTab& val_b, const int f, const Dirichlet_entree_fluide& la_cl, const int num1, Type_Double& flux) const
21{
22 for (int n = 0; n < flux.size_array(); n++)
23 {
24 const int ind = (tab_vitesse().line_size() == flux.size_array()) ? n : 0;
25 const double psc = dt_vitesse(f,ind) * surface_porosite(f);
26 for (int i = 0, e; i < 2; i++)
27 if ((e = elem_(f, i)) > -1)
28 flux[n] = -psc * (((psc > 0 && !i) || (psc <= 0 && i)) ? inco(e, n) : val_b(f, n));
29 }
30}
31
32template <typename DERIVED_T> template <typename Type_Double>
33inline void Eval_Conv_VDF_Elem<DERIVED_T>::flux_face(const DoubleTab& inco, const DoubleTab& val_b, const int f, const Neumann_sortie_libre& la_cl, const int num1, Type_Double& flux) const
34{
35 for (int n = 0; n < flux.size_array(); n++)
36 {
37 const int ind = (tab_vitesse().line_size() == flux.size_array()) ? n : 0;
38 const double psc = dt_vitesse(f, ind) * surface_porosite(f);
39 for (int i = 0, e; i < 2; i++)
40 if ((e = elem_(f, i)) > -1)
41 flux[n] = -psc * (((psc > 0 && !i) || (psc <= 0 && i)) ? inco(e, n) : val_b(f, n));
42 }
44
45template <typename DERIVED_T> template <typename Type_Double>
46inline void Eval_Conv_VDF_Elem<DERIVED_T>::flux_face(const DoubleTab& inco, const DoubleTab&, const int face, const Periodique& la_cl, const int num1, Type_Double& flux) const
47{
48 const int i = elem_(face,0), j = elem_(face,1), ncomp = flux.size_array();
49
50 if (!DERIVED_T::IS_AMONT)
51 {
52 const double psc = dt_vitesse(face) * surface_porosite(face);
53 const int i_0 = amont_amont_(face, 0), j_1 = amont_amont_(face, 1);
54
55 if (DERIVED_T::IS_CENTRE || DERIVED_T::IS_CENTRE4)
56 qcentre_ < Type_Double > (psc, i, j, i_0, j_1, face, inco, flux); // on applique le schema centre 2 ou 4
57 else
58 {
59 Type_Double psc_multi(ncomp);
60 for (int k = 0; k < ncomp; k++)
61 {
62 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
63 psc_multi[k] = dt_vitesse(face, ind) * surface_porosite(face);
64 }
65 quick_fram_(psc_multi, i, j, i_0, j_1, face, inco, flux); // on applique le schema Quick
66 }
67
68 for (int k = 0; k < ncomp; k++) flux[k] *= -1;
69 }
70 else
71 for (int k = 0; k < ncomp; k++)
72 {
73 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
74 const double psc = dt_vitesse(face, ind) * surface_porosite(face);
75 flux[k] = (psc > 0) ? -psc * inco(i, k) : -psc * inco(j, k); /* AMONT */
76 }
77}
78
79template <typename DERIVED_T> template <typename Type_Double>
80inline void Eval_Conv_VDF_Elem<DERIVED_T>::flux_faces_interne(const DoubleTab& inco, const int face, Type_Double& flux) const
81{
82 const int i = elem_(face,0), j = elem_(face,1), ncomp = flux.size_array();
83 if (!DERIVED_T::IS_AMONT)
84 {
85 const double psc = dt_vitesse(face)*surface_porosite(face);
86 const int i_0 = amont_amont_(face,0), j_1 = amont_amont_(face,1);
87 if (DERIVED_T::IS_CENTRE)
88 {
89 qcentre_<Type_Double>(psc,i,j,i_0,j_1,face,inco,flux);
90 for (int k=0; k<ncomp; k++) flux[k] *= -1;
91 }
92 else if (DERIVED_T::IS_CENTRE4)
93 {
94 if ( (i_0 == -1) || (j_1 == -1) )
95 for (int k=0; k<ncomp; k++) flux[k] = -psc*(inco(i,k)+inco(j,k))/2.; // on applique le schema centre2
96 else // on applique le schema centre4
97 {
98 qcentre_<Type_Double>(psc,i,j,i_0,j_1,face,inco,flux);
99 for (int k=0; k<ncomp; k++) flux[k] *= -1;
100 }
101 }
102 else
103 {
104 /* *****************************************************************************************************************************************************
105 * Alexandre C. 19/02/03 : We do not use the first order upwind scheme as it was done before because in LES computations all turbulence is damped
106 * and we can not recover a proper behavior of physical turbulent characteristics, especially when using wall-functions.
107 * Therefore we use the 2nd order centered scheme.
108 * *****************************************************************************************************************************************************
109 * Pierre L. 14/10/04: Correction car le centre explose sur le cas VALIDA On revient au quick en essayant d'ameliorer: on prend le quick si psc est
110 * encore favorable pour avoir les 3 points necessaires au calcul du quick. Cela est deja ce qui est fait pour le quick-sharp de l'evaluateur aux faces.
111 * *****************************************************************************************************************************************************/
112
113 Type_Double psc_multi(ncomp);
114 for (int k = 0; k < ncomp; k++)
115 {
116 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
117 psc_multi[k] = dt_vitesse(face, ind) * surface_porosite(face);
118 }
119 quick_fram_(psc_multi,i,j,i_0,j_1,face,inco,flux);
120 for (int k=0; k<ncomp; k++) flux[k] *= -1;
121 }
122 }
123 else
124 for(int k = 0; k < ncomp; k++)
125 {
126 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
127 const double psc = dt_vitesse(face, ind)*surface_porosite(face);
128 flux[k] = (psc > 0) ? -psc * inco(i, k) : -psc * inco(j, k); /* AMONT */
129 }
130}
131
132/* ************************************** *
133 * ********* POUR L'IMPLICITE ********** *
134 * ************************************** */
135
136template <typename DERIVED_T> template <typename Type_Double>
137inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face_common(const int face, Type_Double& aii, Type_Double& ajj) const
138{
139 assert (aii.size_array() == ajj.size_array());
140 const int i = elem_(face,0), ncomp = aii.size_array();
141 double psc = dt_vitesse(face)*surface_porosite(face);
142 if (i != -1)
143 {
144 if (DERIVED_T::IS_CENTRE || DERIVED_T::IS_CENTRE4)
145 {
146 if (psc > 0)
147 for (int k = 0; k < ncomp; k++) aii[k] = -psc; // TODO : FIXME : Yannick help :/
148 }
149 else
150 for (int k = 0; k < ncomp; k++)
151 {
152 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
153 psc = dt_vitesse(face, ind)*surface_porosite(face);
154 aii[k] = (psc > 0) ? psc : 0.;
155 ajj[k] = 0.;
156 }
157 }
158 else // j != -1
159 {
160 if (DERIVED_T::IS_CENTRE || DERIVED_T::IS_CENTRE4)
161 {
162 if (psc < 0)
163 for (int k = 0; k < ncomp; k++) ajj[k] = -psc;
164 }
165 else
166 for (int k = 0; k < ncomp; k++)
167 {
168 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
169 psc = dt_vitesse(face, ind)*surface_porosite(face);
170 ajj[k] = (psc < 0) ? -psc : 0.;
171 aii[k] = 0.;
172 }
173 }
174}
175
176template <typename DERIVED_T> template <typename Type_Double>
177inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face(const int face, const int, const Dirichlet_entree_fluide& la_cl, Type_Double& aii, Type_Double& ajj) const
178{
179 coeffs_face_common(face,aii,ajj);
180}
181
182template <typename DERIVED_T> template <typename Type_Double>
183inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face(const int face, const int, const Neumann_sortie_libre& la_cl, Type_Double& aii, Type_Double& ajj) const
184{
185 coeffs_face_common(face,aii,ajj);
186}
187
188template <typename DERIVED_T> template <typename Type_Double>
189inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face(const int face, const int, const Periodique& la_cl, Type_Double& aii, Type_Double& ajj ) const
190{
191 assert (aii.size_array() == ajj.size_array());
192 const int ncomp = aii.size_array();
193 if (DERIVED_T::IS_CENTRE || DERIVED_T::IS_CENTRE4)
194 {
195 const double psc = dt_vitesse(face)*surface_porosite(face);
196 Type_Double flux(ncomp);
197 const int i = elem_(face,0), j = elem_(face,1), i_0 = amont_amont_(face,0), j_1 = amont_amont_(face,1);
198 qcentre_<Type_Double>(psc,i,j,i_0,j_1,face,inconnue->valeurs(),flux); // on applique le schema centre 2 ou 4
199 if (psc > 0)
200 for (int k = 0; k < ncomp; k++) aii[k] = -flux[k];
201 else for (int k = 0; k < ncomp; k++) ajj[k] = -flux[k];
202 }
203 else
204 for (int k = 0; k < ncomp; k++)
205 {
206 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
207 const double psc = dt_vitesse(face, ind)*surface_porosite(face);
208 aii[k] = (psc > 0) ? psc : 0.;
209 ajj[k] = (psc > 0) ? 0. : -psc;
210 }
211}
212
213template <typename DERIVED_T> template <typename Type_Double>
214inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_faces_interne(const int face, Type_Double& aii, Type_Double& ajj ) const
215{
216 assert (aii.size_array() == ajj.size_array());
217 const int ncomp = aii.size_array();
218 if (DERIVED_T::IS_CENTRE || DERIVED_T::IS_CENTRE4)
219 {
220 const double psc = dt_vitesse(face)*surface_porosite(face);
221 const int i = elem_(face,0), j = elem_(face,1), i_0 = amont_amont_(face,0), j_1 = amont_amont_(face,1);
222 if ( ((i_0 == -1) || (j_1 == -1)) && DERIVED_T::IS_CENTRE4) // TODO : FIXME : Yannick help :/ pourquoi pas pour centre2 egalement ?
223 {
224 if (psc > 0)
225 for (int k = 0; k < ncomp; k++) aii[k] = -psc;
226 else for (int k = 0; k < ncomp; k++) ajj[k] = -psc;
227 }
228 else
229 {
230 Type_Double flux(ncomp);
231 qcentre_<Type_Double>(psc,i,j,i_0,j_1,face,inconnue->valeurs(),flux); // on applique le schema centre 2 ou 4
232 if (psc > 0)
233 for (int k = 0; k < ncomp; k++) aii[k] = -flux[k];
234 else for (int k = 0; k < ncomp; k++) ajj[k] = -flux[k];
235 }
236 }
237 else
238 for (int k = 0; k < ncomp; k++)
239 {
240 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
241 const double psc = dt_vitesse(face, ind)*surface_porosite(face);
242 aii[k] = (psc > 0) ? psc : 0.;
243 ajj[k] = (psc > 0) ? 0. : -psc;
244 }
245}
246
247template <typename DERIVED_T> template <typename Type_Double>
248inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face_bloc_vitesse(const DoubleTab& inco, const DoubleTab& val_b, const int f, const Dirichlet_entree_fluide& la_cl, const int num1, Type_Double& flux) const
249{
250 if (DERIVED_T::IS_CENTRE4) return ;
251 else
252 {
253 for (int n = 0; n < flux.size_array(); n++)
254 for (int i = 0, e; i < 2; i++)
255 if ((e = elem_(f, i)) > -1)
256 {
257 const int ind = (tab_vitesse().line_size() == flux.size_array()) ? n : 0;
258 flux[n] = surface_porosite(f) *
259 (((dt_vitesse(f, ind) > 0 && !i) || (dt_vitesse(f, ind) <= 0 && i)) ? inco(e, n) : val_b(f,
260 n));
261 }
262 }
263}
264
265template <typename DERIVED_T> template <typename Type_Double>
266inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face_bloc_vitesse(const DoubleTab& inco, const DoubleTab& val_b, const int f, const Neumann_sortie_libre& la_cl, const int num1, Type_Double& flux) const
267{
268 if (DERIVED_T::IS_CENTRE4) return;
269 else
270 {
271 for (int n = 0; n < flux.size_array(); n++)
272 for (int i = 0, e; i < 2; i++)
273 if ((e = elem_(f, i)) > -1)
274 {
275 const int ind = (tab_vitesse().line_size() == flux.size_array()) ? n : 0;
276 flux[n] = surface_porosite(f) *
277 (((dt_vitesse(f, ind) > 0 && !i) || (dt_vitesse(f, ind) <= 0 && i)) ? inco(e, n) : val_b(f,
278 n));
279 }
280 }
281}
282
283template <typename DERIVED_T> template <typename Type_Double>
284inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face_bloc_vitesse_common(const DoubleTab& inco, const int face, Type_Double& flux ) const
285{
286 if (DERIVED_T::IS_CENTRE4) return;
287 else
288 {
289 const int i = elem_(face, 0), j = elem_(face, 1), ncomp = flux.size_array();
290 const double psc = surface_porosite(face);
291 if (DERIVED_T::IS_CENTRE)
292 {
293 const int i_0 = amont_amont_(face, 0), j_1 = amont_amont_(face, 1);
294 qcentre_<Type_Double>(psc, i, j, i_0, j_1, face, inco, flux);
295 }
296 else
297 for (int k = 0; k < ncomp; k++)
298 {
299 const int ind = (tab_vitesse().line_size() == ncomp) ? k : 0;
300 flux[k] = (dt_vitesse(face, ind) > 0) ? psc * inco(i, k) : psc * inco(j, k);
301 }
302 }
303}
304
305template <typename DERIVED_T> template <typename Type_Double>
306inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_face_bloc_vitesse(const DoubleTab& inco, const DoubleTab&, const int face, const Periodique& la_cl, const int, Type_Double& flux ) const
307{
308 coeffs_face_bloc_vitesse_common(inco, face, flux);
309}
310
311template <typename DERIVED_T> template <typename Type_Double>
312inline void Eval_Conv_VDF_Elem<DERIVED_T>::coeffs_faces_interne_bloc_vitesse(const DoubleTab& inco, const int face , Type_Double& flux) const
313{
314 coeffs_face_bloc_vitesse_common(inco, face, flux);
315}
316
317#endif /* Eval_Conv_VDF_Elem_TPP_included */
classe Dirichlet_entree_fluide Cette classe represente une condition aux limite imposant une grandeur
void coeffs_faces_interne(const int, Type_Double &, Type_Double &) const
void coeffs_face_bloc_vitesse(const DoubleTab &, const DoubleTab &, const int, const BC &, const int, Type_Double &) const
void coeffs_face(const int, const int, const BC &, Type_Double &, Type_Double &) const
void flux_faces_interne(const DoubleTab &, const int, Type_Double &) const
void flux_face(const DoubleTab &, const DoubleTab &, const int, const BC &, const int, Type_Double &) const
void coeffs_faces_interne_bloc_vitesse(const DoubleTab &, const int, Type_Double &) const
classe Neumann_sortie_libre Cette classe represente une frontiere ouverte sans vitesse imposee
classe Periodique Cette classe represente une condition aux limites periodique.
Definition Periodique.h:31