TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_PDF_base.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 Source_PDF_base_included
17#define Source_PDF_base_included
18
19#include <Interpolation_IBM_base.h>
20#include <Prepro_IBM_base.h>
21#include <Source_dep_inco_base.h>
22#include <TRUST_Deriv.h>
23#include <PDF_model.h>
24#include <TRUSTTab.h>
25
26class Probleme_base;
27class Champ_Don_base;
28
29/*! @brief class Source_PDF_base Base class for the source terms for the penalisation of the momentum in the Immersed Boundary Method (IBM)
30 *
31 *
32 *
33 * @sa Source_dep_inco_base, and Source_PDF
34 */
35
37{
38
39 Declare_base(Source_PDF_base);
40
41public:
42 inline const int& getInterpolationBool() const { return interpolation_bool_; }
43 inline const Interpolation_IBM_base& getInterpolationLu() const { return interpolation_lue_; }
44 inline const Prepro_IBM_base& getpreproLu() const { return prepro_lu_; }
45 void associer_pb(const Probleme_base& ) override;
46 DoubleTab& ajouter(DoubleTab&) const override;
47 DoubleTab& ajouter_(const DoubleTab&, DoubleTab&) const override;
48 virtual DoubleTab& ajouter_(const DoubleTab&, DoubleTab&, const int) const ;
49 DoubleTab& calculer(DoubleTab&) const override;
50 DoubleTab& calculer(DoubleTab&, const int) const;
51 DoubleTab& calculer_pdf(DoubleTab& ) const;
52 void mettre_a_jour(double ) override;
53 void contribuer_a_avec(const DoubleTab&, Matrice_Morse&) const override;
54 double fonct_coeff(const double, const double, const double) const;
55 double fonct_regul_PDF(const int, const double);
56 virtual DoubleVect diag_coeff_elem(ArrOfDouble&, const DoubleTab&, int) const ;
57 virtual DoubleTab compute_coeff_elem() const ;
58 virtual DoubleTab compute_coeff_matrice() const;
59 virtual void multiply_coeff_volume(DoubleTab&) const ;
60 virtual void correct_variable(const DoubleTab&,DoubleTab&) const;
62 void updateChampRho();
63 inline const Champ_Don_base& get_champ_rotation() const { return champ_rotation_; }
64 inline const Champ_Don_base& get_champ_aire() const { return champ_aire_; }
65 inline const PDF_model& get_modele() const { return modele_lu_; }
66 int impr(Sortie&) const override;
67 void ouvrir_fichier(SFichier&, const Nom&, const int) const override;
68 inline const DoubleTab& get_sec_mem_pdf() const { return sec_mem_pdf; }
69 inline void set_sec_mem_pdf(DoubleTab& it) { sec_mem_pdf = it; }
70 inline const DoubleTab& get_source_pdf() const { return source_term_PDF; }
71 virtual inline void set_source_pdf(DoubleTab& it) { source_term_PDF = it; }
72 DoubleVect& compute_source_term_PDF(int, DoubleTab&, DoubleVect&);
73 DoubleVect& compute_source_term_PDF(DoubleVect&);
74 virtual void volume_source_term_PDF(DoubleTab&);
75 void update_elem_IBM(DoubleTab&, double, double);
76 void update_pseudo_level_set_IBM(DoubleTab&, double);
77 double aire_geometrique_IBM(DoubleTab&, int);
80
83 virtual void correct_pressure(const DoubleTab&,DoubleTab&,const DoubleTab&) const;
84 virtual void correct_incr_pressure(const DoubleTab&,DoubleTab&) const;
85 virtual void filtre_CLD(DoubleTab&) const;
86 inline void set_dt_computation_pdf(double dt) { dt_computation_pdf_ = dt; }
87 double calcul_dt_pdf();
88 inline void set_temps_computation_pdf(double temps_pdf) { temps_computation_pdf_ = temps_pdf; }
89 inline double get_temps_pdf() {return temps_computation_pdf_;}
91 void compute_NeighNode_IBM_elem(DoubleTab&, IntLists&, bool all_elem_vois = false);
92 inline bool get_imm_wall_law() {return imm_wall_law_;}
93
94 // Methods of the post-processable fields interface
95 void get_noms_champs_postraitables(Noms& nom,Option opt=NONE) const override;
96 bool has_champ(const Motcle& nom, OBS_PTR(Champ_base) &ref_champ) const override;
97 bool has_champ(const Motcle& nom) const override;
98 const Champ_base& get_champ(const Motcle&) const override;
99 void creer_champ(const Motcle& motlu) override;
100
101protected:
102 OWN_PTR(Champ_Don_base) champ_nodal_;
103 virtual void compute_variable_imposee_projete(const DoubleTab&, const DoubleTab&, double, double);
104 ArrOfDouble get_tuvw_local() const;
105 void associer_domaines(const Domaine_dis_base&, const Domaine_Cl_dis_base&) override;
107 void rotate_imposed_velocity(DoubleTab&);
108 DoubleTab compute_pond(const DoubleTab& rho_m, const DoubleTab& aire, const DoubleVect& volume_thilde, int& nb_som_elem, int& nb_elems) const;
116
121
127 double temps_relax_ = -100.;
128 double echelle_relax_ = -100.;
129 bool penalized_ = false;
130 DoubleTab sec_mem_pdf; // part of the source term computed with the imposed variable
131 double dt_computation_pdf_ = -123.; //time step used for computation of sec_mem_pdf
132 double temps_computation_pdf_ = -123.; //time of the computation of sec_mem_pdf
133 DoubleTab source_term_PDF; // PDF source term
134
135 mutable OWN_PTR(Champ_Fonc_base) champ_source_term_PDF_; //!< Field for post-processing
136 mutable OWN_PTR(Champ_Fonc_base) champ_barycentre_IBM_; //!< Field for post-processing
137 mutable OWN_PTR(Champ_Fonc_base) champ_aire_IBM_; //!< Field for post-processing
138 mutable OWN_PTR(Champ_Fonc_base) champ_normal_IBM_; //!< Field for post-processing
139 mutable OWN_PTR(Champ_Fonc_base) champ_vitesse_shape_IBM_; //!< Field for post-processing
140 mutable OWN_PTR(Champ_Fonc_base) champ_pseudo_level_set_IBM_; //!< Field for post-processing
141
142 bool aire_from_prepro_ = false;
145
147 bool imm_wall_law_ = false;
148
149 // FOR THE INTERPOLATION
150 OWN_PTR(Interpolation_IBM_base) interpolation_lue_;
152
153 inline void comp_diff_L2_max(double dim0, double dim1, const DoubleTab& Array_src, const DoubleTab& Array_prep)
154 {
155 for (int k = 0; k < dim1; k++)
156 {
157 double err_L2 =0.;
158 double err_max = 0.;
159 double L2 = 0.;
160 for (int dof = 0; dof <dim0; dof++)
161 {
162 double diff = abs(Array_prep(dof,k) - Array_src(dof,k));
163 err_L2 += diff * diff ;
164 L2 += Array_src(dof,k) * Array_src(dof,k) ;
165 if (diff > err_max) err_max = diff;
166 }
167 if (L2 > 1.0e-12) err_L2 = sqrt(err_L2 / L2);
168
169 Cerr<<" component # "<<k<<" => "<<err_L2<<" "<<err_max;
170 }
171 Cerr<<finl;
172 }
173};
174
175#endif /* Source_PDF_base */
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_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
OBS_PTR(Equation_base) mon_equation
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
: class PDF_model
Definition PDF_model.h:34
class Probleme_base It is a Probleme_U that is not a coupling.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
Base class for output streams.
Definition Sortie.h:52
class Source_PDF_base Base class for the source terms for the penalisation of the momentum in the Imm...
virtual void calculer_vitesse_imposee_power_law_tbl_u_star()
ArrOfDouble get_tuvw_local() const
int impr(Sortie &) const override
void set_dt_computation_pdf(double dt)
const int & getInterpolationBool() const
bool matrice_pression_variable_bool_
double temps_computation_pdf_
void set_temps_computation_pdf(double temps_pdf)
DoubleTab compute_pond(const DoubleTab &rho_m, const DoubleTab &aire, const DoubleVect &volume_thilde, int &nb_som_elem, int &nb_elems) const
void creer_champ(const Motcle &motlu) override
OWN_PTR(Interpolation_IBM_base) interpolation_lue_
virtual void calculer_variable_imposee_elem_fluid()
double aire_geometrique_IBM(DoubleTab &, int)
OWN_PTR(Champ_Fonc_base) champ_vitesse_shape_IBM_
Field for post-processing.
const PDF_model & get_modele() const
const bool & get_matrice_pression_variable_bool_() const
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
DoubleVect & compute_source_term_PDF(int, DoubleTab &, DoubleVect &)
const Interpolation_IBM_base & getInterpolationLu() const
virtual void filtre_CLD(DoubleTab &) const
virtual void calculer_vitesse_imposee_power_law_tbl()
OWN_PTR(Champ_Fonc_base) champ_source_term_PDF_
Field for post-processing.
const Prepro_IBM_base & getpreproLu() const
void comp_diff_L2_max(double dim0, double dim1, const DoubleTab &Array_src, const DoubleTab &Array_prep)
void set_sec_mem_pdf(DoubleTab &it)
const Champ_Don_base & get_champ_rotation() const
OWN_PTR(Champ_Fonc_base) champ_barycentre_IBM_
Field for post-processing.
void compute_NeighNode_IBM_elem(DoubleTab &, IntLists &, bool all_elem_vois=false)
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
virtual void calculer_variable_imposee_mean_grad()
OWN_PTR(Champ_Fonc_base) champ_pseudo_level_set_IBM_
Field for post-processing.
virtual void compute_variable_imposee_projete(const DoubleTab &, const DoubleTab &, double, double)
void update_elem_IBM(DoubleTab &, double, double)
OWN_PTR(Prepro_IBM_base) prepro_lu_
double fonct_regul_PDF(const int, const double)
OWN_PTR(Champ_Fonc_base) champ_aire_IBM_
Field for post-processing.
virtual void compute_indicateur_nodal_champ_aire()
virtual void set_source_pdf(DoubleTab &it)
void get_fields_from_prepro(Prepro_IBM_base &)
void rotate_imposed_velocity(DoubleTab &)
DoubleTab & calculer_pdf(DoubleTab &) const
virtual DoubleVect diag_coeff_elem(ArrOfDouble &, const DoubleTab &, int) const
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
contribution to the implicit matrix of source terms, by default no contribution
DoubleTab source_term_PDF
virtual DoubleTab compute_coeff_matrice() const
virtual void volume_source_term_PDF(DoubleTab &)
void ouvrir_fichier(SFichier &, const Nom &, const int) const override
Opening/creation of a file for printing a source term. To override in derived classes.
OWN_PTR(Champ_Don_base) champ_nodal_
virtual void correct_variable(const DoubleTab &, DoubleTab &) const
virtual void correct_pressure(const DoubleTab &, DoubleTab &, const DoubleTab &) const
virtual void multiply_coeff_volume(DoubleTab &) const
double fonct_coeff(const double, const double, const double) const
DoubleTab indicateur_nodal_champ_aire_
void set_fields_to_prepro(Prepro_IBM_base &)
const Champ_Don_base & get_champ_aire() const
const DoubleTab & get_sec_mem_pdf() const
virtual void calculer_variable_imposee_hybrid()
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void update_pseudo_level_set_IBM(DoubleTab &, double)
const DoubleTab & get_source_pdf() const
DoubleTab & ajouter_(const DoubleTab &, DoubleTab &) const override
DoubleTab & calculer(DoubleTab &) const override
virtual void calculer_temperature_imposee_wall_law()
virtual DoubleTab compute_coeff_elem() const
DoubleTab & ajouter(DoubleTab &) const override
const Champ_base & get_champ(const Motcle &) const override
void associer_pb(const Probleme_base &) override
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
DoubleTab variable_imposee_
void set_matrice_pression_variable_bool_(bool &flag)
OWN_PTR(Champ_Fonc_base) champ_normal_IBM_
Field for post-processing.
virtual void correct_incr_pressure(const DoubleTab &, DoubleTab &) const
class Source_dep_inco_base Sources inheriting from this class must implement ajouter_ in a way that a...