TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_bord.cpp
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#include <Domaine_bord.h>
16#include <Hexaedre.h>
17
18Implemente_instanciable_32_64(Domaine_bord_32_64,"Domaine_bord",Domaine_32_64<_T_>);
19
20/*! @brief for now exit()
21 *
22 */
23template <typename _SIZE_>
25{
26 this->exit();
27 return is;
28}
29
30/*! @brief for now exit()
31 *
32 */
33template <typename _SIZE_>
35{
36 this->exit();
37 return os;
38}
39
40/*! @brief builds the domain by calling extraire_domaine_bord()
41 *
42 */
43template <typename _SIZE_>
45{
46 domaine_source_ = source;
47 bord_source_ = nom_bord;
48 extraire_domaine_bord(source, nom_bord, *this, renum_som_);
49}
50
51/*! @brief returns a reference to the source domain
52 *
53 */
54template <typename _SIZE_>
56{
57 return domaine_source_;
58}
59
60/*! @brief returns the name of the source boundary
61 *
62 */
63template <typename _SIZE_>
68
69/*! @brief returns renum_som (for each vertex of domaine_bord, index of the same vertex in the domain)
70 *
71 */
72template <typename _SIZE_>
73const ArrOfInt_T<_SIZE_>& Domaine_bord_32_64<_SIZE_>::get_renum_som() const
74{
75 return renum_som_;
76}
77
78/*! @brief method to convert a face type to an element type (to be moved to the Faces class ?)
79 *
80 */
81template <typename _SIZE_>
82void type_face_to_type_elem(const Elem_geom_base_32_64<_SIZE_>& type_elem, const Type_Face& type_face, Motcle& type_elem_face)
83{
84 switch(type_face)
85 {
86 case Type_Face::vide_0D:
87 type_elem_face = "??";
88 break;
89 case Type_Face::point_1D:
90 type_elem_face = "??";
91 break;
92 case Type_Face::segment_2D:
93 type_elem_face = "segment";
94 break;
95 case Type_Face::segment_2D_axi:
96 type_elem_face = "segment";
97 break;
98 case Type_Face::triangle_3D:
99 type_elem_face = "triangle";
100 break;
101 case Type_Face::quadrilatere_2D_axi:
102 type_elem_face = "quadrangle_VEF";
103 break;
104 case Type_Face::quadrangle_3D:
105 type_elem_face = (sub_type(Hexaedre,type_elem)?"rectangle":"quadrangle_VEF");
106 break;
107 case Type_Face::quadrangle_3D_axi:
108 type_elem_face = "quadrangle_VEF";
109 break;
110 default:
111 type_elem_face = "??";
112 }
113}
114
115/*! @brief fills the domain "dest" with the vertices and faces of the boundary "nom_bord" of the domain "src".
116 *
117 * The vertices of the dest domain are only the vertices that are on a boundary face.
118 * The renum_som array is sized to dest.nb_som() and filled as follows:
119 * renum_som[i] is the index in the domain "src" of vertex i of the domain "dest".
120 *
121 */
122template <typename _SIZE_>
124 const Nom& nom_bord,
125 Domaine_t& dest,
126 ArrOfInt_t& renum_som)
127{
129 {
130 Cerr << "extraire_domaine_bord in parallel: the domain created will not have a distributed structure\n"
131 << " (this will be done one day... ask to B.Mathieu)" << finl;
132 }
133
134 // The destination domain must be empty:
135 assert(dest.nb_elem() == 0);
136 // Domain initialization:
137 // Choose a name for the domain
138 dest.nommer(src.le_nom() + Nom("_") + nom_bord);
139 // Element type of the dest domain:
140 Motcle type_elem;
141 type_face_to_type_elem(src.type_elem().valeur(), src.type_elem()->type_face(), type_elem);
142 const std::string suff = !std::is_same<_SIZE_, int>::value ? "_64" : "";
143 Nom type_elem_64 = type_elem + suff;
144 dest.type_elem().typer(type_elem_64);
145 dest.type_elem()->associer_domaine(dest);
146
147 const Frontiere_t& front = src.frontiere(nom_bord);
148 const int_t nb_faces = front.faces().nb_faces();
149 const int nb_som_face = front.faces().nb_som_faces();
150 const IntTab_t& faces_src = front.faces().les_sommets();
151 IntTab_t& elem_dest = dest.les_elems();
152 elem_dest.resize(nb_faces, nb_som_face);
153 renum_som.reset();
154
155 // renum_inverse: for each vertex of the source domain, its index in the destination domain:
156 ArrOfInt_t renum_inverse(src.nb_som());
157 renum_inverse= -1;
158 int_t nb_som_dest = 0;
159 for (int_t i = 0; i < nb_faces; i++)
160 {
161 for (int j = 0; j < nb_som_face; j++)
162 {
163 const int_t som = faces_src(i, j);
164 // If the vertex has not yet been encountered, assign it an index in the dest domain:
165 if (renum_inverse[som] < 0)
166 {
167 renum_som.append_array(som);
168 renum_inverse[som] = nb_som_dest++;
169 }
170 elem_dest(i, j) = renum_inverse[som];
171 }
172 }
173 // Copy of vertices used in the destination domain
174 DoubleTab_t& som_dest = dest.les_sommets();
175 const DoubleTab_t& som_src = src.les_sommets();
176 const int dim = static_cast<int>(som_src.dimension(1));
177 som_dest.resize(nb_som_dest, dim);
178 for (int_t i = 0; i < nb_som_dest; i++)
179 {
180 const int_t som = renum_som[i];
181 for (int j = 0; j < dim; j++)
182 som_dest(i, j) = som_src(som, j);
183 }
184
185 // TODO if needed: initialize the vertex joint to have the common items,
186 // and others if necessary.
187}
188
189template class Domaine_bord_32_64<int>;
190#if INT_is_64_ == 2
192#endif
193
class Domaine_32_64 A Domain is a mesh composed of a set of geometric elements of the same type.
Definition Domaine.h:62
DoubleTab_t & les_sommets()
Definition Domaine.h:113
const Frontiere_t & frontiere(int i) const
Definition Domaine.h:539
IntTab_t & les_elems()
Definition Domaine.h:129
int_t nb_elem() const
Definition Domaine.h:131
void typer(const Nom &)
Sets the element type of the domain using the name passed as parameter.
Definition Domaine.h:457
int_t nb_som() const
Returns the number of vertices of the domain.
Definition Domaine.h:121
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
This class is a domain whose vertices and elements are extracted from a boundary of a source domain.
virtual void construire_domaine_bord(const Domaine_t &source, const Nom &nom_bord)
builds the domain by calling extraire_domaine_bord()
virtual const Domaine_t & get_domaine_source() const
returns a reference to the source domain
Frontiere_32_64< _SIZE_ > Frontiere_t
ArrOfInt_t renum_som_
virtual const Nom & get_nom_bord_source() const
returns the name of the source boundary
static void extraire_domaine_bord(const Domaine_t &src, const Nom &nom_bord, Domaine_t &dest, ArrOfInt_t &renum_som)
fills the domain "dest" with the vertices and faces of the boundary "nom_bord" of the domain "src".
virtual const ArrOfInt_t & get_renum_som() const
returns renum_som (for each vertex of domaine_bord, index of the same vertex in the domain)
DoubleTab_T< _SIZE_ > DoubleTab_t
Domaine_32_64< _SIZE_ > Domaine_t
IntTab_T< _SIZE_ > IntTab_t
ArrOfInt_T< _SIZE_ > ArrOfInt_t
Class Elem_geom_base This class is the base class for the definition of elements.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
int_t nb_faces() const
Definition Faces.h:66
const IntTab_t & les_sommets() const
Returns the array of vertices of all faces.
Definition Faces.h:74
int nb_som_faces() const
Returns the number of vertices per face.
Definition Faces.h:149
const Faces_t & faces() const
Definition Frontiere.h:54
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static bool is_parallel()
Definition Process.cpp:108
Base class for output streams.
Definition Sortie.h:52
virtual void reset()
Definition TRUSTArray.h:240
void append_array(_TYPE_ valeur)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133