TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Navier_Stokes_std_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 <Navier_Stokes_std_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_sans_constructeur_ni_destructeur( Navier_Stokes_std_sensibility, "Navier_Stokes_standard_sensibility", Navier_Stokes_std) ;
26// XD Navier_Stokes_standard_sensibility navier_stokes_standard Navier_Stokes_standard_sensibility INHERITS_BRACE
27// XD_CONT Resolution of Navier-Stokes sensitivity problem
37{
38 return Navier_Stokes_std::printOn( os );
39}
40
42{
44
45 return is;
46}
47
49{
50
52 param.ajouter_non_std("state",(this),Param::REQUIRED); // XD_ADD_P bloc_lecture
53 // XD_CONT Block to indicate the state problem. Between the braces, you must specify the key word
54 // XD_CONT 'pb_champ_evaluateur' then the name of the state problem and the velocity unknown NL2 Example: state {
55 // XD_CONT pb_champ_evaluateur pb_state velocity }
56 param.ajouter_non_std("uncertain_variable",(this),Param::OPTIONAL); // XD_ADD_P bloc_lecture
57 // XD_CONT Block to indicate the name of the uncertain variable. Between the braces, you must specify the name of the
58 // XD_CONT unknown variable. Choice between velocity and mu. NL2 Example: uncertain_variable { velocity }
59 param.ajouter_non_std("polynomial_chaos",(this),Param::OPTIONAL); // XD_ADD_P floattant
60 // XD_CONT It is the method that we will use to study the sensitivity of the Navier Stokes equation: NL2 if
61 // XD_CONT poly_chaos=0, the sensitivity will be treated by the standard sentivity method. If different than 0, it
62 // XD_CONT will be treated by the polynomial chaos method
63 param.ajouter_non_std("adjoint",(this),Param::OPTIONAL); // XD_ADD_P rien
64 // XD_CONT A keyword to indicate that the adjoint Navier-Stokes equations will be solved
65 if( schema_temps().que_suis_je() != "Schema_euler_explicite" )
66 {
67 Cerr<<"Time scheme: "<<schema_temps().que_suis_je() <<finl;
68 Cerr<<"Only Scheme_euler_explicit time scheme within Navier_Stokes_std_sensibility "<<finl;
70 }
71
72}
73
74
76{
77 if (mot=="state")
78 {
79 int lu_info_evaluateur = 0;
80 Cerr << "Reading and typing of the state : " << finl;
81 Motcle motlu, accolade_fermee="}", accolade_ouverte="{";
82 is >> motlu;
83 if(motlu!=accolade_ouverte)
84 {
85 Cerr << "We expected a { while reading of " << que_suis_je() << finl;
86 Cerr << "and not : " << motlu << finl;
88 }
89
90 is >> motlu;
91 Cerr<<"word read="<<motlu<<finl;
92 if(motlu=="pb_champ_evaluateur")
93 {
95 lu_info_evaluateur = 1;
96 if( (name_state_pb == accolade_fermee) || (name_state_pb == accolade_ouverte) || (name_state_field == accolade_fermee)
97 || (name_state_field == accolade_ouverte) )
98 {
99 Cerr<<"We expected the name of a problem and a fluid fild while reading of "<<motlu<< finl;
100 Cerr << "and not : " <<accolade_ouverte << " or "<< accolade_fermee << finl;
102 }
103 }
104 else
105 {
106 Cerr<<"Navier_Stokes_std_sensibility::lire_motcle_non_standard: keyword "<<motlu<<" is not recognized."<<finl;
107 Cerr<<"The recognized keywords are :"<<"pb_champ_evaluateur "<<finl;
109 }
110 is>>motlu;
111 if(motlu != accolade_fermee)
112 {
113 Cerr << "We expected a } while reading of " << que_suis_je() << finl;
114 Cerr << "and not : " << motlu << finl;
116 }
117 if (lu_info_evaluateur!=1)
118 {
119 Cerr<<"Keyword pb_champ_evaluateur must be specified with associated data"<<finl;
120 Cerr<<"when Navier_Stokes_std_sensibility is used."<<finl;
122 }
124 return 1;
125 }
126 else if (mot=="uncertain_variable")
127 {
128
129 Cerr << "Reading and typing of the uncertain variable: " << finl;
130 Motcle motlu, accolade_fermee="}", accolade_ouverte="{";
131 is >> motlu;
132 if(motlu!=accolade_ouverte)
133 {
134 Cerr << "We expected a { while reading of " << que_suis_je() << finl;
135 Cerr << "and not : " << motlu << finl;
137 }
138
139 is >> motlu;
140 Cerr<<"word read="<<motlu<<finl;
141 uncertain_var = motlu;
142 is>>motlu;
143 if(motlu != accolade_fermee)
144 {
145 Cerr << "We expected a } while reading of " << que_suis_je() << finl;
146 Cerr << "and not : " << motlu << finl;
148 }
149 return 1;
150 }
151 else if (mot=="polynomial_chaos")
152 {
153 Cerr << "Reading and typing of the option polynomial chaos: " << finl;
154 double value;
155 is >> value;
156 poly_chaos = value;
157 return 1;
158 }
159 else if (mot=="adjoint")
160 {
161 Cerr << "Reading and typing of the option adjoint: " << finl;
162 adjoint = true;
163 return 1;
164 }
165 else
167}
168
169//Initialization of the reference to the evaluator field (state_field)
170void Navier_Stokes_std_sensibility::associate_evaluator_field(const Nom& one_name_state_pb,const Motcle& one_name_state_field)
171{
172 Cerr <<"Navier_Stokes_std_sensibility: recoup state from "<<one_name_state_pb<< finl;
173 if(probleme().le_nom() ==one_name_state_pb )
174 {
175 Cerr <<"Navier_Stokes_std_sensibility: we expect here the nom of the state problem and not the name of the sensibility problem"<< finl;
177 }
178 Objet_U& ob= Interprete::objet(one_name_state_pb);
180 OBS_PTR(Champ_base) rch;
181
182 if(sub_type(Probleme_base,ob))
183 {
184 pb = ref_cast(Probleme_base,ob);
185 }
186 else
187 {
188 Cerr <<"No problem named "<< one_name_state_pb <<" has been found."<< finl;
190 }
191 rch = pb->get_champ(one_name_state_field);
192
193 if(sub_type(Champ_Inc_base,rch.valeur()))
194 state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
195 else
196 {
197 Cerr<<pb->le_nom()<<" has no unknown field named "<<one_name_state_field<<finl;
199 }
200}
201//Update the reference to the evaluator field (state_field)
202void Navier_Stokes_std_sensibility::update_evaluator_field(const Nom& one_name_state_pb,const Motcle& one_name_state_field)
203{
204 Cerr <<"Navier_Stokes_std_sensibility: update state from "<<one_name_state_pb<< finl;
205
206 Objet_U& ob= Interprete::objet(one_name_state_pb);
208 OBS_PTR(Champ_base) rch;
209
210 pb = ref_cast(Probleme_base,ob);
211 rch = pb->get_champ(one_name_state_field);
212 state_field = ref_cast(Champ_Inc_base,rch.valeur()) ;
213}
215{
216 // Mise a jour de la classe mere (on tourne la roue).
219}
221{
222 return state_field->valeurs();
223}
225{
226 return state_field;
227}
228
233
235{
236
237 return poly_chaos;
238}
239
241{
242
243 return adjoint;
244}
245
246
247
248
249
Classe Champ_Inc_base.
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
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.
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
Schema_Temps_base & schema_temps()
Renvoie le schema en temps 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 Navier_Stokes_std_sensibility
OBS_PTR(Champ_Inc_base) state_field
void set_param(Param &param) const override
void mettre_a_jour(double temps) override
Effectue une mise a jour en temps de l'equation.
void update_evaluator_field(const Nom &one_name_state_pb, const Motcle &one_name_state_field)
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.
void associate_evaluator_field(const Nom &one_name_state_pb, const Motcle &one_name_state_field)
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
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 mettre_a_jour(double temps) override
Effectue une mise a jour en temps de l'equation.
void set_param(Param &titi) const override
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:76
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
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
@ 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