43 DoubleTab&
ajouter(
const DoubleTab& , DoubleTab& )
const override;
60 DoubleTab&
ajouter_sous_cond(
const DoubleTab& transporte, DoubleTab& resu,
int btd_impl,
int hourglass_impl,
int centre_impl)
const;
82 DoubleTab&
ajouter_sous_cond_gen(
const DoubleTab& transporte, DoubleTab& resu,
int btd_impl,
int hourglass_impl,
int centre_impl)
const;
89 template <AJOUTE_COND _COND_>
90 DoubleTab&
ajouter_sous_cond_template(
const DoubleTab& transporte, DoubleTab& resu,
int btd_impl,
int hourglass_impl,
int centre_impl)
const;
105 static constexpr bool IS_GEN = (_COND_ == AJOUTE_COND::GEN), IS_D3_81 = (_COND_ == AJOUTE_COND::D3_81), IS_D3_82 = (_COND_ == AJOUTE_COND::D3_82),
106 IS_D2_41 = (_COND_ == AJOUTE_COND::D2_41), IS_D2_42 = (_COND_ == AJOUTE_COND::D2_42);
109 const int nb_som_elem = (IS_D3_81 || IS_D3_82) ? 8 : ( (IS_D2_41 || IS_D2_42) ? 4 : domaine_ef.
domaine().nb_som_elem() );
111 if ((btd_impl == 1) && (hourglass_impl == 1) && (centre_impl == 1))
116 const DoubleTab& G = la_vitesse.
valeurs();
118 int transport_rhou = 0;
119 if (vitesse_->le_nom() ==
"rho_u") transport_rhou = 1;
122 int is_not_rho_unif = (rho_elem.
size() == 1 ? 0 : 1);
130 const DoubleTab& IPhi_thilde = domaine_ef.
IPhi_thilde(), & bij = domaine_ef.
Bij();
135 int mcoef3d[8] = { 1, -1, -1, 1, -1, 1, 1, -1 };
136 int sommetoppose[8] = { 7, 6, 5, 4, 3, 2, 1, 0 };
138 DoubleTab transp_loc(nb_som_elem, nb_comp0);
141 int is_not_lambda_unif = 1;
142 if (lambda.
size() == 1)
143 is_not_lambda_unif = 0;
145 const int const_dimension = (IS_D3_81 || IS_D3_82) ? 3 : ( (IS_D2_41 || IS_D2_42) ? 2 :
Objet_U::dimension );
146 const int nb_comp = IS_D3_82 ? 3 : ((IS_D3_81 || IS_D2_41) ? 1 : ( IS_D2_42 ? 2 : nb_comp0 ));
147 const int dim_fois_nbn = (IS_D3_81 || IS_D3_82) ? 24 : ( (IS_D2_41 || IS_D2_42) ? 8 : -100 );
149 if (nb_comp0 != nb_comp)
152 ArrOfDouble G_e(const_dimension);
153 ArrOfDouble pr(nb_comp),ge_bij(nb_som_elem);
155 const double *bij_ptr = bij.addr();
156 const double *transp_loc_ptr = transp_loc.
addr();
157 const double *transporte_ptr = transporte.
addr();
158 double *resu_ptr = resu.
addr();
160#define bij_(elem,i,j) (IS_GEN ? bij(elem,i,j) : bij_ptr[elem*dim_fois_nbn+i*const_dimension+j])
161#define transp_loc_(som,a) (IS_GEN ? transp_loc(som,a) :transp_loc_ptr[som*nb_comp+a])
162#define transporte_(som,a) (IS_GEN ? transporte(som,a) : transporte_ptr[som*nb_comp+a])
163#define resu_(som,a) (IS_GEN ? resu(som,a) : resu_ptr[som*nb_comp+a])
165 double inv_nb_som_elem = 1. / nb_som_elem;
166 for (
int elem = 0; elem < nb_elem_tot; elem++)
170 for (
int i1 = 0; i1 < nb_som_elem; i1++)
172 int glob = elems(elem, i1);
173 for (
int b = 0; b < const_dimension; b++)
174 G_e[b] += G(glob, b);
175 for (
int a = 0; a < nb_comp; a++)
176 transp_loc(i1, a) = transporte_(glob, a);
178 G_e *= inv_nb_som_elem;
180 double vol_elem = volumes(elem);
181 double inv_vol_elem = 1. / vol_elem;
182 double pond2 = volumes_thilde(elem) * inv_vol_elem * inv_vol_elem;
185 pond2 /= (is_not_rho_unif ? rho_elem(elem) : rho_elem(0, 0));
186 double fpond2 = f * pond2;
188 if ((
hourglass) && (nb_som_elem == 8) && (hourglass_impl == 0))
190 double pond3 = f * dotproduct_array(G_e, G_e);
192 pond3 /= (is_not_rho_unif ? rho_elem(elem) : rho_elem(0, 0));
193 if (is_not_lambda_unif)
194 pond3 += lambda(elem);
196 pond3 += lambda(0, 0);
197 pond3 *= volumes_thilde(elem) * inv_vol_elem * pow(vol_elem, 0.3333333333333333);
200 for (
int a = 0; a < nb_comp; a++)
202 double coef2d = 0.042 * pond3;
203 double coef3d = coef2d * 0.5;
205 double t0 = -coef2d * (transp_loc_(0,a)+transp_loc_(1,a)+transp_loc_(2,a)+transp_loc_(3,a)
206 +transp_loc_(4,a)+transp_loc_(5,a)+transp_loc_(6,a)+transp_loc_(7,a));
209 for (
int i = 0; i < 8; i++)
210 t3d += mcoef3d[i] * transp_loc_(i, a);
212 double t3db = coef3d * (transp_loc_(0,a)-transp_loc_(1,a)+transp_loc_(3,a)-transp_loc_(2,a)
213 -transp_loc_(4,a)+transp_loc_(5,a)-transp_loc_(7,a)+transp_loc_(6,a));
214 if (!est_egal(t3d, t3db, 1e-6))
217 for (
int i = 0; i < 8; i++)
218 resu_(elems(elem,i),a)-=mcoef3d[i]*t3d+t0+coef2d*4.*(transp_loc_(i,a)+transp_loc_(sommetoppose[i],a));
223 for (
int yy = 0; yy < nb_som_elem; yy++)
225 if ((centre_impl == 0) || (btd_impl == 0))
227 for (
int i1 = 0; i1 < nb_som_elem; i1++)
230 for (
int b = 0; b < const_dimension; b++)
231 cb += G_e[b] * bij_(elem, i1, b);
234 for (
int i1 = 0; i1 < nb_som_elem; i1++)
237 if (centre_impl == 0)
238 pond = IPhi_thilde(elem, i1) * inv_vol_elem;
239 int glob = elems(elem, i1);
241 for (
int yy = 0; yy < nb_comp; yy++)
246 cbbtd += ge_bij[i1] * (fpond2);
247 for (
int i2 = 0; i2 < nb_som_elem; i2++)
249 const double cbi2 = ge_bij[i2];
250 double coef = cbbtd * cbi2;
251 for (
int a = 0; a < nb_comp; a++)
252 pr[a] -= coef * transp_loc_(i2, a);
254 for (
int a = 0; a < nb_comp; a++)
255 resu_(glob,a)+=pr[a];
261 fluent_.echange_espace_virtuel();