TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Polyedre_poly.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 <Polyedre_poly.h>
17#include <Polyedre.h>
18#include <Domaine.h>
19#include <Linear_algebra_tools_impl.h>
20
21Implemente_instanciable(Polyedre_poly,"Polyedre_poly",Elem_poly_base);
22
23
24Sortie& Polyedre_poly::printOn(Sortie& s ) const { return s << que_suis_je() << finl; }
25
26Entree& Polyedre_poly::readOn(Entree& s ) { return s ; }
27
28void Polyedre_poly::normale(int num_Face,DoubleTab& Face_normales,
29 const IntTab& Face_sommets,
30 const IntTab& Face_voisins,
31 const IntTab& elem_faces,
32 const Domaine& domaine_geom) const
33{
34
35 //Cerr << " num_Face " << num_Face << finl;
36 const DoubleTab& les_coords = domaine_geom.coord_sommets();
37
38 // Cerr << "les face sommet " << Face_sommets << finl;
39
40
41 int nb_som_face_max= Face_sommets.dimension(1);
42 int n0 = Face_sommets(num_Face,0);
43
44 const IntTab& elem=domaine_geom.les_elems();
45 Vecteur3 n(0,0,0);
46 Vecteur3 moinsS0(les_coords(n0,0),les_coords(n0,1),les_coords(n0,2));
47 moinsS0*=-1;
48 for (int s=1; s<nb_som_face_max-1 ; s++)
49 {
50 int n1 = Face_sommets(num_Face,s);
51 int n2 = Face_sommets(num_Face,s+1);
52 if (n2<0)
53 {
54 break;
55 }
56 Vecteur3 S1(les_coords(n1,0),les_coords(n1,1),les_coords(n1,2));
57 Vecteur3 S2(les_coords(n2,0),les_coords(n2,1),les_coords(n2,2));
58 S1+=moinsS0;
59 S2+=moinsS0;
60 Vecteur3 nTr;
62 n+=nTr;
63 }
64 n*=0.5;
65
66 /*
67 int elem1=Face_voisins(num_Face,0);
68 DoubleVect xp;
69 ref_cast(Poly_geom_base,domaine_geom.type_elem().valeur()).calculer_un_centre_gravite(elem1,xp);
70 Vecteur3 M(xp(0),xp(1),xp(2));
71 */
72 // on prend un point a l'interieur (pas le cg trop long)
73
74 int num_poly=Face_voisins(num_Face,0);
75
76 Vecteur3 xg(0,0,0);
77 int nb_som_max=elem.dimension(1);
78 int nb_som_reel;
79 for (nb_som_reel=0; nb_som_reel<nb_som_max; nb_som_reel++)
80 {
81 int ns=elem(num_poly,nb_som_reel);
82 if (ns<0)
83 break;
84 Vecteur3 S(les_coords(ns,0),les_coords(ns,1),les_coords(ns,2));
85 xg+=S;
86 }
87 xg*=1./nb_som_reel;
88
89
90 xg+=moinsS0;
91 double prod_scal=Vecteur3::produit_scalaire(n,xg);
92 if ( (prod_scal) > 0 )
93 {
94 n*=-1;
95 }
96
97
98 Face_normales(num_Face,0) = n[0];
99 Face_normales(num_Face,1) = n[1];
100 Face_normales(num_Face,2) = n[2];
101
102 // double s=sqrt(Vecteur3::produit_scalaire(n,n));
103 // Cerr << "Face_normales " << num_Face<< " s "<< s << finl;
104 // assert(s>0);
105 // Cerr << "Face_normales " << num_Face<< " s "<< s << finl;
106
107}
IntTab_t & les_elems()
Definition Domaine.h:129
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
static double produit_scalaire(const Vecteur3 &x, const Vecteur3 &y)
static void produit_vectoriel(const Vecteur3 &x, const Vecteur3 &y, Vecteur3 &resu)