TrioCFD 1.9.9_beta
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
Class Champ_Inc_base.
class Champ_base This class is the base of the fields hierarchy.
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
Returns the name of the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
A character string (Nom) in uppercase.
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
Performs a time update of the 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
Reads non-simple-type parameters of an Objet_U from an input stream.
void associate_evaluator_field(const Nom &one_name_state_pb, const Motcle &one_name_state_field)
Navier_Stokes_std This class carries the terms of the momentum equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void mettre_a_jour(double temps) override
Performs a time update of the equation.
void set_param(Param &titi) const override
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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
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
class Probleme_base It is a Probleme_U that is not a coupling.
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