TrioCFD 1.9.8
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 Lit les specification d'une frontiere a partir d'un flot d'entree.
26 *
27 * On lit:
28 * le nom
29 * les faces
30 *
31 * @param (Entree& is) un flot d'entree
32 * @return (Entree&) le flot d'entree modifie
33 */
34template <typename _SIZE_>
36{
37 is >> nom;
38 return is >> les_faces;
39}
40
41
42/*! @brief Ecrit la frontiere sur un flot de sortie.
43 *
44 * On ecrit:
45 * le nom de la frontiere
46 * les faces
47 *
48 * @param (Sortie& os) un flot de sortie
49 * @return (Sortie&) le flot de sortie modifie
50 */
51template <typename _SIZE_>
53{
54 os << nom << finl;
55 return os << les_faces;
56}
57
58/*! @brief Associe la frontiere au domaine dont elle depend.
59 *
60 * @param (Domaine& un_domaine) le domaine a associer a la frontiere
61 */
62template <typename _SIZE_>
64{
65 le_dom=un_domaine;
66 les_faces.associer_domaine(un_domaine);
67}
68
69/*! @brief Donne un nom a la frontiere
70 *
71 * @param (Nom& name) le nom a donner a la frontiere
72 */
73template <typename _SIZE_>
75{
76 nom=name;
77}
78
79/*! @brief Ajoute une (ou plusieurs) face(s) a la frontiere, la (les) face(s) est (sont) specifiee(s) par un tableau
80 *
81 * contenant les numeros des sommets.
82 *
83 * @param (IntTab& sommets) tableau contenant les numeros des sommets des face a ajouter
84 */
85template <typename _SIZE_>
87{
88 les_faces.ajouter(sommets);
89}
90
91/*! @brief Type les faces de la frontiere.
92 *
93 * @param (Motcle& typ) le type (geometrique) des faces
94 */
95template <typename _SIZE_>
97{
98 les_faces.typer(typ);
99}
100
101/*! @brief Type les faces de la frontiere
102 *
103 * @param (Type_Face& typ) le type (geometrique) des 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 Renvoie les sommets des faces de la frontiere
112 *
113 * @return (IntTab&) le tableau contenant les numeros des sommets des faces de la frontiere
114 */
115template <typename _SIZE_>
117{
118 return les_faces.les_sommets();
119}
120/*! @brief Renvoie les sommets des faces de la frontiere
121 *
122 * @return (IntTab&) le tableau contenant les numeros des sommets des faces de la frontiere
123 */
124template <typename _SIZE_>
126{
127 return les_faces.les_sommets();
128}
129
130/*! @brief Renumerote les noeuds (sommets) des faces.
131 *
132 * Le noeud de numero k devient le noeud de numero Les_Nums[k]
133 *
134 * @param (IntVect& Les_Nums) le vecteur de renumerotation le_nouveau_sommet[i] = Les_Nums[ancien_sommet[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 Renvoie le domaine associe a la frontiere.
148 *
149 * (version const)
150 *
151 * @return (Domaine&) le domaine associe a la frontiere
152 */
153template <typename _SIZE_>
155{
156 return le_dom.valeur();
157}
158
159/*! @brief Renvoie le domaine associe a la frontiere.
160 *
161 * @return (Domaine&) le domaine associe a la frontiere
162 */
163template <typename _SIZE_>
165{
166 return le_dom.valeur();
167}
168
169
170/*! @brief Ajoute les sommets (et faces) de la frontiere passee en parametre a l'objet (Frontiere_32_64).
171 *
172 * @param (Frontiere_32_64& front) la frontiere a "ajouter" a l'objet
173 */
174template <typename _SIZE_>
176{
177 const Faces_t& a_ajouter=front.faces();
178 int_t nbf1=les_faces.nb_faces();
179 int_t nbf2=a_ajouter.nb_faces();
180 //max to treat the case where my front is empty
181 int nbs=std::max(les_faces.nb_som_faces(), a_ajouter.nb_som_faces());
182 int_t face;
183 les_faces.les_sommets().resize(nbf1+nbf2, nbs);
184 for(face=0; face<nbf2; face++)
185 for(int som=0; som<nbs; som++)
186 les_faces.sommet(nbf1+face, som)=a_ajouter.sommet(face, som);
187
188 if(a_ajouter.voisins().nb_dim() == 1)
189 return;
190
191 int nb_voisins = a_ajouter.voisins().dimension_int(1);
192 les_faces.voisins().resize(nbf1+nbf2, nb_voisins);
193 for(face=0; face<nbf2; face++)
194 for(int voisin=0; voisin<nb_voisins; voisin++)
195 les_faces.voisin(nbf1+face, voisin)=a_ajouter.voisin(face, voisin);
196}
197
198/*! @brief Cree un tableau ayant une "ligne" par face de cette frontiere Voir MD_Vector_tools::creer_tableau_distribue()
199 *
200 */
201template <typename _SIZE_>
203{
204 const MD_Vector& md = les_faces.les_sommets().get_md_vector();
206}
207
208/*! @brief Renvoie la trace sur la frontiere du tableau aux elements y
209 *
210 */
211template <>
212void Frontiere_32_64<int>::trace_elem_local(const DoubleTab& y, DoubleTab& x) const
213{
214 const int size = nb_faces();
215 int nb_compo_ = y.line_size();
216
217 // On dimensionne x si ce n'est pas fait
218 if (x.size_array() == 0 && size != 0)
219 x.resize(size, nb_compo_);
220 else if (x.dimension(0) != size || nb_compo_ != x.line_size())
221 {
222 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;
224 }
225 for (int i = 0; i < size; i++)
226 {
227 int elem = faces().voisin(i, 0);
228 if (elem == -1)
229 elem = faces().voisin(i, 1);
230
231 for(int j = 0; j < nb_compo_; j++)
232 x(i, j) = y(elem, j);
233 }
234}
235
236/*! @brief Renvoie la trace sur la frontiere du tableau aux noeuds y
237 *
238 */
239template <>
240void Frontiere_32_64<int>::trace_som_local(const DoubleTab& y, DoubleTab& x) const
241{
242 const IntTab& som_face = les_sommets_des_faces();
243 const int size = nb_faces();
244 int nb_compo_ = y.line_size();
245 const int nsomfa = som_face.dimension_int(1);
246
247 // On dimensionne x si ce n'est pas fait
248 if (x.size_array() == 0 && size != 0)
249 x.resize(size, nb_compo_);
250 else if (x.dimension(0) != size || nb_compo_ != x.line_size())
251 {
252 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;
254 }
255
256 for (int i = 0; i < size; i++)
257 for(int j=0; j<nb_compo_; j++)
258 {
259 double s = 0.;
260 for (int isom = 0; isom < nsomfa; isom++)
261 s += y(som_face(i, isom), j);
262
263 s /= nsomfa;
264 x(i, j) = s;
265 }
266}
267
268/*! @brief Renvoie la trace sur la frontiere du tableau aux faces y
269 *
270 */
271template <>
272void Frontiere_32_64<int>::trace_face_local(const DoubleVect& y, DoubleVect& x) const
273{
274 Cerr << "Frontiere_32_64<int>::trace_face(const DoubleVect_t& y, DoubleVect_t& x) const" << finl;
275 Cerr << "not coded yet." << finl;
277}
278
279/*! @brief Renvoie la trace sur la frontiere du tableau aux faces y
280 */
281template <>
282void Frontiere_32_64<int>::trace_face_local(const DoubleTab& y, DoubleTab& x) const
283{
284 int size = nb_faces();
285 int M = y.line_size(), N = x.line_size();
286 assert(x.dimension(0)==size);
287 for (int i = 0; i < size; i++)
288 {
289 int face = num_premiere_face() + i;
290 for (int n = 0; n < N; n++)
291 x.addr()[N * i + n] = y.addr()[M * face + n];
292 }
293}
294
295template <>
296void Frontiere_32_64<int>::trace_som_distant(const DoubleTab&, DoubleTab&) const
297{
298 Cerr<<que_suis_je()<<"::trace_som_distant not implemented "<<finl;
300}
301
302template <>
303void Frontiere_32_64<int>::trace_elem_distant(const DoubleTab&, DoubleTab&) const
304{
305 Cerr<<que_suis_je()<<"::trace_elem_distant not implemented "<<finl;
307}
308
309template <>
310void Frontiere_32_64<int>::trace_face_distant(const DoubleTab&, DoubleTab&) const
311{
312 Cerr<<que_suis_je()<<"::trace_face_distant not implemented "<<finl;
314}
315
316template <>
317void Frontiere_32_64<int>::trace_face_distant(const DoubleVect&, DoubleVect&) const
318{
319 Cerr<<que_suis_je()<<"::trace_face_distant not implemented "<<finl;
321}
322
323
324
325// 64 bit versions should never be called:
326
327template <typename _SIZE_>
328void Frontiere_32_64<_SIZE_>::trace_elem_local(const DoubleTab& y, DoubleTab& x) const
329{
330 assert(false);
331 throw;
332}
333
334template <typename _SIZE_>
335void Frontiere_32_64<_SIZE_>::trace_som_local(const DoubleTab& y, DoubleTab& x) const
336{
337 assert(false);
338 throw;
339}
340
341template <typename _SIZE_>
342void Frontiere_32_64<_SIZE_>::trace_face_local(const DoubleVect& y, DoubleVect& x) const
343{
344 assert(false);
345 throw;
346}
347
348template <typename _SIZE_>
349void Frontiere_32_64<_SIZE_>::trace_face_local(const DoubleTab& y, DoubleTab& x) const
350{
351 assert(false);
352 throw;
353}
354
355template <typename _SIZE_>
356void Frontiere_32_64<_SIZE_>::trace_som_distant(const DoubleTab&, DoubleTab&) const
357{
358 assert(false);
359 throw;
360}
361
362template <typename _SIZE_>
363void Frontiere_32_64<_SIZE_>::trace_elem_distant(const DoubleTab&, DoubleTab&) const
364{
365 assert(false);
366 throw;
367}
368
369template <typename _SIZE_>
370void Frontiere_32_64<_SIZE_>::trace_face_distant(const DoubleTab&, DoubleTab&) const
371{
372 assert(false);
373 throw;
374}
375
376template <typename _SIZE_>
377void Frontiere_32_64<_SIZE_>::trace_face_distant(const DoubleVect&, DoubleVect&) const
378{
379 assert(false);
380 throw;
381}
382
383
384
385template class Frontiere_32_64<int>;
386#if INT_is_64_ == 2
387template class Frontiere_32_64<trustIdType>;
388#endif
389
390
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()
Renvoie le tableau des voisins (des faces).
Definition Faces.h:89
int_t nb_faces() const
Definition Faces.h:66
int_t voisin(int_t, int) const
Renvoie le numero du i-ieme voisin de face.
Definition Faces.h:165
int_t sommet(int_t, int) const
Renvoie le numero du j-ieme sommet de la i-ieme face.
Definition Faces.h:130
int nb_som_faces() const
Renvoie le nombre de sommet par face.
Definition Faces.h:149
Classe 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 &)
Ajoute une (ou plusieurs) face(s) a la frontiere, la (les) face(s) est (sont) specifiee(s) par un tab...
Definition Frontiere.cpp:86
void nommer(const Nom &) override
Donne un nom a la frontiere.
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
Renvoie le domaine associe a la frontiere.
int_t num_premiere_face() const
Definition Frontiere.h:67
virtual void trace_elem_local(const DoubleTab &, DoubleTab &) const
void typer_faces(const Motcle &)
Type les faces de la frontiere.
Definition Frontiere.cpp:96
int_t nb_faces() const
Definition Frontiere.h:59
void associer_domaine(const Domaine_t &)
Associe la frontiere au domaine dont elle depend.
Definition Frontiere.cpp:63
IntTab_t & les_sommets_des_faces()
Renvoie les sommets des faces de la frontiere.
void renum(const IntVect_t &)
Renumerote les noeuds (sommets) des 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
Cree un tableau ayant une "ligne" par face de cette frontiere Voir MD_Vector_tools::creer_tableau_dis...
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 &)
Ajoute les sommets (et faces) de la frontiere passee en parametre a l'objet (Frontiere_32_64).
static void creer_tableau_distribue(const MD_Vector &, Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
transforme v en un tableau parallele ayant la structure md.
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
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