TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_VEF.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 Domaine_VEF_included
17#define Domaine_VEF_included
18
19#include <TRUSTArray_kokkos.tpp>
20#include <Elem_VEF_base.h>
21#include <TRUST_Deriv.h>
22#include <Domaine_VF.h>
23#include <kokkos++.h>
24
26class Geometrie;
27
28/*! @brief class Domaine_VEF
29 *
30 * @brief Instantiable class derived from Domaine_VF.
31 * This class contains the geometric information required by the Finite Element Volume method (Crouzeix-Raviart element).
32 * The class holds a number of pieces of information about faces.
33 * Among these faces, boundary and joint faces are also included. Two categories of faces are distinguished:
34 * - non-standard faces: on a joint, a boundary, or internal faces
35 * belonging to a boundary element
36 * - standard faces: internal faces not belonging to any boundary element
37 * This distinction corresponds to boundary condition treatment: standard faces do not "see" boundary conditions.
38 * The full set of faces is numbered as follows:
39 * - faces on a Domaine_joint appear first
40 * (in the order of the les_joints vector)
41 * - faces on a Domaine_bord appear next
42 * (in the order of the les_bords vector)
43 * - internal non-standard faces appear next
44 * - internal standard faces appear last
45 * All non-standard faces requiring special treatment are therefore grouped at the beginning.
46 * Two element types are distinguished:
47 * - non-standard elements: they have at least one boundary face
48 * - standard elements: they have no boundary face
49 * Standard (resp. non-standard) elements are not stored consecutively in the Domaine object.
50 * The array rang_elem_non_std is used to selectively access either type.
51 */
53{
54 Declare_instanciable(Domaine_VEF);
55public:
56 void discretiser() override;
57 virtual void discretiser_suite(const VEF_discretisation&);
58 void discretiser_arete();
59
61 int lecture_ok_arete();
62 void verifie_ok_arete(int) const;
64
65 virtual void creer_tableau_p1bulle(Array_base&, RESIZE_OPTIONS opt = RESIZE_OPTIONS::COPY_INIT) const;
66
67 void swap(int, int, int);
68 void modifier_pour_Cl(const Conds_lim&) override;
69 void typer_elem(Domaine&) override;
71 void calculer_h_carre();
72 DoubleTab& vecteur_face_facette();
73
74 inline const Elem_VEF_base& type_elem() const { return type_elem_.valeur(); }
75 inline int nb_elem_Cl() const { return nb_elem() - nb_elem_std_; }
76 inline int nb_faces_joint() const { return 0; }
77 inline int nb_faces_std() const { return nb_faces_std_; }
78 inline int nb_elem_std() const { return nb_elem_std_; }
79 inline int premiere_face_std() const { return nb_faces() - nb_faces_std_; }
80 inline int nb_faces_non_std() const { return nb_faces() - nb_faces_std_; }
81 inline double carre_pas_du_maillage() const { return h_carre; }
82 inline const DoubleVect& carre_pas_maille() const { return h_carre_; }
83 inline auto& facette_normales() { return facette_normales_; }
84 inline const auto& facette_normales() const { return facette_normales_; }
85 inline IntVect& rang_elem_non_std() { return rang_elem_non_std_; }
86 inline const IntVect& rang_elem_non_std() const { return rang_elem_non_std_; }
87
88 inline double volume_au_sommet(int som) const { return volumes_som_[som]; }
89 inline const DoubleVect& volume_aux_sommets() const { return volumes_som_; }
90 inline int get_P1Bulle() const { assert(P1Bulle != -1); return P1Bulle; }
91 inline int get_alphaE() const { assert(alphaE != -1); return alphaE; }
92 inline int get_alphaS() const { assert(alphaS != -1); return alphaS; }
93 inline int get_alphaA() const { assert(alphaA != -1); return alphaA; }
94 inline int get_alphaRT() const { assert(alphaRT != -1); return alphaRT; }
95 inline int get_modif_div_face_dirichlet() const { assert(modif_div_face_dirichlet != -1); return modif_div_face_dirichlet; }
96 inline int get_cl_pression_sommet_faible() const { assert(cl_pression_sommet_faible != -1); return cl_pression_sommet_faible; }
97 inline const ArrOfInt& get_renum_arete_perio() const { return renum_arete_perio; }
98 inline const IntVect& get_ok_arete() const { return ok_arete; }
99 inline const DoubleVect& get_volumes_aretes() const { return volumes_aretes; }
100
101 inline virtual const MD_Vector& md_vector_p1b() const { assert(md_vector_p1b_); return md_vector_p1b_; }
102
103 inline int numero_premier_element() const;
104 inline int numero_premier_sommet() const;
105 inline int numero_premiere_arete() const;
106
107 inline double dist_face_elem0(int num_face,int n0) const override;
108 inline double dist_face_elem1(int num_face,int n1) const override;
109
110private:
111 double h_carre = 1.e30; // squared mesh step size
112 DoubleVect h_carre_; // squared cell step size
113 OWN_PTR(Elem_VEF_base) type_elem_; // type of the discretisation element
114 // normals to interlaced volume faces:
115#ifdef TRUST_USE_GPU
116 BigDoubleTab facette_normales_; // Cause size=nb_elem*6*dim may be > 2^31
117#else
118 DoubleTab facette_normales_;
119#endif
120 DoubleTab vecteur_face_facette_; // vector from face center to facette center
121 IntVect orientation_;
122
123
124 DoubleVect volumes_som_, volumes_aretes;
125 ArrOfInt renum_arete_perio;
126 IntVect ok_arete;
127
128 int P1Bulle = -1, alphaE = -1, alphaS = -1, alphaA = -1;
129 int alphaRT = -1; // for trio stationary
130 int modif_div_face_dirichlet = -1;
131 int cl_pression_sommet_faible = -1; // determines whether pressure BCs are imposed weakly or strongly -> see divergence and assembler
132 // Descriptor for p1b arrays (depending on alphaE, alphaS and alphaA) (built in Domaine_VEF::discretiser())
133 MD_Vector md_vector_p1b_;
134
135 Sortie& ecrit(Sortie& os) const;
136};
137
138// Out-of-class Kokkos function: otherwise dom_VEF.oriente_normale(...) would copy a Domaine_VEF instance from host to device!
139KOKKOS_INLINE_FUNCTION int oriente_normale(int face_opp, int elem2, CIntTabView face_voisins)
140{
141 return (face_voisins(face_opp, 0) == elem2) ? 1 : -1;
142}
143
144// Test method:
145void exemple_champ_non_homogene(const Domaine_VEF&, DoubleTab&);
146
148{
149 if (!alphaE)
150 return -1;
151 else
152 return 0;
153}
155{
156 if (!alphaS)
157 return -1;
158 else if (!alphaE)
159 return 0;
160 else
161 return nb_elem_tot();
162}
164{
165 if (!alphaA)
166 return -1;
167 else if (!alphaE && !alphaS)
168 return 0;
169 else if (!alphaE && alphaS)
170 return nb_som_tot();
171 else if (!alphaS && alphaE)
172 return nb_elem_tot();
173 else
174 return nb_elem_tot() + nb_som_tot();
175}
176
177inline double Domaine_VEF::dist_face_elem0(int f,int e) const
178{
179 return std::fabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f);
180}
181
182inline double Domaine_VEF::dist_face_elem1(int f,int e) const
183{
184 return std::fabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f);
185}
186#endif
Empty class used as a base for all the arrays.
Definition Array_base.h:41
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual void creer_tableau_p1bulle(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
const auto & facette_normales() const
Definition Domaine_VEF.h:84
void verifie_ok_arete(int) const
int numero_premiere_arete() const
int nb_faces_std() const
Definition Domaine_VEF.h:77
void construire_ok_arete()
const IntVect & get_ok_arete() const
Definition Domaine_VEF.h:98
int nb_faces_joint() const
Definition Domaine_VEF.h:76
IntVect & rang_elem_non_std()
Definition Domaine_VEF.h:85
void modifier_pour_Cl(const Conds_lim &) override
void swap(int, int, int)
double dist_face_elem1(int num_face, int n1) const override
int numero_premier_sommet() const
double dist_face_elem0(int num_face, int n0) const override
DoubleTab & vecteur_face_facette()
int nb_elem_Cl() const
Definition Domaine_VEF.h:75
int premiere_face_std() const
Definition Domaine_VEF.h:79
void calculer_volumes_entrelaces()
int numero_premier_element() const
int nb_faces_non_std() const
Definition Domaine_VEF.h:80
double carre_pas_du_maillage() const
Definition Domaine_VEF.h:81
const DoubleVect & get_volumes_aretes() const
Definition Domaine_VEF.h:99
void calculer_h_carre()
int get_modif_div_face_dirichlet() const
Definition Domaine_VEF.h:95
void typer_elem(Domaine &) override
int get_cl_pression_sommet_faible() const
Definition Domaine_VEF.h:96
const Elem_VEF_base & type_elem() const
Definition Domaine_VEF.h:74
const IntVect & rang_elem_non_std() const
Definition Domaine_VEF.h:86
int lecture_ok_arete()
int get_alphaA() const
Definition Domaine_VEF.h:93
const ArrOfInt & get_renum_arete_perio() const
Definition Domaine_VEF.h:97
virtual void discretiser_suite(const VEF_discretisation &)
void discretiser_arete()
virtual const MD_Vector & md_vector_p1b() const
int get_alphaRT() const
Definition Domaine_VEF.h:94
int nb_elem_std() const
Definition Domaine_VEF.h:78
const DoubleVect & volume_aux_sommets() const
Definition Domaine_VEF.h:89
int get_alphaS() const
Definition Domaine_VEF.h:92
const DoubleVect & carre_pas_maille() const
Definition Domaine_VEF.h:82
int get_alphaE() const
Definition Domaine_VEF.h:91
void construire_renum_arete_perio(const Conds_lim &)
auto & facette_normales()
Definition Domaine_VEF.h:83
void discretiser() override
double volume_au_sommet(int som) const
Definition Domaine_VEF.h:88
int get_P1Bulle() const
Definition Domaine_VEF.h:90
class Domaine_VF
Definition Domaine_VF.h:44
IntVect rang_elem_non_std_
Definition Domaine_VF.h:252
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
DoubleTab xp_
Definition Domaine_VF.h:218
double dot(const double *a, const double *b, const double *ma=nullptr, const double *mb=nullptr) const
Definition Domaine_VF.h:695
DoubleTab xv_
Definition Domaine_VF.h:219
int nb_elem_std_
Definition Domaine_VF.h:250
int nb_faces_std_
Definition Domaine_VF.h:251
DoubleTab face_normales_
Definition Domaine_VF.h:212
int nb_elem_tot() const
int nb_som_tot() const
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
Base class for output streams.
Definition Sortie.h:52