TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Trianguler_H.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 <Trianguler_H.h>
17#include <Domaine.h>
18
19Implemente_instanciable(Trianguler_H,"Trianguler_H",Triangulation_base);
20// XD trianguler_h triangulate trianguler_h INHERITS_BRACE To achieve a triangular mesh from a mesh comprising
21// XD_CONT rectangles (4 triangles per rectangle). Should be used in VEF discretization. Principle: NL2
22// XD_CONT \includeimage{{triangulerh.jpeg}}
23
24
25
26/*! @brief Simple appel a: Interprete::printOn(Sortie&)
27 *
28 * @param (Sortie& os) un flot de sortie
29 * @return (Sortie&) le flot de sortie modifie
30 */
32{
33 return Interprete::printOn(os);
34}
35
36
37/*! @brief Simple appel a: Interprete::readOn(Entree&)
38 *
39 * @param (Entree& is) un flot d'entree
40 * @return (Entree&) le flot d'entree modifie
41 */
43{
44 return Interprete::readOn(is);
45}
46
47/*! @brief Triangule tous les element d'un domaine: transforme les elements goemetriques du domaine en triangles.
48 *
49 * Pour l'instant on ne sait trianguler que des Rectangles
50 * (on les coupe en 2).
51 *
52 * @param (Domaine& domaine) le domaine dont on veut trianguler les elements
53 */
55{
56 Domaine& dom=domaine;
57 IntTab& les_elems=domaine.les_elems();
58 int oldsz=les_elems.dimension(0);
59 DoubleTab& sommets=dom.les_sommets();
60 int cpt=sommets.dimension(0);
61 {
62 DoubleTab sommets_ajoutes(oldsz, dimension);
63 domaine.type_elem()->calculer_centres_gravite(sommets_ajoutes);
64 sommets.resize(cpt+oldsz, dimension);
65 for(int i=0; i<oldsz; i++)
66 for(int j=0; j<dimension; j++)
67 sommets(cpt+i,j)=sommets_ajoutes(i,j);
68 }
69 if ((domaine.type_elem()->que_suis_je() == "Rectangle")|| (domaine.type_elem()->que_suis_je() == "Quadrangle"))
70 {
71 domaine.typer("Triangle");
72 IntTab new_elems(4*oldsz, 3);
73 for(int i=0; i< oldsz; i++)
74 {
75 int i0=les_elems(i,0);
76 int i1=les_elems(i,1);
77 int i2=les_elems(i,2);
78 int i3=les_elems(i,3);
79
80 new_elems(i,0)= i+cpt;
81 new_elems(i,1)= i0;
82 new_elems(i,2)= i1;
83
84 new_elems(i+oldsz,0)= i+cpt;
85 new_elems(i+oldsz,1)= i0;
86 new_elems(i+oldsz,2)= i2;
88
89 new_elems(i+2*oldsz,0)= i+cpt;
90 new_elems(i+2*oldsz,1)= i1;
91 new_elems(i+2*oldsz,2)= i3;
93
94 new_elems(i+3*oldsz,0)= i+cpt;
95 new_elems(i+3*oldsz,1)= i2;
96 new_elems(i+3*oldsz,2)= i3;
98 }
99 les_elems.ref(new_elems);
100 }
101 else
102 {
103 Cerr << "We do not yet know how to Trianguler_h the "
104 << domaine.type_elem()->que_suis_je() <<"s"<<finl;
105 }
106}
107
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
void mettre_a_jour_sous_domaine(Domaine_t &domaine, int_t &elem, int_t num_premier_elem, int_t nb_elem) const
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 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
Triangulation_base Classe destinee a factoriser l'action de triangulation des interpretes.
Classe Trianguler_H Cette classe est un interprete qui sert a lire et executer.
void trianguler(Domaine &) const override
Triangule tous les element d'un domaine: transforme les elements goemetriques du domaine en triangles...