TrioCFD 1.9.8
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 << "Interpretation de la fonction " << lambda.getString() << " ... ";
38 lambda.parseString();
39 Cerr << " Ok" << finl;
40 if (diam_hydr->nb_comp() != 1)
41 {
42 Cerr << "Il faut definir le champ diam_hydr a une composante" << 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 << "Mot cle \"" << mot << "\" non compris lors de la lecture d'un " << 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 du Ksing de la 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
Renvoie le temps du champ.
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VF
Definition Domaine_VF.h:44
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
static int is_ecriture_special(int &special, int &a_faire)
indique si le format special a ete demande en lecture active par sauvegarde xyz .
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()
Renvoie le probleme associe a l'equation.
classe Fluide_base Cette classe represente un d'un fluide incompressible ainsi que
Definition Fluide_base.h:38
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
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
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:76
static int dimension
Definition Objet_U.h:99
friend class Sortie
Definition Objet_U.h:75
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
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
associe le_fluide et la_vitesse
void mettre_a_jour(double t) override
DOES NOTHING - to override in derived classes.
int reprendre(Entree &is) override
Reprise d'un Objet_U sur un flot d'entree Methode a surcharger.
void completer() override
Met a jour les references internes a l'objet Source_base.
bool sous_domaine
Le terme est-il limite a une sous-domaine ?
int sauvegarder(Sortie &os) const override
Sauvegarde d'un Objet_U sur un flot de sortie Methode a surcharger.
Nom nom_sous_domaine
Nom de la sous-domaine, initialise dans readOn().
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 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 &)
Lit les specifications d'une perte de charge singuliere a partir d'un flot d'entree.
int direction_perte_charge_
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Domaine & domaine() const
Renvoie le domaine associe au probleme.
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
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
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()
Met a jour les references internes a l'objet Source_base.
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91