TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Rectangle_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 <Rectangle_axi.h>
17#include <Domaine.h>
18
19Implemente_instanciable_32_64(Rectangle_axi_32_64,"Rectangle_axi",Rectangle_32_64<_T_>);
20
21template <typename _SIZE_>
23{
24 return s;
25}
26
27template <typename _SIZE_>
29{
30 return s;
31}
32
33
34/*! @brief Computes the centers of gravity of all elements of the domain associated with the geometric element.
35 *
36 * @param xp the array containing the coordinates of the centers of gravity
37 */
38template <typename _SIZE_>
40{
41 const IntTab_t& les_Polys = this->mon_dom->les_elems();
42 const Domaine_t& le_dom = this->mon_dom.valeur();
43 int_t nb_elem = mon_dom->nb_elem();
44 int_t num_som;
45
46 xp.resize(nb_elem,dimension);
47 xp=0;
48 for (int_t num_elem=0; num_elem<nb_elem; num_elem++)
49 {
50 double d_teta;
51 d_teta = le_dom.coord(les_Polys(num_elem,3),1) -
52 le_dom.coord(les_Polys(num_elem,1),1);
53 if( d_teta<0 )
54 {
55 // Modif axi !
56
57 for(int s=0; s<this->nb_som(); s++)
58 {
59 num_som = les_Polys(num_elem,s);
60 for(int i=0; i<dimension; i++)
61 xp(num_elem,i) += le_dom.coord(num_som,i);
62 if(le_dom.coord(num_som,1) == 0.)
63 xp(num_elem,1) += 2*M_PI;
64 }
65
66 }
67 else
68 for(int s=0; s<this->nb_som(); s++)
69 {
70 num_som = les_Polys(num_elem,s);
71 for(int i=0; i<dimension; i++)
72 xp(num_elem,i) += le_dom.coord(num_som,i);
73 }
74 }
75 double x=1./this->nb_som();
76 xp*=x;
77}
78
79/*! @brief Returns the LML name of a rectangle_axi = "VOXEL8".
80 *
81 * @return always equal to "VOXEL8"
82 */
83template <typename _SIZE_>
85{
86 static Nom nom="VOXEL8";
87 return nom;
88}
89
90/*! @brief Computes the volumes of the elements of the associated domain.
91 *
92 * @param volumes the vector containing the volume values of the domain elements
93 */
94template <typename _SIZE_>
96{
97 const Domaine_t& dom=this->mon_dom.valeur();
98 double r,dr,d_teta;
99
100 int_t size_tot = dom.nb_elem_tot();
101 assert(volumes.size_totale()==size_tot);
102 for (int_t num_poly=0; num_poly<size_tot; num_poly++)
103 {
104 int_t S1 = dom.sommet_elem(num_poly,0),
105 S2 = dom.sommet_elem(num_poly,1),
106 S4 = dom.sommet_elem(num_poly,3);
107 r = 0.5*(dom.coord(S2,0) + dom.coord(S1,0));
108 dr = dom.coord(S2,0) - dom.coord(S1,0);
109 d_teta = dom.coord(S4,1) - dom.coord(S2,1);
110 if (d_teta<0) d_teta+=2.*M_PI;
111 volumes[num_poly]= dr*r*d_teta;
112 }
113}
114
115/*! @brief Returns 1 if element ielem of the domain associated with the geometric element contains the point
116 *
117 * with coordinates specified by parameter "pos".
118 *
119 * @param pos coordinates of the point to locate
120 * @param element the index of the element in the domain in which the point is searched.
121 * @return 1 if the point belongs to element ielem, 0 otherwise
122 *
123 */
124template <typename _SIZE_>
125int Rectangle_axi_32_64<_SIZE_>::contient(const ArrOfDouble& pos, int_t element ) const
126{
127 assert(pos.size_array()==2);
128 const Domaine_t& dom = this->mon_dom.valeur();
129 int_t som0 = dom.sommet_elem(element,0),
130 som3 = dom.sommet_elem(element,3);
131 double r0,r3,t0,t3;
132 r0=dom.coord(som0,0);
133 r3=dom.coord(som3,0);
134 t0=dom.coord(som0,1);
135 t3=dom.coord(som3,1);
136 if (t3<t0) t3+=2*M_PI;
137 if ( inf_ou_egal(r0,pos[0]) && inf_ou_egal(pos[0],r3)
138 && inf_ou_egal(t0,pos[1]) && inf_ou_egal(pos[1],t3) )
139 return 1;
140 else
141 return 0;
142}
143
144
145
146
147template class Rectangle_axi_32_64<int>;
148#if INT_is_64_ == 2
150#endif
151
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 Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
Rectangle class — represents the rectangular geometric element.
Definition Rectangle.h:31
int nb_som() const override
Nb of vertices for the element.
Definition Rectangle.h:50
Class Rectangle_axi: represents the deformed rectangle in.
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes of the elements of the associated domain.
Domaine_32_64< _SIZE_ > Domaine_t
IntTab_T< _SIZE_ > IntTab_t
static int dimension
Definition Objet_U.h:94
void calculer_centres_gravite(DoubleTab_t &) const override
Computes the centers of gravity of all elements of the domain associated with the geometric element.
DoubleTab_T< _SIZE_ > DoubleTab_t
int contient(const ArrOfDouble &pos, int_t elem) const override
Returns 1 if element ielem of the domain associated with the geometric element contains the point.
DoubleVect_T< _SIZE_ > DoubleVect_t
const Nom & nom_lml() const override
Returns the LML name of a rectangle_axi = "VOXEL8".
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