TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Segment.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 <Segment.h>
17#include <Domaine.h>
18
19Implemente_instanciable_32_64(Segment_32_64,"Segment",Elem_geom_base_32_64<_T_>);
20// XD segment sonde_base segment NO_BRACE Keyword to define the number of probe segment points. The file is arranged in
21// XD_CONT columns.
22// XD attr nbr entier nbr REQ Number of probe points of the segment, evenly distributed.
23// XD attr point_deb un_point point_deb REQ First outer probe segment point.
24// XD attr point_fin un_point point_fin REQ Second outer probe segment point.
25
26static int faces_sommets_segment[2][1] =
27{ { 0 } ,{ 1 } };
28
29template <typename _SIZE_>
31{
32 return s;
33}
34
35template <typename _SIZE_>
37{
38 return s;
39}
40
41/*! @brief Reordonne les sommets du segment.
42 *
43 */
44template <typename _SIZE_>
46{
47 Domaine_t& domaine=mon_dom.valeur();
48 IntTab_t& elem=domaine.les_elems();
49 const Domaine_t& dom=domaine;
50 SmallArrOfTID_t S(2);
51 int i;
52 const int_t nb_elem=domaine.nb_elem();
53 for (int_t num_poly=0; num_poly<nb_elem; num_poly++)
54 {
55 for(i=0; i<2; i++)
56 S[i] = elem(num_poly,i);
57
58 if(sup_strict(dom.coord(S[0], 0),dom.coord(S[1], 0)))
59 {
60 int_t tmp=S[0];
61 S[0]=S[1];
62 S[1]=tmp;
63 }
64
65 for(i=0; i<2; i++)
66 elem(num_poly, i)=S[i];
67 }
68}
69
70
71/*! @brief Renvoie le nom LML d'un triangle = "VOXEL8".
72 *
73 * @return (Nom&) toujours egal a "VOXEL8"
74 */
75template <typename _SIZE_>
77{
78 static Nom nom="SEGMENT";
79 if (dimension==2)
80 nom="QUADRANGLE_3D";
81 return nom;
82}
83
84
85/*! @brief Renvoie 1 si l'element ielem du domaine associe a l'element geometrique contient le point
86 *
87 * de coordonnees specifiees par le parametre "pos".
88 * Renvoie 0 sinon.
89 *
90 * @param (DoubleVect& pos) coordonnees du point que l'on cherche a localiser
91 * @param (int element) le numero de l'element du domaine dans lequel on cherche le point.
92 * @return (int) 1 si le point de coordonnees specifiees appartient a l'element "element" 0 sinon
93 */
94template <typename _SIZE_>
95int Segment_32_64<_SIZE_>::contient(const ArrOfDouble& pos, int_t element ) const
96{
97 assert(pos.size_array()==dimension);
98
99 const Domaine_t& domaine=mon_dom.valeur();
100 const Domaine_t& dom=domaine;
101 const IntTab_t& elem=domaine.les_elems();
102 // Test whether OM = a.O1 with O and 1 the extreme points of the seg and M the point to be tested
103 double autre_a = 0;
104 for (int d=0; d<dimension; d++)
105 {
106 double O1 = dom.coord(elem(element,1), d) - dom.coord(elem(element,0), d);
107 double OM = pos[d] - dom.coord(elem(element,0), d);
108 if (!est_egal(O1,0))
109 {
110 double a = OM/O1;
111 // M is outside O1?
112 if (a<-Objet_U::precision_geom || a>1+Objet_U::precision_geom) return 0;
113 // a is not the same as for another dimension, <=> not aligned
114 if (autre_a>0 && !est_egal(a, autre_a)) return 0;
115 autre_a = a;
116 }
117 else if (!est_egal(OM,0)) return 0; // M is not along O1
118 }
119 return 1;
120}
121
122
123/*! @brief Renvoie 1 si les sommets specifies par le parametre "pos" sont les sommets de l'element "element" du domaine associe a
124 *
125 * l'element geometrique.
126 *
127 * @param (IntVect& pos) les numeros des sommets a comparer avec ceux de l'elements "element"
128 * @param (int element) le numero de l'element du domaine dont on veut comparer les sommets
129 * @return (int) 1 si les sommets passes en parametre sont ceux de l'element specifie, 0 sinon
130 */
131template <typename _SIZE_>
133{
134 assert(pos.size_array()==1);
135 const Domaine_t& domaine=mon_dom.valeur();
136 if((domaine.sommet_elem(element,0)==pos[0])&&
137 (domaine.sommet_elem(element,1)==pos[1]))
138 return 1;
139 else
140 return 0;
141}
142
143/*! @brief Calcule les volumes des elements du domaine associe.
144 *
145 * @param (DoubleVect& volumes) le vecteur contenant les valeurs des des volumes des elements du domaine
146 */
147template <typename _SIZE_>
149{
150 const Domaine_t& domaine=mon_dom.valeur();
151 const Domaine_t& dom=domaine;
152 double dx;
153 int_t S1,S2;
154
155 int_t size_tot = domaine.nb_elem_tot();
156 assert(volumes.size_totale()==size_tot);
157 for (int_t num_poly=0; num_poly<size_tot; num_poly++)
158 {
159 S1 = domaine.sommet_elem(num_poly,0);
160 S2 = domaine.sommet_elem(num_poly,1);
161 dx=0;
162 for (int i=0; i<dimension; i++)
163 {
164 double d = dom.coord(S2,i) - dom.coord(S1,i);
165 dx+=d*d;
166 }
167 volumes[num_poly]= sqrt(dx);
168 }
169}
170
171/*! @brief voir ElemGeomBase::get_tab_faces_sommets_locaux
172 */
173template <typename _SIZE_>
175{
176 faces_som_local.resize(2,1);
177 for (int j=0; j<2; j++)
178 faces_som_local(j,0) = faces_sommets_segment[j][0];
179 return 1;
180}
181
182
183template class Segment_32_64<int>;
184#if INT_is_64_ == 2
185template class Segment_32_64<trustIdType>;
186#endif
187
double coord(int_t i, int j) const
Definition Domaine.h:110
Classe Elem_geom_base Cette classe est la classe de base pour la definition d'elements.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static double precision_geom
Definition Objet_U.h:86
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe Segment Cette classe represente l'element geometrique segment.
Definition Segment.h:29
static int dimension
Definition Objet_U.h:99
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
voir ElemGeomBase::get_tab_faces_sommets_locaux
Definition Segment.cpp:174
_SIZE_ int_t
Definition Segment.h:35
void calculer_volumes(DoubleVect_t &vols) const override
Calcule les volumes des elements du domaine associe.
Definition Segment.cpp:148
const Nom & nom_lml() const override
Renvoie le nom LML d'un triangle = "VOXEL8".
Definition Segment.cpp:76
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
Definition Segment.h:37
IntTab_T< _SIZE_ > IntTab_t
Definition Segment.h:36
DoubleVect_T< _SIZE_ > DoubleVect_t
Definition Segment.h:38
int contient(const ArrOfDouble &pos, int_t elem) const override
Renvoie 1 si l'element ielem du domaine associe a l'element geometrique contient le point.
Definition Segment.cpp:95
void reordonner() override
Reordonne les sommets du segment.
Definition Segment.cpp:45
Domaine_32_64< _SIZE_ > Domaine_t
Definition Segment.h:39
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61