TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_Temperature_sensibility.cpp
1/****************************************************************************
2* Copyright (c) 2020, 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 <Convection_Diffusion_Temperature_sensibility.h>
17#include <Probleme_base.h>
18#include <Schema_Temps_base.h>
19#include <Param.h>
20#include <Debog.h>
21#include <LecFicDiffuse.h>
22#include <communications.h>
23#include <Interprete.h>
24
25Implemente_instanciable( Convection_Diffusion_Temperature_sensibility, "Convection_Diffusion_Temperature_sensibility", Convection_Diffusion_Temperature ) ;
26// XD Convection_Diffusion_Temperature_sensibility convection_diffusion_temperature Convection_Diffusion_Temperature_sensibility INHERITS_BRACE Energy sensitivity equation (temperature diffusion convection)
27// XD attr convection_sensibility convection_deriv sensibility OPT Choice between: amont and muscl NL2 Example:
28// XD_CONT convection { Sensibility { amont } }
29
31{
33 return os;
34}
35
37{
39 return is;
40}
42{
44 param.ajouter_non_std("velocity_state",(this),Param::REQUIRED); // XD_ADD_P bloc_lecture
45 // XD_CONT Block to indicate the state problem. Between the braces, you must specify the key word
46 // XD_CONT 'pb_champ_evaluateur' then the name of the state problem and the velocity unknown NL2 Example:
47 // XD_CONT velocity_state { pb_champ_evaluateur pb_state velocity }
48 param.ajouter_non_std("temperature_state",(this),Param::REQUIRED); // XD_ADD_P bloc_lecture
49 // XD_CONT Block to indicate the state problem. Between the braces, you must specify the key word
50 // XD_CONT 'pb_champ_evaluateur' then the name of the state problem and the temperature unknown NL2 Example:
51 // XD_CONT velocity_state { pb_champ_evaluateur pb_state temperature }
52 param.ajouter_non_std("uncertain_variable",(this),Param::REQUIRED); // XD_ADD_P bloc_lecture
53 // XD_CONT Block to indicate the name of the uncertain variable. Between the braces, you must specify the name of the
54 // XD_CONT unknown variable (choice between: temperature, beta_th, boussinesq_temperature, Cp and lambda . NL2
55 // XD_CONT Example: uncertain_variable { temperature }
56 param.ajouter("polynomial_chaos",&poly_chaos,Param::OPTIONAL); // XD_ADD_P floattant
57 // XD_CONT It is the method that we will use to study the sensitivity of the
58
59}
60
61
63{
64 if (mot=="velocity_state")
65 {
66 int lu_info_evaluateur = 0;
67 Cerr << "Reading and typing of the velocity state : " << finl;
68 Motcle motlu, accolade_fermee="}", accolade_ouverte="{";
69 is >> motlu;
70 if(motlu!=accolade_ouverte)
71 {
72 Cerr << "We expected a { while reading of " << que_suis_je() << finl;
73 Cerr << "and not : " << motlu << finl;
75 }
76
77 is >> motlu;
78 Cerr<<"word read="<<motlu<<finl;
79 if(motlu=="pb_champ_evaluateur")
80 {
82 lu_info_evaluateur = 1;
83 if( (name_state_pb == accolade_fermee) || (name_state_pb == accolade_ouverte) || (name_velocity_state_field == accolade_fermee)
84 || (name_velocity_state_field == accolade_ouverte) )
85 {
86 Cerr<<"We expected the name of a problem and a fluid fild while reading of "<<motlu<< finl;
87 Cerr << "and not : " <<accolade_ouverte << " or "<< accolade_fermee << finl;
89 }
90 }
91 else
92 {
93 Cerr<<"Convection_Diffusion_Temperature_sensibility::lire_motcle_non_standard: keyword "<<motlu<<" is not recognized."<<finl;
94 Cerr<<"The recognized keywords are :"<<"pb_champ_evaluateur "<<finl;
96 }
97 is>>motlu;
98 if(motlu != accolade_fermee)
99 {
100 Cerr << "We expected a } while reading of " << que_suis_je() << finl;
101 Cerr << "and not : " << motlu << finl;
103 }
104 if (lu_info_evaluateur!=1)
105 {
106 Cerr<<"Keyword pb_champ_evaluateur must be specified with associated data"<<finl;
107 Cerr<<"when Convection_Diffusion_Temperature_sensibility is used."<<finl;
109 }
110 //const Motcle velocity;
112 return 1;
113 }
114 else if (mot=="temperature_state")
115 {
116 int lu_info_evaluateur = 0;
117 Cerr << "Reading and typing of the temperature state : " << finl;
118 Motcle motlu, accolade_fermee="}", accolade_ouverte="{";
119 is >> motlu;
120 if(motlu!=accolade_ouverte)
121 {
122 Cerr << "We expected a { while reading of " << que_suis_je() << finl;
123 Cerr << "and not : " << motlu << finl;
125 }
126
127 is >> motlu;
128 Cerr<<"word read="<<motlu<<finl;
129 if(motlu=="pb_champ_evaluateur")
130 {
132 lu_info_evaluateur = 1;
133 if( (name_state_pb == accolade_fermee) || (name_state_pb == accolade_ouverte) || (name_temperature_state_field == accolade_fermee)
134 || (name_temperature_state_field == accolade_ouverte) )
135 {
136 Cerr<<"We expected the name of a problem and a fluid fild while reading of "<<motlu<< finl;
137 Cerr << "and not : " <<accolade_ouverte << " or "<< accolade_fermee << finl;
139 }
140 }
141 else
142 {
143 Cerr<<"Convection_Diffusion_Temperature_sensibility::lire_motcle_non_standard: keyword "<<motlu<<" is not recognized."<<finl;
144 Cerr<<"The recognized keywords are :"<<"pb_champ_evaluateur "<<finl;
146 }
147 is>>motlu;
148 if(motlu != accolade_fermee)
149 {
150 Cerr << "We expected a } while reading of " << que_suis_je() << finl;
151 Cerr << "and not : " << motlu << finl;
153 }
154 if (lu_info_evaluateur!=1)
155 {
156 Cerr<<"Keyword pb_champ_evaluateur must be specified with associated data"<<finl;
157 Cerr<<"when Convection_Diffusion_Temperature_sensibility is used."<<finl;
159 }
161 return 1;
162 }
163 else if (mot=="uncertain_variable")
164 {
165
166 Cerr << "Reading and typing of the uncertain variable: " << finl;
167 Motcle motlu, accolade_fermee="}", accolade_ouverte="{";
168 is >> motlu;
169 if(motlu!=accolade_ouverte)
170 {
171 Cerr << "We expected a { while reading of " << que_suis_je() << finl;
172 Cerr << "and not : " << motlu << finl;
174 }
175
176 is >> motlu;
177 Cerr<<"word read="<<motlu<<finl;
178 uncertain_var = motlu;
179 is>>motlu;
180 if(motlu != accolade_fermee)
181 {
182 Cerr << "We expected a } while reading of " << que_suis_je() << finl;
183 Cerr << "and not : " << motlu << finl;
185 }
186 return 1;
187 }
188 else
190}
191
192//Initialization of the reference to the evaluator field (state_field)
193void Convection_Diffusion_Temperature_sensibility::associate_evaluator_field(const Nom& one_name_state_pb,const Motcle& one_name_state_field)
194{
195 Cerr <<"Convection_Diffusion_Temperature_sensibility::get_state_field(): recoup state from "<<one_name_state_pb<< finl;
196 if(probleme().le_nom() ==one_name_state_pb )
197 {
198 Cerr <<"Convection_Diffusion_Temperature_sensibility: we expect here the nom of the state problem and not the name of the sensibility problem"<< finl;
200 }
201 Objet_U& ob= Interprete::objet(one_name_state_pb);
203 OBS_PTR(Champ_base) rch;
204
205 if(sub_type(Probleme_base,ob))
206 {
207 pb = ref_cast(Probleme_base,ob);
208 }
209 else
210 {
211 Cerr <<"No problem named "<< one_name_state_pb <<" has been found."<< finl;
213 }
214 rch = pb->get_champ(one_name_state_field);
215
216 if(sub_type(Champ_Inc_base,rch.valeur()))
217 {
218 if(one_name_state_field==name_velocity_state_field)
219 velocity_state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
220 else
221 temperature_state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
222 }
223 else
224 {
225 Cerr<<pb->le_nom()<<" has no unknown field named "<<one_name_state_field<<finl;
227 }
228}
229//Update the reference to the evaluator field (state_field)
230void Convection_Diffusion_Temperature_sensibility::update_evaluator_field(const Nom& one_name_state_pb,const Motcle& one_name_state_field)
231{
232 Cerr <<"Convection_Diffusion_Temperature_sensibility: update state from "<<one_name_state_pb<< finl;
233
234 Objet_U& ob= Interprete::objet(one_name_state_pb);
236 OBS_PTR(Champ_base) rch;
237
238 pb = ref_cast(Probleme_base,ob);
239 rch = pb->get_champ(one_name_state_field);
240 if(one_name_state_field==name_velocity_state_field)
241 velocity_state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
242 else
243 temperature_state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
244}
246{
247 // Mise a jour de la classe mere (on tourne la roue).
251
252 /* Cout <<"velocity_state_field.que_suis_je() = "<< velocity_state_field->valeurs().que_suis_je()<<finl; //DoubleTab
253 Cout <<"velocity_state_field nb comp = "<< velocity_state_field->nb_comp()<<finl;// nb_composants vitesse (2,3) ou 1 pour la pression
254 Cout <<"velocity_state_field nom = "<< velocity_state_field->le_nom()<<finl;//vitesse ou pression
255 Cout<<"innconue valeurs = "<< velocity_state_field->valeurs()<<finl;// les valeurs
256 getchar();
257
258 Cout <<"temperature_state_field.que_suis_je() = "<< temperature_state_field->valeurs().que_suis_je()<<finl; //DoubleTab
259 Cout <<"temperature_state_field nb comp = "<< temperature_state_field->nb_comp()<<finl;// nb_composants 1 pour la temperature
260 Cout <<"temperature_state_field nom = "<< temperature_state_field->le_nom()<<finl;//temperature
261 Cout<<"innconue valeurs = "<< temperature_state_field->valeurs()<<finl;// les valeurs
262 getchar();*/
263
264}
266{
267 return velocity_state_field->valeurs();
268}
270{
271 return temperature_state_field->valeurs();
272}
273
275{
276 return velocity_state_field.valeur();
277}
279{
280 return temperature_state_field.valeur();
281}
282
287
293
294
Classe Champ_Inc_base.
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
: class Convection_Diffusion_Temperature_sensibility
void update_evaluator_field(const Nom &one_name_state_pb, const Motcle &one_name_state_field)
void mettre_a_jour(double temps) override
La valeur de l'inconnue sur le pas de temps a ete calculee.
int lire_motcle_non_standard(const Motcle &mot, Entree &is) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
OBS_PTR(Champ_Inc_base) velocity_state_field
void associate_evaluator_field(const Nom &one_name_state_pb, const Motcle &one_name_state_field)
classe Convection_Diffusion_Temperature Cas particulier de Convection_Diffusion_std
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.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom de l'equation.
virtual void mettre_a_jour(double temps)
La valeur de l'inconnue sur le pas de temps a ete calculee.
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
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
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
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
@ OPTIONAL
Definition Param.h:115
@ 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
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
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