TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Gen.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 <Multiplicateur_diphasique_base.h>
17#include <EcritureLectureSpecial.h>
18#include <Fluide_Incompressible.h>
19#include <Perte_Charge_Gen.h>
20#include <Pb_Multiphase.h>
21#include <Avanc.h>
22#include <Param.h>
23
24Implemente_base(Perte_Charge_Gen, "Perte_Charge_Gen", Source_base);
25
26Sortie& Perte_Charge_Gen::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
27
29{
30 Param param(que_suis_je());
31 Cerr << que_suis_je() << "::readOn " << finl;
32 lambda.setNbVar(4 + dimension);
34 regul_ = 0;
35 set_param(param);
36 param.lire_avec_accolades_depuis(is);
37 Cerr << "Interpreting the function " << lambda.getString() << " ... ";
38 lambda.parseString();
39 Cerr << " Ok" << finl;
40 if (diam_hydr->nb_comp() != 1)
41 {
42 Cerr << "The diam_hydr field must be defined with one component" << finl;
43 exit();
44 }
45 return is;
46}
47
49{
50 param.ajouter_non_std("lambda", (this), Param::REQUIRED);
51 param.ajouter("diam_hydr", &diam_hydr, Param::REQUIRED);
52 param.ajouter_non_std("sous_domaine|sous_zone", (this));
53 param.ajouter("implicite", &implicite_);
54 param.ajouter_non_std("regul", (this));
55}
56
58{
59 int a_faire, special;
61 if (a_faire)
62 {
63 double temps = equation().inconnue().temps();
64 Nom ident_k = Nom("K") + equation().probleme().le_nom() + identifiant_ + Nom(temps, "%e");
65 os << ident_k << finl;
66 os << "constante" << finl;
67 os << K_;
68 os << flush;
69 Cerr << "Saving K at time : " << Nom(temps, "%e") << " with value " << K_ << finl;
70 }
71 return 8;//un double
72}
73
75{
76 Nom ident_k = Nom("K") + equation().probleme().le_nom() + identifiant_ + Nom(equation().schema_temps().temps_courant(), equation().probleme().reprise_format_temps());
77 avancer_fichier(is, ident_k);
78 is >> K_;
79 Cerr << "Resuming with the value K = " << K_ << finl;
80 return 1;
81}
82
84{
85 if (mot == "lambda")
86 {
87 Nom tmp;
88 is >> tmp;
89 lambda.setString(tmp);
90 lambda.addVar("Re");
91 lambda.addVar("t");
92 lambda.addVar("x");
93 if (dimension > 1)
94 lambda.addVar("y");
95 if (dimension > 2)
96 lambda.addVar("z");
97 return 1;
98 }
99 else if (mot == "sous_domaine")
100 {
101 is >> nom_sous_domaine;
102 sous_domaine = true;
103 return 1;
104 }
105 else if (mot == "regul")
106 {
107 lire_regul(is);
108 num_faces.resize(ref_cast(Domaine_VF, equation().domaine_dis()).nb_elem());
109 lire_surfaces(is, equation().domaine_dis().domaine(), equation().domaine_dis(), num_faces, sgn, 0);
110 return 1;
111 }
112 else // non compris
113 {
114 Cerr << "Keyword \"" << mot << "\" not understood while reading a " << que_suis_je() << finl;
116 }
117 return -1;
118}
119
121{
123 if (regul_) //fichier de sortie si regulation
124 {
125 bilan().resize(3); //K deb cible
126 identifiant_ = sous_domaine ? nom_sous_domaine : le_dom_vf_->domaine().le_nom();
127 set_fichier(Nom("DP_") + identifiant_);
128 set_description(Nom("Regulation of the Ksing of surface ") + identifiant_);
129 Noms col_names;
130 col_names.add("K");
131 col_names.add("Flow_rate");
132 col_names.add("Target_Flow_rate");
133 set_col_names(col_names);
134 }
135 if (sous_domaine)
136 le_sous_domaine = equation().probleme().domaine().ss_domaine(nom_sous_domaine);
137}
138
144
146{
147 la_vitesse = equation().inconnue();
148 le_fluide = ref_cast(Fluide_base, equation().milieu());
149}
150
151void Perte_Charge_Gen::associer_domaines(const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& domaine_Cl_dis)
152{
153 le_dom_vf_ = ref_cast(Domaine_VF, domaine_dis);
154 le_dom_Cl_dis_ = domaine_Cl_dis;
155}
double temps() const
Returns the time of the field.
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
static int is_ecriture_special(int &special, int &a_faire)
Indicates whether the special format was requested in active writing by xyz save.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
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
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
virtual void set_param(Param &param) const override
void associer_pb(const Probleme_base &) override
associates le_fluide and la_vitesse
void mettre_a_jour(double t) override
DOES NOTHING - to override in derived classes.
int reprendre(Entree &is) override
Restores an Objet_U from an input stream. Virtual method to override.
void completer() override
Updates internal references of the Source_base object.
bool sous_domaine
Is the term limited to a sub-domain?
int sauvegarder(Sortie &os) const override
Saves an Objet_U to an output stream. Virtual method to override.
Nom nom_sous_domaine
Name of the sub-domain, initialized in readOn().
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void update_K(const Equation_base &eqn, double deb, DoubleVect &bilan)
double calculate_Q(const Equation_base &eqn, const IntVect &num_faces, const IntVect &sgn) const
virtual void lire_surfaces(Entree &, const Domaine &, const Domaine_dis_base &, IntVect &, IntVect &, int lire_derniere_accolade=1)
Entree & lire_regul(Entree &)
Reads the specifications of a singular pressure drop from an input stream.
int direction_perte_charge_
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
class Probleme_base It is a Probleme_U that is not a coupling.
const Domaine & domaine() const
Returns the domain associated with the problem.
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
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
void set_fichier(const Nom &)
DoubleVect & bilan()
Definition Source_base.h:88
void set_col_names(const Noms &col_names)
Definition Source_base.h:84
void set_description(const Nom &nom)
Definition Source_base.h:83
virtual void completer()
Updates internal references of the Source_base object.
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91