TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Raffiner_anisotrope.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Raffiner_anisotrope.h>
17#include <Scatter.h>
18
19Implemente_instanciable_32_64(Raffiner_anisotrope_32_64,"Raffiner_anisotrope",Interprete_geometrique_base_32_64<_T_>);
20// XD raffiner_anisotrope interprete raffiner_anisotrope INHERITS_BRACE Only for VEF discretizations, allows to cut
21// XD_CONT triangle elements in 3, or tetrahedra in 4 parts, by defining a new summit located at the center of the
22// XD_CONT element: \includeimage{{raffineranisotri.jpeg}} \includeimage{{raffineranisotetra.jpeg}} NL2 Note that such a
23// XD_CONT cut creates flat elements (anisotropic).
24// XD attr domain_name ref_domaine domain_name REQ Name of domain.
25
26
27template <typename _SIZE_>
29{
30 return Interprete::printOn(os);
31}
32
33template <typename _SIZE_>
35{
36 return Interprete::readOn(is);
37}
38
39template <typename _SIZE_>
41{
42 if (this->dimension == 2)
43 {
44 Cerr << "Refinement of each element into 3 new triangles... " <<finl;
45 }
46 else if (this->dimension == 3)
47 {
48 Cerr << "Refinement of each element into 4 new tetrahedra... " <<finl;
49 }
50 else
51 {
52 Cerr << "we can not refine in dimension " << this->dimension <<finl;
53 this->exit();
54 }
55 this->associer_domaine(is);
57 raffiner_(this->domaine());
59 Cerr << "Refinement... OK" << finl;
60 return is;
61}
62
63template <typename _SIZE_>
65{
66 if ((domaine.type_elem()->que_suis_je() == "Triangle")
67 ||(domaine.type_elem()->que_suis_je() == "Tetraedre"))
68 {
69 Domaine_t& dom=domaine;
70 IntTab_t& les_elems=domaine.les_elems();
71 int_t oldsz=les_elems.dimension(0);
72 DoubleTab_t& sommets=dom.les_sommets();
73 int_t cpt=sommets.dimension(0);
74 {
75 DoubleTab_t sommets_ajoutes(oldsz, this->dimension);
76 domaine.type_elem()->calculer_centres_gravite(sommets_ajoutes);
77 sommets.resize(cpt+oldsz, this->dimension);
78 for(int_t i=0; i<oldsz; i++)
79 for(int j=0; j<this->dimension; j++)
80 sommets(cpt+i,j)=sommets_ajoutes(i,j);
81 }
82
83 domaine.typer(domaine.type_elem()->que_suis_je());
84 IntTab_t new_elems((this->dimension+1)*oldsz, this->dimension+1);
85
86 if(this->dimension==2)
87 {
88 for(int_t i=0; i< oldsz; i++)
89 {
90 new_elems(i , 0) = i+cpt;
91 new_elems(i , 1) = les_elems(i,0);
92 new_elems(i , 2) = les_elems(i,1);
93
94 new_elems(i+oldsz, 0) = i+cpt;
95 new_elems(i+oldsz, 1) = les_elems(i,0);
96 new_elems(i+oldsz, 2) = les_elems(i,2);
97
98 this->mettre_a_jour_sous_domaine(domaine,i,i+oldsz,1);
99
100 new_elems(i+2*oldsz, 0) = i+cpt;
101 new_elems(i+2*oldsz, 1) = les_elems(i,1);
102 new_elems(i+2*oldsz, 2) = les_elems(i,2);
103
104 this->mettre_a_jour_sous_domaine(domaine,i,i+2*oldsz,1);
105 }
106 }
107 else
108 {
109 for(int_t i=0; i< oldsz; i++)
110 {
111 new_elems(i , 0) = i+cpt;
112 new_elems(i , 1) = les_elems(i,0);
113 new_elems(i , 2) = les_elems(i,1);
114 new_elems(i , 3) = les_elems(i,2);
115
116 new_elems(i+oldsz, 0) = i+cpt;
117 new_elems(i+oldsz, 1) = les_elems(i,0);
118 new_elems(i+oldsz, 2) = les_elems(i,1);
119 new_elems(i+oldsz, 3) = les_elems(i,3);
120
121 this->mettre_a_jour_sous_domaine(domaine,i,i+oldsz,1);
122
123 new_elems(i+2*oldsz, 0) = i+cpt;
124 new_elems(i+2*oldsz, 1) = les_elems(i,0);
125 new_elems(i+2*oldsz, 2) = les_elems(i,2);
126 new_elems(i+2*oldsz, 3) = les_elems(i,3);
127
128 this->mettre_a_jour_sous_domaine(domaine,i,i+2*oldsz,1);
129
130 new_elems(i+3*oldsz, 0) = i+cpt;
131 new_elems(i+3*oldsz, 1) = les_elems(i,1);
132 new_elems(i+3*oldsz, 2) = les_elems(i,2);
133 new_elems(i+3*oldsz, 3) = les_elems(i,3);
134
135 this->mettre_a_jour_sous_domaine(domaine,i,i+3*oldsz,1);
136 }
137 }
138
139 les_elems.ref(new_elems);
140
141 // Reconstruction de l'octree
142 if (this->dimension == 2)
143 Cerr << "We have split the triangles ..." << finl;
144 else
145 Cerr << "We have split the tetrahedra ..." << finl;
146 domaine.invalide_octree();
147
148 Cerr<<"END of Raffiner_anisotrope..."<<finl;
149 Cerr<<" 1 NbElem="<<domaine.les_elems().dimension(0)<<" NbNod="<<domaine.nb_som()<<finl;
150 }
151 else
152 {
153 Cerr << "We do not yet know how to Raffiner_anisotrope the "
154 << domaine.type_elem()->que_suis_je() <<"s"<<finl;
155 this->exit();
156 }
157}
158
159
160template class Raffiner_anisotrope_32_64<int>;
161#if INT_is_64_ == 2
163#endif
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 .
void mettre_a_jour_sous_domaine(Domaine_t &domaine, int_t &elem, int_t num_premier_elem, int_t nb_elem) const
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
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
class Raffiner_anisotrope Realise un maillage en decoupant chaque tetraedre en 4 nouveaux tetraedres
Entree & interpreter_(Entree &) override
DoubleTab_T< _SIZE_ > DoubleTab_t
Domaine_32_64< _SIZE_ > Domaine_t
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
virtual void ref(const TRUSTTab &)
Definition TRUSTTab.tpp:308
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133