TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
RegroupeBord.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
16#include <RegroupeBord.h>
17#include <EFichier.h>
18
19Implemente_instanciable_32_64(RegroupeBord_32_64,"RegroupeBord",Interprete_geometrique_base_32_64<_T_>);
20// XD regroupebord interprete regroupebord INHERITS_BRACE Keyword to build one boundary new_bord with several boundaries
21// XD_CONT of the domain named domaine.
22// XD attr domaine ref_domaine domain REQ Name of domain
23// XD attr new_bord chaine new_bord REQ Name of the new boundary
24// XD attr bords bloc_lecture bords REQ { Bound1 Bound2 }
25
26// XD regroupebord_64 regroupebord regroupebord_64 INHERITS_BRACE Keyword to build one boundary new_bord with several
27// XD_CONT boundaries of the big (64b) domain named domaine.
28template <typename _SIZE_>
30{
31 return Interprete::printOn(os);
32}
33
34template <typename _SIZE_>
36{
37 return Interprete::readOn(is);
38}
39
40template <typename _SIZE_>
42{
43 Nom nom;
44 LIST(Nom) nlistbord;
45 this->associer_domaine(is);
46 is >> nom;
47
48 //is>>nlistbord;
49 // recodage pour ne pas mettre les virgules
50 {
51 Nom mot;
52 is >>mot;
53 if (mot!="{")
54 {
55 Cerr<< "we expected { and not "<<mot<<finl;
56 this->exit();
57 }
58 is >>mot;
59 while (mot!="}")
60 {
61 nlistbord.add(mot);
62 is>>mot;
63 }
64 }
65
66 Domaine_t& dom = this->domaine();
67 // test pour savoir si la frontiere a regrouper est valide
68 // i.e : si frontiere est une frontiere du domaine : on applique regroupe_bord()
69 LIST(Nom) nlistbord_dom; // liste stockant tous les noms de frontiere du domaine
70 int nbfr=dom.nb_front_Cl();
71 for (int b=0; b<nbfr; b++)
72 {
73 Frontiere_t& org=dom.frontiere(b);
74 nlistbord_dom.add(org.le_nom());
75 }
76 for (int i=0; i<nlistbord.size(); i++)
77 {
78 if (!nlistbord_dom.contient(nlistbord[i]))
79 {
80 Cerr << "Problem in the RegroupeBord instruction " << finl;
81 Cerr << "The boundary named " << nlistbord[i] << " is not a boundary of the domain " << dom.le_nom() << finl;
82 this->exit();
83
84 }
85 }
86
87 regroupe_bord(dom,nom,nlistbord);
88 return is;
89}
90
91template <typename _SIZE_>
93{
94 int nbfr=dom.nb_front_Cl();
95 for (int b=0; b<nbfr; b++)
96 {
97
98 Frontiere_t& org=dom.frontiere(b);
99 const Nom& nom_bord=org.le_nom();
100
101 LIST(Nom) listn;
102 listn.add(nom_bord);
103 regroupe_bord(dom,nom_bord,listn);
104 // si on a detruit des bords on revient sur b
105 if (nbfr!=dom.nb_front_Cl())
106 {
107 Cerr<<"Boundary "<<nom_bord<<" has been collected"<<finl;
108 nbfr=dom.nb_front_Cl();
109 b--;
110 }
111 }
112}
113
114template <typename _SIZE_>
116{
117 int nbfr=dom.nb_front_Cl();
118 int_t nbfacestot=0;
119 int prem_b=-1;
120
121 for (int b=0; b<nbfr; b++)
122 {
123 Frontiere_t& org=dom.frontiere(b);
124
125 if (nlistbord.contient(org.le_nom()))
126 {
127 if (prem_b==-1) prem_b=b;
128 //Frontiere& org=domaine.frontiere(b);
129 nbfacestot+=org.nb_faces();
130 }
131 }
132 Frontiere_t& newb=dom.frontiere(prem_b);
133
134
135 Faces_t& newfaces=newb.faces();
136 //newfaces.typer(domaine.frontiere(0).faces().type_face());
137 int nbsom=newfaces.nb_som_faces();
138 int_t nbfacestot0=newfaces.nb_faces();
139 newfaces.dimensionner(nbfacestot);
140 IntTab_t& newsommet=newfaces.les_sommets();
141 nbfacestot = nbfacestot0;
142 for (int b=0; b<nbfr; b++)
143 {
144 if (b!=prem_b)
145 {
146 Frontiere_t& org=dom.frontiere(b);
147 Nom nombord=org.le_nom();
148
149 if (nlistbord.contient(nombord))
150 {
151 const IntTab_t& sommets=org.faces().les_sommets();
152 int_t nbface=org.nb_faces();
153 for (int_t fa=0; fa<nbface; fa++)
154 for (int s=0; s<nbsom; s++)
155 newsommet(fa+nbfacestot,s)=sommets(fa,s);
156 nbfacestot+=org.nb_faces();
157 }
158 }
159 }
160 dom.frontiere(prem_b).nommer("bord_a_conserver_coute_que_coute");
161 Nom bordcons =dom.frontiere(prem_b).le_nom();
162
163 for (int b=0; b<nbfr; b++)
164 {
165 // la recup des bords et des raccords est dans la boucle
166 // pour pouvoir supprimer ...
167 Bords_t& listbord=dom.faces_bord();
168 Raccords_t& listrac=dom.faces_raccord();
169 //const Nom& nombord=nlistbord[b];
170 Frontiere_t& org=dom.frontiere(b);
171 const Nom& nombord=org.le_nom();
172
173 if (nlistbord.contient(nombord))
174 if (nombord!=bordcons)
175 {
176
177 int num_b=dom.rang_frontiere(nombord);
178 if (num_b<listbord.size())
179 listbord.suppr(dom.bord(nombord));
180 else
181 listrac.suppr(dom.raccord(nombord));
182
183 // on supprime un bord
184 nbfr--;
185 b--; // on veut verifie que le suivant n'est pas dans la liste
186
187 }
188
189 }
190 newb.nommer(nom);
192}
193
194template class RegroupeBord_32_64<int>;
195#if INT_is_64_ == 2
197#endif
int nb_front_Cl() const
Definition Domaine.h:236
Raccord_t & raccord(int i)
Definition Domaine.h:248
int rang_frontiere(const Nom &) const
Definition Domaine.cpp:1052
Bords_t & faces_bord()
Definition Domaine.h:198
const Frontiere_t & frontiere(int i) const
Definition Domaine.h:539
Raccords_t & faces_raccord()
Definition Domaine.h:253
void fixer_premieres_faces_frontiere()
Definition Domaine.cpp:1102
Bord_t & bord(int i)
Definition Domaine.h:193
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
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
int_t dimensionner(int_t)
(Re-)dimensionne les faces On redimensionne les voisins en consequence.
Definition Faces.cpp:344
const IntTab_t & les_sommets() const
Renvoie le tableau des sommets de toutes les faces.
Definition Faces.h:74
int nb_som_faces() const
Renvoie le nombre de sommet par face.
Definition Faces.h:149
void nommer(const Nom &) override
Donne un nom a la frontiere.
Definition Frontiere.cpp:74
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Renvoie le nombre de faces de la frontiere.
Definition Frontiere.h:59
const Faces_t & faces() const
Definition Frontiere.h:54
void add(const Frontiere_32_64 &)
Ajoute les sommets (et faces) de la frontiere passee en parametre a l'objet (Frontiere_32_64).
classe Interprete_geometrique_base .
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
bool contient(const Nom &nom) const
Definition Nom.h:86
friend class Entree
Definition Objet_U.h:76
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
class RegroupeBord Regroupe_bord dom titi { bord1 , bord2 }
Frontiere_32_64< _SIZE_ > Frontiere_t
void rassemble_bords(Domaine_t &dom)
Domaine_32_64< _SIZE_ > Domaine_t
Raccords_32_64< _SIZE_ > Raccords_t
Bords_32_64< _SIZE_ > Bords_t
IntTab_T< _SIZE_ > IntTab_t
Faces_32_64< _SIZE_ > Faces_t
void regroupe_bord(Domaine_t &dom, Nom nom, const LIST(Nom)&nlistbord)
Entree & interpreter_(Entree &) override
Classe de base des flux de sortie.
Definition Sortie.h:52