TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Anisotrope_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_Anisotrope_VDF_Face.h>
17#include <Param.h>
18
19Implemente_instanciable(Perte_Charge_Anisotrope_VDF_Face, "Perte_Charge_Anisotrope_VDF_Face", Perte_Charge_VDF_base);
20
21Sortie& Perte_Charge_Anisotrope_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("direction", &v, Param::REQUIRED);
39}
40
42{
43 if (mot == "lambda_ortho")
44 {
45 Nom tmp;
46 is >> tmp;
47 Cerr << "Reading and interpreting the function " << tmp << " ... ";
48 lambda_ortho.setNbVar(2 + dimension);
49 lambda_ortho.setString(tmp);
50 lambda_ortho.addVar("Re");
51 lambda_ortho.addVar("t");
52 lambda_ortho.addVar("x");
53 if (dimension > 1)
54 lambda_ortho.addVar("y");
55 if (dimension > 2)
56 lambda_ortho.addVar("z");
57 lambda_ortho.parseString();
58 Cerr << " Ok" << finl;
59 return 1;
60 }
61 else
63}
64
65void Perte_Charge_Anisotrope_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,
66 double& coeff_long, double& u_l, DoubleVect& v_valeur) const
67{
68
69 // Compute lambda
70 lambda.setVar(0, reynolds);
71 lambda.setVar(1, t);
72 lambda.setVar(2, pos[0]);
73 if (dimension > 1)
74 lambda.setVar(3, pos[1]);
75 if (dimension > 2)
76 lambda.setVar(4, pos[2]);
77
78 // Compute lambda_ortho
79 lambda_ortho.setVar(0, reynolds);
80 lambda_ortho.setVar(1, t);
81 lambda_ortho.setVar(2, pos[0]);
82 if (dimension > 1)
83 lambda_ortho.setVar(3, pos[1]);
84 if (dimension > 2)
85 lambda_ortho.setVar(4, pos[2]);
86 double l_ortho = lambda_ortho.eval(); // To avoid evaluating the parser twice
87
88 // Compute v and ||v||^2
89 // DoubleVect v_valeur(dimension);
90 double vcarre = 0;
91 v->valeur_a(pos, v_valeur);
92 for (int dim = 0; dim < dimension; dim++)
93 vcarre += v_valeur[dim] * v_valeur[dim];
94 v_valeur /= sqrt(vcarre);
95 // Compute u.v
96 double scal = 0;
97 for (int dim = 0; dim < dimension; dim++)
98 scal += u[dim] * v_valeur[dim];
99
100 // Compute the result
101 /*
102 for (int dim=0;dim<dimension;dim++)
103 p_charge[dim] = -l_ortho*norme_u/2./dh*u[dim]
104 -(lambda.eval()-l_ortho)*scal*v_valeur[dim]*norme_u/2./dh;
105 */
106 coeff_ortho = l_ortho * norme_u / 2. / dh;
107 coeff_long = lambda.eval() * norme_u / 2. / dh;
108 u_l = scal;
109}
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 loss (along a unit vector v and in the plane orthogonal to that vector).
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.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
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