TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_dis_base.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 <Build_Map_to_Structured.h>
17#include <Discretisation_base.h>
18#include <Frontiere_dis_base.h>
19#include <Domaine_dis_base.h>
20#include <Probleme_base.h>
21#include <Sous_Domaine.h>
22#include <Domaine.h>
23
24Implemente_base(Domaine_dis_base,"Domaine_dis_base",Objet_U);
25
27{
28 return os ;
29}
30
32{
33 return is ;
34}
35
40
42{
43 return les_sous_domaines_dis_[i].valeur();
44}
45
50
51/*! @brief Associates a Domain with the object.
52 *
53 * @param (Domaine& un_domaine) the domain to associate with the discretized domain
54 */
55void Domaine_dis_base::associer_domaine(const Domaine& un_domaine)
56{
57 le_dom_=un_domaine;
58}
59
60/*! @brief Returns the boundary of Name nom.
61 *
62 * (We index the boundaries with their name)
63 *
64 * @param (Nom& nom) the name of the boundary to index
65 * @return (Frontiere_dis_base&) the indexed discretized boundary
66 * @throws boundary with unknown name thrown by rang_frontiere(Nom&)
67 */
69{
70 return frontiere_dis(rang_frontiere(nom));
71}
72
77
78/*! @brief Returns the rank of the boundary of Name nom Returns -1 if no boundary is named nom.
79 *
80 * @param (Nom& nom) the name of the boundary whose rank we seek
81 * @return (int) the rank of the boundary if it exists -1 otherwise
82 * @throws no boundary of Name nom found
83 */
85{
86 for(int i=0; i<nb_front_Cl(); i++)
87 if (frontiere_dis(i).le_nom()==nom)
88 return i;
89 Cerr << "We did not find the boundary name " << nom << " on the domain " << domaine().le_nom() << finl;
90 Cerr << "Check the given boundary name or the domain." << finl;
91 exit();
92 return -1;
93}
94
96{
97 for(int i=0; i<nb_front_Cl(); i++)
98 if (frontiere_dis(i).le_nom()==nom)
99 return i;
100 Cerr << "We did not find the boundary name " << nom << " on the domain " << domaine().le_nom() << finl;
101 Cerr << "Check the given boundary name or the domain." << finl;
102 exit();
103 return -1;
104}
105
106/*! @brief Writes the boundary names to an output stream.
107 *
108 * @param (Sortie& os) an output stream
109 */
114
116{
117 Cerr << "Domaine_dis_base::creer_elements_fictifs should be overloaded by "<< que_suis_je() <<finl;
118 assert(0);
119 exit();
120}
121
123{
124 Cerr << que_suis_je() << "does not implement the method face_sommets()"
125 << finl;
126 exit();
127 throw;
128}
129
131{
132 Cerr << que_suis_je() << "does not implement the method face_sommets()"
133 << finl;
134 exit();
135 throw;
136}
137
139{
140 Cerr << que_suis_je() << "does not implement the method face_aretes()"
141 << finl;
142 exit();
143 throw;
144}
145
146const IntTab& Domaine_dis_base::face_aretes() const
147{
148 Cerr << que_suis_je() << "does not implement the method face_aretes()"
149 << finl;
150 exit();
151 throw;
152}
153
155{
156 Cerr << que_suis_je() << "does not implement the method face_voisins()"
157 << finl;
158 exit();
159 throw;
160}
161
163{
164 Cerr << que_suis_je() << "does not implement the method face_voisins()"
165 << finl;
166 exit();
167 throw;
168}
169
170/**! Make sure the reordering option passed to the discretisation options is known to the Domaine_dis_base:
171 */
173{
174 reorder_ = disc.get_reorder();
175}
176
178{
179 // Should we handle faces
180 Nom ze_typ(typ);
181 ze_typ.suffix("NO_FACE_");
182 bool face_ok = (ze_typ == typ);
183
184 const Domaine& dom = le_dom_.valeur();
185
186 if (face_ok)
187 discretiser();
188 else
190
192 build_map_mc_Cmesh(face_ok); /* here to have the info on face_normals */
193
194 // Fills the sub-domains_dis, their types, and associates the corresponding domaine_dis and sous_domaine objects.
195 les_sous_domaines_dis_.dimensionner(dom.nb_ss_domaines());
196
197 for (int i=0; i<dom.nb_ss_domaines(); i++)
198 {
199 const Domaine& domaine_from_ss_domaine = dom.ss_domaine(i).domaine();
200 if (!domaine_from_ss_domaine.est_egal_a(dom))
201 {
202 Cerr << "In Domaine_dis_base::discretiser(), impossible to find a Domain corresponding to sous_domaine " << i << finl;
203 exit();
204 }
205 if (face_ok)
207 }
208}
209
211{
212 if (motlu == "VOLUME_MAILLE" && !volume_maille_)
213 {
214 pb.discretisation().volume_maille(pb.schema_temps(), pb.domaine_dis(), volume_maille_);
215 champs_compris_.ajoute_champ(volume_maille_);
216 }
217 else if (motlu == "MESH_NUMBERING" && !mesh_numbering_)
218 {
219 pb.discretisation().mesh_numbering(pb.schema_temps(), pb.domaine_dis(), mesh_numbering_);
220 champs_compris_.ajoute_champ(mesh_numbering_);
221 }
222}
223
225{
226 if (un_nom == "VOLUME_MAILLE")
227 return volume_maille();
228 else if (un_nom == "MESH_NUMBERING")
229 return mesh_numbering();
230
231 throw std::runtime_error(std::string("Field ") + un_nom.getString() + std::string(" not found !"));
232}
233
234bool Domaine_dis_base::has_champ(const Motcle& un_nom, OBS_PTR(Champ_base) &ref_champ) const
235{
236 if (un_nom == "VOLUME_MAILLE")
237 {
238 ref_champ = volume_maille();
239 return true;
240 }
241 else if (un_nom == "MESH_NUMBERING")
242 {
243 ref_champ = mesh_numbering();
244 return true;
245 }
246 return false;
247}
248
249bool Domaine_dis_base::has_champ(const Motcle& un_nom) const
250{
251 if (un_nom == "VOLUME_MAILLE" || un_nom == "MESH_NUMBERING")
252 return true;
253 else
254 return false;
255}
256
258{
259 Noms noms_compris = champs_compris_.liste_noms_compris();
260 noms_compris.add("VOLUME_MAILLE");
261 noms_compris.add("MESH_NUMBERING");
262 if (opt==DESCRIPTION)
263 Cerr<<que_suis_je()<<" : "<< noms_compris <<finl;
264 else
265 nom.add(noms_compris);
266}
267
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Discretisation_base This class represents a spatial discretization scheme, which
void mesh_numbering(const Schema_Temps_base &sch, const Domaine_dis_base &z, OWN_PTR(Champ_Fonc_base)&ch) const
void volume_maille(const Schema_Temps_base &sch, const Domaine_dis_base &z, OWN_PTR(Champ_Fonc_base)&ch) const
const Reorder_Mesh & get_reorder() const
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
int nb_ss_domaines() const
Definition Domaine.h:289
void ecrire_noms_bords(Sortie &) const
Writes the boundary names to an output stream.
Definition Domaine.cpp:1031
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Frontiere_dis_base & frontiere_dis(const Nom &) const
Returns the boundary of Name nom.
virtual void build_map_mc_Cmesh(const bool with_faces)
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
Champs_compris champs_compris_
virtual IntTab & face_voisins()
int nombre_de_sous_domaines_dis() const
int nb_front_Cl() const
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual void discretiser_no_face()=0
int rang_frontiere(const Nom &)
const Champ_Fonc_base & mesh_numbering() const
virtual IntTab & face_sommets()
void completer(const Discretisation_base &disc)
const Sous_domaine_dis_base & sous_domaine_dis(int i) const
void creer_champ(const Motcle &motlu) override
virtual void discretiser()
const Domaine & domaine() const
const Champ_base & get_champ(const Motcle &) const override
void associer_domaine(const Domaine &)
Associates a Domain with the object.
TRUST_Vector< OWN_PTR(Sous_domaine_dis_base)> les_sous_domaines_dis_
virtual IntTab & face_aretes()
void discretiser_root(const Nom &typ)
const Champ_Fonc_base & volume_maille() const
void ecrire_noms_bords(Sortie &) const
Writes the boundary names to an output stream.
virtual void typer_discretiser_ss_domaine(int i)=0
virtual void creer_elements_fictifs(const Domaine_Cl_dis_base &)
OBS_PTR(Domaine) le_dom_
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Frontiere_dis_base Class representing a discretized boundary.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Nom & suffix(const char *const)
Suffix extraction: Nom x("azerty");.
Definition Nom.cpp:266
const std::string & getString() const
Definition Nom.h:92
An array of character strings (VECT(Nom)).
Definition Noms.h:26
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
friend class Sortie
Definition Objet_U.h:70
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 int est_egal_a(const Objet_U &) const
Returns 1 if x and *this are the same instance (same memory address).
Definition Objet_U.cpp:299
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Probleme_base It is a Probleme_U that is not a coupling.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
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
Domaine_t & domaine()
This class is at the base of the discretized sub-domain hierarchy. At the time of domain discretizati...