TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Frontiere.cpp
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#include <MD_Vector_tools.h>
17#include <Frontiere.h>
18#include <TRUSTTab.h>
19
20Implemente_base_32_64(Frontiere_32_64,"Frontiere",Objet_U);
21// XD bord_base objet_lecture bord_base INHERITS_BRACE Basic class for block sides. Block sides that are neither edges
22// XD_CONT nor connectors are not specified. The duplicate nodes of two blocks in contact are automatically recognized
23// XD_CONT and deleted.
24
25/*! @brief Reads the specifications of a boundary from an input stream.
26 *
27 * Reads:
28 * the name
29 * the faces
30 *
31 * @param (Entree& is) an input stream
32 * @return (Entree&) the modified input stream
33 */
34template <typename _SIZE_>
36{
37 is >> nom;
38 return is >> les_faces;
39}
40
41
42/*! @brief Writes the boundary to an output stream.
43 *
44 * Writes:
45 * the name of the boundary
46 * the faces
47 *
48 * @param (Sortie& os) an output stream
49 * @return (Sortie&) the modified output stream
50 */
51template <typename _SIZE_>
53{
54 os << nom << finl;
55 return os << les_faces;
56}
57
58/*! @brief Associates the boundary to the domain it belongs to.
59 *
60 * @param (Domaine& un_domaine) the domain to associate with the boundary
61 */
62template <typename _SIZE_>
64{
65 le_dom=un_domaine;
66 les_faces.associer_domaine(un_domaine);
67}
68
69/*! @brief Gives a name to the boundary.
70 *
71 * @param (Nom& name) the name to give to the boundary
72 */
73template <typename _SIZE_>
75{
76 nom=name;
77}
78
79/*! @brief Adds one or more faces to the boundary; the face(s) are specified by an array
80 *
81 * containing the vertex indices.
82 *
83 * @param (IntTab& sommets) array containing the vertex indices of the faces to add
84 */
85template <typename _SIZE_>
87{
88 les_faces.ajouter(sommets);
89}
90
91/*! @brief Sets the type of the boundary faces.
92 *
93 * @param (Motcle& typ) the geometric type of the faces
94 */
95template <typename _SIZE_>
97{
98 les_faces.typer(typ);
99}
100
101/*! @brief Sets the type of the boundary faces.
102 *
103 * @param (Type_Face& typ) the geometric type of the faces
104 */
105template <typename _SIZE_>
106void Frontiere_32_64<_SIZE_>::typer_faces(const Type_Face& typ)
107{
108 les_faces.typer(typ);
109}
110
111/*! @brief Returns the vertices of the boundary faces.
112 *
113 * @return (IntTab&) the array containing the vertex indices of the boundary faces
114 */
115template <typename _SIZE_>
117{
118 return les_faces.les_sommets();
119}
120/*! @brief Returns the vertices of the boundary faces (const version).
121 *
122 * @return (IntTab&) the array containing the vertex indices of the boundary faces
123 */
124template <typename _SIZE_>
126{
127 return les_faces.les_sommets();
128}
129
130/*! @brief Renumbers the nodes (vertices) of the faces.
131 *
132 * The node with index k becomes the node with index Les_Nums[k].
133 *
134 * @param (IntVect& Les_Nums) the renumbering vector: new_vertex[i] = Les_Nums[old_vertex[i]]
135 */
136template <typename _SIZE_>
138{
139 IntTab_t& les_sommets=faces().les_sommets();
140 int_t nb_som = les_sommets.dimension(0);
141 int nb_som_dim = les_sommets.dimension_int(1);
142 for(int_t i=0; i<nb_som; i++)
143 for(int j=0; j<nb_som_dim; j++)
144 les_sommets(i,j)=Les_Nums[les_sommets(i,j)];
145}
146
147/*! @brief Returns the domain associated with the boundary (const version).
148 *
149 * @return (Domaine&) the domain associated with the boundary
150 */
151template <typename _SIZE_>
153{
154 return le_dom.valeur();
155}
156
157/*! @brief Returns the domain associated with the boundary.
158 *
159 * @return (Domaine&) the domain associated with the boundary
160 */
161template <typename _SIZE_>
163{
164 return le_dom.valeur();
165}
166
167
168/*! @brief Adds the vertices (and faces) of the given boundary to this object (Frontiere_32_64).
169 *
170 * @param (Frontiere_32_64& front) the boundary to "add" to this object
171 */
172template <typename _SIZE_>
174{
175 const Faces_t& a_ajouter=front.faces();
176 int_t nbf1=les_faces.nb_faces();
177 int_t nbf2=a_ajouter.nb_faces();
178 //max to treat the case where my front is empty
179 int nbs=std::max(les_faces.nb_som_faces(), a_ajouter.nb_som_faces());
180 int_t face;
181 les_faces.les_sommets().resize(nbf1+nbf2, nbs);
182 for(face=0; face<nbf2; face++)
183 for(int som=0; som<nbs; som++)
184 les_faces.sommet(nbf1+face, som)=a_ajouter.sommet(face, som);
185
186 if(a_ajouter.voisins().nb_dim() == 1)
187 return;
188
189 int nb_voisins = a_ajouter.voisins().dimension_int(1);
190 les_faces.voisins().resize(nbf1+nbf2, nb_voisins);
191 for(face=0; face<nbf2; face++)
192 for(int voisin=0; voisin<nb_voisins; voisin++)
193 les_faces.voisin(nbf1+face, voisin)=a_ajouter.voisin(face, voisin);
194}
195
196/*! @brief Creates an array with one "row" per face of this boundary.
197 *
198 * See MD_Vector_tools::creer_tableau_distribue()
199 */
200template <typename _SIZE_>
202{
203 const MD_Vector& md = les_faces.les_sommets().get_md_vector();
205}
206
207/*! @brief Returns the trace on the boundary of the element-based array y.
208 *
209 */
210template <>
211void Frontiere_32_64<int>::trace_elem_local(const DoubleTab& y, DoubleTab& x) const
212{
213 const int size = nb_faces();
214 int nb_compo_ = y.line_size();
215
216 // Resize x if not already done
217 if (x.size_array() == 0 && size != 0)
218 x.resize(size, nb_compo_);
219 else if (x.dimension(0) != size || nb_compo_ != x.line_size())
220 {
221 Cerr << "Call to Frontiere_32_64<int>::trace_elem with a DoubleTab x not located on boundary faces or don't have the same number of components" << finl;
223 }
224 for (int i = 0; i < size; i++)
225 {
226 int elem = faces().voisin(i, 0);
227 if (elem == -1)
228 elem = faces().voisin(i, 1);
229
230 for(int j = 0; j < nb_compo_; j++)
231 x(i, j) = y(elem, j);
232 }
233}
234
235/*! @brief Returns the trace on the boundary of the node-based array y.
236 *
237 */
238template <>
239void Frontiere_32_64<int>::trace_som_local(const DoubleTab& y, DoubleTab& x) const
240{
241 const IntTab& som_face = les_sommets_des_faces();
242 const int size = nb_faces();
243 int nb_compo_ = y.line_size();
244 const int nsomfa = som_face.dimension_int(1);
245
246 // Resize x if not already done
247 if (x.size_array() == 0 && size != 0)
248 x.resize(size, nb_compo_);
249 else if (x.dimension(0) != size || nb_compo_ != x.line_size())
250 {
251 Cerr << "Call to Frontiere_32_64<int>::trace_elem with a DoubleTab x not located on boundary faces or don't have the same number of components" << finl;
253 }
254
255 for (int i = 0; i < size; i++)
256 for(int j=0; j<nb_compo_; j++)
257 {
258 double s = 0.;
259 for (int isom = 0; isom < nsomfa; isom++)
260 s += y(som_face(i, isom), j);
261
262 s /= nsomfa;
263 x(i, j) = s;
264 }
265}
266
267/*! @brief Returns the trace on the boundary of the face-based array y.
268 *
269 */
270template <>
271void Frontiere_32_64<int>::trace_face_local(const DoubleVect& y, DoubleVect& x) const
272{
273 Cerr << "Frontiere_32_64<int>::trace_face(const DoubleVect_t& y, DoubleVect_t& x) const" << finl;
274 Cerr << "not coded yet." << finl;
276}
277
278/*! @brief Returns the trace on the boundary of the face-based array y (DoubleTab version).
279 */
280template <>
281void Frontiere_32_64<int>::trace_face_local(const DoubleTab& y, DoubleTab& x) const
282{
283 int size = nb_faces();
284 int M = y.line_size(), N = x.line_size();
285 assert(x.dimension(0)==size);
286 for (int i = 0; i < size; i++)
287 {
288 int face = num_premiere_face() + i;
289 for (int n = 0; n < N; n++)
290 x.addr()[N * i + n] = y.addr()[M * face + n];
291 }
292}
293
294template <>
295void Frontiere_32_64<int>::trace_som_distant(const DoubleTab&, DoubleTab&) const
296{
297 Cerr<<que_suis_je()<<"::trace_som_distant not implemented "<<finl;
299}
300
301template <>
302void Frontiere_32_64<int>::trace_elem_distant(const DoubleTab&, DoubleTab&) const
303{
304 Cerr<<que_suis_je()<<"::trace_elem_distant not implemented "<<finl;
306}
307
308template <>
309void Frontiere_32_64<int>::trace_face_distant(const DoubleTab&, DoubleTab&) const
310{
311 Cerr<<que_suis_je()<<"::trace_face_distant not implemented "<<finl;
313}
314
315template <>
316void Frontiere_32_64<int>::trace_face_distant(const DoubleVect&, DoubleVect&) const
317{
318 Cerr<<que_suis_je()<<"::trace_face_distant not implemented "<<finl;
320}
321
322
323
324// 64 bit versions should never be called:
325
326template <typename _SIZE_>
327void Frontiere_32_64<_SIZE_>::trace_elem_local(const DoubleTab& y, DoubleTab& x) const
328{
329 assert(false);
330 throw;
331}
332
333template <typename _SIZE_>
334void Frontiere_32_64<_SIZE_>::trace_som_local(const DoubleTab& y, DoubleTab& x) const
335{
336 assert(false);
337 throw;
338}
339
340template <typename _SIZE_>
341void Frontiere_32_64<_SIZE_>::trace_face_local(const DoubleVect& y, DoubleVect& x) const
342{
343 assert(false);
344 throw;
345}
346
347template <typename _SIZE_>
348void Frontiere_32_64<_SIZE_>::trace_face_local(const DoubleTab& y, DoubleTab& x) const
349{
350 assert(false);
351 throw;
352}
353
354template <typename _SIZE_>
355void Frontiere_32_64<_SIZE_>::trace_som_distant(const DoubleTab&, DoubleTab&) const
356{
357 assert(false);
358 throw;
359}
360
361template <typename _SIZE_>
362void Frontiere_32_64<_SIZE_>::trace_elem_distant(const DoubleTab&, DoubleTab&) const
363{
364 assert(false);
365 throw;
366}
367
368template <typename _SIZE_>
369void Frontiere_32_64<_SIZE_>::trace_face_distant(const DoubleTab&, DoubleTab&) const
370{
371 assert(false);
372 throw;
373}
374
375template <typename _SIZE_>
376void Frontiere_32_64<_SIZE_>::trace_face_distant(const DoubleVect&, DoubleVect&) const
377{
378 assert(false);
379 throw;
380}
381
382
383
384template class Frontiere_32_64<int>;
385#if INT_is_64_ == 2
386template class Frontiere_32_64<trustIdType>;
387#endif
388
389
Empty class used as a base for all the arrays.
Definition Array_base.h:41
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
IntTab_t & voisins()
Returns the array of neighbors (of the faces).
Definition Faces.h:89
int_t nb_faces() const
Definition Faces.h:66
int_t voisin(int_t, int) const
Returns the number of the i-th neighbor of face.
Definition Faces.h:165
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th face.
Definition Faces.h:130
int nb_som_faces() const
Returns the number of vertices per face.
Definition Faces.h:149
Class Frontiere.
Definition Frontiere.h:32
virtual void trace_elem_distant(const DoubleTab &, DoubleTab &) const
virtual void trace_face_distant(const DoubleTab &, DoubleTab &) const
IntVect_T< _SIZE_ > IntVect_t
Definition Frontiere.h:38
void ajouter_faces(const IntTab_t &)
Adds one or more faces to the boundary; the face(s) are specified by an array.
Definition Frontiere.cpp:86
void nommer(const Nom &) override
Gives a name to the boundary.
Definition Frontiere.cpp:74
virtual void trace_face_local(const DoubleTab &, DoubleTab &) const
Domaine_32_64< _SIZE_ > Domaine_t
Definition Frontiere.h:42
const Domaine_t & domaine() const
Returns the domain associated with the boundary (const version).
int_t num_premiere_face() const
Definition Frontiere.h:67
virtual void trace_elem_local(const DoubleTab &, DoubleTab &) const
void typer_faces(const Motcle &)
Sets the type of the boundary faces.
Definition Frontiere.cpp:96
int_t nb_faces() const
Definition Frontiere.h:59
void associer_domaine(const Domaine_t &)
Associates the boundary to the domain it belongs to.
Definition Frontiere.cpp:63
IntTab_t & les_sommets_des_faces()
Returns the vertices of the boundary faces.
void renum(const IntVect_t &)
Renumbers the nodes (vertices) of the faces.
IntTab_T< _SIZE_ > IntTab_t
Definition Frontiere.h:39
virtual void creer_tableau_faces(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates an array with one "row" per face of this boundary.
Faces_32_64< _SIZE_ > Faces_t
Definition Frontiere.h:43
virtual void trace_som_distant(const DoubleTab &, DoubleTab &) const
const Faces_t & faces() const
Definition Frontiere.h:54
virtual void trace_som_local(const DoubleTab &y, DoubleTab &x) const
void add(const Frontiere_32_64 &)
Adds the vertices (and faces) of the given boundary to this object (Frontiere_32_64).
static void creer_tableau_distribue(const MD_Vector &, Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Transforms v into a parallel array having the structure md.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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 void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const
_TYPE_ * addr()
int dimension_int(int d) const
Definition TRUSTTab.tpp:152
int nb_dim() const
Definition TRUSTTab.h:199
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67