TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_debit_QC_fonc_t.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Champ_front_debit_QC_fonc_t.h>
17#include <Probleme_base.h>
18#include <Equation_base.h>
19#include <Fluide_Quasi_Compressible.h>
20#include <Motcle.h>
21#include <Domaine_VDF.h>
22#include <Interprete.h>
23
24Implemente_instanciable(Champ_front_debit_QC_fonc_t,"Champ_front_debit_QC_VDF_fonc_t",Ch_front_var_instationnaire_indep);
25// XD Champ_front_debit_QC_VDF_fonc_t front_field_base Champ_front_debit_QC_VDF_fonc_t NO_BRACE This keyword is used to
26// XD_CONT define a flow rate field for quasi-compressible fluids in VDF discretization. The flow rate could be constant
27// XD_CONT or time-dependent.
28// XD attr dimension entier dim REQ Problem dimension
29// XD attr liste bloc_lecture liste REQ List of the mass flow rate values [kg/s/m2] with the following syntaxe: { val1
30// XD_CONT ... valdim } where val1 ... valdim are constant or function of time.
31// XD attr moyen chaine moyen OPT Option to use rho mean value
32// XD attr pb_name chaine pb_name REQ Problem name
33
34
35
36/*! @brief Impression sur un flot de sortie au format: taille
37 *
38 * valeur(0) ... valeur(i) ... valeur(taille-1)
39 *
40 * @param (Sortie& os) un flot de sortie
41 * @return (Sortie&) le flot de sortie modifie
42 */
44{
45 const DoubleTab& tab=valeurs();
46 os << tab.size() << " ";
47 for(int i=0; i<tab.size(); i++)
48 os << tab(0,i);
49 return os;
50}
51
52/*! @brief Lecture a partir d'un flot d'entree au format: nombre_de_composantes
53 *
54 * moyenne moyenne(0) ... moyenne(nombre_de_composantes-1)
55 * moyenne amplitude(0) ... amplitude(nombre_de_composantes-1)
56 *
57 * @param (Entree& is) un flot d'entree
58 * @return (Entree&) le flot d'entree modifie
59 * @throws accolade ouvrante attendue
60 * @throws mot clef inconnu a cet endroit
61 * @throws accolade fermante attendue
62 */
64{
65 Cerr<<"Champ_front_debit_QC_VDF_fonc_t usage : dim { val1 .. valdim } [ moyen ] nom_pb"<<finl;
66 int dim;
67 is >> dim;
68 Motcle motlu;
69 Motcles les_mots(2);
70 les_mots[0]="{";
71 les_mots[1]="}";
72 is >> motlu;
73 if (motlu != les_mots[0])
74 {
75 Cerr << "Erreur a la lecture d'un Champ_front_debit_QC_VDF_fonc_t" << finl;
76 Cerr << "On attendait { a la place de " << motlu << finl;
77 exit();
78 }
79 fixer_nb_comp(dim);
80 f_debit_t.dimensionner(dim);
81
82 for (int i = 0; i<dim; i++)
83 {
84 Nom tmp;
85 is >> tmp;
86 Cerr << "Reading and interpretation of the function " << tmp << finl;
87 f_debit_t[i].setNbVar(1);
88 f_debit_t[i].setString(tmp);
89 f_debit_t[i].addVar("t");
90 f_debit_t[i].parseString();
91 Cerr << "Interpretation of function " << tmp << " Ok" << finl;
92 }
93 is >> motlu;
94 if (motlu != les_mots[1])
95 {
96 Cerr << "Erreur a la lecture d'un Champ_front_debit_QC_VDF_fonc_t" << finl;
97 Cerr << "On attendait } a la place de " << finl;
98 exit();
99 }
100 Nom nom_pb;
101 is>>nom_pb;
102 Motcle nom;
103 nom=nom_pb;
104 if (nom=="moyen")
105 {
106 ismoyen=1;
107 is >> nom_pb;
108 }
109 Objet_U& ob1=Interprete::objet(nom_pb);
110 const Probleme_base& pb=ref_cast(Probleme_base,ob1);
111 fluide=ref_cast(Fluide_Quasi_Compressible,pb.equation(0).milieu());
112 return is;
113}
114
115
116/*! @brief Pas code !!
117 *
118 * @param (Champ_front_base& ch)
119 * @return (Champ_front_base&)
120 */
125
126/*! @brief Mise a jour du temps et retirage aleatoire des valeurs du bruit.
127 *
128 * @param (double tps) le temps de mise a jour
129 */
131{
132
133
134 const Frontiere& front=la_frontiere_dis->frontiere();
135 int nb_faces=front.nb_faces();
136 DoubleTab& tab=valeurs();
137 DoubleTab& Debit=valeurs_au_temps(tps);
138 int dim=nb_comp();
139 const Domaine_VDF& le_dom_VDF = ref_cast(Domaine_VDF,domaine_dis());
140 const IntTab& face_voisins=le_dom_VDF.face_voisins();
141 const Front_VF& front_vf=ref_cast(Front_VF,la_frontiere_dis.valeur());
142 int ndeb = front_vf.num_premiere_face();
143 int nfin = ndeb + nb_faces;
144 const DoubleTab& tab_rhonp1P0 =fluide->loi_etat()->rho_np1();
145 if (ismoyen==0)
146
147 for (int num_face=ndeb; num_face<nfin; num_face++)
148 {
149 int n0 = face_voisins(num_face, 0);
150
151 if (n0 == -1)
152 n0 = face_voisins(num_face, 1);
153 for (int ori=0; ori<dim; ori++)
154 {
155 f_debit_t[ori].setVar("t",tps);
156 Debit(num_face-ndeb,ori)=f_debit_t[ori].eval();
157 tab(num_face-ndeb,ori)=Debit(num_face-ndeb,ori)/tab_rhonp1P0(n0);
158 }
159 }
160 else
161 {
162 int num_face;
163 double rho_moy=0,S=0,s;
164 const DoubleVect& surface=le_dom_VDF.face_surfaces();
165 for ( num_face=ndeb; num_face<nfin; num_face++)
166 {
167 int n0 = face_voisins(num_face, 0);
168
169 if (n0 == -1)
170 n0 = face_voisins(num_face, 1);
171 s=surface(num_face);
172 S+=s;
173 rho_moy+=s*tab_rhonp1P0(n0);
174 }
175 S = mp_sum(S);
176 rho_moy = mp_sum(rho_moy);
177 rho_moy/=S;
178 for ( num_face=ndeb; num_face<nfin; num_face++)
179 for (int ori=0; ori<dim; ori++)
180 {
181 f_debit_t[ori].setVar("t",tps);
182 Debit(num_face-ndeb,ori)=f_debit_t[ori].eval();
183 tab(num_face-ndeb,ori)=Debit(num_face-ndeb,ori)/rho_moy;
184 }
185 }
186
187}
188
189double Champ_front_debit_QC_fonc_t::valeur_au_temps(double tps, int som, int k) const
190{
191 Parser_U& f_debit_tk=f_debit_t[k];
192 f_debit_tk.setVar("t",tps);
193 return f_debit_tk.eval();
194}
195
196
classe Ch_front_var_instationnaire_indep Cette classe abstraite represente un champ sur une frontiere...
classe Champ_front_base Classe de base pour la hierarchie des champs aux frontieres.
virtual const Domaine_dis_base & domaine_dis() const
virtual DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ.
classe Champ_front_debit_QC_fonc_t Classe derivee de Champ_front_base qui represente les
virtual double valeur_au_temps(double temps, int som, int comp) const
Champ_front_base & affecter_(const Champ_front_base &ch) override
Pas code !!
void mettre_a_jour(double temps) override
Mise a jour du temps et retirage aleatoire des valeurs du bruit.
DoubleTab & valeurs_au_temps(double temps) override
Renvoie les valeurs au temps desire.
class Domaine_VDF
Definition Domaine_VDF.h:64
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
virtual int nb_comp() const
Definition Field_base.h:56
class Front_VF
Definition Front_VF.h:36
int num_premiere_face() const
Definition Front_VF.h:63
int_t nb_faces() const
Renvoie le nombre de faces de la frontiere.
Definition Frontiere.h:59
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
classe Parser_U Version de la classe Parser, derivant de Objet_U.
Definition Parser_U.h:32
void setVar(const char *sv, double val)
Definition Parser_U.h:149
double eval()
Definition Parser_U.h:125
virtual const Equation_base & equation(int) const =0
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45