22 #ifdef KRATOS_INDEPENDENT
69 template<
class TConfiguration>
78 typedef typename TConfiguration::data_type
data_type;
89 static constexpr std::size_t
DIMENSION = TConfiguration::DIMENSION;
90 static constexpr std::size_t
MAX_LEVEL = TConfiguration::MAX_LEVEL;
92 static constexpr std::size_t
MIN_LEVEL = TConfiguration::MIN_LEVEL;
118 if (data_) configuration_type::DeleteData(data_);
128 configuration_type::DeleteData(data_);
142 char next_level = ( char)( level_ - 1);
143 key_type level_bit = 1 << next_level;
144 return (((x_key & level_bit) >> next_level) + (((y_key & level_bit) >> next_level) << 1) + (((z_key & level_bit) >> next_level) << 2));
155 char next_level = ( char)( level_ - 1);
158 children_[
i].
SetMinKey(min_key_[0] | ((
i & 1) << next_level), min_key_[1] | (((
i & 2) >> 1)) << next_level, min_key_[2] | (((
i & 4) >> 2)) << next_level);
167 min_point[
i] = GetCoordinateNormalized(min_key_[
i]);
172 double size = CalcSizeNormalized();
174 max_point[
i] = GetCoordinateNormalized(min_key_[
i]) + size;
180 if (min_key_[0] >= 1) {
181 keys[0] = min_key_[0] - 1;
182 keys[1] = min_key_[1];
183 keys[2] = min_key_[2];
191 keys[0] = min_key_[0] + (
static_cast<key_type>(1) << level_);
192 keys[1] = min_key_[1];
193 keys[2] = min_key_[2];
201 if (min_key_[1] >= 1) {
202 keys[0] = min_key_[0];
203 keys[1] = min_key_[1] - 1;
204 keys[2] = min_key_[2];
212 keys[0] = min_key_[0];
213 keys[1] = min_key_[1] + (
static_cast<key_type>(1) << level_);
214 keys[2] = min_key_[2];
222 if (min_key_[2] >= 1) {
223 keys[0] = min_key_[0];
224 keys[1] = min_key_[1];
225 keys[2] = min_key_[2] - 1;
233 keys[0] = min_key_[0];
234 keys[1] = min_key_[1];
235 keys[2] = min_key_[2] + (
static_cast<key_type>(1) << level_);
245 const std::size_t x_position[] = {0, 2, 2, 0, 0, 2, 2, 0, 1, 1, 2, 1, 0, 0, 2, 2, 0, 1, 2, 1, 0, 1, 1, 2, 1, 0, 1};
246 const std::size_t y_position[] = {0, 0, 2, 2, 0, 0, 2, 2, 1, 0, 1, 2, 1, 0, 0, 2, 2, 0, 1, 2, 1, 1, 0, 1, 2, 1, 1};
247 const std::size_t z_position[] = {0, 0, 0, 0, 2, 2, 2, 2, 1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 1, 1, 1, 1, 2};
249 keys[0] = min_key_[0] + ((x_position[position]) << (level_ - 1));
250 keys[1] = min_key_[1] + ((y_position[position]) << (level_ - 1));
251 keys[2] = min_key_[2] + ((z_position[position]) << (level_ - 1));
277 assert(direction<18);
278 const std::size_t x_offset[]={0,2,1,1,1,1,0,2,0,2,0,2,0,2,1,1,1,1};
279 const std::size_t y_offset[]={1,1,0,2,1,1,0,0,2,2,1,1,1,1,0,2,0,2};
280 const std::size_t z_offset[]={1,1,1,1,0,2,1,1,1,1,0,0,2,2,0,0,2,2};
281 const std::size_t x_coef[] ={0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0};
282 const std::size_t y_coef[] ={0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1};
283 const std::size_t z_coef[] ={0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,1,1};
285 std::size_t size = (1<<level_);
288 keys[0] = min_key_[0] + x_offset[direction] + x_coef[direction] * size;
289 keys[1] = min_key_[1] + y_offset[direction] + y_coef[direction] * size;
290 keys[2] = min_key_[2] + z_offset[direction] + z_coef[direction] * size;
310 keys[0] += (direction & 1) << 1;
311 keys[1] += (direction & 2);
312 keys[2] += (direction & 4) >> 1;
332 const std::size_t local_index[]={0, 9, 1,12,21,10, 3,11, 2,13,22,14,25, 8,23,16,24,15, 4,17, 5,20,26,18, 7,19,6};
336 position[
i] = (
keys[
i] - min_key_[
i]) >> (level_-1);
338 std::size_t index = position[0] + position[1] * 3 + position[2] * 9;
355 return local_index[index];
361 objects_.push_back(
object);
366 if (!objects_.size())
return;
370 double min_coord[3]={0.00, 0.00, 0.00};
371 double max_coord[3]={0.00, 0.00, 0.00};
382 for (
int j=0;
j<(
int)objects_.size();
j++){
385 const int is_intersected = configuration_type::IsIntersected(
object,tolerance, min_coord, max_coord);
410 min_key_x = min_key_[0];
411 min_key_y = min_key_[1];
412 min_key_z = min_key_[2];
416 min_key_[0] = min_key_x;
417 min_key_[1] = min_key_y;
418 min_key_[2] = min_key_z;
422 return children_[pos];
426 return children_ + pos;
472 return (children_ == NULL);
476 return (children_ != NULL);
485 virtual std::string
Info()
const {
486 return "OctreeBinaryCell";
495 rOStream <<
Info() <<
" at level " <<
static_cast<int> (level_);
501 rOStream <<
"(" << GetCoordinateNormalized(min_key_[0]) <<
"," << GetCoordinateNormalized(min_key_[1]) <<
"," << GetCoordinateNormalized(min_key_[2]) <<
"),";
502 rOStream <<
"(" << GetCoordinateNormalized(min_key_[0]) + CalcSizeNormalized() <<
"," << GetCoordinateNormalized(min_key_[1]) + CalcSizeNormalized() <<
"," << GetCoordinateNormalized(min_key_[2]) + CalcSizeNormalized() <<
")" << std::endl;
510 rOStream <<
"child #" <<
i;
577 double CalcSizeNormalized()
const {
578 const double scale = 1.00 / (1 <<
ROOT_LEVEL);
580 return (1 << level_) * scale;
583 double GetCoordinateNormalized(
key_type key)
const {
584 const double scale = 1.00 / (1 <<
ROOT_LEVEL);
586 return static_cast<double>(key * scale);
645 template<
class TConfiguration>
This class represents a cell in an octree to be used with Octree class.
Definition: octree_binary_cell.h:70
OctreeBinaryCell * GetChildren()
Definition: octree_binary_cell.h:433
static constexpr std::size_t DIMENSION
Definition: octree_binary_cell.h:89
std::size_t GetLocalPosition(key_type *keys)
Definition: octree_binary_cell.h:327
OctreeBinaryCell & rGetChild(std::size_t pos) const
Definition: octree_binary_cell.h:421
std::vector< pointer_type > * pGetObjects()
Definition: octree_binary_cell.h:456
int GetFrontKey(key_type *keys) const
Definition: octree_binary_cell.h:210
static constexpr std::size_t ROOT_LEVEL
Definition: octree_binary_cell.h:91
void TransferObjectsToSonsNormalized()
Definition: octree_binary_cell.h:364
void DeleteData()
Definition: octree_binary_cell.h:126
const std::vector< pointer_type > * pGetObjects() const
Definition: octree_binary_cell.h:451
void Insert(pointer_type object)
Definition: octree_binary_cell.h:360
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: octree_binary_cell.h:491
TConfiguration configuration_type
Definition: octree_binary_cell.h:80
virtual ~OctreeBinaryCell()
Destructor.
Definition: octree_binary_cell.h:116
void EmptyObjects()
Definition: octree_binary_cell.h:461
int GetTopKey(key_type *keys) const
Definition: octree_binary_cell.h:231
bool IsLeaf() const
Definition: octree_binary_cell.h:471
OctreeBinaryCell(char Level=ROOT_LEVEL)
Default constructor.
Definition: octree_binary_cell.h:109
int SubdivideCell()
Definition: octree_binary_cell.h:147
TConfiguration::pointer_type pointer_type
Definition: octree_binary_cell.h:82
static constexpr std::size_t CHILDREN_NUMBER
Definition: octree_binary_cell.h:88
bool HasChildren() const
Definition: octree_binary_cell.h:475
static constexpr std::size_t MIN_LEVEL
Definition: octree_binary_cell.h:92
std::vector< pointer_type > object_container_type
Definition: octree_binary_cell.h:84
void DeleteChildren()
Definition: octree_binary_cell.h:122
void GetMinKey(key_type &min_key_x, key_type &min_key_y, key_type &min_key_z) const
Definition: octree_binary_cell.h:409
std::size_t key_type
Definition: octree_binary_cell.h:86
data_type * pGetData() const
Definition: octree_binary_cell.h:441
@ LEFT
Definition: octree_binary_cell.h:95
@ BACK
Definition: octree_binary_cell.h:97
@ FRONT
Definition: octree_binary_cell.h:98
@ BOTTOM
Definition: octree_binary_cell.h:99
@ RIGHT
Definition: octree_binary_cell.h:96
@ TOP
Definition: octree_binary_cell.h:100
OctreeBinaryCell const * GetChildren() const
Definition: octree_binary_cell.h:437
int GetKey(std::size_t position, key_type *keys) const
Definition: octree_binary_cell.h:241
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: octree_binary_cell.h:500
int GetNeighbourKey(std::size_t position, std::size_t direction, key_type *keys) const
Definition: octree_binary_cell.h:305
int GetNeighbourKey(std::size_t direction, key_type *keys) const
Definition: octree_binary_cell.h:265
int GetRightKey(key_type *keys) const
Definition: octree_binary_cell.h:189
char SetLevel(char level)
Definition: octree_binary_cell.h:404
data_type ** pGetDataPointer()
Definition: octree_binary_cell.h:446
OctreeBinaryCell * pGetChild(key_type x_key, key_type y_key, key_type z_key) const
Definition: octree_binary_cell.h:429
static constexpr std::size_t MAX_LEVEL
Definition: octree_binary_cell.h:90
TConfiguration::data_type data_type
Pointer definition of OctreeBinaryCell.
Definition: octree_binary_cell.h:78
unsigned char GetLevel() const
Definition: octree_binary_cell.h:400
int GetBackKey(key_type *keys) const
Definition: octree_binary_cell.h:199
void GetMinPointNormalized(double *min_point) const
Definition: octree_binary_cell.h:165
int GetBottomKey(key_type *keys) const
Definition: octree_binary_cell.h:220
std::size_t GetChildIndex(key_type x_key, key_type y_key, key_type z_key) const
Definition: octree_binary_cell.h:141
void GetMaxPointNormalized(double *max_point) const
Definition: octree_binary_cell.h:171
int GetLeftKey(key_type *keys) const
Definition: octree_binary_cell.h:178
virtual std::string Info() const
Turn back information as a string.
Definition: octree_binary_cell.h:485
OctreeBinaryCell * pGetChild(std::size_t pos) const
Definition: octree_binary_cell.h:425
void SetMinKey(key_type min_key_x, key_type min_key_y, key_type min_key_z)
Definition: octree_binary_cell.h:415
pybind11::list keys(Parameters const &self)
Definition: add_kratos_parameters_to_python.cpp:32
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
integer i
Definition: TensorModule.f:17