16#ifndef NbCasesParNoeuds
17#define NbCasesParNoeuds 512
20#include <TRUSTVects.h>
26template <
typename _SIZE_>
31 is << finl <<
"--------------------------------" << finl;
32 is <<
"level: " <<
niveau() <<
" size: " <<
taille() << finl;
33 for(i=0; i<nb_octrees; i++)
43template <
typename _SIZE_>
49template <
typename _SIZE_>
82 case GaucheArriereBas:
90 case GaucheArriereHaut:
106 case GaucheAvantHaut:
114 case DroitArriereBas:
122 case DroitArriereHaut:
163 if( (x<xmil) && (y<ymil) && (z<zmil))
164 return GaucheArriereBas;
165 if( (x<xmil) && (y<ymil) && !(z<zmil))
166 return GaucheArriereHaut;
167 if( (x<xmil) && !(y<ymil) && (z<zmil))
168 return GaucheAvantBas;
169 if( (x<xmil) && !(y<ymil) && !(z<zmil))
170 return GaucheAvantHaut;
171 if( !(x<xmil) && (y<ymil) && (z<zmil))
172 return DroitArriereBas;
173 if( !(x<xmil) && (y<ymil) && !(z<zmil))
174 return DroitArriereHaut;
175 if( !(x<xmil) && !(y<ymil) && (z<zmil))
176 return DroitAvantBas;
177 if( !(x<xmil) && !(y<ymil) && !(z<zmil))
178 return DroitAvantHaut;
180 Cerr <<
"Error in OctreeLoc::direction" << finl;
194template <
typename _SIZE_>
213 element =
les_octrees[i]->rang_elem_loc(loci, x, y, z);
216 element =
les_octrees[0]->rang_elem_loc(loc, x, y, z);
230template <
typename _SIZE_>
249 element =
les_octrees[i]->rang_elem_depuis_loc(loci, prems, x, y, z);
252 element =
les_octrees[0]->rang_elem_depuis_loc(loc, prems, x, y, z);
257template <
typename _SIZE_>
261 for(
int som=0; som<nb_som_elem; som++)
263 int_t sommet=les_elems(i,som);
265 if(coord(sommet,0)<xmil)
267 if(!ok[GaucheArriereBas])
269 SousTab[GaucheArriereBas][compteur[GaucheArriereBas]]=i;
270 compteur[GaucheArriereBas]++;
271 ok[GaucheArriereBas]=1;
276 if(!ok[DroitArriereBas])
278 SousTab[DroitArriereBas][compteur[DroitArriereBas]]=i;
279 compteur[DroitArriereBas]++;
280 ok[DroitArriereBas]=1;
289template <
typename _SIZE_>
290inline void range2D(
double x,
double y,
double xmil,
double ymil,
291 ArrOfInt& ok,
TRUST_Vector<IntTab_T<_SIZE_>>& SousTab, SmallArrOfTID_T<_SIZE_>& compteur, _SIZE_ i)
297 if(!ok[GaucheArriereBas])
299 SousTab[GaucheArriereBas][compteur[GaucheArriereBas]]=i;
300 compteur[GaucheArriereBas]++;
301 ok[GaucheArriereBas]=1;
306 if(!ok[GaucheAvantBas])
308 SousTab[GaucheAvantBas][compteur[GaucheAvantBas]]=i;
309 compteur[GaucheAvantBas]++;
310 ok[GaucheAvantBas]=1;
318 if(!ok[DroitArriereBas])
320 SousTab[DroitArriereBas][compteur[DroitArriereBas]]=i;
321 compteur[DroitArriereBas]++;
322 ok[DroitArriereBas]=1;
327 if(!ok[DroitAvantBas])
329 SousTab[DroitAvantBas][compteur[DroitAvantBas]]=i;
330 compteur[DroitAvantBas]++;
337template <
typename _SIZE_>
338inline void range3D(
double x,
double y,
double z,
339 double xmil,
double ymil,
double zmil,
340 ArrOfInt& ok,
TRUST_Vector<IntTab_T<_SIZE_>>& SousTab, SmallArrOfTID_T<_SIZE_>& compteur, _SIZE_ i)
348 if(!ok[GaucheArriereBas])
350 SousTab[GaucheArriereBas][compteur[GaucheArriereBas]]=i;
351 compteur[GaucheArriereBas]++;
352 ok[GaucheArriereBas]=1;
357 if(!ok[GaucheArriereHaut])
359 SousTab[GaucheArriereHaut][compteur[GaucheArriereHaut]]=i;
360 compteur[GaucheArriereHaut]++;
361 ok[GaucheArriereHaut]=1;
369 if(!ok[GaucheAvantBas])
371 SousTab[GaucheAvantBas][compteur[GaucheAvantBas]]=i;
372 compteur[GaucheAvantBas]++;
373 ok[GaucheAvantBas]=1;
378 if(!ok[GaucheAvantHaut])
380 SousTab[GaucheAvantHaut][compteur[GaucheAvantHaut]]=i;
381 compteur[GaucheAvantHaut]++;
382 ok[GaucheAvantHaut]=1;
393 if(!ok[DroitArriereBas])
395 SousTab[DroitArriereBas][compteur[DroitArriereBas]]=i;
396 compteur[DroitArriereBas]++;
397 ok[DroitArriereBas]=1;
402 if(!ok[DroitArriereHaut])
404 SousTab[DroitArriereHaut][compteur[DroitArriereHaut]]=i;
405 compteur[DroitArriereHaut]++;
406 ok[DroitArriereHaut]=1;
414 if(!ok[DroitAvantBas])
416 SousTab[DroitAvantBas][compteur[DroitAvantBas]]=i;
417 compteur[DroitAvantBas]++;
423 if(!ok[DroitAvantHaut])
425 SousTab[DroitAvantHaut][compteur[DroitAvantHaut]]=i;
426 compteur[DroitAvantHaut]++;
427 ok[DroitAvantHaut]=1;
437template <
typename _SIZE_>
441 double xmin=DMAXFLOAT, xmax=-DMAXFLOAT;
442 double ymin=xmin, ymax=xmax;
443 for(
int som=0; som<nb_som_elem; som++)
445 int_t sommet=elems(idx,som);
450 xmin=std::min(xmin, coord(sommet,0));
451 xmax=std::max(xmax, coord(sommet,0));
452 ymin=std::min(ymin, coord(sommet,1));
453 ymax=std::max(ymax, coord(sommet,1));
456 range2D(xmin, ymin, xmil, ymil, ok, SousTab, compteur, idx);
457 range2D(xmin, ymax, xmil, ymil, ok, SousTab, compteur, idx);
458 range2D(xmax, ymin, xmil, ymil, ok, SousTab, compteur, idx);
459 range2D(xmax, ymax, xmil, ymil, ok, SousTab, compteur, idx);
462template <
typename _SIZE_>
467 double xmin=DMAXFLOAT, xmax=-DMAXFLOAT;
468 double ymin=xmin, ymax=xmax;
469 double zmin=xmin, zmax=xmax;
470 for(
int som=0; som<nb_som_elem; som++)
472 int_t sommet=elems(idx,som);
477 xmin=std::min(xmin, coord(sommet,0))-epsilon;
478 xmax=std::max(xmax, coord(sommet,0))+epsilon;
479 ymin=std::min(ymin, coord(sommet,1))-epsilon;
480 ymax=std::max(ymax, coord(sommet,1))+epsilon;
481 zmin=std::min(zmin, coord(sommet,2))-epsilon;
482 zmax=std::max(zmax, coord(sommet,2))+epsilon;
485 range3D(xmin, ymin, zmin, xmil, ymil, zmil, ok, SousTab, compteur, idx);
486 range3D(xmin, ymax, zmin, xmil, ymil, zmil, ok, SousTab, compteur, idx);
487 range3D(xmax, ymin, zmin, xmil, ymil, zmil, ok, SousTab, compteur, idx);
488 range3D(xmax, ymax, zmin, xmil, ymil, zmil, ok, SousTab, compteur, idx);
489 range3D(xmin, ymin, zmax, xmil, ymil, zmil, ok, SousTab, compteur, idx);
490 range3D(xmin, ymax, zmax, xmil, ymil, zmil, ok, SousTab, compteur, idx);
491 range3D(xmax, ymin, zmax, xmil, ymil, zmil, ok, SousTab, compteur, idx);
492 range3D(xmax, ymax, zmax, xmil, ymil, zmil, ok, SousTab, compteur, idx);
502template <
typename _SIZE_>
514 <<
" nb_elem=" << nb_elem << finl;
518 if(nb_elem<=NbCasesParNoeuds)
520 for(
int i=0; i<nb_octrees; i++)
533 for(
int i=0; i<nb_octrees; i++)
534 SousTab[i].resize(nb_elem);
538 ArrOfInt ok(nb_octrees);
539 for(
int_t elem=0; elem<nb_elem; elem++)
549 les_elems, compteur, SousTab, xmil);
553 les_elems, compteur, SousTab, xmil, ymil);
557 les_elems, compteur, SousTab, xmil, ymil, zmil);
565 for(
int i=0; i<nb_octrees; i++)
570 SousTab[i].
resize(compteur[i]);
571 if(compteur[i]==nb_elem)
573 else if(compteur[i]>NbCasesParNoeuds)
575 else if(compteur[i]!=0)
587template <
typename _SIZE_>
593 for(
int i=0; i<nb_octrees; i++)
601template <
typename _SIZE_>
605 if (
pere==0)
return i;
606 return (
pere->niveau()+1);
614template <
typename _SIZE_>
619 for(
int i=0; i<nb_octrees; i++)
626template <
typename _SIZE_>
637 double min[3] = { 1e30, 1e30, 1e30 };
638 double max[3] = {-1e30,-1e30,-1e30 };
645 for (
int_t i = 0; i < n; i++)
647 for (
int j = 0; j < 3; j++)
662 loc.ymax = 2. * M_PI;
685 for(
int_t i=0; i<nb_elem; i++)
688 Cerr <<
"Construction of the OctreeRoot OK " << finl;
701template <
typename _SIZE_>
710 for(
int i=0; i<nb_som_elem; i++)
716 Cerr <<
"This is not a mesh !" << finl;
724 if(std::fabs(dom.
coord(sommet,0)-x)<epsilon)
728 if((std::fabs(dom.
coord(sommet,0)-x)<epsilon) &&
729 (std::fabs(dom.
coord(sommet,1)-y)<epsilon))
733 if((std::fabs(dom.
coord(sommet,0)-x)<epsilon) &&
734 (std::fabs(dom.
coord(sommet,1)-y)<epsilon) &&
735 (std::fabs(dom.
coord(sommet,2)-z)<epsilon))
739 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_sommet" << finl;
759template <
typename _SIZE_>
765 if (elem>=elem_aretes.
dimension(0))
return -2;
766 if (elem != -1 && elem<elem_aretes.
dimension(0))
773 for(
int i=0; i<nb_aretes_elem; i++)
777 int_t arete=elem_aretes(elem,i);
778 int_t s0=aretes_som(arete,0);
779 int_t s1=aretes_som(arete,1);
783 if((std::fabs(0.5*(coord(s0,0)+coord(s1,0))-x)<epsilon) &&
784 (std::fabs(0.5*(coord(s0,1)+coord(s1,1))-y)<epsilon) &&
785 (std::fabs(0.5*(coord(s0,2)+coord(s1,2))-z)<epsilon))
789 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_elem" << finl;
807template <
typename _SIZE_>
811 if( (x<
loc.xmin-epsilon) || (y<
loc.ymin-epsilon) || (z<
loc.zmin-epsilon)
812 || (x>
loc.xmax+epsilon) || (y>
loc.ymax+epsilon) || (z>
loc.zmax+epsilon) )
825template <
typename _SIZE_>
829 if( (x<
loc.xmin-epsilon) || (y<
loc.ymin-epsilon) || (z<
loc.zmin-epsilon)
830 || (x>
loc.xmax+epsilon) || (y>
loc.ymax+epsilon) || (z>
loc.zmax+epsilon) )
843template <
typename _SIZE_>
849 for(
int i=0; i<sz; i++)
851 double x=0, y=0, z=0;
867 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_sommet" << finl;
883template <
typename _SIZE_>
889 for(
int i=0; i<sz; i++)
891 double x=0, y=0, z=0;
907 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_arete" << finl;
922template <
typename _SIZE_>
927 elems.resize_array(sz);
928 for(
int i=0; i<sz; i++)
930 double x=0, y=0, z=0;
946 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_elem" << finl;
962template <
typename _SIZE_>
967 elems.resize_array(sz);
968 for(
int i=0; i<sz; i++)
970 double x=0, y=0, z=0;
986 Cerr <<
"Error in OctreeRoot_32_64<_SIZE_>::rang_elem_depuis" << finl;
1002template <
typename _SIZE_>
1005 std::vector<int_t> els;
1022 for(
int j=0; j<i; j++)
1023 elements[j] = els[j];
1031template <
typename _SIZE_>
1034 if((!le_dom)||(
valid_!=1))
1041template <
typename _SIZE_>
1046 Cerr <<
"Invalidation of the Octree" << finl;
1061template <
typename _SIZE_>
1071 for (
int_t ielem = 0; ielem < sz; ielem++)
1095template <
typename _SIZE_>
1106 while((ielem < sz) && !trouve)
1111 if(element >= prems)
1131template <
typename _SIZE_>
1149template <
typename _SIZE_>
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
int_t nb_elem_tot() const
const DoubleTab_t & coord_sommets() const
double coord(int_t i, int j) const
int_t sommet_elem(int_t i, int j) const
Returns the (global) number of the j-th vertex of the i-th element.
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,...
Base class for TRUST objects (Objet_U).
Octree_32_64 ** les_octrees
int_t rang_elem_depuis_loc(const OctreeLoc &, int_t prems, double x, double y=0, double z=0) const override
Octree_32_64< _SIZE_ > Octree_t
ArrOfInt_T< _SIZE_ > ArrOfInt_t
OctreeFloor_32_64(Octree_t *mon_pere, const ArrOfInt_t &val, const OctreeLoc &loc)
void construire(Octree_t *, const ArrOfInt_t &, const OctreeLoc &)
int_t taille() const override
Returns the size of the octree.
int_t rang_elem_loc(const OctreeLoc &, double x, double y=0, double z=0) const override
int_t rang_sommet(double x, double y=0, double z=0) const
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
int_t rang_elem(double x, double y=0, double z=0) const
int_t rang_elem_depuis(int_t prems, double x, double y=0, double z=0) const
IntTab_T< _SIZE_ > IntTab_t
void construire(int reel=0)
void rang_elems_sommet(SmallArrOfTID_t &, double x, double y=0, double z=0) const
int construit() const
Returns true if the domain associated with the octree is non-null.
ArrOfInt_T< _SIZE_ > ArrOfInt_t
int_t rang_arete(double x, double y=0, double z=0) const
const Domaine_t & domaine() const override
DoubleTab_T< _SIZE_ > DoubleTab_t
Domaine_32_64< _SIZE_ > Domaine_t
Octree_32_64 ** les_octrees
void detruire()
Destroys the octree.
virtual int_t rang_elem_depuis_loc(const OctreeLoc &, int_t prems, double x, double y=0, double z=0) const
DoubleTab_T< _SIZE_ > DoubleTab_t
virtual int_t taille() const
Returns the size of the octree.
void ranger_elem_3D(ArrOfInt &oks, int_t elem, int_t idx, int nb_som_elem, const DoubleTab_t &coords_som, const IntTab_t &les_elems, SmallArrOfTID_t &compteur, Vect_IntTab_t &sous_tab, double xmil, double ymil, double zmil)
IntTab_T< _SIZE_ > IntTab_t
virtual int_t rang_elem_loc(const OctreeLoc &, double x, double y=0, double z=0) const
TRUST_Vector< IntTab_t > Vect_IntTab_t
static int nombre_d_octrees()
ArrOfInt_T< _SIZE_ > ArrOfInt_t
void ranger_elem_1D(ArrOfInt &oks, int_t elem, int_t idx, int nb_som_elem, const DoubleTab_t &coords_som, const IntTab_t &les_elems, SmallArrOfTID_t &compteur, Vect_IntTab_t &sous_tab, double xmil)
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
void construire(int, const ArrOfInt_t &, const OctreeLoc &, Octree_t *p=0)
double get_epsilon() const
virtual Sortie & printOn(Sortie &is) const
void ranger_elem_2D(ArrOfInt &oks, int_t elem, int_t idx, int nb_som_elem, const DoubleTab_t &coords_som, const IntTab_t &les_elems, SmallArrOfTID_t &compteur, Vect_IntTab_t &sous_tab, double xmil, double ymil)
virtual Entree & readOn(Entree &is)
virtual const Domaine_t & domaine() const
Domaine_32_64< _SIZE_ > Domaine_t
Octree_32_64< _SIZE_ > Octree_t
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
int dimension_int(int d) const
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
void construire(const OctreeLoc &loc, int i)
int direction(double x, double y, double z) const