TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Navier_Stokes_Aposteriori.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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 <Estimateur_Aposteriori_P0_VEF.h>
17#include <Navier_Stokes_Aposteriori.h>
18#include <Champ_P1_isoP1Bulle.h>
19#include <Discretisation_base.h>
20#include <Schema_Temps_base.h>
21#include <Postraitements.h>
22#include <Probleme_base.h>
23#include <Champ_P1NC.h>
24#include <EChaine.h>
25
26Implemente_instanciable(Navier_Stokes_Aposteriori,"Navier_Stokes_Aposteriori",Navier_Stokes_std);
27// XD Navier_Stokes_Aposteriori navier_stokes_standard Navier_Stokes_Aposteriori INHERITS_BRACE Modification of the
28// XD_CONT Navier_Stokes_standard class in order to accept the estimateur_aposteriori post-processing. To post-process
29// XD_CONT estimateur_aposteriori, add this keyword into the list of fields to be post-processed. This estimator whill
30// XD_CONT generate a map of aposteriori error estimators; it is defined on each mesh cell and is a measure of the local
31// XD_CONT discretisation error. This will serve for adaptive mesh refinement
32
35
37{
38 if (discretisation().que_suis_je() != "VEFPreP1B")
39 {
40 Cerr << "Error : Pb_Hydraulique_Aposteriori is currently only available for the discretization VEFPreP1B !" << finl;
41 Cerr << "Please update your data file ..." << finl;
43 }
45}
46
48{
50
51 if (motlu == "estimateur_aposteriori")
52 {
53 if (!estimateur_aposteriori_)
54 {
55 estimateur_aposteriori();
56 champs_compris_.ajoute_champ(estimateur_aposteriori_);
57
58 Nom chaine = "{ numero_source 0 sources { refChamp { pb_champ ";
59 chaine += probleme().le_nom();
60 chaine += " vitesse } } }";
61 EChaine echaine(chaine);
62 echaine >> champ_src_;
63 champ_src_.completer(probleme().postraitements().front());
64 }
65 }
66}
67
68
70{
72 Noms noms_compris = champs_compris_.liste_noms_compris();
73 noms_compris.add("estimateur_aposteriori");
74 if (opt==DESCRIPTION)
75 Cerr<<" Navier_Stokes_Aposteriori : "<< noms_compris <<finl;
76 else
77 nom.add(noms_compris);
78}
79
80bool Navier_Stokes_Aposteriori::has_champ(const Motcle& nom, OBS_PTR(Champ_base)& ref_champ) const
81{
82 if (nom == "estimateur_aposteriori")
83 {
85 return true;
86 }
87 else
88 return Navier_Stokes_std::has_champ(nom, ref_champ);
89}
90
92{
93 if (nom == "estimateur_aposteriori")
94 return true;
95 else
97}
98
100{
101 const double temps_init = schema_temps().temps_init();
102
103 if (nom == "estimateur_aposteriori")
104 {
105 Champ_Fonc_base& ch = ref_cast_non_const(Champ_Fonc_base, estimateur_aposteriori_.valeur());
106 if (((ch.temps() != la_vitesse->temps()) || (ch.temps() == temps_init)) && (la_vitesse->mon_equation_non_nul()))
107 ch.mettre_a_jour(la_vitesse->temps());
108
109 return champs_compris_.get_champ(nom);
110 }
111 else
113}
114
115void Navier_Stokes_Aposteriori::estimateur_aposteriori()
116{
117 const Domaine_VEF& domaine_vef = ref_cast(Domaine_VEF, domaine_dis());
118 const Domaine_Cl_VEF& domaine_cl_vef = ref_cast(Domaine_Cl_VEF, domaine_Cl_dis());
119 estimateur_aposteriori_.typer("Estimateur_Aposteriori_P0_VEF");
120 Estimateur_Aposteriori_P0_VEF& ch = ref_cast(Estimateur_Aposteriori_P0_VEF, estimateur_aposteriori_.valeur());
121 ch.associer_domaine_dis_base(domaine_vef);
122 const Champ_P1NC& vit = ref_cast(Champ_P1NC, la_vitesse.valeur());
123 const Champ_P1_isoP1Bulle& pres = ref_cast(Champ_P1_isoP1Bulle, la_pression.valeur());
124 ch.associer_champ(vit, pres, diffusivite_pour_transport() /* viscosite_cinematique */, domaine_cl_vef);
125 ch.nommer("estimateur_aposteriori");
126 ch.fixer_nb_comp(1);
127 ch.fixer_nb_valeurs_nodales(domaine_vef.nb_elem());
128 ch.fixer_unite("sans");
129 ch.changer_temps(la_vitesse->temps());
130}
int fixer_nb_valeurs_nodales(int n) override
Sets the number of degrees of freedom per component.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
void associer_domaine_dis_base(const Domaine_dis_base &) override
void mettre_a_jour(double temps) override
Time update of the field.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
double temps() const
Returns the time of the field.
class Domaine_VEF
Definition Domaine_VEF.h:53
An input stream whose source is a character string.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with 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.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
void associer_champ(const Champ_P1NC &, const Champ_P1_isoP1Bulle &, const Champ_Don_base &, const Domaine_Cl_dis_base &)
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
void nommer(const Nom &) override
Gives a name to the field.
virtual const Nom & fixer_unite(const Nom &)
Specifies the unit of a scalar field or whose all components have the same unit.
A character string (Nom) in uppercase.
Definition Motcle.h:26
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void creer_champ(const Motcle &motlu) override
const Champ_base & get_champ(const Motcle &nom) const override
void discretiser() override
Discretizes the equation.
Navier_Stokes_std This class carries the terms of the momentum equation.
void creer_champ(const Motcle &motlu) override
const Champ_base & get_champ(const Motcle &nom) const override
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void discretiser() override
Discretizes the equation.
virtual const Champ_Don_base & diffusivite_pour_transport() const
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
double temps_init() const
Returns the initial time.
Base class for output streams.
Definition Sortie.h:52