TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Trianguler.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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>
17#include <Domaine.h>
18
19Implemente_instanciable(Trianguler,"Trianguler",Triangulation_base);
20// XD triangulate interprete trianguler INHERITS_BRACE To achieve a triangular mesh from a mesh comprising rectangles (2
21// XD_CONT triangles per rectangle). Should be used in VEF discretization. Principle: NL2
22// XD_CONT \includeimage{{trianguler.jpeg}}
23// XD attr domain_name ref_domaine domain_name REQ Name of domain.
24
25/*! @brief Simple appel a: Interprete::printOn(Sortie&)
26 *
27 * @param (Sortie& os) un flot de sortie
28 * @return (Sortie&) le flot de sortie modifie
29 */
31{
32 return Interprete::printOn(os);
33}
34
35
36/*! @brief Simple appel a: Interprete::readOn(Entree&)
37 *
38 * @param (Entree& is) un flot d'entree
39 * @return (Entree&) le flot d'entree modifie
40 */
42{
43 return Interprete::readOn(is);
44}
45
46/*! @brief Triangule tous les element d'un domaine: transforme les elements goemetriques du domaine en triangles.
47 *
48 * Pour l'instant on ne sait trianguler que des Rectangles
49 * (on les coupe en 2).
50 *
51 * @param (Domaine& domaine) le domaine dont on veut trianguler les elements
52 */
53void Trianguler::trianguler(Domaine& domaine) const
54{
55 if ((domaine.type_elem()->que_suis_je() == "Rectangle") || (domaine.type_elem()->que_suis_je() == "Quadrangle"))
56 {
57 domaine.typer("Triangle");
58 IntTab& les_elems=domaine.les_elems();
59 const DoubleTab& som =domaine.les_sommets();
60 int oldsz=les_elems.dimension(0);
61 IntTab new_elems(2*oldsz, 3);
62 for(int i=0; i< oldsz; i++)
63 {
64 int i0=les_elems(i,0);
65 int i1=les_elems(i,1);
66 int i2=les_elems(i,2);
67 int i3=les_elems(i,3);
68
69 // NEW on coupe par la petite diagonale si elles n'ont pas meme longueur
70 double d1=0,d2=0;
71 for (int dir=0; dir<dimension; dir++)
72 {
73 d1+=(som(i1,dir)-som(i2,dir))*(som(i1,dir)-som(i2,dir));
74 d2+=(som(i3,dir)-som(i0,dir))*(som(i3,dir)-som(i0,dir));
75 }
76 int test;
77 if (est_egal(d1,d2))
78 test=(i%2)==0;
79 else
80 test=(d1<d2);
81 if (test)
82 {
83 new_elems(i,0)=i0;
84 new_elems(i,1)=i1;
85 new_elems(i,2)=i2;
86 new_elems(i+oldsz,0)=i1;
87 new_elems(i+oldsz,1)=i2;
88 new_elems(i+oldsz,2)=i3;
89 }
90 else
91 {
92 new_elems(i,0)=i0;
93 new_elems(i,1)=i1;
94 new_elems(i,2)=i3;
95 new_elems(i+oldsz,0)=i0;
96 new_elems(i+oldsz,1)=i2;
97 new_elems(i+oldsz,2)=i3;
98 }
100 }
101 les_elems.ref(new_elems);
102 }
103 else
104 {
105 Cerr << "We do not yet know how to Trianguler the "
106 << domaine.type_elem()->que_suis_je() <<"s"<<finl;
107 }
108}
109
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
Triangulation_base Classe destinee a factoriser l'action de triangulation des interpretes.
Classe Trianguler Cette classe est un interprete qui sert a lire et executer.
Definition Trianguler.h:32
void trianguler(Domaine &) const override
Triangule tous les element d'un domaine: transforme les elements goemetriques du domaine en triangles...