TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Circulaire_VDF_Face.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 <Perte_Charge_Circulaire_VDF_Face.h>
17#include <Param.h>
18
19Implemente_instanciable(Perte_Charge_Circulaire_VDF_Face, "Perte_Charge_Circulaire_VDF_Face", Perte_Charge_VDF_base);
20
21Sortie& Perte_Charge_Circulaire_VDF_Face::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
22
24{
26 if (v->nb_comp() != dimension)
27 {
28 Cerr << "The direction field must be defined with " << dimension << " components" << finl;
30 }
31 return s;
32}
33
35{
37 param.ajouter_non_std("lambda_ortho", (this), Param::REQUIRED);
38 param.ajouter("diam_hydr_ortho", &diam_hydr_ortho, Param::REQUIRED);
39 param.ajouter("direction", &v, Param::REQUIRED);
40}
41
43{
44 if (mot == "lambda")
45 {
46 lambda.addVar("Re_tot");
47 lambda.addVar("Re_long");
49 }
50 else if (mot == "lambda_ortho")
51 {
52 Nom tmp;
53 is >> tmp;
54 Cerr << "Reading and interpreting the function " << tmp << " ... ";
55 lambda_ortho.setNbVar(3 + dimension);
56 lambda_ortho.setString(tmp);
57 lambda_ortho.addVar("Re_tot");
58 lambda_ortho.addVar("Re_ortho");
59 lambda_ortho.addVar("t");
60 lambda_ortho.addVar("x");
61 if (dimension > 1)
62 lambda_ortho.addVar("y");
63 if (dimension > 2)
64 lambda_ortho.addVar("z");
65 lambda_ortho.parseString();
66 Cerr << " Ok" << finl;
67 return 1;
68 }
69 else
70 {
72 }
73}
74
75void Perte_Charge_Circulaire_VDF_Face::coeffs_perte_charge(const DoubleVect& u, const DoubleVect& pos, double t, double norme_u, double dh, double nu, double reynolds, double& coeff_ortho,
76 double& coeff_long, double& u_l, DoubleVect& av_valeur) const
77{
78
79 // compute dh_ortho
80 double dh_ortho = diam_hydr_ortho->valeur_a_compo(pos, 0);
81
82 // compute u.d/||d||
83 // Compute v and ||v||^2
84 av_valeur.resize(dimension);
85
86 v->valeur_a(pos, av_valeur);
87 // normalize v
88 {
89 double vcarre = 0;
90 for (int dim = 0; dim < dimension; dim++)
91 vcarre += av_valeur[dim] * av_valeur[dim];
92 av_valeur /= sqrt(vcarre);
93 }
94 // Compute u.v/||v||
95 u_l = 0;
96
97 for (int dim = 0; dim < dimension; dim++)
98 u_l += u[dim] * av_valeur[dim];
99
100 double u_ortho = sqrt(norme_u * norme_u - u_l * u_l);
101 // compute Re_l and Re_ortho
102 // Compute Reynolds number
103 /* PL: To avoid a possible division by zero, we replace:
104 double nu=norme_u*dh/reynolds;
105 double Re_l=std::fabs(u_l)*dh/nu; */
106 // By:
107 double Re_l = dh * std::fabs(u_l) / nu;
108 if (Re_l < 1e-10)
109 Re_l = 1e-10;
110 // PL: To avoid a possible division by zero, we replace:
111 /* double Re_ortho=u_ortho*dh_ortho/nu; */
112 // By:
113 double Re_ortho = dh_ortho * u_ortho / nu;
114 if (Re_ortho < 1e-10)
115 Re_ortho = 1e-10;
116 // Compute lambda
117 lambda.setVar(0, reynolds);
118 lambda.setVar(1, Re_l);
119 lambda.setVar(2, t);
120 lambda.setVar(3, pos[0]);
121 if (dimension > 1)
122 lambda.setVar(4, pos[1]);
123 if (dimension > 2)
124 lambda.setVar(5, pos[2]);
125
126 // Compute lambda_ortho
127 lambda_ortho.setVar(0, reynolds);
128 lambda_ortho.setVar(1, Re_ortho);
129 lambda_ortho.setVar(2, t);
130 lambda_ortho.setVar(3, pos[0]);
131 if (dimension > 1)
132 lambda_ortho.setVar(4, pos[1]);
133 if (dimension > 2)
134 lambda_ortho.setVar(5, pos[2]);
135 double l_ortho = lambda_ortho.eval(); // To avoid evaluating the parser twice
136 double l_long = lambda.eval();
137 coeff_ortho = l_ortho * u_ortho / 2. / dh_ortho;
138 coeff_long = l_long * std::fabs(u_l) / 2. / dh;
139}
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
virtual void set_param(Param &) const
Definition Objet_U.h:130
virtual int lire_motcle_non_standard(const Motcle &motlu, Entree &is)
Reads non-simple-type parameters of an Objet_U from an input stream.
Definition Objet_U.cpp:115
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
Anisotropic pressure drop (along a unit vector v and in the plane orthogonal to it).
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void coeffs_perte_charge(const DoubleVect &u, const DoubleVect &pos, double t, double norme_u, double dh, double nu, double reynolds, double &coeff_ortho, double &coeff_long, double &u_l, DoubleVect &v_valeur) const override
Implements the effective pressure loss computation for a given location.
Factorizes the functionalities of several pressure drop terms in VEF, velocity at faces.
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
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91