TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Rectangle.h
1/****************************************************************************
2* Copyright (c) 2024, 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 Rectangle_included
17#define Rectangle_included
18
19
20#include <Elem_geom_base.h>
21
22/*! @brief Rectangle class — represents the rectangular geometric element.
23 *
24 * A rectangle has 4 faces, 4 vertices and 1 single face type with 2
25 * vertices per face.
26 *
27 * @sa Elem_geom_base Elem_geom Rectangle_axi
28 */
29template <typename _SIZE_>
31{
32
33 Declare_instanciable_32_64(Rectangle_32_64);
34
35public :
36 using int_t = _SIZE_;
37 using IntTab_t = IntTab_T<_SIZE_>;
38 using SmallArrOfTID_t = SmallArrOfTID_T<_SIZE_>;
39 using DoubleVect_t = DoubleVect_T<_SIZE_>;
40 using DoubleTab_t = DoubleTab_T<_SIZE_>;
42
43
44 inline int face_sommet(int i, int j) const override;
45 inline int face_sommet0(int i) const;
46 inline int face_sommet1(int i) const;
47 inline int face_sommet2(int i) const;
48 inline int face_sommet3(int i) const;
49
50 inline int nb_som() const override { return 4; }
51 inline int nb_faces(int=0) const override;
52 inline int nb_som_face(int=0) const override;
53 inline bool est_structure() const override { return true; }
54 const Nom& nom_lml() const override;
55
56 int contient(const ArrOfDouble& pos, int_t elem) const override;
57 int contient(const SmallArrOfTID_t& soms, int_t elem) const override;
58 inline Type_Face type_face(int=0) const override;
59 void reordonner() override ;
60 void calculer_volumes(DoubleVect_t& vols) const override;
61 void calculer_normales(const IntTab_t& faces_sommets , DoubleTab_t& face_normales) const override;
62 int get_tab_faces_sommets_locaux(IntTab& faces_som_local) const override;
63
65
66protected:
67 // Members herited from top classes:
69 using Elem_geom_base_32_64<_SIZE_>::mon_dom;
70
71};
72
73
74/*! @brief Returns the index of the j-th vertex of the i-th face of the element.
75 *
76 * @param (int i) a face index
77 * @param (int j) a vertex index
78 * @return (int) the index of the j-th vertex of the i-th face
79 */
80template <typename _SIZE_>
81inline int Rectangle_32_64<_SIZE_>::face_sommet(int i, int j) const
82{
83 assert(i<4);
84 switch(i)
85 {
86 case 0:
87 return face_sommet0(j);
88 case 1:
89 return face_sommet1(j);
90 case 2:
91 return face_sommet2(j);
92 case 3:
93 return face_sommet3(j);
94 default :
95 return -1;
96 }
97}
98
99
100/*! @brief Returns the index of the i-th vertex of face 0.
101 *
102 * @param (int i) the vertex index to return
103 * @return (int) the index of the i-th vertex of face 0
104 */
105template <typename _SIZE_>
107{
108 // face_sommet0(0)=0;
109 // face_sommet0(1)=2;
110 assert(i>=0);
111 assert(i<2);
112 return 2*i;
113}
114
115
116/*! @brief Returns the index of the i-th vertex of face 1.
117 *
118 * @param (int i) the vertex index to return
119 * @return (int) the index of the i-th vertex of face 1
120 */
121template <typename _SIZE_>
123{
124 // face_sommet1(0)=0;
125 // face_sommet1(1)=1;
126 assert(i>=0);
127 assert(i<2);
128 return i;
129}
130
131
132/*! @brief Returns the index of the i-th vertex of face 2.
133 *
134 * @param (int i) the vertex index to return
135 * @return (int) the index of the i-th vertex of face 2
136 */
137template <typename _SIZE_>
139{
140 // face_sommet2(0)=1;
141 // face_sommet2(1)=3;
142 assert(i>=0);
143 assert(i<2);
144 return 2*i+1;
145}
146
147
148/*! @brief Returns the index of the i-th vertex of face 3.
149 *
150 * @param (int i) the vertex index to return
151 * @return (int) the index of the i-th vertex of face 3
152 */
153template <typename _SIZE_>
155{
156 // face_sommet3(0)=2;
157 // face_sommet3(1)=3;
158 assert(i>=0);
159 assert(i<2);
160 return i+2;
161}
162
163
164/*! @brief Returns the number of faces of the specified type that the geometric element has.
165 *
166 * @param (int i) the face type
167 * @return (int) the number of faces of type i
168 */
169template <typename _SIZE_>
171{
172 assert(i==0);
173 return 4;
174}
175
176
177/*! @brief Returns the number of vertices of faces of the specified type.
178 *
179 * @param (int i) the face type
180 * @return (int) the number of vertices of faces of type i
181 */
182template <typename _SIZE_>
184{
185 assert(i==0);
186 return 2;
187}
188
189
190/*! @brief Returns the i-th face type.
191 *
192 * A rectangle has only one face type.
193 *
194 * @param (int i) the rank of the face type to return
195 * @return (Type_Face) a face type
196 */
197template <typename _SIZE_>
198inline Type_Face Rectangle_32_64<_SIZE_>::type_face(int i) const
199{
200 assert(i==0);
201 return Type_Face::segment_2D;
202}
203
204using Rectangle = Rectangle_32_64<int>;
205using Rectangle_64 = Rectangle_32_64<trustIdType>;
206
207#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
Rectangle class — represents the rectangular geometric element.
Definition Rectangle.h:31
DoubleVect_T< _SIZE_ > DoubleVect_t
Definition Rectangle.h:39
int face_sommet0(int i) const
Returns the index of the i-th vertex of face 0.
Definition Rectangle.h:106
int face_sommet1(int i) const
Returns the index of the i-th vertex of face 1.
Definition Rectangle.h:122
int contient(const SmallArrOfTID_t &soms, int_t elem) const override
Returns 1 if the vertices specified by parameter "pos" are the vertices of element "element" of the d...
int face_sommet2(int i) const
Returns the index of the i-th vertex of face 2.
Definition Rectangle.h:138
void calculer_normales(const IntTab_t &faces_sommets, DoubleTab_t &face_normales) const override
Computes the normals to the faces of the elements of the associated domain.
int face_sommet3(int i) const
Returns the index of the i-th vertex of face 3.
Definition Rectangle.h:154
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 Rectangle.h:81
const Nom & nom_lml() const override
Returns the LML name of a rectangle = "VOXEL8".
int nb_som_face(int=0) const override
Returns the number of vertices of faces of the specified type.
Definition Rectangle.h:183
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes of the elements of the associated domain.
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
voir ElemGeomBase::get_tab_faces_sommets_locaux
int reordonner_elem()
Reorders and verifies that the elements are indeed rectangles.
Definition Rectangle.cpp:59
int contient(const ArrOfDouble &pos, int_t elem) const override
Returns 1 if element ielem of the domain associated with the geometric element contains the point.
int nb_faces(int=0) const override
Returns the number of faces of the specified type that the geometric element has.
Definition Rectangle.h:170
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
Definition Rectangle.h:38
int nb_som() const override
Nb of vertices for the element.
Definition Rectangle.h:50
Domaine_32_64< _SIZE_ > Domaine_t
Definition Rectangle.h:41
DoubleTab_T< _SIZE_ > DoubleTab_t
Definition Rectangle.h:40
void reordonner() override
Reorders the vertices of the rectangle.
Definition Rectangle.cpp:45
bool est_structure() const override
Definition Rectangle.h:53
IntTab_T< _SIZE_ > IntTab_t
Definition Rectangle.h:37
Type_Face type_face(int=0) const override
Returns the i-th face type.
Definition Rectangle.h:198