TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_debit_QC.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 <Champ_front_debit_QC.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,"Champ_front_debit_QC_VDF",Ch_front_var_instationnaire_indep);
25// XD Champ_front_debit_QC_VDF front_field_base Champ_front_debit_QC_VDF NO_BRACE This keyword is used to define a flow
26// XD_CONT rate field for quasi-compressible fluids in VDF discretization. The flow rate is kept constant during a
27// XD_CONT transient.
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 }
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 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" << finl;
76 Cerr << "Expected { instead of " << motlu << finl;
77 exit();
78 }
79 fixer_nb_comp(dim);
80 Debit.resize(dim);
81 for(int i=0; i<dim; i++)
82 is >> Debit(i);
83 is >> motlu;
84 if (motlu != les_mots[1])
85 {
86 Cerr << "Error reading a Champ_front_debit_QC" << finl;
87 Cerr << "Expected } instead of " << finl;
88 exit();
89 }
90 Nom nom_pb;
91 is>>nom_pb;
92 Motcle nom;
93 nom=nom_pb;
94 if (nom=="moyen")
95 {
96 ismoyen=1;
97 is >> nom_pb;
98 }
99 Objet_U& ob1=Interprete::objet(nom_pb);
100 const Probleme_base& pb=ref_cast(Probleme_base,ob1);
101 fluide=ref_cast(Fluide_Quasi_Compressible,pb.equation(0).milieu());
102 return is;
103}
104
105
106/*! @brief Not implemented!!
107 *
108 * @param ch source boundary field
109 * @return reference to this boundary field
110 */
115
116/*! @brief Updates the time and re-draws random noise values.
117 *
118 * @param tps current time for the update
119 */
121{
122
123
124 const Frontiere& front=la_frontiere_dis->frontiere();
125 int nb_faces=front.nb_faces();
126 DoubleTab& tab=valeurs();
127 int dim=nb_comp();
128 const Domaine_VDF& le_dom_VDF = ref_cast(Domaine_VDF,domaine_dis());
129 const IntTab& face_voisins=le_dom_VDF.face_voisins();
130 const Front_VF& front_vf=ref_cast(Front_VF,la_frontiere_dis.valeur());
131 int ndeb = front_vf.num_premiere_face();
132 int nfin = ndeb + nb_faces;
133 const DoubleTab& tab_rhonp1P0 =fluide->loi_etat()->rho_np1();
134 if (ismoyen==0)
135
136 for (int num_face=ndeb; num_face<nfin; num_face++)
137 {
138 int n0 = face_voisins(num_face, 0);
139
140 if (n0 == -1)
141 n0 = face_voisins(num_face, 1);
142 for (int ori=0; ori<dim; ori++)
143 tab(num_face-ndeb,ori)=Debit(ori)/tab_rhonp1P0(n0);
144 }
145 else
146 {
147 int num_face;
148 double rho_moy=0,S=0,s;
149 const DoubleVect& surface=le_dom_VDF.face_surfaces();
150 for ( num_face=ndeb; num_face<nfin; num_face++)
151 {
152 int n0 = face_voisins(num_face, 0);
153
154 if (n0 == -1)
155 n0 = face_voisins(num_face, 1);
156 s=surface(num_face);
157 S+=s;
158 rho_moy+=s*tab_rhonp1P0(n0);
159 }
160 // Optimization: combine 2 mp_sum into 1 collective call
161 mp_sum_for_each(S, rho_moy);
162 rho_moy/=S;
163 for ( num_face=ndeb; num_face<nfin; num_face++)
164 for (int ori=0; ori<dim; ori++)
165 tab(num_face-ndeb,ori)=Debit(ori)/rho_moy;
166 }
167
168}
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
void mettre_a_jour(double temps) override
Updates the time and re-draws random noise values.
Champ_front_base & affecter_(const Champ_front_base &ch) override
Not implemented!!
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
virtual const Equation_base & equation(int) const =0
static void mp_sum_for_each(T &arg1, T &arg2)
C++14 compatible mp_sum_for_each: combine multiple mp_sum calls into one collective operation Usage: ...
Definition Process.cpp:208
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