TrioCFD 1.9.9_beta
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 Prints to an output stream in the format: size
37 *
38 * value(0) ... value(i) ... value(size-1)
39 *
40 * @param os output stream
41 * @return modified output stream
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 Reads from an input stream in the format: number_of_components
53 *
54 * mean mean(0) ... mean(number_of_components-1)
55 * mean amplitude(0) ... amplitude(number_of_components-1)
56 *
57 * @param is input stream
58 * @return modified input stream
59 * @throws opening brace expected
60 * @throws unknown keyword at this location
61 * @throws closing brace expected
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 << "Error reading a Champ_front_debit_QC_VDF_fonc_t" << finl;
76 Cerr << "Expected { instead of " << 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 << "Error reading a Champ_front_debit_QC_VDF_fonc_t" << finl;
97 Cerr << "Expected } instead of " << 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 Not implemented!!
117 *
118 * @param ch source boundary field
119 * @return reference to this boundary field
120 */
125
126/*! @brief Updates the time and re-draws random noise values.
127 *
128 * @param tps current time for the update
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
class Ch_front_var_instationnaire_indep This abstract class represents a field on a boundary,
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual const Domaine_dis_base & domaine_dis() const
virtual DoubleTab & valeurs() override
Returns the array of field values.
class Champ_front_debit_QC_fonc_t
virtual double valeur_au_temps(double temps, int som, int comp) const
Champ_front_base & affecter_(const Champ_front_base &ch) override
Not implemented!!
void mettre_a_jour(double temps) override
Updates the time and re-draws random noise values.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
class Domaine_VDF
Definition Domaine_VDF.h:61
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in 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)
Sets the number of components of the field.
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
Returns the number of faces of the boundary.
Definition Frontiere.h:59
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Parser_U Version of the Parser class, deriving from 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)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45