TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Mailler.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 <NettoieNoeuds.h>
17#include <TRUST_Deriv.h>
18#include <Mailler.h>
19#include <Domaine.h>
20#include <Scatter.h>
21
22#include <list>
23#include <memory>
24
25Implemente_instanciable_32_64(Mailler_32_64,"Mailler",Interprete_geometrique_base_32_64<_T_>);
26// XD mailler interprete mailler INHERITS_BRACE The Mailler (Mesh) interpretor allows a Domain type object domaine to be
27// XD_CONT meshed with objects objet_1, objet_2, etc...
28// XD attr domaine ref_domaine domaine REQ Name of domain.
29// XD attr bloc list_bloc_mailler bloc REQ Instructions to mesh.
30
31// XD mailler_64 mailler mailler_64 INHERITS_BRACE The Mailler (Mesh) interpretor allows a big (64b) domain type object
32// XD_CONT domaine to be meshed with objects objet_1, objet_2, etc...
33
34template <typename _SIZE_>
36{
37 return Interprete::printOn(os);
38}
39
40template <typename _SIZE_>
42{
43 return Interprete::readOn(is);
44}
45
46inline void verifie_syntaxe(Motcle& motlu)
47{
48 if (motlu!="}" && motlu!=",")
49 {
50 Cerr << "We expected , or }" << finl;
52 }
53}
54/*! @brief Main function of the Mailler interpreter Data set structure (in dimension 2):
55 *
56 * Mailler dom
57 * {
58 * [Epsilon eps]
59 * [object1]
60 * ,
61 * [object2]
62 * ...
63 * }
64 * Two points will be merged as soon as the distance between them is
65 * less than Epsilon.
66 *
67 * @param (Entree& is) an input stream
68 * @return (Entree&) the input stream
69 * @throws the object to be meshed is not of Domaine_t type
70 * @throws opening brace expected
71 * @throws closing brace or comma expected
72 */
73template <typename _SIZE_>
75{
77 {
78 Cerr << "Mailler keyword can't be used in parallel calculation!" << finl;
79 Cerr << "Use only Scatter keyword to read partitioned mesh." << finl;
81 }
82 double precision_geom_sa = this->precision_geom;
83 this->associer_domaine(is);
84 Domaine_t& dom = this->domaine();
85
86 // Unlock structures to allow domain modification
88
89 Motcle motlu;
90 is >> motlu;
91 if (motlu != "{")
92 {
93 Cerr << "We expected a {" << finl;
95 }
96 Nom typ_domaine;
97 std::list<Domaine_t*> dom_lst; // the list of domains we will merge later when calling comprimer()
98 std::list<OWN_PTR(Domaine_t)> dom_lst2; // just for memory management
99 do
100 {
101 is >> typ_domaine;
102 motlu = typ_domaine;
103 if(motlu=="epsilon")
104 {
105 double eps;
106 is >> eps;
107 dom.fixer_epsilon(eps);
108 // GF the domain eps is no longer used when searching for duplicate vertices;
109 this->precision_geom=eps;
110 is >> motlu;
111 verifie_syntaxe(motlu);
112 }
113 else if(motlu=="Domain")
114 {
115 Nom nom_dom;
116 is >> nom_dom;
117 Cerr << "Adding a domain " << nom_dom << finl;
118 Domaine_t& added_dom=ref_cast(Domaine_t, this->objet(nom_dom));
119 dom_lst.push_back(&added_dom);
120 is >> motlu;
121 verifie_syntaxe(motlu);
122 }
123 else
124 {
125 dom_lst2.push_back(OWN_PTR(Domaine_t)()); // to keep them alive till the end of the method
126 OWN_PTR(Domaine_t)& un_domaine = dom_lst2.back();
127 un_domaine.typer(typ_domaine); // Most likely a Pave ...
128 Domaine_t& ze_domaine = un_domaine.valeur();
129 is >> ze_domaine;
130 dom_lst.push_back(&ze_domaine);
131 is >> motlu;
132 verifie_syntaxe(motlu);
133 }
134 }
135 while(motlu != "}");
136
137 // If precision_geom was modified, restore its original value
138 this->precision_geom=precision_geom_sa;
139 dom.fill_from_list(dom_lst);
141
143
145 return is;
146}
147
148template class Mailler_32_64<int>;
149#if INT_is_64_ == 2
150template class Mailler_32_64<trustIdType>;
151#endif
void fill_from_list(std::list< Domaine_32_64 * > &lst)
Fills the Domaine from a list of Domaine objects by aggregating them.
Definition Domaine.cpp:1507
void fixer_premieres_faces_frontiere()
Definition Domaine.cpp:1101
void fixer_epsilon(double eps)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Class Interprete_geometrique_base.
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
Class Mailler A mesher by agglomeration of domains (paves in 2D and blocks in 3D).
Definition Mailler.h:48
Domaine_32_64< _SIZE_ > Domaine_t
Definition Mailler.h:51
Entree & interpreter_(Entree &) override
Main function of the Mailler interpreter Data set structure (in dimension 2):
Definition Mailler.cpp:74
A character string (Nom) in uppercase.
Definition Motcle.h:26
static void nettoie(Domaine_t &)
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static double precision_geom
Definition Objet_U.h:81
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static bool is_parallel()
Definition Process.cpp:108
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
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:2739
static void uninit_sequential_domain(Domaine_32_64< _SIZE_ > &dom)
Method used by interpreters that modify the domain (sequential), destroys the descriptors of vertices...
Definition Scatter.cpp:2754
Base class for output streams.
Definition Sortie.h:52