TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Polygone_poly.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Polygone_poly.h>
17#include <Domaine.h>
18#include <Poly_geom_base.h>
19
20Implemente_instanciable( Polygone_poly, "Polygone_poly", Elem_poly_base ) ;
21
23{
24 return os << que_suis_je() << finl;
25}
26
28{
30 return is;
31}
32/*! @brief Fills in the face_normales array in the Domaine_poly.
33 *
34 */
35void Polygone_poly::normale(int num_Face,DoubleTab& Face_normales,
36 const IntTab& Face_sommets,
37 const IntTab& Face_voisins,
38 const IntTab& elem_faces,
39 const Domaine& domaine_geom) const
40{
41 const DoubleTab& les_coords = domaine_geom.coord_sommets();
42
43 double x1,y1;
44 double nx,ny;
45 int n0 = Face_sommets(num_Face,0);
46 int n1 = Face_sommets(num_Face,1);
47 x1 = les_coords(n0,0)-les_coords(n1,0);
48 y1 = les_coords(n0,1)-les_coords(n1,1);
49 nx = -y1;
50 ny = x1;
51
52
53
54 /* DoubleTab xp;
55
56 domaine_geom.Domaine::calculer_centres_gravite(xp);
57 */
58 /*
59 int no3;
60 int f0;
61
62 // Orient the normal from elem1 to elem2
63 // by searching for the vertex of elem1 that is not on the Face
64 int elem1 = Face_voisins(num_Face,0);
65 if ( (f0 = elem_faces(elem1,0)) == num_Face )
66 f0 = elem_faces(elem1,1);
67 if ( (no3 = Face_sommets(f0,0)) != n0 && no3 != n1 )
68 ;
69 else
70 no3 = Face_sommets(f0,1);
71
72 x1 = les_coords(no3,0) - les_coords(n0,0);
73 y1 = les_coords(no3,1) - les_coords(n0,1);
74
75 double dot=(nx*x1+ny*y1);
76 */
77 int elem1=Face_voisins(num_Face,0);
78
79 DoubleVect xp;
80 ref_cast(Poly_geom_base,domaine_geom.type_elem().valeur()).calculer_un_centre_gravite(elem1,xp);
81 x1=xp(0)-les_coords(n0,0);
82 y1=xp(1)-les_coords(n0,1);
83
84 double dot=(nx*x1+ny*y1);
85
86 double scale = 1.0;
88 {
89 const double r0 = les_coords(n0,0);
90 const double r1 = les_coords(n1,0);
91 const double r_bar = 0.5*(r0 + r1);
92 scale = 2.0 * M_PI * r_bar; // multiply edge-length normal by Δθ * r̄
93 }
94
95 if ( (dot) > 0 )
96 {
97 Face_normales(num_Face,0) = - nx * scale;
98 Face_normales(num_Face,1) = - ny * scale;
99 }
100 else
101 {
102 assert(dot !=0);
103 Face_normales(num_Face,0) = nx * scale;
104 Face_normales(num_Face,1) = ny * scale;
105 }
106}
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
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static int bidim_axi
Definition Objet_U.h:97
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
: class Polygone_poly
void normale(int, DoubleTab &, const IntTab &, const IntTab &, const IntTab &, const Domaine &) const override
Fills in the face_normales array in the Domaine_poly.
Base class for output streams.
Definition Sortie.h:52