104 domaine_surfacique.
nommer(nom_domaine_surfacique);
105 Parser_U condition_elements,condition_faces;
107 condition_elements.
addVar(
"x");
108 condition_elements.
addVar(
"y");
110 condition_elements.
addVar(
"z");
112 condition_faces.
addVar(
"x");
113 condition_faces.
addVar(
"y");
115 condition_faces.
addVar(
"z");
119 condition_elements.
setString(expr_elements);
127 if (type_elem==
Motcle(
"Tetraedre"))
128 domaine_surfacique.
typer(
"Triangle");
129 else if (type_elem==
Motcle(
"Segment"))
130 domaine_surfacique.
typer(
"Point");
131 else if (type_elem==
Motcle(
"Segment_axi"))
132 domaine_surfacique.
typer(
"Point");
133 else if ((type_elem==
Motcle(
"Hexaedre"))|| (type_elem==
Motcle(
"Hexaedre_VEF")))
134 domaine_surfacique.
typer(
"Quadrangle");
135 else if (type_elem==
Motcle(
"Polyedre"))
136 domaine_surfacique.
typer(
"Polygone");
139 Cerr<<
"WARNING "<<type_elem<<
" not coded, use Quadrangle" <<finl;
140 domaine_surfacique.
typer(
"Quadrangle");
144 domaine_surfacique.
typer(
"segment");
147 int nb_elem=domaine_vf.
nb_elem();
148 IntTrav tab_marq_elem;
151 ParserView parser_condition_elements(condition_elements);
153 CDoubleTabView xp = domaine_vf.
xp().view_ro();
154 IntArrView marq_elem =
static_cast<ArrOfInt&
>(tab_marq_elem).view_wo();
155 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
const int elem)
157 int threadId = parser_condition_elements.
acquire();
158 parser_condition_elements.
setVar(0,xp(elem,0),threadId);
159 parser_condition_elements.
setVar(1,xp(elem,1),threadId);
161 parser_condition_elements.
setVar(2,xp(elem,2),threadId);
162 double res = parser_condition_elements.
eval(threadId);
163 parser_condition_elements.
release(threadId);
164 marq_elem(elem) = std::fabs(res)>1e-5 ? 1 : 0;
166 end_gpu_timer(__KERNEL_NAME__);
171 ArrOfInt tab_marq(nb_faces);
174 for(
int njoint=0; njoint<nbjoints; njoint++)
176 const Joint& joint_temp = domaine_vf.
joint(njoint);
177 int pe_voisin=joint_temp.
PEvoisin();
181 const int nbfaces = tab_indices_faces_joint.
dimension(0);
182 CIntTabView indices_faces_joint = tab_indices_faces_joint.
view_ro();
183 IntArrView marq = tab_marq.view_rw();
184 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nbfaces), KOKKOS_LAMBDA(
const int j)
186 int face_de_joint = indices_faces_joint(j, 1);
187 marq[face_de_joint] = -1;
189 end_gpu_timer(__KERNEL_NAME__);
195 ArrOfInt tab_face_bord_int(nb_faces);
198 if (noms_des_bords.size()!=0)
202 Cerr<<
" the option avec_les_bords is incompatible with the option avec_certains_bords"<<finl;
205 for (
int b=0; b<noms_des_bords.size(); b++)
210 IntArrView face_bord_int = tab_face_bord_int.view_rw();
211 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(deb, fin), KOKKOS_LAMBDA(
const int f)
215 end_gpu_timer(__KERNEL_NAME__);
220 ParserView parser_condition_faces(condition_faces);
222 CDoubleTabView xv = domaine_vf.
xv().view_ro();
223 CIntTabView face_voisin = domaine_vf.
face_voisins().view_ro();
224 CIntArrView face_bord_int = tab_face_bord_int.view_ro();
225 IntArrView marq = tab_marq.view_rw();
226 Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), nb_faces, KOKKOS_LAMBDA(
const int fac,
int& local_nb_t)
228 int elem0=face_voisin(fac,0);
229 int elem1=face_voisin(fac,1);
231 if (elem0!=-1) val0=marq_elem(elem0);
233 if (elem1!=-1) val1=marq_elem(elem1);
237 if (((val0*val1==0)&&(val0+val1==1))||((val0==1)&&(face_bord_int[fac]==1))||((val1==1)&&(face_bord_int[fac]==1)))
240 int threadId = parser_condition_faces.
acquire();
241 parser_condition_faces.
setVar(0,xv(fac,0),threadId);
242 parser_condition_faces.
setVar(1,xv(fac,1),threadId);
244 parser_condition_faces.
setVar(2,xv(fac,2),threadId);
245 double res=parser_condition_faces.
eval(threadId);
246 parser_condition_faces.
release(threadId);
247 if (std::fabs(res)>1e-5)
257 end_gpu_timer(__KERNEL_NAME__);
259 ArrOfInt tab_indices(nb_faces);
260 IntArrView indices = tab_indices.view_wo();
261 Kokkos::parallel_scan(start_gpu_timer(__KERNEL_NAME__), nb_faces, KOKKOS_LAMBDA(
const int fac,
int& update,
const bool final)
265 if (
final) indices(fac) = update;
269 end_gpu_timer(__KERNEL_NAME__);
271 Cerr<<
"Number of elements of the new domain : "<<nb_t<<finl;
272 CIntTabView face_sommets = domaine_vf.
face_sommets().view_ro();
273 int nb_sommet_face=(int)face_sommets.extent(1);
274 IntTab& tab_les_elems=domaine_surfacique.
les_elems();
275 tab_les_elems.
resize(nb_t,nb_sommet_face);
277 IntTabView les_elems = tab_les_elems.
view_wo();
278 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_faces, KOKKOS_LAMBDA(
const int fac)
282 int nb = indices(fac);
283 double normal[3] = {0., 0., 0.} , normal_b[3], point0b[3], point1b[3], point2b[3];
284 int el1 = face_voisin(fac, 0);
285 if (el1 == -1) el1 = face_voisin(fac, 1);
286 if (marq_elem(el1) != 1)
287 el1 = face_voisin(fac, 1);
288 for (
int i = 0; i < dim; i++)
289 normal[i] = xv(fac, i) - xp(el1, i);
290 for (
int s = 0; s < nb_sommet_face; s++)
291 les_elems(nb, s) = face_sommets(fac, s);
293 if (nb_sommet_face > 1)
297 for (
int i = 0; i < 3; i++)
299 point0b[i] = coord(les_elems(nb, 0), i);
300 point1b[i] = coord(les_elems(nb, 1), i);
301 point2b[i] = coord(les_elems(nb, 2), i);
303 calcul_normal(point0b, point1b, point2b, normal_b);
304 double dot_product=0;
305 for (
int i = 0; i < dim; i++)
306 dot_product+=normal[i]*normal_b[i];
310 les_elems(nb, 1) = face_sommets(fac, 2);
311 les_elems(nb, 2) = face_sommets(fac, 1);
316 for (
int i = 0; i < nb_sommet_face; i++)
317 point0b[i] = coord(les_elems(nb, 1), i) - coord(les_elems(nb, 0), i);
318 double produit = normal[0] * point0b[1] - normal[1] * point0b[0];
322 les_elems(nb, 0) = face_sommets(fac, 1);
323 les_elems(nb, 1) = face_sommets(fac, 0);
329 end_gpu_timer(__KERNEL_NAME__);
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
creation d'un tableau parallele de valeurs aux elements.
void typer(const Nom &)
Type les elements du domaine avec le nom passe en parametre.
int_t nb_som_tot() const
Renvoie le nombre total de sommets du domaine i.e. le nombre de sommets reels et virtuels sur le proc...
int face_sommets(int i, int j) const
renvoie le numero du ieme sommet de la face num_face.
Frontiere_dis_base & frontiere_dis(int) override
renvoie la ieme frontiere_discrete.
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
void nommer(const Nom &nom) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.