TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_Poly_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 Domaine_Poly_base_included
17#define Domaine_Poly_base_included
18
19#include <Domaine_Poly_tools.h>
20#include <Static_Int_Lists.h>
21#include <Elem_poly_base.h>
22#include <Elem_poly_base.h>
23#include <TRUST_Deriv.h>
24#include <TRUSTLists.h>
25#include <Periodique.h>
26#include <Domaine_VF.h>
27#include <TRUSTTrav.h>
28#include <Conds_lim.h>
29#include <Domaine.h>
30#include <Lapack.h>
31#include <math.h>
32#include <vector>
33#include <string>
34#include <array>
35#include <map>
36
37class Geometrie;
38extern bool polymac_flica5;
39/*! @brief class Domaine_Poly_base
40 *
41 * Instantiable class derived from Domaine_VF.
42 * This class contains the geometric information required by the
43 * Finite Volume Element method (Crouzeix-Raviart element).
44 * The class holds a number of pieces of information concerning the faces.
45 * In this set of faces, the boundary and joint faces are also included.
46 * To handle the faces, two categories are distinguished:
47 * - non-standard faces: located on a joint, a boundary, or internal
48 * but belonging to a boundary element
49 * - standard faces: internal faces not belonging to a boundary element
50 * This distinction corresponds to the treatment of boundary conditions:
51 * standard faces do not "see" boundary conditions.
52 * The set of faces is numbered as follows:
53 * - faces on a Domaine_joint appear first
54 * (in the order of the les_joints vector)
55 * - faces on a Domaine_bord appear next
56 * (in the order of the les_bords vector)
57 * - non-standard internal faces appear next
58 * - standard internal faces appear last
59 * Consequently, all non-standard faces requiring special treatment are
60 * grouped together at the beginning.
61 * Two types of elements are distinguished:
62 * - non-standard elements: they have at least one boundary face
63 * - standard elements: they have no boundary face
64 * Standard elements (resp. non-standard elements) are not stored
65 * consecutively in the Domaine object. The rang_elem_non_std array
66 * is used to selectively access one or the other type of element.
67 *
68 */
70{
71 Declare_base(Domaine_Poly_base);
72public :
73 void typer_elem(Domaine& domaine_geom) override;
74 void discretiser() override;
75 virtual void calculer_volumes_entrelaces() { }
76 void discretiser_aretes();
77
78 void orthocentrer();
79
80 inline const DoubleVect& longueur_aretes() const { return longueur_aretes_; }
81 inline const DoubleTab& ta() const { return ta_; }
82
83 void modifier_pour_Cl(const Conds_lim& ) override;
84
85 inline const Elem_poly_base& type_elem() const { return type_elem_.valeur(); }
86 inline int nb_elem_Cl() const { return nb_elem() - nb_elem_std_; }
87 inline int nb_faces_joint() const { return 0; /* return nb_faces_joint_; A FAIRE */ }
88 inline int nb_faces_std() const { return nb_faces_std_; }
89 inline int nb_elem_std() const { return nb_elem_std_; }
90 inline double carre_pas_du_maillage() const { return h_carre; }
91 inline double carre_pas_maille(int i) const { return h_carre_(i); }
92 inline IntVect& rang_elem_non_std() { return rang_elem_non_std_; }
93 inline const IntVect& rang_elem_non_std() const { return rang_elem_non_std_; }
94
95 virtual void calculer_h_carre();
96
97 inline DoubleTab& volumes_entrelaces_dir() { return volumes_entrelaces_dir_; } // returns the interlaced volumes array per side.
98 inline const DoubleTab& volumes_entrelaces_dir() const { return volumes_entrelaces_dir_; }
99
100 //equivalent to dot(), but for the product (a - ma).nu.(b - mb)
101 inline double nu_dot(const DoubleTab* nu, int e, int n, const double *a, const double *b, const double *ma = nullptr, const double *mb = nullptr) const;
102
103 inline double dist_norm(int num_face) const override;
104 inline double dist_norm_bord(int num_face) const override;
105 DoubleVect& dist_norm_bord(DoubleVect& , const Nom& nom_bord) const;
106 inline double dist_face_elem0(int num_face,int n0) const override;
107 inline double dist_face_elem1(int num_face,int n1) const override;
108 inline double dist_face_elem0_period(int num_face,int n0,double l) const override;
109 inline double dist_face_elem1_period(int num_face,int n1,double l) const override;
110
111 void detecter_faces_non_planes() const;
112
113 //equivalent faces: equiv(f, 0/1, i) = face equivalent to e_f(f_e(f, 0/1), i) on the other side, -1 if there is none
114 const IntTab& equiv() const;
115 virtual void init_equiv() const = 0;
116
117 //connectivite sommet-elements
118 const Static_Int_Lists& som_elem() const;
119
120 //indexing in arrays of type (element, vertex) and (element, edge)
121 const IntTab& elem_som_d() const; //entry of vertex les_elems(e, i) of element e: elem_som_d()(e) + i
122 const IntTab& elem_arete_d() const; //entry of edge elem_arete(e, i) of element e: elem_arete_d()(e) + i
123
124 //for each element, distribution of its volume among each of its vertices
125 const DoubleTab& vol_elem_som() const;
126 //for each vertex, product porosity * volume
127 const DoubleTab& pvol_som(const DoubleVect& poro) const;
128
129 //som_arete[som1][som2 > som1] -> arete correspondant a (som1, som2)
130 std::vector<std::map<int, int> > som_arete;
131
132 //MD_Vectors for Champ_Elem_PolyMAC_CDO (elems + faces) and for Champ_Face_PolyMAC_CDO (faces + edges)
134
136 void fill_normales();
137 void recalculer_xv();
138
139protected:
140 void verifier_type_elem() const;
142
143 double h_carre = DMAXFLOAT; // square of the mesh step size
144 DoubleVect h_carre_; // square of the mesh cell step size
145 OWN_PTR(Elem_poly_base) type_elem_; // type of the discretization element
146
147 Sortie& ecrit(Sortie& os) const;
148
149 mutable IntTab equiv_;
150 mutable Static_Int_Lists som_elem_;
151 mutable IntTab elem_som_d_, elem_arete_d_;
152 mutable DoubleTab vol_elem_som_, pvol_som_;
153
154 DoubleVect longueur_aretes_; //edge lengths
155 mutable DoubleTab ta_; //tangent vectors to the edges
156};
157
158/* equivalent of dist_norm_bord from VDF */
159inline double Domaine_Poly_base::dist_norm_bord(int f) const
160{
161 assert(face_voisins(f, 1) == -1);
162 return std::fabs(dot(&xp_(face_voisins(f, 0), 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f);
163}
164
165inline double Domaine_Poly_base::dist_norm(int f) const
166{
167 return std::fabs(dot(&xp_(face_voisins(f, 0), 0), &face_normales_(f, 0), &xp_(face_voisins(f, 1), 0))) / face_surfaces(f);
168}
169
170inline double Domaine_Poly_base::dist_face_elem0(int f,int e) const
171{
172 return std::fabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f);
173}
174
175inline double Domaine_Poly_base::dist_face_elem1(int f,int e) const
176{
177 return std::fabs(dot(&xp_(e, 0), &face_normales_(f, 0), &xv_(f, 0))) / face_surfaces(f);
178}
179
180inline double Domaine_Poly_base::dist_face_elem0_period(int num_face,int n0,double l) const
181{
182 abort();
183 return 0;
184}
185
186inline double Domaine_Poly_base::dist_face_elem1_period(int num_face,int n1,double l) const
187{
188 abort();
189 return 0;
190}
191
192//returns the dot product a.nu.b regardless of the number of components and the type of nu tensor
193inline double Domaine_Poly_base::nu_dot(const DoubleTab* nu, int e, int n, const double *a, const double *b, const double *ma, const double *mb) const
194{
195 if (!nu) return dot(a, b, ma, mb);
196 int d, db, D = dimension;
197 double resu = 0;
198 if (nu->nb_dim() == 2) resu += (*nu)(e, n) * dot(a, b, ma, mb); //isotrope
199 else if (nu->nb_dim() == 3)
200 for (d = 0; d < D; d++) //anisotrope diagonal
201 resu += (*nu)(e, n, d) * (a[d] - (ma ? ma[d] : 0)) * (b[d] - (mb ? mb[d] : 0));
202 else for (d = 0; d < D; d++)
203 for (db = 0; db < D; db++)
204 resu += (*nu)(e, n, d, db) * (a[d] - (ma ? ma[d] : 0)) * (b[db] - (mb ? mb[db] : 0));
205 return resu;
206}
207
208#endif /* Domaine_Poly_base_included */
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
class Domaine_Poly_base
double dist_face_elem0(int num_face, int n0) const override
const IntVect & rang_elem_non_std() const
void detecter_faces_non_planes() const
const Elem_poly_base & type_elem() const
const DoubleTab & vol_elem_som() const
virtual void calculer_volumes_entrelaces()
const DoubleVect & longueur_aretes() const
double dist_face_elem1_period(int num_face, int n1, double l) const override
int nb_faces_joint() const
double dist_face_elem0_period(int num_face, int n0, double l) const override
void modifier_pour_Cl(const Conds_lim &) override
double dist_face_elem1(int num_face, int n1) const override
void verifier_type_elem() const
const Static_Int_Lists & som_elem() const
double dist_norm(int num_face) const override
const IntTab & elem_som_d() const
OWN_PTR(Elem_poly_base) type_elem_
DoubleTab & volumes_entrelaces_dir()
virtual void init_equiv() const =0
double carre_pas_maille(int i) const
const IntTab & equiv() const
std::vector< std::map< int, int > > som_arete
const DoubleTab & ta() const
double carre_pas_du_maillage() const
void discretiser() override
const DoubleTab & pvol_som(const DoubleVect &poro) const
const DoubleTab & volumes_entrelaces_dir() const
virtual void calculer_h_carre()
Static_Int_Lists som_elem_
IntVect & rang_elem_non_std()
double dist_norm_bord(int num_face) const override
double nu_dot(const DoubleTab *nu, int e, int n, const double *a, const double *b, const double *ma=nullptr, const double *mb=nullptr) const
void corriger_face_voisins_sur_les_faces_virtuelles()
const IntTab & elem_arete_d() const
Sortie & ecrit(Sortie &os) const
void typer_elem(Domaine &domaine_geom) override
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
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
DoubleTab volumes_entrelaces_dir_
Definition Domaine_VF.h:211
IntTab & face_voisins() override
Returns the face-element connectivity array; see above.
Definition Domaine_VF.h:426
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
int nb_dim() const
Definition TRUSTTab.h:199