TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Eval_Diff_VDF_Elem_Gen.h
1/****************************************************************************
2* Copyright (c) 2025, 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 Eval_Diff_VDF_Elem_Gen_included
17#define Eval_Diff_VDF_Elem_Gen_included
18
19#include <Champ_front_calc_interne.h>
20#include <Echange_interne_impose.h>
21#include <CL_Types_include.h>
22#include <Evaluateur_VDF.h>
23#include <Eval_VDF_Elem.h>
24
25/*! @brief class Eval_Diff_VDF_Elem_Gen Evaluateur VDF pour la diffusion : Le champ diffuse est un Champ_P0_VDF
26 *
27 * @sa Eval_VDF_Elem, Evaluateur_VDF
28 */
29template <typename DERIVED_T>
31{
32public:
33
34 /*
35 * Notes about that MACRO's predefined in the previous version of TRUST (just to understand when,where and why (not sure of why :) )
36 *
37 * - MULTD --TRUST : predefined for Diff/Dift const_Elem / var_Elem / var_Elem_aniso (not Multi-Inco) --TrioCFD : predefined for Diff/Dift K_Eps_var_VDF_Elem & K_Eps_Bas_Re_VDF_var_Elem
38 *
39 * - D_AXI --TRUST : predefined for Diff/Dift Axi operators --TrioCFD : predefined for Diff/Dift Axi operators K_Eps
40 *
41 * - DEQUIV --TRUST : predefined for Dift (not Diff) Multi_inco_const_Elem / Multi_inco_var_Elem && Axi operators const_Elem_Axi / var_Elem_Axi / Multi_inco_var_Elem_Axi / Multi_inco_const_Elem_Axi
42 *
43 * - MODIF_DEQ --TRUST : predefined for Dift (not Diff) const_Elem / var_Elem (no Axi, no Multi_Inco)
44 *
45 * - ISQUASI --TrioCFD : predefined Diff_K_Eps_QC_VDF_Elem && Diff_K_Eps_QC_var_VDF_Elem
46 *
47 * These static constexpr bools & Methods that will generalize the implementation almost for all operator classes. The previous MACRO methodology do not exist anymore
48 * See their generic declaration later & override them in the derived class if needed to stay coherent with the previous macros
49 */
50 static constexpr bool IS_MULTD = true, IS_AXI = false, IS_DEQUIV = false, IS_MODIF_DEQ = false,
51 IS_QUASI = false, IS_ANISO = false, IS_RANS = false, IS_MULTI_SCALAR_DIFF = false;
52
53 /*
54 * XXX XXX XXX : VERY IMPORTANT
55 * Partial specialization is not supported in C++ (otherwise I miss some information)
56 * For example template<typename DERIVED_T>template<> will not compile due to invalid explicit specialization before '>' token
57 * Complete specialization works ie: template<>template<>
58 *
59 * So, we need to overload some functions for specific BC's outside the function template (for F5 for example ...)
60 */
61
62 /* ************************************** *
63 * ********* POUR L'EXPLICITE ********** *
64 * ************************************** */
65
66 template <typename BC, typename Type_Double> // Generic return
67 inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const BC&, int, Type_Double& ) const { /* Do nothing */ }
68
69 // To overload
70 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Dirichlet_entree_fluide&, const int, Type_Double& ) const;
71 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Scalaire_impose_paroi&, const int, Type_Double& ) const;
72 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Dirichlet_loi_paroi&, const int, Type_Double& ) const;
73 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Neumann_paroi&, const int, Type_Double& ) const;
74 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Periodique&, const int, Type_Double& ) const;
75 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Echange_global_impose&, const int, Type_Double& ) const;
76 template <typename Type_Double> inline void flux_face(const DoubleTab&, const DoubleTab&, const int, const Dirichlet_paroi_fixe&, const int, Type_Double& ) const;
77 template <typename Type_Double> inline void flux_face(const DoubleTab&, const int, const int, const int, const Echange_externe_impose&, const int, Type_Double& ) const;
78 template <typename Type_Double> inline void flux_faces_interne(const DoubleTab&, const int, Type_Double& ) const;
79
80 /* ************************************** *
81 * ********* POUR L'IMPLICITE ********** *
82 * ************************************** */
83
84 template <typename BC, typename Type_Double> // Generic return
85 inline void coeffs_face(const int, const int, const BC&, Type_Double&, Type_Double& ) const { /* Do nothing */ }
86
87 // To overload
88 template <typename Type_Double> inline void coeffs_face(const int, const int, const Dirichlet_entree_fluide&, Type_Double&, Type_Double& ) const;
89 template <typename Type_Double> inline void coeffs_face(const int, const int, const Scalaire_impose_paroi&, Type_Double&, Type_Double& ) const;
90 template <typename Type_Double> inline void coeffs_face(const int, const int, const Dirichlet_loi_paroi&, Type_Double&, Type_Double& ) const;
91 template <typename Type_Double> inline void coeffs_face(const int, const int, const Periodique&, Type_Double&, Type_Double& ) const;
92 template <typename Type_Double> inline void coeffs_face(const int, const int, const Echange_global_impose&, Type_Double&, Type_Double& ) const;
93 template <typename Type_Double> inline void coeffs_face(const int, const int, const Dirichlet_paroi_fixe&, Type_Double&, Type_Double& ) const;
94 template <typename Type_Double> inline void coeffs_face(const DoubleTab&, const int, const int, const int, const int, const Echange_externe_impose&, Type_Double&, Type_Double& ) const;
95 template <typename Type_Double> inline void coeffs_faces_interne(const int, Type_Double&, Type_Double& ) const;
96
97 // A virer un jour .. voir avec le baltik Rayonnement
98 template <typename BC, typename Type_Double> // Generic return
99 inline void secmem_face(const int, const BC&, const int, Type_Double& ) const { /* Do nothing */ }
100
101 template <typename Type_Double> inline void secmem_face(const int, const Dirichlet_entree_fluide&, const int, Type_Double& ) const;
102 template <typename Type_Double> inline void secmem_face(const int, const Neumann_paroi&, const int, Type_Double& ) const;
103 template <typename Type_Double> inline void secmem_face(const int, const Echange_global_impose&, const int, Type_Double& ) const;
104 template <typename Type_Double> inline void secmem_face(const int, const int, const int, const Echange_externe_impose&, const int, Type_Double& ) const;
105 template <typename Type_Double> inline void secmem_faces_interne(const int, Type_Double& ) const { /* Do nothing */ }
106
107private:
108 inline double Dist_face_elem0(const int face, const int n0) const { return DERIVED_T::IS_AXI ? le_dom->dist_face_elem0_axi(face,n0) : le_dom->dist_face_elem0(face,n0); }
109 inline double Dist_face_elem1(const int face, const int n1) const { return DERIVED_T::IS_AXI ? le_dom->dist_face_elem1_axi(face,n1) : le_dom->dist_face_elem1(face,n1); }
110 inline double Dist_norm_bord (const int face) const
111 {
112 double val = DERIVED_T::IS_AXI ? le_dom->dist_norm_bord_axi(face) : le_dom->dist_norm_bord(face);
113 return DERIVED_T::IS_MULTD ? val : 2*val;
114 }
115
116 inline double Dist_norm_bord_externe_VEC(const int boundary_index, const int global_face, const int local_face) const
117 {
118 if (DERIVED_T::IS_DEQUIV) return equivalent_distance(boundary_index,local_face);
119 else return DERIVED_T::IS_AXI ? le_dom->dist_norm_bord_axi(global_face) : le_dom->dist_norm_bord(global_face);
120 }
121
122 inline double Dist_norm_bord_externe_(const int global_face) const
123 {
124 assert (!DERIVED_T::IS_DEQUIV);
125 return DERIVED_T::IS_AXI ? le_dom->dist_norm_bord_axi(global_face) : le_dom->dist_norm_bord(global_face);
126 }
127
128 inline void not_implemented_k_eps(const char * nom_funct) const
129 {
130 std::cerr << "Error in : " << nom_funct << " ! This function is not yet implemented for Op_Diff_K_Eps_QC !" << std::endl;
131 throw;
132 }
133
134 // CRTP pattern to static_cast the appropriate class and get the implementation : This is magic !
135 inline int ind_Fluctu_Term() const { return static_cast<const DERIVED_T *>(this)->get_ind_Fluctu_Term(); } // See generic impl in the class Eval_Diff_VDF. They will be overloaded for Dift ops
136 inline double nu_1(const int i, int compo = 0) const { return static_cast<const DERIVED_T *>(this)->nu_1_impl(i,compo); }
137 inline double nu_2(const int i, int compo = 0) const { return static_cast<const DERIVED_T *>(this)->nu_2_impl(i,compo); }
138 inline double compute_heq(const double d0, const int i0, const double d1, const int i1, int compo = 0) const { return static_cast<const DERIVED_T *>(this)->compute_heq_impl(d0,i0,d1,i1,compo); }
139 inline double equivalent_distance (const int boundary_index, const int local_face) const { return static_cast<const DERIVED_T *>(this)->get_equivalent_distance(boundary_index,local_face); }
140 inline double dv_mvol(const int i) const { return static_cast<const DERIVED_T *>(this)->get_dv_mvol(i); }
141};
142
143#include <Eval_Diff_VDF_Elem_Gen.tpp> // templates specializations ici ;)
144
145#endif /* Eval_Diff_VDF_Elem_Gen_included */
classe Dirichlet_entree_fluide Cette classe represente une condition aux limite imposant une grandeur
Classe Dirichlet_loi_paroi Classe de base pour les valeurs impose pour une condition aux limites des ...
classe Dirichlet_paroi_fixe Represente une paroi immobile dans une equation de type Navier_Stokes.
Classe Echange_externe_impose: Cette classe represente le cas particulier de la classe.
Classe Echange_global_impose Cette classe represente le cas particulier de la classe.
class Eval_Diff_VDF_Elem_Gen Evaluateur VDF pour la diffusion : Le champ diffuse est un Champ_P0_VDF
static constexpr bool IS_QUASI
void flux_face(const DoubleTab &, const DoubleTab &, const int, const BC &, int, Type_Double &) const
static constexpr bool IS_MODIF_DEQ
static constexpr bool IS_AXI
void coeffs_face(const int, const int, const BC &, Type_Double &, Type_Double &) const
static constexpr bool IS_MULTD
static constexpr bool IS_ANISO
void secmem_faces_interne(const int, Type_Double &) const
static constexpr bool IS_DEQUIV
void secmem_face(const int, const BC &, const int, Type_Double &) const
static constexpr bool IS_MULTI_SCALAR_DIFF
static constexpr bool IS_RANS
void coeffs_faces_interne(const int, Type_Double &, Type_Double &) const
void flux_faces_interne(const DoubleTab &, const int, Type_Double &) const
class Eval_VDF_Elem Cette classe represente le prototype fonctionnel
Classe Neumann_paroi Cette condition limite correspond a un flux impose pour l'equation de.
classe Periodique Cette classe represente une condition aux limites periodique.
Definition Periodique.h:31
classe Scalaire_impose_paroi Impose un scalaire a la paroi dans une equation de type Convection-Difus...