16#include <Champ_som_lu_VEF.h>
38 int nb_pos = positions.
size();
40 tab_valeurs.
resize(nb_pos);
46 Cerr <<
"Il y a un pbl !! Il faut etre en 2D ou 3D !!" << finl;
68 return not_implemented_champ_<double>(__func__);
73 return not_implemented_champ_<double>(__func__);;
81 const DoubleTab& coord = mon_domaine->coord_sommets();
82 const IntTab& sommet_poly = mon_domaine->les_elems();
84 if (val.
nb_dim() > 2) erreur_champ_(__func__);
88 Cerr <<
"ATTENTION : Cela n a pas encore ete teste en 2D!!!" << finl;
89 Cerr <<
"Il manque les fonctions de forme en 2D!! A vous de jouer!!" << finl;
92 const DoubleTab& ch =
valeurs();
94 for (
int rang_poly = 0; rang_poly < les_polys.
size(); rang_poly++)
96 le_poly = les_polys(rang_poly);
98 for (
int ncomp = 0; ncomp <
nb_compo_; ncomp++) val(rang_poly, ncomp) = 0;
100 for (
int ncomp = 0; ncomp <
nb_compo_; ncomp++)
102 val(rang_poly, ncomp) = 0;
103 xs = positions(rang_poly, 0);
104 ys = positions(rang_poly, 1);
105 zs = (
dimension == 3) ? positions(rang_poly, 2) : 0.;
108 som = sommet_poly(le_poly, i);
109 val(rang_poly, ncomp) += ch(som, ncomp)
110 * ((
dimension == 2) ? coord_barycentrique2D(sommet_poly, coord, xs, ys, le_poly, i) : coord_barycentrique3D(sommet_poly, coord, xs, ys, zs, le_poly, i));
121 const DoubleTab& coord = mon_domaine->coord_sommets();
122 const IntTab& sommet_poly = mon_domaine->les_elems();
124 const DoubleTab& ch =
valeurs();
128 Cerr <<
"ATTENTION : Cela n a pas encore ete teste en 2D!!!" << finl;
129 Cerr <<
"Il manque les fonctions de forme en 2D!! A vous de jouer!!" << finl;
133 for (
int rang_poly = 0; rang_poly < les_polys.
size(); rang_poly++)
135 le_poly = les_polys(rang_poly);
136 if (le_poly == -1) val(rang_poly) = 0;
140 xs = positions(rang_poly, 0);
141 ys = positions(rang_poly, 1);
142 zs = (
dimension == 3) ? positions(rang_poly, 2) : 0.;
145 som = sommet_poly(le_poly, i);
146 val(rang_poly) += ch(som, ncomp) * ((
dimension == 2) ? coord_barycentrique2D(sommet_poly, coord, xs, ys, le_poly, i) : coord_barycentrique3D(sommet_poly, coord, xs, ys, zs, le_poly, i));
153double coord_barycentrique3D(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
double z,
int le_poly,
int i)
155 int som0, som1, som2, som3;
161 som0 = polys(le_poly, 0);
162 som1 = polys(le_poly, 1);
163 som2 = polys(le_poly, 2);
164 som3 = polys(le_poly, 3);
169 som0 = polys(le_poly, 1);
170 som1 = polys(le_poly, 2);
171 som2 = polys(le_poly, 3);
172 som3 = polys(le_poly, 0);
177 som0 = polys(le_poly, 2);
178 som1 = polys(le_poly, 3);
179 som2 = polys(le_poly, 0);
180 som3 = polys(le_poly, 1);
185 som0 = polys(le_poly, 3);
186 som1 = polys(le_poly, 0);
187 som2 = polys(le_poly, 1);
188 som3 = polys(le_poly, 2);
193 som0 = som1 = som2 = som3 = -1;
200 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));
201 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));
202 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));
203 double den = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
205 xp = (coord(som2, 1) - coord(som1, 1)) * (z - coord(som1, 2)) - (coord(som2, 2) - coord(som1, 2)) * (y - coord(som1, 1));
206 yp = (coord(som2, 2) - coord(som1, 2)) * (x - coord(som1, 0)) - (coord(som2, 0) - coord(som1, 0)) * (z - coord(som1, 2));
207 zp = (coord(som2, 0) - coord(som1, 0)) * (y - coord(som1, 1)) - (coord(som2, 1) - coord(som1, 1)) * (x - coord(som1, 0));
208 double num = xp * (coord(som3, 0) - coord(som1, 0)) + yp * (coord(som3, 1) - coord(som1, 1)) + zp * (coord(som3, 2) - coord(som1, 2));
211 double coord_bary = num / den;
212 assert(sup_ou_egal(coord_bary, 0) && inf_ou_egal(coord_bary, 1));
216double coord_barycentrique2D(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
int le_poly,
int i)
218 int som0 = polys(le_poly, i), som1 = polys(le_poly, 1);
220 if (i == 1) som1 = polys(le_poly, 0);
222 double xref = coord(som1, 0) - coord(som0, 0);
223 double yref = coord(som1, 1) - coord(som0, 1);
225 double xp = x - coord(som0, 0);
226 double yp = y - coord(som0, 1);
228 double pscal = (xref * xp) + (yref * yp);
229 double norm = (xref * xref) + (yref * yref);
232 double coord_bary = pscal / norm;
233 assert(sup_ou_egal(coord_bary, 0) && inf_ou_egal(coord_bary, 1));
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
provoque une erreur ! doit etre surchargee par les classes derivees
DoubleVect & valeur_a_compo(const DoubleVect &position, DoubleVect &valeurs, int ncomp) const
DoubleVect & valeur_a_elem_compo(const DoubleVect &position, DoubleVect &valeurs, int le_poly, int ncomp) const
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
provoque une erreur ! doit etre surchargee par les classes derivees
Class defining operators and methods for all reading operation in an input flow (file,...
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
_SIZE_ size_totale() const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)