64 std::fill(mMinValues.begin(), mMinValues.end(),
static_cast<double>(INT_MAX));
65 std::fill(mMaxValues.begin(), mMaxValues.end(), -
static_cast<double>(INT_MAX));
72 bool is_inside =
true;
75 double v = NormalCoordinate(
i, r_point[0], r_point[1], r_point[2]);
76 is_inside &= ((
v >= mMinValues[
i] - tolerance) && (
v <= mMaxValues[
i] + tolerance));
96 if( (mMaxValues[
i] <= rOther.
MinValues()[
i] - tolerance) || (mMinValues[
i] >= rOther.
MaxValues()[
i] + tolerance) )
103 if(
mode != 0 && test_tangent)
107 if( !(mMaxValues[
i] >= rOther.
MinValues()[
i] + tolerance) && !(mMinValues[
i] <= rOther.
MaxValues()[
i] - tolerance) )
119 void InsertPoint(
const double& rX,
const double& rY,
const double& rZ)
123 double v = NormalCoordinate(
i, rX, rY, rZ);
124 if(
v < mMinValues[
i])
126 if(
v > mMaxValues[
i])
132 template<
bool current_configuration>
135 for(std::size_t
i = 0;
i < rGeometry.
size(); ++
i)
137 if(current_configuration)
146 this->
InsertPoint(rGeometry[
i].X0(), rGeometry[
i].Y0(), rGeometry[
i].Z0());
154 if( (rBV1.
GetType() != this->GetType()) || (rBV2.
GetType() != this->GetType()) )
181 const std::vector<double>&
MinValues()
const {
return mMinValues;}
182 const std::vector<double>&
MaxValues()
const {
return mMaxValues;}
187 std::size_t longest_axis = 0;
191 double tmp = fabs(mMaxValues[
i] - mMinValues[
i]);
232 rB(2 *
i) = mMaxValues[
i];
237 rB(2 *
i + 1) = -mMinValues[
i];
243 rOStream << this->
GetType() <<
"-DOP:";
245 rOStream <<
" (" << mMinValues[
i] <<
", " << mMaxValues[
i] <<
")";
249 std::vector<double> mMinValues;
250 std::vector<double> mMaxValues;
253 double NormalCoordinate(
int i,
const double& rX,
const double& rY,
const double& rZ)
const
255 return rX * Direction()[
i][0] + rY * Direction()[
i][1] + rZ * Direction()[
i][2];
383 const kDOP& rBoundingVolume,
395 unsigned int n = rGeometry.
size();
397 for(std::size_t
i = 0;
i <
n; ++
i)
402 C[0] += rGeometry[
i].X();
403 C[1] += rGeometry[
i].Y();
404 C[2] += rGeometry[
i].Z();
422 const kDOP& rBoundingVolume,
436 const kDOP& rBoundingVolume,
462 mpBV = kDOP::Pointer(
new _6DOP());
464 mpBV = kDOP::Pointer(
new _8DOP());
466 mpBV = kDOP::Pointer(
new _12DOP());
468 mpBV = kDOP::Pointer(
new _14DOP());
470 mpBV = kDOP::Pointer(
new _18DOP());
472 mpBV = kDOP::Pointer(
new _20DOP());
474 mpBV = kDOP::Pointer(
new _26DOP());
484 mGeometryIds.clear();
488 if(rAllConditions.
size() < 2)
493 rPartitioner.
Partition(rAllConditions, *mpBV, ChildSet1, ChildSet2);
496 if( (ChildSet1.
size() == 0 && ChildSet2.
size() > 0)
497 || (ChildSet1.
size() > 0 && ChildSet2.
size() == 0) )
498 KRATOS_THROW_ERROR(std::logic_error,
"There is something wrong with the partitioning. The size of the two sub-sets must be non-zero concurrently",
"")
500 if(ChildSet1.
size() > 0)
503 mpLeft->BuildTreeTopDown(ChildSet1, rPartitioner);
505 if(ChildSet2.
size() > 0)
508 mpRight->BuildTreeTopDown(ChildSet2, rPartitioner);
519 if((mpLeft != NULL) && (mpRight != NULL))
521 mpLeft->UpdateTree(rAllConditions);
522 mpRight->UpdateTree(rAllConditions);
523 mpBV->SetVolume(mpLeft->GetBoundingVolume(), mpRight->GetBoundingVolume());
528 for(std::set<std::size_t>::iterator it = mGeometryIds.begin(); it != mGeometryIds.end(); ++it)
529 mpBV->InsertGeometry<
true>(rAllConditions(*it)->GetGeometry());
537 mpBV->InsertGeometry<
true>((*it)->GetGeometry());
538 mGeometryIds.insert((*it)->Id());
544 bool IsLeaf()
const {
return (mpLeft == NULL) && (mpRight == NULL);}
548 if(this->
IsLeaf() && mGeometryIds.size() != 1)
554 valid = valid && mpLeft->CheckValidity();
556 valid = valid && mpRight->CheckValidity();
563 return *(mGeometryIds.begin());
572 void Print(std::ostream& rOStream,
unsigned int level)
const
574 mpBV->PrintInfo(rOStream);
575 rOStream <<
", Geometry Id:";
576 for(std::set<std::size_t>::iterator it = mGeometryIds.begin(); it != mGeometryIds.end(); ++it)
577 rOStream <<
" " << *it;
578 rOStream << std::endl;
581 for(
unsigned int i = 0;
i < level; ++
i)
583 rOStream <<
"'->Left branch:";
584 mpLeft->Print(rOStream, level + 1);
588 for(
unsigned int i = 0;
i < level; ++
i)
590 rOStream <<
"'->Right branch:";
591 mpRight->Print(rOStream, level + 1);
598 BoundingVolumeTree::Pointer mpLeft;
599 BoundingVolumeTree::Pointer mpRight;
601 std::set<std::size_t> mGeometryIds;
Definition: bounding_volume_tree.h:296
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:303
_12DOP()
Definition: bounding_volume_tree.h:301
~_12DOP() override
Definition: bounding_volume_tree.h:302
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:298
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:299
KRATOS_CLASS_POINTER_DEFINITION(_12DOP)
Definition: bounding_volume_tree.h:310
KRATOS_CLASS_POINTER_DEFINITION(_14DOP)
_14DOP()
Definition: bounding_volume_tree.h:315
~_14DOP() override
Definition: bounding_volume_tree.h:316
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:317
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:313
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:312
Definition: bounding_volume_tree.h:324
_18DOP()
Definition: bounding_volume_tree.h:329
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:326
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:327
~_18DOP() override
Definition: bounding_volume_tree.h:330
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:331
KRATOS_CLASS_POINTER_DEFINITION(_18DOP)
Definition: bounding_volume_tree.h:338
~_20DOP() override
Definition: bounding_volume_tree.h:344
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:345
KRATOS_CLASS_POINTER_DEFINITION(_20DOP)
_20DOP()
Definition: bounding_volume_tree.h:343
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:340
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:341
Definition: bounding_volume_tree.h:352
KRATOS_CLASS_POINTER_DEFINITION(_26DOP)
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:359
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:354
~_26DOP() override
Definition: bounding_volume_tree.h:358
_26DOP()
Definition: bounding_volume_tree.h:357
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:355
Definition: bounding_volume_tree.h:267
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:269
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:270
~_6DOP() override
Definition: bounding_volume_tree.h:273
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:274
KRATOS_CLASS_POINTER_DEFINITION(_6DOP)
_6DOP()
Definition: bounding_volume_tree.h:272
Definition: bounding_volume_tree.h:282
~_8DOP() override
Definition: bounding_volume_tree.h:288
std::size_t NumberOfDirections() const override
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:289
kDOP::ArrayType ArrayType
Definition: bounding_volume_tree.h:284
kDOP::Array2DType Array2DType
Definition: bounding_volume_tree.h:285
KRATOS_CLASS_POINTER_DEFINITION(_8DOP)
_8DOP()
Definition: bounding_volume_tree.h:287
Definition: bounding_volume_tree.h:371
KRATOS_CLASS_POINTER_DEFINITION(BoundingVolumePartitioner)
BoundingVolumePartitioner()
Definition: bounding_volume_tree.h:374
Node NodeType
Definition: bounding_volume_tree.h:378
NodeType::PointType PointType
Definition: bounding_volume_tree.h:380
void ComputeCentroid(GeometryType &rGeometry, double C[3])
Definition: bounding_volume_tree.h:390
~BoundingVolumePartitioner()
Definition: bounding_volume_tree.h:375
Geometry< NodeType > GeometryType
Definition: bounding_volume_tree.h:379
virtual void Partition(ConditionsContainerType &rAllConditions, const kDOP &rBoundingVolume, ConditionsContainerType &rOutputSet1, ConditionsContainerType &rOutputSet2)
Definition: bounding_volume_tree.h:382
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: bounding_volume_tree.h:377
Definition: bounding_volume_tree.h:453
const BoundingVolumeTree & GetRightTree() const
Definition: bounding_volume_tree.h:569
const BoundingVolumeTree & GetLeftTree() const
Definition: bounding_volume_tree.h:566
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: bounding_volume_tree.h:457
KRATOS_CLASS_POINTER_DEFINITION(BoundingVolumeTree)
virtual ~BoundingVolumeTree()
Definition: bounding_volume_tree.h:479
const kDOP & GetBoundingVolume() const
Definition: bounding_volume_tree.h:542
BoundingVolumeTree::Pointer pGetRightTree() const
Definition: bounding_volume_tree.h:570
BoundingVolumeTree(int type)
Definition: bounding_volume_tree.h:459
BoundingVolumeTree::Pointer pGetLeftTree() const
Definition: bounding_volume_tree.h:567
void UpdateTree(ConditionsContainerType &rAllConditions)
Definition: bounding_volume_tree.h:517
void BuildTreeTopDown(ConditionsContainerType &rAllConditions, BoundingVolumePartitioner &rPartitioner)
Definition: bounding_volume_tree.h:482
void Print(std::ostream &rOStream, unsigned int level) const
Definition: bounding_volume_tree.h:572
std::size_t GetFirstGeometryId() const
Definition: bounding_volume_tree.h:561
void UpdateTree(ModelPart &r_model_part)
Definition: bounding_volume_tree.h:512
bool IsLeaf() const
Definition: bounding_volume_tree.h:544
bool CheckValidity() const
Definition: bounding_volume_tree.h:546
void AddGeometryFromConditions(ConditionsContainerType &rAllConditions)
Definition: bounding_volume_tree.h:533
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Definition: bounding_volume_tree.h:429
void Partition(ConditionsContainerType &rAllConditions, const kDOP &rBoundingVolume, ConditionsContainerType &rOutputSet1, ConditionsContainerType &rOutputSet2) override
Definition: bounding_volume_tree.cpp:47
~LineRegressionVolumePartitioner()
Definition: bounding_volume_tree.h:433
LineRegressionVolumePartitioner()
Definition: bounding_volume_tree.h:432
KRATOS_CLASS_POINTER_DEFINITION(LineRegressionVolumePartitioner)
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ptr_iterator ptr_end()
Returns an iterator pointing to the end of the underlying data container.
Definition: pointer_vector_set.h:404
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
typename TContainerType::iterator ptr_iterator
Definition: pointer_vector_set.h:104
Definition: bounding_volume_tree.h:415
void Partition(ConditionsContainerType &rAllConditions, const kDOP &rBoundingVolume, ConditionsContainerType &rOutputSet1, ConditionsContainerType &rOutputSet2) override
REF: https://github.com/brandonpelfrey/Fast-BVH.
Definition: bounding_volume_tree.cpp:68
SimpleBoundingVolumePartitioner()
Definition: bounding_volume_tree.h:418
~SimpleBoundingVolumePartitioner()
Definition: bounding_volume_tree.h:419
KRATOS_CLASS_POINTER_DEFINITION(SimpleBoundingVolumePartitioner)
Definition: bounding_volume_tree.h:39
const std::vector< double > & MaxValues() const
Definition: bounding_volume_tree.h:182
void InsertPoint(const double &rX, const double &rY, const double &rZ)
Add a point to the DOP /// This is mainly used for debugging.
Definition: bounding_volume_tree.h:119
void GetInequalities(Matrix &rM, Vector &rB) const
Definition: bounding_volume_tree.h:218
kDOP()
Definition: bounding_volume_tree.h:49
NodeType::PointType PointType
Definition: bounding_volume_tree.h:45
bool IsInside(const PointType &r_point, double tolerance) const
Definition: bounding_volume_tree.h:70
std::size_t GetLongestAxis() const
Get the longest axis.
Definition: bounding_volume_tree.h:185
KRATOS_CLASS_POINTER_DEFINITION(kDOP)
void PrintInfo(std::ostream &rOStream) const
Definition: bounding_volume_tree.h:241
virtual ~kDOP()
Definition: bounding_volume_tree.h:51
void Initialize()
Initialize the bounding volume to initial state.
Definition: bounding_volume_tree.h:60
void InsertGeometry(const GeometryType &rGeometry)
Add a geometry (from an element/a condition) to the k-DOP.
Definition: bounding_volume_tree.h:133
bool SetVolumeIntersection(const kDOP &rBV1, const kDOP &rBV2, double tolerance)
Set the bounding volume by intersecting two BVs. It will re-initialize all data of this kDOP.
Definition: bounding_volume_tree.h:165
Node NodeType
Definition: bounding_volume_tree.h:43
int TestOverlapped(const kDOP &rOther, double tolerance, bool test_tangent=true) const
Definition: bounding_volume_tree.h:88
const double ArrayType[3]
Definition: bounding_volume_tree.h:46
virtual std::size_t NumberOfDirections() const
Return the number of directions of the k-DOP.
Definition: bounding_volume_tree.h:54
void SetVolume(const kDOP &rBV1, const kDOP &rBV2)
Set the bounding volume by summing up two BVs. It will re-initialize all data of this kDOP.
Definition: bounding_volume_tree.h:152
const double(& Direction(std::size_t i) const)[3]
Get the i'th-direction.
Definition: bounding_volume_tree.h:202
std::size_t GetType() const
Get the type of this k-DOP.
Definition: bounding_volume_tree.h:205
Geometry< NodeType > GeometryType
Definition: bounding_volume_tree.h:44
const std::vector< double > & MinValues() const
Get the respective minimum values and maximum values of this bounding volume.
Definition: bounding_volume_tree.h:181
ArrayType * Array2DType
Definition: bounding_volume_tree.h:47
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: find_conditions_neighbours_process.h:45
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
v
Definition: generate_convection_diffusion_explicit_element.py:114
type
Definition: generate_gid_list_file.py:35
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
test
Definition: run_make_mesh_ethier_benchmark.py:26
string mode
Definition: sensitivityMatrix.py:23
integer i
Definition: TensorModule.f:17