16#ifndef Champ_implementation_P1_included
17#define Champ_implementation_P1_included
19#include <Champ_implementation_sommet.h>
22#include <TRUSTArray_kokkos.tpp>
28 static void init_from_file(DoubleTab& val,
const Domaine& dom,
int nb_comp,
double tolerance,
Entree& input);
31 void value_interpolation(
const DoubleTab& positions,
const ArrOfInt& cells,
const DoubleTab& values, DoubleTab& resu,
int ncomp = -1)
const override;
36 virtual double form_function(
const ArrOfDouble& position,
const IntTab& les_elems,
const DoubleTab& nodes, ArrOfInt& index,
int cell,
int ddl)
const;
39extern double coord_barycentrique_P1(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
int le_poly,
int i);
40extern double coord_barycentrique_P1(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
double z,
int le_poly,
int i);
47KOKKOS_INLINE_FUNCTION
double coord_barycentrique_P1_triangle(CIntTabView polys, CDoubleTabView coord,
double x,
double y,
int le_poly,
int i)
54 som0 = polys(le_poly, 0);
55 som1 = polys(le_poly, 1);
56 som2 = polys(le_poly, 2);
61 som0 = polys(le_poly, 1);
62 som1 = polys(le_poly, 2);
63 som2 = polys(le_poly, 0);
68 som0 = polys(le_poly, 2);
69 som1 = polys(le_poly, 0);
70 som2 = polys(le_poly, 1);
79 Kokkos::abort(
"A triangle does not have correct nodes in Champ_P1::coord_barycentrique.");
81 Process::exit(
"A triangle does not have correct nodes in Champ_P1::coord_barycentrique.");
85 double den = (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 1) - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 0) - coord(som1, 0));
87 double num = (coord(som2, 0) - coord(som1, 0)) * (y - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (x - coord(som1, 0));
89 double coord_bary = num / den;
92KOKKOS_INLINE_FUNCTION
double coord_barycentrique_P1_tetraedre(CIntTabView polys, CDoubleTabView coord,
double x,
double y,
double z,
int le_poly,
int i)
94 int som0, som1, som2, som3;
99 som0 = polys(le_poly, 0);
100 som1 = polys(le_poly, 1);
101 som2 = polys(le_poly, 2);
102 som3 = polys(le_poly, 3);
107 som0 = polys(le_poly, 1);
108 som1 = polys(le_poly, 2);
109 som2 = polys(le_poly, 3);
110 som3 = polys(le_poly, 0);
115 som0 = polys(le_poly, 2);
116 som1 = polys(le_poly, 3);
117 som2 = polys(le_poly, 0);
118 som3 = polys(le_poly, 1);
123 som0 = polys(le_poly, 3);
124 som1 = polys(le_poly, 0);
125 som2 = polys(le_poly, 1);
126 som3 = polys(le_poly, 2);
136 Kokkos::abort(
"Error in Champ_P1::coord_barycentrique : A tetrahedron does not have correct nodes ");
138 Process::exit(
"Error in Champ_P1::coord_barycentrique : A tetrahedron does not have correct nodes ");
143 double xp = (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 2) - coord(som1, 2)) - (coord(som2, 2) - coord(som1, 2)) * (coord(som0, 1) - coord(som1, 1));
144 double yp = (coord(som2, 2) - coord(som1, 2)) * (coord(som0, 0) - coord(som1, 0)) - (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 2) - coord(som1, 2));
145 double zp = (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 1) - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 0) - coord(som1, 0));
146 double den = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
148 xp = (coord(som2, 1) - coord(som1, 1)) * (z - coord(som1, 2)) - (coord(som2, 2) - coord(som1, 2)) * (y - coord(som1, 1));
149 yp = (coord(som2, 2) - coord(som1, 2)) * (x - coord(som1, 0)) - (coord(som2, 0) - coord(som1, 0)) * (z - coord(som1, 2));
150 zp = (coord(som2, 0) - coord(som1, 0)) * (y - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (x - coord(som1, 0));
151 double num = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
153 double coord_bary = num / den;
156inline double coord_barycentrique_P1_triangle(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
int le_poly,
int i)
159 int som0, som1, som2;
164 som0 = polys(le_poly, 0);
165 som1 = polys(le_poly, 1);
166 som2 = polys(le_poly, 2);
171 som0 = polys(le_poly, 1);
172 som1 = polys(le_poly, 2);
173 som2 = polys(le_poly, 0);
178 som0 = polys(le_poly, 2);
179 som1 = polys(le_poly, 0);
180 som2 = polys(le_poly, 1);
188 Cerr <<
"A triangle does not have " << i <<
" nodes in Champ_P1::coord_barycentrique." << finl;
192 double den = (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 1) - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 0) - coord(som1, 0));
194 double num = (coord(som2, 0) - coord(som1, 0)) * (y - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (x - coord(som1, 0));
197 double coord_bary = num / den;
201 Cerr <<
"WARNING: The barycentric coordinate of point :" << finl;
202 Cerr <<
"x= " << x <<
" y=" << y << finl;
203 Cerr <<
"is not between 0 and 1 : " << coord_bary << finl;
204 Cerr <<
"On the element " << le_poly <<
" of the processor " <<
Process::me() << finl;
210inline double coord_barycentrique_P1_rectangle(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
int le_poly,
int i)
213 double alpha_x, alpha_y;
244 Cerr <<
"Error in Champ_P1::coord_barycentrique : " << finl;
249 int som0 = polys(le_poly, 0);
250 int som1 = polys(le_poly, 1);
251 int som2 = polys(le_poly, 2);
252 double delta_x = coord(som1, 0) - coord(som0, 0);
253 double delta_y = coord(som2, 1) - coord(som0, 1);
254 double x0 = coord(som0, 0) + delta_x / 2.;
255 double y0 = coord(som0, 1) + delta_y / 2.;
256 double coord_bary = 0.25 * (1. + 2. * alpha_x * (x - x0) / delta_x) * (1. + 2. * alpha_y * (y - y0) / delta_y);
260 Cerr <<
"WARNING: The barycentric coordinate of point :" << finl;
261 Cerr <<
"x= " << x <<
" y=" << y << finl;
262 Cerr <<
"is not between 0 and 1 : " << coord_bary << finl;
263 Cerr <<
"On the element " << le_poly <<
" of the processor " <<
Process::me() << finl;
269inline double coord_barycentrique_P1_tetraedre(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
double z,
int le_poly,
int i)
271 int som0, som1, som2, som3;
277 som0 = polys(le_poly, 0);
278 som1 = polys(le_poly, 1);
279 som2 = polys(le_poly, 2);
280 som3 = polys(le_poly, 3);
285 som0 = polys(le_poly, 1);
286 som1 = polys(le_poly, 2);
287 som2 = polys(le_poly, 3);
288 som3 = polys(le_poly, 0);
293 som0 = polys(le_poly, 2);
294 som1 = polys(le_poly, 3);
295 som2 = polys(le_poly, 0);
296 som3 = polys(le_poly, 1);
301 som0 = polys(le_poly, 3);
302 som1 = polys(le_poly, 0);
303 som2 = polys(le_poly, 1);
304 som3 = polys(le_poly, 2);
313 Cerr <<
"Error in Champ_P1::coord_barycentrique : " << finl;
314 Cerr <<
"A tetrahedron does not have " << i <<
"nodes " << finl;
319 double xp = (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 2) - coord(som1, 2)) - (coord(som2, 2) - coord(som1, 2)) * (coord(som0, 1) - coord(som1, 1));
320 double yp = (coord(som2, 2) - coord(som1, 2)) * (coord(som0, 0) - coord(som1, 0)) - (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 2) - coord(som1, 2));
321 double zp = (coord(som2, 0) - coord(som1, 0)) * (coord(som0, 1) - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (coord(som0, 0) - coord(som1, 0));
322 double den = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
324 xp = (coord(som2, 1) - coord(som1, 1)) * (z - coord(som1, 2)) - (coord(som2, 2) - coord(som1, 2)) * (y - coord(som1, 1));
325 yp = (coord(som2, 2) - coord(som1, 2)) * (x - coord(som1, 0)) - (coord(som2, 0) - coord(som1, 0)) * (z - coord(som1, 2));
326 zp = (coord(som2, 0) - coord(som1, 0)) * (y - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (x - coord(som1, 0));
327 double num = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
330 double coord_bary = num / den;
334 Cerr <<
"WARNING: The barycentric coordinate of point :" << finl;
335 Cerr <<
"x= " << x <<
" y=" << y <<
" z=" << z << finl;
336 Cerr <<
"is not between 0 and 1 : " << coord_bary << finl;
337 Cerr <<
"On the element " << le_poly <<
" of the processor " <<
Process::me() << finl;
342inline double coord_barycentrique_P1_hexaedre(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
double z,
int le_poly,
int i)
345 double alpha_x, alpha_y, alpha_z;
409 Cerr <<
"Error in Champ_P1::coord_barycentrique : " << finl;
414 int som0 = polys(le_poly, 0);
415 int som1 = polys(le_poly, 1);
416 int som2 = polys(le_poly, 2);
417 int som3 = polys(le_poly, 4);
419 double delta_x = coord(som1, 0) - coord(som0, 0);
420 double delta_y = coord(som2, 1) - coord(som0, 1);
421 double delta_z = coord(som3, 2) - coord(som0, 2);
423 double x0 = coord(som0, 0) + delta_x / 2.;
424 double y0 = coord(som0, 1) + delta_y / 2.;
425 double z0 = coord(som0, 2) + delta_z / 2.;
427 double coord_bary = (1. / 8.) * (1. + 2. * alpha_x * (x - x0) / delta_x) * (1. + 2. * alpha_y * (y - y0) / delta_y) * (1. + 2. * alpha_z * (z - z0) / delta_z);
431 Cerr <<
"WARNING: The barycentric coordinate of point :" << finl;
432 Cerr <<
"x= " << x <<
" y=" << y <<
" z=" << z << finl;
433 Cerr <<
"is not between 0 and 1 : " << coord_bary << finl;
434 Cerr <<
"On the element " << le_poly <<
" of the processor " <<
Process::me() << finl;
classe Champ_base Cette classe est la base de la hierarchie des champs.
const Champ_base & le_champ() const override=0
Champ_base & le_champ() override=0
static void init_from_file(DoubleTab &val, const Domaine &dom, int nb_comp, double tolerance, Entree &input)
Initialise le tableau de valeurs aux sommets du domaine dom a partir de valeurs lues dans "input".
~Champ_implementation_P1() override
void value_interpolation(const DoubleTab &positions, const ArrOfInt &cells, const DoubleTab &values, DoubleTab &resu, int ncomp=-1) const override
: class Champ_implementation_sommet
Class defining operators and methods for all reading operation in an input flow (file,...
static double precision_geom
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
_SIZE_ dimension(int d) const