TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Navier_Stokes_std.h
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#ifndef Navier_Stokes_std_included
17#define Navier_Stokes_std_included
18
19#include <Traitement_particulier_NS_base.h>
20#include <Assembleur_base.h>
21#include <Operateur_Grad.h>
22#include <Operateur_Conv.h>
23#include <Operateur_Diff.h>
24#include <Operateur_Div.h>
25#include <TRUST_Deriv.h>
26#include <TRUST_Ref.h>
27
28class Fluide_base;
29
30/*! @brief Navier_Stokes_std This class carries the terms of the momentum equation
31 *
32 * for a fluid without turbulence modelling.
33 * The incompressible fluid hypothesis is assumed: div U = 0.
34 * The density is considered constant (equal to rho_0) except in the
35 * gravity force term (Boussinesq hypothesis).
36 * Under these hypotheses, the following form of the Navier-Stokes equations is used:
37 * DU/dt = div(viscous term) - gradP/rho_0 + Bt(T-T0)g + other sources/rho_0
38 * div U = 0
39 * where DU/dt : material derivative of velocity
40 * rho_0 : reference density
41 * T0 : reference temperature
42 * Bt : thermal expansion coefficient of the fluid
43 * g : gravity vector
44 * Note: the class implementation allows neglecting
45 * certain terms of the equation (viscous term, convective term,
46 * any given source term).
47 * The unknown is the velocity field.
48 *
49 * For handling special cases: addition of Traitement_particulier
50 * example: THI, channel (CA)
51 *
52 * @sa Equation_base Pb_Hydraulique Pb_Thermohydraulique
53 */
55{
56 Declare_instanciable_sans_constructeur(Navier_Stokes_std);
57
58public :
59
61 void set_param(Param& titi) const override;
62 int lire_motcle_non_standard(const Motcle&, Entree&) override;
63 void associer_pb_base(const Probleme_base&) override;
64 inline void associer_fluide(const Fluide_base& un_fluide ) { le_fluide = un_fluide; }
65 const Milieu_base& milieu() const override;
66 Milieu_base& milieu() override;
67 const Fluide_base& fluide() const;
69 void associer_milieu_base(const Milieu_base& ) override;
70 int nombre_d_operateurs() const override;
71 int nombre_d_operateurs_tot() const override;
72 const Operateur& operateur(int) const override;
73 Operateur& operateur(int) override;
74 const Operateur& operateur_fonctionnel(int) const override;
75 Operateur& operateur_fonctionnel(int) override;
81 const Operateur_Diff& operateur_diff() const;
82 const Champ_Inc_base& inconnue() const override;
83 Champ_Inc_base& inconnue() override;
85 void discretiser() override;
86 virtual void discretiser_vitesse();
87 virtual void discretiser_grad_p();
88 void completer() override;
89 Entree& lire_cond_init(Entree&) override;
90 bool initTimeStep(double dt) override;
91 void mettre_a_jour(double temps) override;
92 void abortTimeStep() override;
93 void resetTime(double time) override;
94 int impr(Sortie& os) const override;
95
96 void dimensionner_matrice_sans_mem(Matrice_Morse& matrice) override;
97
98 /*
99 interface {dimensionner,assembler}_blocs
100 specificites : prend en compte le gradient de pression (en dernier)
101 */
102 int has_interface_blocs() const override;
103 void dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl = {}) const override;
104 void assembler_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl = {}) const override;
105
106 std::vector<YAML_data> data_a_sauvegarder() const override;
107 int sauvegarder(Sortie&) const override;
108 int reprendre(Entree&) override;
109
110 DoubleTab& derivee_en_temps_inco(DoubleTab& ) override;
111 DoubleTab& corriger_derivee_expl(DoubleTab& ) override;
112 DoubleTab& corriger_derivee_impl(DoubleTab& ) override;
113
114 int preparer_calcul() override;
115
117 inline OWN_PTR(Assembleur_base)& assembleur_pression() { return assembleur_pression_; }
118
119 inline bool has_grad_P() const { return bool(gradient_P); }
120 inline Champ_Inc_base& grad_P() { return gradient_P.valeur(); }
121 inline const Champ_Inc_base& grad_P() const { return gradient_P.valeur(); }
122 inline Champ_Inc_base& pression() { return la_pression.valeur(); }
123 inline const Champ_Inc_base& pression() const { return la_pression.valeur(); }
124 inline Champ_Inc_base& pression_pa() { return la_pression_en_pa.valeur(); }
125 inline const Champ_Inc_base& pression_pa() const { return la_pression_en_pa.valeur(); }
126 inline Champ_Inc_base& div() { return divergence_U.valeur(); }
127 inline const Champ_Inc_base& div() const { return divergence_U.valeur(); }
128
129 virtual const Champ_Don_base& diffusivite_pour_transport() const;
130 virtual const Champ_base& diffusivite_pour_pas_de_temps() const;
131 virtual const Champ_base& vitesse_pour_transport() const;
132
133 // Methods of the post-processable fields interface
134 /////////////////////////////////////////////////////
135 void creer_champ(const Motcle& motlu) override;
136 const Champ_base& get_champ(const Motcle& nom) const override;
137 bool has_champ(const Motcle& nom, OBS_PTR(Champ_base) &ref_champ) const override;
138 bool has_champ(const Motcle& nom) const override;
139 void get_noms_champs_postraitables(Noms& nom,Option opt=NONE) const override;
140 /////////////////////////////////////////////////////
141
142 const Motcle& domaine_application() const override;
143
144 virtual inline const Champ_Inc_base& vitesse() const { return la_vitesse.valeur(); }
145 virtual inline Champ_Inc_base& vitesse() { return la_vitesse.valeur(); }
146
147 virtual void projeter();
148 virtual int projection_a_faire();
149 virtual void sauver() const;
150 virtual void calculer_la_pression_en_pa();
151 virtual void calculer_pression_hydrostatique(Champ_base& pression_hydro) const;
152 int verif_Cl() const override;
153
154 virtual const Champ_Inc_base& rho_la_vitesse() const;
156
157 virtual void updateFluidForce(DoubleTab&);
158 // Retrieve true if implicit coupling with another code
159 // required to perform filtering of pressure Champ_P1_isoP1Bull during sub-iterations of the implicit loop
160 virtual bool getCouplingInfoForFiltering() const ;
161 inline DoubleTab getPressureTimeN() {return P_n; } // Pressure at start of time step (used for FSI implicit coupling in sub-iterations)
162 void setPressureTimeN();
163 void update_y_plus(const DoubleTab& tab) ;
165
166protected:
167 virtual void discretiser_assembleur_pression();
168 virtual void modify_initial_variable() { /* Do nothing */ }
169 virtual void modify_initial_gradP( DoubleTrav& ) { /* Do nothing */ }
170
172
176
182 OWN_PTR(Assembleur_base) assembleur_pression_;
184
187 mutable double cumulative_;
188
189 OWN_PTR(Traitement_particulier_NS_base) le_traitement_particulier;
190
191 void uzawa(const DoubleTab&, const Matrice_Base&, SolveurSys&, DoubleTab&, DoubleTab&);
195 // for genepi it is important to have divu=0 because of error accumulation
196 // even if it is not achievable with all schemes
198
199private :
200 // Pressure at the beginning of the time step, useful for abortTimeStep, in particular for Piso
201 // WEC: eventually, use 2 time slots for the la_pression field
202 DoubleTab P_n;
203 // To avoid computing an extra gradient if no post-processing of the pressure gradient
204 mutable int postraitement_gradient_P_;
205 double LocalFlowRateRelativeError() const; // Estimation of a flow rate relative error
206};
207
208#endif /* Navier_Stokes_std_included */
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
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
class Equation_base The role of an equation is the calculation of one or more fields....
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
Matrice_Base class - Base class of the matrix hierarchy.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
Matrice class - Generic class in the matrix hierarchy.
Definition Matrice.h:34
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
A character string (Nom) in uppercase.
Definition Motcle.h:26
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
OWN_PTR(Traitement_particulier_NS_base) le_traitement_particulier
Operateur_Diff terme_diffusif
void dimensionner_matrice_sans_mem(Matrice_Morse &matrice) override
const Champ_Inc_base & pression() const
virtual const Champ_Inc_base & rho_la_vitesse() const
virtual void updateFluidForce(DoubleTab &)
const Milieu_base & milieu() const override
Returns the physical medium of the equation (Fluide_base upcast to Milieu_base).
const Champ_Inc_base & div() const
const Motcle & domaine_application() const override
Returns the name of the application domain: "Hydraulique".
OWN_PTR(Assembleur_base) assembleur_pression_
virtual void modify_initial_variable()
void resetTime(double time) override
Reset current time of the equation. Used from ICoCo. See documentation of Problem_base::resetTime().
Operateur_Grad gradient
int reprendre(Entree &) override
Performs a restart from an input stream.
Operateur_Conv terme_convectif
const Champ_Inc_base & grad_P() const
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
void creer_champ(const Motcle &motlu) override
virtual const Champ_base & vitesse_pour_transport() const
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Entree & lire_cond_init(Entree &) override
Reading of initial conditions in an input stream.
DoubleTab & corriger_derivee_impl(DoubleTab &) override
Resolution de la pression, inconnue implicitee de Navier Stokes.
const Fluide_base & fluide() const
Returns the incompressible fluid (physical medium of the equation) associated with the equation.
virtual Champ_Inc_base & vitesse()
void mettre_a_jour(double temps) override
Performs a time update of the equation.
virtual const Champ_Inc_base & vitesse() const
virtual void projeter()
Computes the solution U of the equations: | M(U-V)/dt + BtP = 0.
Operateur_Div & operateur_divergence()
Returns the divergence operator associated with the equation.
void completer() override
Completes the base equation, associates the pressure with the equation,.
int sauvegarder(Sortie &) const override
Calls Equation_base::sauvegarder(Sortie&) and saves the pressure to an output stream.
const Champ_base & get_champ(const Motcle &nom) const override
Champ_Inc_base & pression_pa()
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
void abortTimeStep() override
Reinitialize what must be.
int impr(Sortie &os) const override
Prints some information to an output stream: - maximum of div U.
virtual void calculer_pression_hydrostatique(Champ_base &pression_hydro) const
std::vector< YAML_data > data_a_sauvegarder() const override
for PDI IO: retrieve name, type and dimensions of the fields to save/restore
Champ_Inc_base & div()
void associer_pb_base(const Probleme_base &) override
Associates with the problem: calls Equation_base::associer_pb_base(const Probleme_base&).
virtual void sauver() const
Operateur_Conv & get_terme_convectif()
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
Operateur_Grad & operateur_gradient()
Returns the gradient operator associated with the equation.
Champ_Inc_base & grad_P()
virtual void discretiser_grad_p()
bool postraiter_gradient_pression_sans_masse_
Operateur_Div divergence
void update_y_plus(const DoubleTab &tab)
virtual void discretiser_assembleur_pression()
Types the pressure assembler.
virtual void modify_initial_gradP(DoubleTrav &)
DoubleTab & corriger_derivee_expl(DoubleTab &) override
Add a specific term for Navier Stokes (-gradP(n)) if necessary.
int has_interface_blocs() const override
void set_param(Param &titi) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
int verif_Cl() const override
Verifies the compatibility of boundary conditions with the equation.
DoubleTab & derivee_en_temps_inco(DoubleTab &) override
Returns the time derivative of the unknown I of the equation: dI/dt = M-1*(sum(operators(I) + sources...
virtual int projection_a_faire()
virtual void discretiser_vitesse()
void discretiser() override
Discretizes the equation.
void uzawa(const DoubleTab &, const Matrice_Base &, SolveurSys &, DoubleTab &, DoubleTab &)
virtual bool getCouplingInfoForFiltering() const
virtual const Champ_Don_base & diffusivite_pour_transport() const
OWN_PTR(Assembleur_base) &assembleur_pression()
int preparer_calcul() override
cf Equation_base::preparer_calcul() Assembly of the pressure solver and
Operateur_Diff & operateur_diff()
const Operateur & operateur_fonctionnel(int) const override
void reassembler_pression_si_necessaire()
const Operateur & operateur(int) const override
Returns the i-th operator of the equation: - terme_diffusif if i = 0.
int nombre_d_operateurs_tot() const override
void associer_milieu_base(const Milieu_base &) override
Associates a physical medium with the equation by dynamically constructing (casting) an object of typ...
Matrice & matrice_pression()
void assembler_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
SolveurSys & solveur_pression()
Returns the pressure solver (const version).
OBS_PTR(Fluide_base) le_fluide
const Champ_Inc_base & pression_pa() const
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
virtual void calculer_la_pression_en_pa()
Computes "la_pression_en_pa" from "la_pression".
int nombre_d_operateurs() const override
Returns the number of operators in the equation: 2 for the standard Navier-Stokes equations.
DoubleTab getPressureTimeN()
Champ_Inc_base & pression()
void associer_fluide(const Fluide_base &un_fluide)
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
friend class Sortie
Definition Objet_U.h:70
Operateur_Conv Generic class of the hierarchy of operators representing a convection term.
Operateur_Diff Generic class of the hierarchy of operators representing a diffusion.
Operateur_Div Generic class of the hierarchy of operators computing the divergence.
Classe Operateur_Grad Generic class of the hierarchy of operators computing the gradient.
class Operateur Generic class of the operator hierarchy.
Definition Operateur.h:39
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
class Probleme_base It is a Probleme_U that is not a coupling.
class SolveurSys A SolveurSys represents any class
Definition SolveurSys.h:32
Base class for output streams.
Definition Sortie.h:52
Traitement_particulier_NS_base Derives from Support_Champ_Masse_Volumique: use of rho.