TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Transformer.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 <TRUST_Vector.h>
17#include <Transformer.h>
18#include <Rectangle.h>
19#include <Parser_U.h>
20#include <Hexaedre.h>
21#include <Scatter.h>
22
23Implemente_instanciable_32_64(Transformer_32_64, "Transformer", Interprete_geometrique_base_32_64<_T_>);
24// XD transformer interprete transformer INHERITS_BRACE Keyword to transform the coordinates of the geometry. NL2
25// XD_CONT Exemple to rotate your mesh by a 90o rotation and to scale the z coordinates by a factor 2: Transformer
26// XD_CONT domain_name -y -x 2*z
27// XD attr domain_name ref_domaine domain_name REQ Name of domain.
28// XD attr formule listchainef formule REQ Function_for_x Function_for_y \‍[ Function_for z \‍]
29
30// XD transformer_64 transformer transformer_64 INHERITS_BRACE Transformer keyword applied on a big mesh
31
32template <typename _SIZE_>
34{
35 return Interprete::printOn(os);
36}
37
38template <typename _SIZE_>
40{
41 return Interprete::readOn(is);
42}
43
44template <typename _SIZE_>
46{
47 this->associer_domaine(is);
49
50 Noms les_fcts;
51
52 les_fcts.dimensionner(Objet_U::dimension);
53
54 for (int i = 0; i < Objet_U::dimension; i++)
55 is >> les_fcts[i];
56
58
59
60 return is;
61}
62
63template <typename _SIZE_>
65{
66 VECT(Parser_U) fxyz(Objet_U::dimension);
67
68 for (int i = 0; i < Objet_U::dimension; i++)
69 {
70 Cerr << "Reading and interpretation of the function " << les_fcts[i] << finl;
71 fxyz[i].setNbVar(3);
72 fxyz[i].setString(les_fcts[i]);
73 fxyz[i].addVar("x");
74 fxyz[i].addVar("y");
75 fxyz[i].addVar("z");
76 fxyz[i].parseString();
77 Cerr << "Interpretation of the function " << les_fcts[i] << " Ok" << finl;
78 }
79 DoubleTab_t& sommets = dom.les_sommets();
80 DoubleTab_t new_sommets(sommets);
81 int_t sz = sommets.dimension(0);
82 double x = 0;
83 double y = 0;
84 double z = 0;
85 for (int_t i = 0; i < sz; i++)
86 {
87 for (int j = 0; j < Objet_U::dimension; j++)
88 {
89 x = sommets(i, 0);
90 y = sommets(i, 1);
91 z = 0;
92
93 if (Objet_U::dimension > 2)
94 z = sommets(i, 2);
95 }
96 for (int j = 0; j < Objet_U::dimension; j++)
97 {
98 fxyz[j].setVar("x", x);
99 fxyz[j].setVar("y", y);
100 fxyz[j].setVar("z", z);
101 new_sommets(i, j) = fxyz[j].eval();
102 }
103 }
104 sommets = new_sommets;
105}
106
107template <typename _SIZE_>
109{
110 auto& type_elem = this->domaine().type_elem();
111 if (type_elem->que_suis_je() == "Hexaedre_VEF")
112 {
113 Cerr << "------------------------------------------------------------------" << finl;
114 Cerr << "It is advised to not use directly \"Transformer\" on a mesh" << finl;
115 Cerr << "with VEF hexahedra since the method Hexaedre_VEF::reordonner" << finl;
116 Cerr << "is not fairly general in TRUST." << finl;
117 Cerr << "If your purpose is to make tetrahedra on your mesh," << finl;
118 Cerr << "create it first after reading your hexahedral meshing," << finl;
119 Cerr << "then use \"Transformer\"." << finl;
120 Cerr << "------------------------------------------------------------------" << finl;
121 this->exit();
122 }
123}
124
125template <typename _SIZE_>
127{
129 transformer(this->domaine(), les_fcts);
130
131 // Transformation de l'element parfois necessaire
132 auto& type_elem = this->domaine().type_elem();
133 if (type_elem->que_suis_je() == "Rectangle")
134 {
135 if (ref_cast(Rectangle,type_elem.valeur()).reordonner_elem() == -1) // Le reordonner_elem revele que l'on n'a plus des Rectangle
136 {
137 type_elem.typer("Quadrangle");
138 type_elem->associer_domaine(this->domaine());
139 }
140 }
141 if (type_elem->que_suis_je() == "Hexaedre")
142 {
143 if (ref_cast(Hexaedre,type_elem.valeur()).reordonner_elem() == -1) // Le reordonner_elem revele que l'on n'a plus des Hexaedre
144 {
145 type_elem.typer("Hexaedre_VEF");
146 type_elem->associer_domaine(this->domaine());
147 Bords_t& les_bords = this->domaine().faces_bord();
148
149 for (auto &itr : les_bords)
150 itr.faces().typer(Type_Face::quadrangle_3D);
151
152 les_bords.associer_domaine(this->domaine());
153 }
154 }
155 // Il faut reordonner apres un Transformer -y x par exemple car
156 // la numerotation des elements est melangee... Le probleme c'est
157 // que tous les reordonner ne sont pas correctement faits...
158 // 2-3
159 // 0-1
160 this->domaine().reordonner();
162}
163
164template class Transformer_32_64<int>;
165#if INT_is_64_ == 2
166template class Transformer_32_64<trustIdType>;
167#endif
void associer_domaine(const Domaine_t &)
Associe un domaine a tous les bords de la liste.
Definition Bords.cpp:32
DoubleTab_t & les_sommets()
Definition Domaine.h:113
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Interprete_geometrique_base .
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:76
static int dimension
Definition Objet_U.h:99
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
classe Parser_U Version de la classe Parser, derivant de Objet_U.
Definition Parser_U.h:32
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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_ dimension(int d) const
Definition TRUSTTab.tpp:133
Classe Transformer Applique un changement de coordonnees.
Definition Transformer.h:29
Bords_32_64< _SIZE_ > Bords_t
Definition Transformer.h:35
DoubleTab_T< _SIZE_ > DoubleTab_t
Definition Transformer.h:33
void transformer(Domaine_t &, Noms &)
Domaine_32_64< _SIZE_ > Domaine_t
Definition Transformer.h:36
void transformation_complete(Noms &les_fcts)
Entree & interpreter_(Entree &) override