TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
PDC_PolyMAC_CDO_impl.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 <PDC_PolyMAC_CDO_impl.h>
17#include <Equation_base.h>
18#include <Motcle.h>
19#include <Param.h>
20
22{
23 Nom tmp;
24 is >> tmp;
25 Cerr << "Reading and interpreting the function " << tmp << " ... ";
26 lambda_ortho.setNbVar(2 + Objet_U::dimension);
27 lambda_ortho.setString(tmp);
28 lambda_ortho.addVar("Re");
29 lambda_ortho.addVar("t");
30 lambda_ortho.addVar("x");
31 if (Objet_U::dimension > 1)
32 lambda_ortho.addVar("y");
33 if (Objet_U::dimension > 2)
34 lambda_ortho.addVar("z");
35 lambda_ortho.parseString();
36 Cerr << " Ok" << finl;
37 return 1;
38}
39
40void PDC_Anisotrope_PolyMAC_CDO::coeffs_perte_charge_impl(const DoubleVect& u, const DoubleVect& pos, double t, double norme_u,
41 double dh, double nu, double reynolds, double K, double& coeff_ortho,
42 double& coeff_long, double& u_l, DoubleVect& v_valeur, Parser_U& lambda) const
43{
44 // Compute lambda
45 lambda.setVar(0, reynolds);
46 lambda.setVar(1, t);
47 lambda.setVar(2, pos[0]);
48 if (Objet_U::dimension > 1)
49 lambda.setVar(3, pos[1]);
50 if (Objet_U::dimension > 2)
51 lambda.setVar(4, pos[2]);
52
53 // Compute lambda_ortho
54 lambda_ortho.setVar(0, reynolds);
55 lambda_ortho.setVar(1, t);
56 lambda_ortho.setVar(2, pos[0]);
57 if (Objet_U::dimension > 1)
58 lambda_ortho.setVar(3, pos[1]);
59 if (Objet_U::dimension > 2)
60 lambda_ortho.setVar(4, pos[2]);
61 double l_ortho = lambda_ortho.eval(); // to avoid evaluating the parser twice
62
63 // Compute v and ||v||^2
64 // DoubleVect v_valeur(dimension);
65 double vcarre = 0;
66 v->valeur_a(pos, v_valeur);
67 for (int dim = 0; dim < Objet_U::dimension; dim++)
68 vcarre += v_valeur[dim] * v_valeur[dim];
69 v_valeur /= sqrt(vcarre);
70 // Compute u.v
71 double scal = 0;
72 for (int dim = 0; dim < Objet_U::dimension; dim++)
73 scal += u[dim] * v_valeur[dim];
74
75 // Compute the result
76 /*
77 for (int dim=0;dim<dimension;dim++)
78 p_charge[dim] = -l_ortho*norme_u/2./dh*u[dim]
79 -(lambda.eval()-l_ortho)*scal*v_valeur[dim]*norme_u/2./dh;
80 */
81 coeff_ortho = K * l_ortho * norme_u / 2. / dh;
82 coeff_long = K * lambda.eval() * norme_u / 2. / dh;
83 u_l = scal;
84}
85
87{
88 Nom tmp;
89 is >> tmp;
90 Cerr << "Reading and interpreting the function " << tmp << " ... ";
91 lambda_ortho.setNbVar(3 + Objet_U::dimension);
92 lambda_ortho.setString(tmp);
93 lambda_ortho.addVar("Re_tot");
94 lambda_ortho.addVar("Re_ortho");
95 lambda_ortho.addVar("t");
96 lambda_ortho.addVar("x");
97 if (Objet_U::dimension > 1)
98 lambda_ortho.addVar("y");
99 if (Objet_U::dimension > 2)
100 lambda_ortho.addVar("z");
101 lambda_ortho.parseString();
102 Cerr << " Ok" << finl;
103 return 1;
104}
105
106void PDC_Circulaire_PolyMAC_CDO::coeffs_perte_charge_impl(const DoubleVect& u, const DoubleVect& pos, double t,
107 double norme_u, double dh, double nu, double reynolds, double K, double& coeff_ortho,
108 double& coeff_long, double& u_l, DoubleVect& av_valeur, Parser_U& lambda) const
109{
110 // compute dh_ortho
111 double dh_ortho = diam_hydr_ortho->valeur_a_compo(pos, 0);
112
113 // compute u.d/||d||
114 // Compute v and ||v||^2
115 av_valeur.resize(Objet_U::dimension);
116
117 v->valeur_a(pos, av_valeur);
118 // normalize v
119 {
120 double vcarre = 0;
121 for (int dim = 0; dim < Objet_U::dimension; dim++)
122 vcarre += av_valeur[dim] * av_valeur[dim];
123 av_valeur /= sqrt(vcarre);
124 }
125 // Compute u.v/||v||
126 u_l = 0;
127
128 for (int dim = 0; dim < Objet_U::dimension; dim++)
129 u_l += u[dim] * av_valeur[dim];
130
131 double u_ortho = sqrt(norme_u * norme_u - u_l * u_l);
132 // compute Re_l and Re_ortho
133 // Compute the Reynolds number
134 /* PL: To avoid a possible division by zero, we replace:
135 double nu=norme_u*dh/reynolds;
136 double Re_l=std::fabs(u_l)*dh/nu; */
137 // By:
138 double Re_l = dh * std::fabs(u_l) / nu;
139 if (Re_l < 1e-10)
140 Re_l = 1e-10;
141 // PL: To avoid a possible division by zero, we replace:
142 /* double Re_ortho=u_ortho*dh_ortho/nu; */
143 // By:
144 double Re_ortho = dh_ortho * u_ortho / nu;
145 if (Re_ortho < 1e-10)
146 Re_ortho = 1e-10;
147 // Compute lambda
148 lambda.setVar(0, reynolds);
149 lambda.setVar(1, Re_l);
150 lambda.setVar(2, t);
151 lambda.setVar(3, pos[0]);
152 if (Objet_U::dimension > 1)
153 lambda.setVar(4, pos[1]);
154 if (Objet_U::dimension > 2)
155 lambda.setVar(5, pos[2]);
156
157 // Compute lambda_ortho
158 lambda_ortho.setVar(0, reynolds);
159 lambda_ortho.setVar(1, Re_ortho);
160 lambda_ortho.setVar(2, t);
161 lambda_ortho.setVar(3, pos[0]);
162 if (Objet_U::dimension > 1)
163 lambda_ortho.setVar(4, pos[1]);
164 if (Objet_U::dimension > 2)
165 lambda_ortho.setVar(5, pos[2]);
166 double l_ortho = lambda_ortho.eval(); // to avoid evaluating the parser twice
167 double l_long = lambda.eval();
168 coeff_ortho = K * l_ortho * u_ortho / 2. / dh_ortho;
169 coeff_long = K * l_long * std::fabs(u_l) / 2. / dh;
170}
171
172void PDC_Directionnelle_PolyMAC_CDO::coeffs_perte_charge_impl(const DoubleVect& u, const DoubleVect& pos, double t, double norme_u,
173 double dh, double nu, double reynolds, double K, double& coeff_ortho,
174 double& coeff_long, double& u_l, DoubleVect& v_valeur, Parser_U& lambda) const
175{
176 // Compute lambda
177 lambda.setVar(0, reynolds);
178 lambda.setVar(1, t);
179 lambda.setVar(2, pos[0]);
180 if (Objet_U::dimension > 1)
181 lambda.setVar(3, pos[1]);
182 if (Objet_U::dimension > 2)
183 lambda.setVar(4, pos[2]);
184
185 // Compute v and ||v||^2
186 // DoubleVect v_valeur(dimension);
187 double vcarre = 0;
188 v->valeur_a(pos, v_valeur);
189 for (int dim = 0; dim < Objet_U::dimension; dim++)
190 vcarre += v_valeur[dim] * v_valeur[dim];
191 v_valeur /= sqrt(vcarre);
192 // Compute u.v
193 double scal = 0;
194 for (int dim = 0; dim < Objet_U::dimension; dim++)
195 scal += u[dim] * v_valeur[dim];
196 /*
197 // Compute the result
198 for (int dim=0;dim<dimension;dim++)
199 p_charge[dim] = -lambda.eval()*scal*v_valeur[dim]*norme_u/2./dh;
200 */
201 u_l = scal;
202 coeff_long = K * lambda.eval() * norme_u / 2. / dh;
203 coeff_ortho = 0;
204}
205
206void PDC_Isotrope_PolyMAC_CDO::coeffs_perte_charge_impl(const DoubleVect& u, const DoubleVect& pos, double t, double norme_u,
207 double dh, double nu, double reynolds, double K, double& coeff_ortho,
208 double& coeff_long, double& u_l, DoubleVect& v_valeur, Parser_U& lambda) const
209{
210 // Compute lambda
211 lambda.setVar(0, reynolds);
212 lambda.setVar(1, t);
213 lambda.setVar(2, pos[0]);
214 if (Objet_U::dimension > 1)
215 lambda.setVar(3, pos[1]);
216 if (Objet_U::dimension > 2)
217 lambda.setVar(4, pos[2]);
218
219 // Compute the result
220 coeff_ortho = K * lambda.eval() * norme_u / 2. / dh;
221 coeff_long = coeff_ortho;
222 // v is not used because coeff_ortho=coeff_long
223 // for (int dim=0;dim<dimension;dim++)
224 // p_charge[dim] = -lambda.eval()*norme_u/2./dh*u[dim];
225 u_l = 0;
226}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
void coeffs_perte_charge_impl(const DoubleVect &, const DoubleVect &, double, double, double, double, double, double, double &, double &, double &, DoubleVect &, Parser_U &) const
Implements the effective computation of the pressure drop for a given location.
int lire_motcle_non_standard_impl(const Motcle &, Entree &)
v
Direction vector of the pressure drop.
int lire_motcle_non_standard_impl(const Motcle &, Entree &)
void coeffs_perte_charge_impl(const DoubleVect &, const DoubleVect &, double, double, double, double, double, double, double &, double &, double &, DoubleVect &, Parser_U &) const
Implements the effective computation of the pressure drop for a given location.
void coeffs_perte_charge_impl(const DoubleVect &, const DoubleVect &, double, double, double, double, double, double, double &, double &, double &, DoubleVect &, Parser_U &) const
Implements the effective computation of the pressure drop for a given location.
void coeffs_perte_charge_impl(const DoubleVect &, const DoubleVect &, double, double, double, double, double, double, double &, double &, double &, DoubleVect &, Parser_U &) const
class Parser_U Version of the Parser class, deriving from Objet_U.
Definition Parser_U.h:32
void setVar(const char *sv, double val)
Definition Parser_U.h:149
double eval()
Definition Parser_U.h:125
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91