TRUST 1.9.8
HPC thermohydraulic platform
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 << "Il faut definir le champ direction a " << dimension << " composantes" << 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 << "Lecture et interpretation de la fonction " << 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 // calcul de dh_ortho
80 double dh_ortho = diam_hydr_ortho->valeur_a_compo(pos, 0);
81
82 // calcul de u.d/||d||
83 // Calcul de v et ||v||^2
84 av_valeur.resize(dimension);
85
86 v->valeur_a(pos, av_valeur);
87 // on norme 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 // Calcul de 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 // calcule de Re_l et Re_ortho
102 // Calcul du reynolds
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 // Calcul de 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 // Calcul de 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(); // Pour ne pas evaluer 2 fois le parser
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
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual void set_param(Param &) const
Definition Objet_U.h:135
virtual int lire_motcle_non_standard(const Motcle &motlu, Entree &is)
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
Definition Objet_U.cpp:115
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
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
Perte de charge anisotrope (selon un vecteur unitaire v et dans le plan orthogonal a ce vecteur).
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
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
Implemente le calcul effectif de la perte de charge pour un lieu donne.
Factorise les fonctionnalites de plusieurs pertes de charge en VEF, vitesse aux faces.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91