TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Anisotrope_VEF_P1NC.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_Anisotrope_VEF_P1NC.h>
17#include <Motcle.h>
18#include <Equation_base.h>
19#include <Param.h>
20
21Implemente_instanciable(Perte_Charge_Anisotrope_VEF_P1NC,"Perte_Charge_Anisotrope_VEF_P1NC",Perte_Charge_VEF);
22// XD perte_charge_anisotrope source_base perte_charge_anisotrope BRACE Anisotropic pressure loss.
23// XD attr lambda chaine lambda_u REQ Function for loss coefficient which may be Reynolds dependant (Ex: 64/Re).
24// XD attr lambda_ortho chaine lambda_ortho REQ Function for loss coefficient in transverse direction which may be
25// XD_CONT Reynolds dependant (Ex: 64/Re).
26// XD attr diam_hydr champ_don_base diam_hydr REQ Hydraulic diameter value.
27// XD attr direction champ_don_base direction REQ Field which indicates the direction of the pressure loss.
28// XD attr sous_zone chaine sous_zone OPT Optional sub-area where pressure loss applies.
29
31{
32 return s << que_suis_je() << finl;
33}
34
36{
38 if (v->nb_comp()!=dimension)
39 {
40 Cerr << "Il faut definir le champ direction a " << dimension << " composantes" << finl;
41 exit();
42 }
43 return s;
44}
45
47{
49 param.ajouter_non_std("lambda_ortho",(this),Param::REQUIRED);
50 param.ajouter("direction",&v,Param::REQUIRED);
51}
52
54{
55 if (mot=="lambda_ortho")
56 {
57 Nom tmp;
58 is >> tmp;
59 Cerr << "Lecture et interpretation de la fonction " << tmp << " ... ";
60 lambda_ortho.setNbVar(2+dimension);
61 lambda_ortho.setString(tmp);
62 lambda_ortho.addVar("Re");
63 lambda_ortho.addVar("t");
64 lambda_ortho.addVar("x");
65 if (dimension>1)
66 lambda_ortho.addVar("y");
67 if (dimension>2)
68 lambda_ortho.addVar("z");
69 lambda_ortho.parseString();
70 Cerr << " Ok" << finl;
71 return 1;
72 }
73 else
74 {
76 }
77}
78
79////////////////////////////////////////////////////////////////
80// //
81// Fonction principale : perte_charge //
82// //
83////////////////////////////////////////////////////////////////
84
85void Perte_Charge_Anisotrope_VEF_P1NC::coeffs_perte_charge(const DoubleVect& u, const DoubleVect& pos,
86 double t, double norme_u, double dh, double nu, double reynolds, double& coeff_ortho, double& coeff_long,double& u_l, DoubleVect& v_valeur) const
87{
88
89 // Calcul de lambda
90 lambda.setVar(0,reynolds);
91 lambda.setVar(1,t);
92 lambda.setVar(2,pos[0]);
93 if (dimension>1)
94 lambda.setVar(3,pos[1]);
95 if (dimension>2)
96 lambda.setVar(4,pos[2]);
97
98 // Calcul de lambda_ortho
99 lambda_ortho.setVar(0,reynolds);
100 lambda_ortho.setVar(1,t);
101 lambda_ortho.setVar(2,pos[0]);
102 if (dimension>1)
103 lambda_ortho.setVar(3,pos[1]);
104 if (dimension>2)
105 lambda_ortho.setVar(4,pos[2]);
106 double l_ortho=lambda_ortho.eval(); // Pour ne pas evaluer 2 fois le parser
107
108 // Calcul de v et ||v||^2
109 // DoubleVect v_valeur(dimension);
110 double vcarre=0;
111 v->valeur_a(pos,v_valeur);
112 for (int dim=0; dim<dimension; dim++)
113 vcarre+=v_valeur[dim]*v_valeur[dim];
114 v_valeur/=sqrt(vcarre);
115 // Calcul de u.v
116 double scal=0;
117 for (int dim=0; dim<dimension; dim++)
118 scal+=u[dim]*v_valeur[dim];
119
120 // Calcul du resultat
121 /*
122 for (int dim=0;dim<dimension;dim++)
123 p_charge[dim] = -l_ortho*norme_u/2./dh*u[dim]
124 -(lambda.eval()-l_ortho)*scal*v_valeur[dim]*norme_u/2./dh;
125 */
126 coeff_ortho=l_ortho*norme_u/2./dh;
127 coeff_long=lambda.eval()*norme_u/2./dh;
128 u_l=scal;
129}
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
friend class Entree
Definition Objet_U.h:76
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.
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.
virtual void set_param(Param &param) const override
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