TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Hexaedre_axi.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 <Hexaedre_axi.h>
17#include <Domaine.h>
18
19Implemente_instanciable_32_64(Hexaedre_axi_32_64,"Hexaedre_axi",Hexaedre_32_64<_T_>);
20
21
22/*! @brief Does nothing.
23 *
24 * @param s An output stream.
25 * @return The output stream.
26 */
27template <typename _SIZE_>
29{
30 return s;
31}
32
33
34/*! @brief Does nothing.
35 *
36 * @param (Entree& s) an input stream
37 * @return (Entree&) the input stream
38 */
39template <typename _SIZE_>
41{
42 return s;
43}
44
45
46/*! @brief Returns the LML name of a Hexaedre_axi element = "VOXEL8".
47 *
48 * @return (Nom&) always equal to "VOXEL8"
49 */
50template <typename _SIZE_>
52{
53 static Nom nom="VOXEL8";
54 return nom;
55}
56
57
58/*! @brief Computes the center of gravity of all elements of the domain associated with the geometric element.
59 *
60 * @param (DoubleTab& xp) the array containing the coordinates of the centers of gravity
61 */
62template <typename _SIZE_>
64{
65 const IntTab_t& les_Polys = this->mon_dom->les_elems();
66 const Domaine_t& le_dom = this->mon_dom.valeur();
67 int_t nb_elem = this->mon_dom->nb_elem();
68
69 xp.resize(nb_elem, Objet_U::dimension);
70 xp=0;
71
72 for (int_t num_elem=0; num_elem<nb_elem; num_elem++)
73 {
74 double d_teta;
75 d_teta = le_dom.coord(les_Polys(num_elem,3),1) -
76 le_dom.coord(les_Polys(num_elem,1),1);
77 if( d_teta<0 )
78 {
79 // Modif axi !
80
81 for(int s=0; s<this->nb_som(); s++)
82 {
83 int_t num_som = les_Polys(num_elem,s);
84 for(int i=0; i < Objet_U::dimension; i++)
85 xp(num_elem,i) += le_dom.coord(num_som,i);
86 if(le_dom.coord(num_som,1) == 0.)
87 xp(num_elem,1) += 2*M_PI;
88 }
89
90 }
91 else
92 for(int s=0; s<this->nb_som(); s++)
93 {
94 int_t num_som = les_Polys(num_elem,s);
95 for(int i=0; i<Objet_U::dimension; i++)
96 xp(num_elem,i) += le_dom.coord(num_som,i);
97 }
98 }
99 double x=1./this->nb_som();
100 xp*=x;
101}
102
103
104/*! @brief DOES NOTHING: TO BE CODED, always returns 0.
105 *
106 * Returns 1 if element "element" of the domain associated with
107 * the geometric element contains the point
108 * with coordinates specified by parameter "pos".
109 * Returns 0 otherwise.
110 *
111 * @param (DoubleVect& pos) coordinates of the point to locate
112 * @param (int element) the index of the domain element in which the point is searched.
113 * @return (int) 1 if the point belongs to element "element", 0 otherwise
114 */
115template <typename _SIZE_>
116int Hexaedre_axi_32_64<_SIZE_>::contient(const ArrOfDouble& pos, int_t element ) const
117{
118 assert(pos.size_array()==3);
119 const Domaine_t& dom=this->mon_dom.valeur();
120 int_t som0 = dom.sommet_elem(element,0);
121 int_t som7 = dom.sommet_elem(element,7);
122 double t7 = dom.coord(som7,1);
123 if (t7<dom.coord(som0,1)) t7+=2*M_PI;
124 if ( inf_ou_egal(dom.coord(som0,0),pos[0]) && inf_ou_egal(pos[0],dom.coord(som7,0))
125 && inf_ou_egal(dom.coord(som0,1),pos[1]) && inf_ou_egal(pos[1],t7)
126 && inf_ou_egal(dom.coord(som0,2),pos[2]) && inf_ou_egal(pos[2],dom.coord(som7,2)) )
127 return 1;
128 else
129 return 0;
130}
131
132
133/*! @brief Returns 1 if the vertices specified by parameter "pos" are the vertices of element "element" of the domain associated with
134 *
135 * the geometric element.
136 *
137 * @param (IntVect& pos) the vertex indices to compare with those of element "element"
138 * @param (int element) the index of the domain element whose vertices are to be compared
139 * @return (int) 1 if the vertices passed as parameter are those of the specified element, 0 otherwise
140 */
141template <typename _SIZE_>
143{
144 const Domaine_t& dom=this->mon_dom.valeur();
145 if((dom.sommet_elem(element,0)==som[0])&&
146 (dom.sommet_elem(element,1)==som[1])&&
147 (dom.sommet_elem(element,2)==som[2])&&
148 (dom.sommet_elem(element,3)==som[3])&&
149 (dom.sommet_elem(element,4)==som[4])&&
150 (dom.sommet_elem(element,5)==som[5])&&
151 (dom.sommet_elem(element,6)==som[6])&&
152 (dom.sommet_elem(element,7)==som[7]))
153 return 1;
154 else
155 return 0;
156}
157
158
159
160/*! @brief Computes the volumes of the elements of the associated domain.
161 *
162 * @param (DoubleVect& volumes) the vector containing the volume values of the domain elements
163 */
164template <typename _SIZE_>
166{
167 const Domaine_t& dom=this->mon_dom.valeur();
168 double r,dr,d_teta,dz;
169 int_t S1,S2,S4,S5;
170
171 int_t size_tot = dom.nb_elem_tot();
172 assert(volumes.size_totale()==size_tot);
173 for (int_t num_poly=0; num_poly<size_tot; num_poly++)
174 {
175 S1 = dom.sommet_elem(num_poly,0);
176 S2 = dom.sommet_elem(num_poly,1);
177 S4 = dom.sommet_elem(num_poly,3);
178 S5 = dom.sommet_elem(num_poly,4);
179 r = 0.5*(dom.coord(S2,0) + dom.coord(S1,0));
180 dr = dom.coord(S2,0) - dom.coord(S1,0);
181 d_teta = dom.coord(S4,1) - dom.coord(S2,1);
182 if (d_teta<0) d_teta+=2.*M_PI;
183 dz = dom.coord(S5,2) - dom.coord(S1,2);
184 volumes[num_poly]= dr*r*d_teta*dz;
185 }
186}
187
188
189template class Hexaedre_axi_32_64<int>;
190#if INT_is_64_ == 2
192#endif
193
int_t nb_elem_tot() const
Definition Domaine.h:132
double coord(int_t i, int j) const
Definition Domaine.h:110
int_t sommet_elem(int_t i, int j) const
Returns the (global) number of the j-th vertex of the i-th element.
Definition Domaine.h:136
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Class Hexaedre: represents a geometric element with 6 faces, 8 vertices, and.
Definition Hexaedre.h:29
int nb_som() const override
Nb of vertices for the element.
Definition Hexaedre.h:49
Class Hexaedre_axi: represents the deformed hexahedron in.
void calculer_centres_gravite(DoubleTab_t &c) const override
Computes the center of gravity of all elements of the domain associated with the geometric element.
Domaine_32_64< _SIZE_ > Domaine_t
DoubleTab_T< _SIZE_ > DoubleTab_t
int contient(const ArrOfDouble &pos, int_t elem) const override
DOES NOTHING: TO BE CODED, always returns 0.
DoubleVect_T< _SIZE_ > DoubleVect_t
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes of the elements of the associated domain.
const Nom & nom_lml() const override
Returns the LML name of a Hexaedre_axi element = "VOXEL8".
IntTab_T< _SIZE_ > IntTab_t
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
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