18#include <Linear_algebra_tools_impl.h>
24static int faces_sommets_tetra[4][3] =
32template <
typename _SIZE_>
38template <
typename _SIZE_>
49template <
typename _SIZE_>
52 static Nom nom=
"TETRA4";
78inline bool is_on_same_side_of_plane(
const double& X0,
const double& Y0,
const double& Z0,
79 const double& X1,
const double& Y1,
const double& Z1,
80 const double& X2,
const double& Y2,
const double& Z2,
81 const double& X3,
const double& Y3,
const double& Z3,
82 const double& Mx,
const double& My,
const double& Mz
87 double xn = (Y1 - Y0) * (Z2 - Z0) - (Z1 - Z0) * (Y2 - Y0);
88 double yn = (Z1 - Z0) * (X2 - X0) - (X1 - X0) * (Z2 - Z0);
89 double zn = (X1 - X0) * (Y2 - Y0) - (Y1 - Y0) * (X2 - X0);
92 double prod1 = xn * (X3 - X0) + yn * (Y3 - Y0) + zn * (Z3 - Z0);
93 double prod2 = xn * (Mx - X0) + yn * (My - Y0) + zn * (Mz - Z0);
114template <
typename _SIZE_>
119 const Domaine_t& domaine=mon_dom.valeur();
122 int_t som0 = domaine.sommet_elem(ielem,0);
123 int_t som1 = domaine.sommet_elem(ielem,1);
124 int_t som2 = domaine.sommet_elem(ielem,2);
125 int_t som3 = domaine.sommet_elem(ielem,3);
126 double X0 = coord(som0,0);
127 double Y0 = coord(som0,1);
128 double Z0 = coord(som0,2);
129 double X1 = coord(som1,0);
130 double Y1 = coord(som1,1);
131 double Z1 = coord(som1,2);
132 double X2 = coord(som2,0);
133 double Y2 = coord(som2,1);
134 double Z2 = coord(som2,2);
135 double X3 = coord(som3,0);
136 double Y3 = coord(som3,1);
137 double Z3 = coord(som3,2);
155 if (not is_on_same_side_of_plane(X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, pos[0], pos[1], pos[2]))
161 if (not is_on_same_side_of_plane(X3, Y3, Z3, X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, pos[0], pos[1], pos[2]))
167 if (not is_on_same_side_of_plane(X2, Y2, Z2, X3, Y3, Z3, X0, Y0, Z0, X1, Y1, Z1, pos[0], pos[1], pos[2]))
173 if (not is_on_same_side_of_plane(X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X0, Y0, Z0, pos[0], pos[1], pos[2]))
191template <
typename _SIZE_>
194 const Domaine_t& domaine=mon_dom.valeur();
195 if((domaine.sommet_elem(element,0)==som[0])&&
196 (domaine.sommet_elem(element,1)==som[1])&&
197 (domaine.sommet_elem(element,1)==som[2])&&
198 (domaine.sommet_elem(element,1)==som[3]))
208template <
typename _SIZE_>
211 const Domaine_t& domaine=mon_dom.valeur();
213 int_t size_tot = domaine.nb_elem_tot();
215 ConstView<_SIZE_,2> les_Polys = domaine.les_elems().view_ro();
216 CDoubleTabView coord = domaine.coord_sommets().view_ro();
217 auto volumes = tab_volumes.view_wo();
218 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), size_tot, KOKKOS_LAMBDA(
const int_t num_poly)
220 int_t s0 = les_Polys(num_poly, 0);
221 int_t s1 = les_Polys(num_poly, 1);
222 int_t s2 = les_Polys(num_poly, 2);
223 int_t s3 = les_Polys(num_poly, 3);
224 double x0 = coord(s0, 0), y0 = coord(s0, 1), z0 = coord(s0, 2);
225 double x1 = coord(s1, 0), y1 = coord(s1, 1), z1 = coord(s1, 2);
226 double x2 = coord(s2, 0), y2 = coord(s2, 1), z2 = coord(s2, 2);
227 double x3 = coord(s3, 0), y3 = coord(s3, 1), z3 = coord(s3, 2);
228 volumes(num_poly) = Kokkos::fabs((x1-x0)*((y2-y0)*(z3-z0)-(y3-y0)*(z2-z0))-
229 (x2-x0)*((y1-y0)*(z3-z0)-(y3-y0)*(z1-z0))+
230 (x3-x0)*((y1-y0)*(z2-z0)-(y2-y0)*(z1-z0)))/6;
232 end_gpu_timer(__KERNEL_NAME__);
241template <
typename _SIZE_>
244 const Domaine_t& domaine_geom = mon_dom.valeur();
247 for (
int_t numface=0; numface<nbfaces; numface++)
250 int_t n0 = Face_sommets(numface,0);
251 int_t n1 = Face_sommets(numface,1);
252 int_t n2 = Face_sommets(numface,2);
254 double x1 = les_coords(n0,0) - les_coords(n1,0);
255 double y1 = les_coords(n0,1) - les_coords(n1,1);
256 double z1 = les_coords(n0,2) - les_coords(n1,2);
258 double x2 = les_coords(n2,0) - les_coords(n1,0);
259 double y2 = les_coords(n2,1) - les_coords(n1,1);
260 double z2 = les_coords(n2,2) - les_coords(n1,2);
262 face_normales(numface,0) = (y1*z2 - y2*z1)/2;
263 face_normales(numface,1) = (-x1*z2 + x2*z1)/2;
264 face_normales(numface,2) = (x1*y2 - x2*y1)/2;
270template <
typename _SIZE_>
274 faces_som_local.
resize(4,3);
275 for (
int i=0; i<4; i++)
276 for (
int j=0; j<3; j++)
277 faces_som_local(i,j) = faces_sommets_tetra[i][j];
281template <
typename _SIZE_>
288 for (
int i = 0; i < 3; i++)
290 for (
int j = i + 1; j < 4; j++)
const DoubleTab_t & coord_sommets() const
Class Elem_geom_base This class is the base class for the definition of elements.
Class defining operators and methods for all reading operation in an input flow (file,...
class Nom: a character string for naming TRUST objects.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Base class for output streams.
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const
_SIZE_ size_totale() const
Tetraedre class — represents the tetrahedral geometric element.
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes of the elements of the associated domain.
int contient(const ArrOfDouble &pos, int_t elem) const override
Returns 1 if element "ielem" of the domain associated with this geometric element contains the point ...
Domaine_32_64< _SIZE_ > Domaine_t
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
See ElemGeomBase::get_tab_faces_sommets_locaux.
IntTab_T< _SIZE_ > IntTab_t
void get_tab_aretes_sommets_locaux(IntTab &aretes_som_local) const override
Same as Elem_geom_base::get_tab_faces_sommets_locaux but for edges: aretes_som_local.
const Nom & nom_lml() const override
Returns the LML name of a tetrahedron = "TETRA4".
DoubleTab_T< _SIZE_ > DoubleTab_t
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
DoubleVect_T< _SIZE_ > DoubleVect_t
void calculer_normales(const IntTab_t &faces_sommets, DoubleTab_t &face_normales) const override
Computes the face normals of the elements of the associated domain.