TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Equation_Navier_Cauchy.cpp
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#include <Equation_Navier_Cauchy.h>
17#include <Discretisation_base.h>
18#include <Schema_Temps_base.h>
19#include <Probleme_base.h>
20#include <Domaine_dis_base.h>
21#include <Process.h>
22
23Implemente_instanciable(Equation_Navier_Cauchy,"Equation_Navier_Cauchy",Equation_base);
24// XD Equation_Navier_Cauchy eqn_base Equation_Navier_Cauchy INHERITS_BRACE Equation_Navier_Cauchy equation
25
27
29{
31
32 // terme_diffusif.set_fichier("Contrainte_visqueuse");
33 // terme_diffusif.set_description("Friction drag exerted by the fluid=Integral(-mu*(grad(u) +grad(u)^T)*ndS) [N] if SI units used");
34 solveur_masse->set_name_of_coefficient_temporel("masse_volumique");
35
36 return is;
37}
38
40{
42 param.ajouter_non_std("diffusion",(this));
43}
44
46{
47 if (mot=="diffusion")
48 {
49 Cerr << "Reading and typing of the diffusion operator : " << finl;
50 terme_diffusif.associer_diffusivite(diffusivite_pour_transport());
51 is >> terme_diffusif;
52 terme_diffusif.associer_diffusivite_pour_pas_de_temps(diffusivite_pour_pas_de_temps());
53 terme_diffusif.associer_diffusivite(milieu_->mu_lame());
54 terme_diffusif.associer_diffusivite_volumique(milieu_->lambda_lame());
55 return 1;
56 }
57 else
59}
60
62{
63 if (i != 0) Process::exit();
64 return terme_diffusif;
65}
66
68{
69 if (i != 0) Process::exit();
70 return terme_diffusif;
71}
72
74{
75 if (!sub_type(Milieu_Elasticite, mil))
76 {
77 Cerr << que_suis_je() << " expects a Milieu_Elasticite but received a " << mil.que_suis_je() << finl;
79 }
80 milieu_ = ref_cast(Milieu_Elasticite, mil);
81}
82
84{
86 const Domaine_dis_base& dom = domaine_dis();
87 const Schema_Temps_base& sch = schema_temps();
88
89 const int nb_val_temp = sch.nb_valeurs_temporelles();
90 const double temps = sch.temps_courant();
91
92 dis.discretiser_champ("vitesse", dom, "deplacement", "m", dimension, nb_val_temp, temps, deplacement_);
93 dis.discretiser_champ("champ_elem", dom, "von_mises", "Pa", 1, temps, von_mises_);
94 dis.discretiser_champ("champ_elem", dom, "contraintes", "Pa", 3, temps, contraintes_);
95 dis.discretiser_champ("champ_elem", dom, "deformations", "", 3, temps, deformations_);
96 dis.discretiser_champ("vitesse", dom, "vitesse_noeuds", "m/s", dimension, temps, vitesse_noeuds_);
97 deformations_->fixer_nom_compo(0, bidim_axi ? "eps_r" : "eps_xx");
98 deformations_->fixer_nom_compo(1, bidim_axi ? "eps_z" : "eps_yy");
99 deformations_->fixer_nom_compo(2, bidim_axi ? "eps_theta" : "eps_zz");
100 contraintes_->fixer_nom_compo(0, bidim_axi ? "sigma_r" : "sigma_xx");
101 contraintes_->fixer_nom_compo(1, bidim_axi ? "sigma_z" : "sigma_yy");
102 contraintes_->fixer_nom_compo(2, bidim_axi ? "sigma_theta" : "sigma_zz");
103 champs_compris_.ajoute_champ(deplacement_);
104 champs_compris_.ajoute_champ(von_mises_);
105 champs_compris_.ajoute_champ(contraintes_);
106 champs_compris_.ajoute_champ(deformations_);
107 champs_compris_.ajoute_champ(vitesse_noeuds_);
108 terme_diffusif.associer_eqn(*this);
109
111}
112
114{
115 static Motcle domaine = "Mecanique";
116 return domaine;
117}
118
120{
122 update_velocity();
123 const bool update_rho = domaine_dis().domaine().deformable();
124 milieu_->update_fields(probleme().schema_temps().temps_courant(), update_rho);
125}
126
127void Equation_Navier_Cauchy::update_velocity()
128{
129 const double dt = schema_temps().pas_de_temps();
130 const DoubleTab& disp_n = deplacement_->valeurs();
131 const DoubleTab& disp_nm1 = deplacement_->passe();
132 DoubleTab& vit_n = vitesse_noeuds_->valeurs();
133
134 for (int i = 0; i < vit_n.dimension_tot(0); i++)
135 for (int j = 0; j < dimension; j++)
136 vit_n(i, j) = (disp_n(i, j) - disp_nm1(i, j)) / dt;
137}
138
140{
142
143 von_mises_->changer_temps(temps);
144 contraintes_->changer_temps(temps);
145 deformations_->changer_temps(temps);
146 vitesse_noeuds_->changer_temps(temps);
147 update_velocity();
148 ref_cast(Operateur_Diff_base, terme_diffusif.l_op_base()).calculer_von_mises(deplacement_->valeurs(), deformations_->valeurs(), contraintes_->valeurs(), von_mises_->valeurs());
149}
class Discretisation_base This class represents a spatial discretization scheme, which
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
bool deformable() const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Navier–Cauchy equation for small-strain linear elasticity.
void set_param(Param &param) const override
const Motcle & domaine_application() const override
Returns "indeterminate" Navier_Stokes_standard for example overrides this method.
void associer_milieu_base(const Milieu_base &) override
void discretiser() override
Discretizes the equation.
int lire_motcle_non_standard(const Motcle &mot, Entree &is) override
Reads non-simple-type parameters of an Objet_U from an input stream.
virtual const Champ_Don_base & diffusivite_pour_transport() const
const Operateur & operateur(int) const override
void valider_iteration() override
virtual method to correct the unknown during implicit iterations for example K-eps must remain positi...
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
void mettre_a_jour(double temps) override
The value of the unknown at the time step has been calculated.
class Equation_base The role of an equation is the calculation of one or more fields....
virtual void set_param(Param &titi) const override
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void valider_iteration()
virtual method to correct the unknown during implicit iterations for example K-eps must remain positi...
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
Probleme_base & probleme()
Returns the problem associated with the equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Isotropic small-strain linear elastic medium.
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
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
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
static int bidim_axi
Definition Objet_U.h:97
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
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
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Schema_Temps_base
double temps_courant() const
Returns the current time.
double pas_de_temps() const
Returns the current time step (delta_t).
virtual int nb_valeurs_temporelles() const =0
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160