TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Polygone.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 Polygone_included
17#define Polygone_included
18
19#include <Poly_geom_base.h>
20
21/*! @brief Class Polygone represents the geometric element Polygone.
22 *
23 * A polyhedron is an element defined by its faces of type Type_Face::polygone_3D
24 *
25 * @sa Poly_geom_base Elem_geom
26 */
27template <typename _SIZE_>
29{
30
31 Declare_instanciable_32_64(Polygone_32_64);
32
33public :
34 // Template classes with different template parameter do not see each other - build_reduced() needs this.
35 template <class T> friend class Polygone_32_64;
36
37 using int_t = _SIZE_;
38 using ArrOfInt_t = ArrOfInt_T<_SIZE_>;
39 using IntTab_t = IntTab_T<_SIZE_>;
40 using SmallArrOfTID_t = SmallArrOfTID_T<_SIZE_>;
41 using DoubleVect_t = DoubleVect_T<_SIZE_>;
42 using DoubleTab_t = DoubleTab_T<_SIZE_>;
44
45
46 inline int face_sommet(int i, int j) const override;
47 inline int nb_som() const override;
48 inline int nb_faces(int=0) const override;
49 inline int nb_som_face(int=0) const override;
50 const Nom& nom_lml() const override;
51
52 int contient(const ArrOfDouble& pos, int_t elem) const override;
53 int contient(const SmallArrOfTID_t& soms, int_t elem) const override;
54 inline Type_Face type_face(int=0) const override;
55 void calculer_volumes(DoubleVect_t& vols) const override;
56 void calculer_centres_gravite(DoubleTab_t& xp) const override;
57
58 void calculer_un_centre_gravite(const int_t elem, DoubleVect& xp) const override ;
59
60 int get_tab_faces_sommets_locaux(IntTab& faces_som_local) const override;
61 int get_tab_faces_sommets_locaux(IntTab& faces_som_local, int_t elem) const override;
62 void affecte_connectivite_numero_global(const ArrOfInt_t& FacesIndex,const ArrOfInt_t& PolygonIndex,IntTab_t& les_elems);
63
65 inline int get_nb_face_elem_max() const { return nb_face_elem_max_ ; }
66
67 _SIZE_ get_somme_nb_faces_elem() const override;
68
69 inline const ArrOfInt_t& getPolygonIndex() const { return PolygonIndex_; }
70 inline const ArrOfInt_t& getElemIndex() const override { return PolygonIndex_; }
72 void build_reduced(OWN_PTR(Elem_geom_base_32_64<int>)& type_elem, const ArrOfInt_t& elems_sous_part) const override;
73 void compute_virtual_index() override;
74
75protected:
76 // Members herited from top classes:
78 using Elem_geom_base_32_64<_SIZE_>::mon_dom;
79 // FacesIndex_[f] first vertex index of face f in Nodes
83
84 /*! PolygonIndex_[ele] gives the index of the first face of element 'ele'
85 * See FaceIndex_ in base class.
86 */
88};
89
90
91/*! @brief Returns the index of the j-th vertex of the i-th face of the element.
92 *
93 * @param (int i) a face index
94 * @param (int j) a vertex index
95 * @return (int) the index of the j-th vertex of the i-th face
96 */
97template <typename _SIZE_>
98inline int Polygone_32_64<_SIZE_>::face_sommet(int face, int sommet) const
99{
100 BLOQUE;
101 return -1;
102}
103
104
105/*! @brief Returns the number of vertices of a Polygone element.
106 *
107 * @return (int) the maximum number of vertices of a polyhedron
108 */
109template <typename _SIZE_>
111{
112 return get_nb_som_elem_max();
113}
114
115
116/*! @brief Returns the number of faces of the specified type that the geometric element has.
117 *
118 * A Polygone has 1 type of face: polygon_3D
119 *
120 * @param (int i) the face type
121 */
122template <typename _SIZE_>
123inline int Polygone_32_64<_SIZE_>::nb_faces(int i) const
124{
125 assert(i==0);
126 switch(i)
127 {
128 case 0:
129 return get_nb_face_elem_max();
130 default :
131 Cerr << "Error, a polyhedron has 1 type of faces and not " << i << finl;
133 return -1;
134 }
135}
136
137
138/*! @brief Returns the maximum number of vertices of the faces of the specified type.
139 *
140 * @param (int i) the face type
141 * @return (int) the number of vertices of faces of type i
142 */
143template <typename _SIZE_>
145{
146 assert(i==0);
147 return 2;
148}
149
150/*! @brief Returns the i-th face type.
151 *
152 * A polyhedron has 2 face types: quadrangle and triangle
153 *
154 * @param (int i) the rank of the face type to return
155 * @return (Type_Face) the type of face i
156 */
157template <typename _SIZE_>
158inline Type_Face Polygone_32_64<_SIZE_>::type_face(int i) const
159{
160 assert(i<=0);
161 switch(i)
162 {
163 case 0:
164 return Type_Face::segment_2D;
165 default :
166 Cerr << "Error, a polyhedron has 1 type of faces and not " << i << finl;
168 return Type_Face::quadrangle_3D;
169 }
170}
171
172
173using Polygone = Polygone_32_64<int>;
174using Polygone_64 = Polygone_32_64<trustIdType>;
175
176#endif
class Domaine_32_64 A Domain is a mesh composed of a set of geometric elements of the same type.
Definition Domaine.h:62
Class Elem_geom_base This class is the base class for the definition of elements.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
Base class for polyedrons and polygons. Connectivity is stored in descending mode:
Class Polygone represents the geometric element Polygone.
Definition Polygone.h:29
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
Fills faces_som_local(i,j) giving for 0 <= i < nb_faces() and 0 <= j < nb_som_face(i) the local verte...
Definition Polygone.cpp:285
_SIZE_ get_somme_nb_faces_elem() const override
Definition Polygone.cpp:121
void build_reduced(OWN_PTR(Elem_geom_base_32_64< int >)&type_elem, const ArrOfInt_t &elems_sous_part) const override
Definition Polygone.cpp:87
int get_tab_faces_sommets_locaux(IntTab &faces_som_local, int_t elem) const override
Definition Polygone.cpp:291
friend class Polygone_32_64
Definition Polygone.h:35
int nb_som() const override
Returns the number of vertices of a Polygone element.
Definition Polygone.h:110
Domaine_32_64< _SIZE_ > Domaine_t
Definition Polygone.h:43
void calculer_un_centre_gravite(const int_t elem, DoubleVect &xp) const override
Definition Polygone.cpp:403
ArrOfInt_T< _SIZE_ > ArrOfInt_t
Definition Polygone.h:38
void calculer_centres_gravite(DoubleTab_t &xp) const override
Compute all centers of mass of all elements in the domain.
Definition Polygone.cpp:356
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes (areas) of the elements of the associated domain.
Definition Polygone.cpp:240
int get_nb_som_elem_max() const
Definition Polygone.cpp:127
int nb_som_face(int=0) const override
Returns the maximum number of vertices of the faces of the specified type.
Definition Polygone.h:144
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
Definition Polygone.h:40
ArrOfInt_t PolygonIndex_
Definition Polygone.h:87
DoubleTab_T< _SIZE_ > DoubleTab_t
Definition Polygone.h:42
void affecte_connectivite_numero_global(const ArrOfInt_t &FacesIndex, const ArrOfInt_t &PolygonIndex, IntTab_t &les_elems)
Definition Polygone.cpp:317
_SIZE_ int_t
Definition Polygone.h:37
void compute_virtual_index() override
Definition Polygone.cpp:114
int contient(const SmallArrOfTID_t &soms, int_t elem) const override
Not yet implemented — always returns 0. Returns 1 if the vertices specified by "pos" are those of ele...
Definition Polygone.cpp:228
int get_nb_face_elem_max() const
Definition Polygone.h:65
IntTab_T< _SIZE_ > IntTab_t
Definition Polygone.h:39
int face_sommet(int i, int j) const override
Returns the index of the j-th vertex of the i-th face of the element.
Definition Polygone.h:98
const ArrOfInt_t & getElemIndex() const override
Definition Polygone.h:70
int nb_faces(int=0) const override
Returns the number of faces of the specified type that the geometric element has.
Definition Polygone.h:123
int contient(const ArrOfDouble &pos, int_t elem) const override
Returns 1 if element "num_poly" of the domain associated with this geometric element contains the poi...
Definition Polygone.cpp:197
DoubleVect_T< _SIZE_ > DoubleVect_t
Definition Polygone.h:41
const Nom & nom_lml() const override
Returns the LML name of a polygon = "POLYEDRE_" + 2*nb_som_max (or "POLYGONE_" + nb_som_max in 3D).
Definition Polygone.cpp:140
void rebuild_index()
Definition Polygone.cpp:58
Type_Face type_face(int=0) const override
Returns the i-th face type.
Definition Polygone.h:158
const ArrOfInt_t & getPolygonIndex() const
Definition Polygone.h:69
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466