TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Remove_Invalid_Internal_Boundaries.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 <Remove_Invalid_Internal_Boundaries.h>
17#include <Connectivite_som_elem.h>
18#include <Static_Int_Lists.h>
19#include <Scatter.h>
20#include <Domaine.h>
21#include <Param.h>
22
23Implemente_instanciable(Remove_Invalid_Internal_Boundaries,"Remove_Invalid_Internal_Boundaries",Interprete_geometrique_base);
24// XD remove_invalid_internal_boundaries interprete remove_invalid_internal_boundaries INHERITS_BRACE Keyword to
25// XD_CONT suppress an internal boundary of the domain_name domain. Indeed, some mesh tools may define internal
26// XD_CONT boundaries (eg: for post processing task after the calculation) but TRUST does not support it yet.
27// XD attr domain_name ref_domaine domain_name REQ Name of domain.
28
30
32
34{
36
37 Domaine& domain = domaine(0);
38
40
41 Static_Int_Lists incidence;
42 construire_connectivite_som_elem(domain.nb_som_tot(), domain.les_elems(), incidence, 1);
43
44 LIST(Nom) name_of_useless_boundaries;
45 LIST(Nom) name_of_useless_connectors;
46 ArrOfInt nodes_of_frontier_face;
47 ArrOfInt cells_on_frontier_face;
48
49
50 for (auto &itr : domain.faces_bord())
51 {
52 const Faces& frontier_faces = itr.faces();
53 const int nb_frontier_faces = frontier_faces.nb_faces_tot();
54 const int nb_nodes_per_face = frontier_faces.nb_som_faces();
55
56 nodes_of_frontier_face.resize_array(nb_nodes_per_face);
57 cells_on_frontier_face.resize_array(0);
58
59 // Only work on the first face of the current Bord
60 for (int i=0; i<nb_nodes_per_face; ++i)
61 nodes_of_frontier_face[i] = frontier_faces.sommet(0,i);
62 find_adjacent_elements(incidence,nodes_of_frontier_face,cells_on_frontier_face);
63
64 bool remove_frontier = false;
65
66 if (cells_on_frontier_face.size_array() == 1)
67 remove_frontier = false;
68 else if (cells_on_frontier_face.size_array() == 2)
69 {
70 // The face is used in two elements. This is not valid and should be removed
71 remove_frontier = true;
72 Nom dummy;
73 Nom& new_useless_frontier_name = name_of_useless_boundaries.add(dummy);
74 new_useless_frontier_name = itr.le_nom();
75 }
76 else
77 {
78 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
79 Cerr << " Invalid incidence" << finl;
81 }
82
83 for (int f=0; f<nb_frontier_faces; ++f)
84 {
85 for (int i=0; i<nb_nodes_per_face; ++i)
86 nodes_of_frontier_face[i] = frontier_faces.sommet(0,i);
87 find_adjacent_elements(incidence,nodes_of_frontier_face,cells_on_frontier_face);
88
89 if (remove_frontier)
90 {
91 if (cells_on_frontier_face.size_array() != 2)
92 {
93 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
94 Cerr << " Invalid incidence" << finl;
96 }
97 }
98 else
99 {
100 if (cells_on_frontier_face.size_array() != 1)
101 {
102 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
103 Cerr << " Invalid incidence" << finl;
105 }
106 }
107 }
108 }
109
110 for (auto &itr : domain.faces_raccord())
111 {
112 const Faces& frontier_faces = itr->faces();
113 const int nb_frontier_faces = frontier_faces.nb_faces_tot();
114 const int nb_nodes_per_face = frontier_faces.nb_som_faces();
115
116 nodes_of_frontier_face.resize_array(nb_nodes_per_face);
117 cells_on_frontier_face.resize_array(0);
118
119 for (int i = 0; i < nb_nodes_per_face; ++i)
120 nodes_of_frontier_face[i] = frontier_faces.sommet(0, i);
121
122 find_adjacent_elements(incidence, nodes_of_frontier_face, cells_on_frontier_face);
123
124 bool remove_frontier = false;
125
126 if (cells_on_frontier_face.size_array() == 1)
127 remove_frontier = false;
128 else if (cells_on_frontier_face.size_array() == 2)
129 {
130 remove_frontier = true;
131 Nom dummy;
132 Nom& new_useless_frontier_name = name_of_useless_connectors.add(dummy);
133 new_useless_frontier_name = itr->le_nom();
134 }
135 else
136 {
137 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
138 Cerr << " Invalid incidence" << finl;
140 }
141
142 for (int f = 0; f < nb_frontier_faces; ++f)
143 {
144 for (int i = 0; i < nb_nodes_per_face; ++i)
145 nodes_of_frontier_face[i] = frontier_faces.sommet(0, i);
146 find_adjacent_elements(incidence, nodes_of_frontier_face, cells_on_frontier_face);
147
148 if (remove_frontier)
149 {
150 if (cells_on_frontier_face.size_array() != 2)
151 {
152 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
153 Cerr << " Invalid incidence" << finl;
155 }
156 }
157 else
158 {
159 if (cells_on_frontier_face.size_array() != 1)
160 {
161 Cerr << "Error in 'Remove_Invalid_Internal_Boundaries::interpreter_()' :" << finl;
162 Cerr << " Invalid incidence" << finl;
164 }
165 }
166 }
167 }
168
169 for (auto& itr : name_of_useless_boundaries)
170 {
171 Bords& boundaries = domain.faces_bord();
172 boundaries.suppr(domain.bord(itr));
173 }
174
175 for (auto& itr : name_of_useless_connectors)
176 {
177 Raccords& connectors = domain.faces_raccord();
178 connectors.suppr(domain.raccord(itr));
179 }
180
182
183 return is;
184}
Raccord_t & raccord(int i)
Definition Domaine.h:248
Bords_t & faces_bord()
Definition Domaine.h:198
Raccords_t & faces_raccord()
Definition Domaine.h:253
IntTab_t & les_elems()
Definition Domaine.h:129
Bord_t & bord(int i)
Definition Domaine.h:193
int_t nb_som_tot() const
Renvoie le nombre total de sommets du domaine i.e. le nombre de sommets reels et virtuels sur le proc...
Definition Domaine.h:123
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
int_t nb_faces_tot() const
Renvoie le nombre total de Faces i (reelles et virt) sur le proc courant.
Definition Faces.h:68
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
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const Nom & le_nom() const override
Renvoie *this;.
Definition Nom.cpp:563
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
Allows to remove internal boundary from a domain, ie boundary which faces are actually used in two el...
static void init_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Create parallel descriptors for the vertex and element arrays of the domain (necessary because Scatte...
Definition Scatter.cpp:2742
static void uninit_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
methode utilisee par les interpretes qui modifient le domaine (sequentiel), detruit les descripteurs ...
Definition Scatter.cpp:2757
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)