10 #if !defined(KRATOS_SPHERE_BOUNDING_BOX_H_INCLUDED )
11 #define KRATOS_SPHERE_BOUNDING_BOX_H_INCLUDED
83 std::cout<<
"Calling Rigid Sphere Wall BBX empty constructor" <<std::endl;
100 "center": [0.0, 0.0, 0.0],
104 "velocity": [0.0, 0.0, 0.0]
112 if(CustomParameters[
"parameters_list"].IsArray() ==
true && CustomParameters[
"parameters_list"].size() != 1)
119 Parameters BoxParameters = CustomParameters[
"parameters_list"][0];
162 std::cout<<
" [--CIRCLE/SPHERE WALL--] "<<std::endl;
169 std::cout<<
" [Radius:"<<
mBox.
Radius<<std::endl;
170 std::cout<<
" [Center:"<<
mBox.
Center<<std::endl;
171 std::cout<<
" [--------] "<<std::endl;
231 bool is_inside =
false;
236 SphereRadius *= 1.25;
239 SphereRadius *= 0.75;
256 bool is_inside =
false;
281 if ( fabs(Normal(2)) > 1
e-5) {
282 rT1(2) = (-pow(Normal(0),2) - pow(Normal(1),2) ) / Normal(2);
285 rT1(0) = 0; rT1(1) = 0; rT1(2) = 1;
289 rT2(0) = Normal(1) * rT1(2) - Normal(2)*rT1(1);
290 rT2(1) = -Normal(0) * rT1(2) + Normal(2)*rT1(0);
291 rT2(2) = Normal(0) * rT1(1) - Normal(1)*rT1(0);
306 unsigned int NodeId = 0;
312 unsigned int InitialNodeId = NodeId;
315 std::vector<std::string> BoundaryModelPartsName;
323 if( i_mp->Is(BOUNDARY) || i_mp->Is(ACTIVE) ){
324 for(ModelPart::NodesContainerType::iterator i_node = i_mp->NodesBegin() ; i_node != i_mp->NodesEnd() ; ++i_node)
326 if( i_node->Id() == rModelPart.
Nodes().front().Id() ){
327 BoundaryModelPartsName.push_back(i_mp->Name());
354 std::vector<PointType> FacePoints;
356 for(
int k=0;
k<=angular_partitions;
k++)
358 alpha = (3.14159262 *
k)/(
double)angular_partitions;
361 RotationAxis = DirectionX *
alpha;
364 RotatedDirectionY = DirectionY;
372 FacePoints.push_back(BasePoint);
375 unsigned int size = FacePoints.
size();
377 for(
int k=1;
k<=angular_partitions;
k++)
379 alpha = (2 * 3.14159262 *
k)/((
double)angular_partitions+1);
382 RotationAxis = DirectionY *
alpha;
385 for(
unsigned int j=1;
j<size-1;
j++)
395 FacePoints.push_back(BasePoint);
401 for(
unsigned int i=0;
i<FacePoints.size();
i++)
408 NodeType::Pointer pNode = this->
CreateNode(rModelPart, FacePoints[
i], NodeId);
410 pNode->Set(RIGID,
true);
415 for(
unsigned int j=0;
j<BoundaryModelPartsName.size();
j++)
416 (pMainModelPart->
GetSubModelPart(BoundaryModelPartsName[
j])).AddNode( pNode );
444 virtual std::string
Info()
const override
446 return "SphereBoundingBox";
450 virtual void PrintInfo(std::ostream& rOStream)
const override
456 virtual void PrintData(std::ostream& rOStream)
const override
505 double GapNormal = 0;
507 GapNormal = (-1) *
norm_2(rPoint - Projection);
510 GapNormal =
norm_2(Projection - rPoint);
553 rGapNormal = (-1) *
norm_2(rPoint - Projection);
556 rGapNormal =
norm_2(Projection - rPoint);
588 if( i_mp->Is(ACTIVE) )
594 if( i_mp->Is(ACTIVE) )
600 unsigned int ElementId = 0;
608 GeometryType::Pointer pFace;
609 ElementType::Pointer pElement;
613 Properties::Pointer pProperties = Kratos::make_shared<Properties>(number_of_properties);
616 matrix<int> Connectivities(angular_partitions+2,angular_partitions+1);
618 for(
unsigned int i=0;
i<=angular_partitions;
i++)
620 Connectivities(
i,0) = 1;
622 for(
unsigned int j=1;
j<=angular_partitions;
j++)
629 Connectivities(
i,angular_partitions) = angular_partitions+1;
630 for(
unsigned int j=1;
j<angular_partitions;
j++)
638 for(
unsigned int i=0;
i<=angular_partitions;
i++)
640 Connectivities(angular_partitions+1,
i) = Connectivities(0,
i);
647 for(
unsigned int i=0;
i<=angular_partitions;
i++ )
651 FaceNodesIds[0] = rInitialNodeId + Connectivities(
i,0) ;
652 FaceNodesIds[1] = rInitialNodeId + Connectivities(
i,1);
653 FaceNodesIds[2] = rInitialNodeId + Connectivities(
i+1,1);
662 for(
unsigned int j=0;
j<3;
j++)
667 pFace = Kratos::make_shared<Triangle3D3<NodeType> >( FaceNodes );
668 pElement = Kratos::make_intrusive<Element>(ElementId, pFace, pProperties);
671 pElement->Set(ACTIVE,
false);
672 pComputingModelPart->AddElement(pElement);
677 for(
unsigned int i=1;
i<angular_partitions-1;
i++)
679 for(
unsigned int k=0;
k<=angular_partitions;
k++ )
683 FaceNodesIds[0] = rInitialNodeId + Connectivities(
k,
i);
684 FaceNodesIds[1] = rInitialNodeId + Connectivities(
k,
i+1);
685 FaceNodesIds[2] = rInitialNodeId + Connectivities(
k+1,
i+1);
686 FaceNodesIds[3] = rInitialNodeId + Connectivities(
k+1,
i);
695 for(
unsigned int j=0;
j<4;
j++)
700 pFace = Kratos::make_shared<Quadrilateral3D4<NodeType> >(FaceNodes);
701 pElement = Kratos::make_intrusive<Element>(ElementId, pFace, pProperties);
704 pElement->Set(ACTIVE,
false);
705 pComputingModelPart->AddElement(pElement);
711 for(
unsigned int i=0;
i<=angular_partitions;
i++ )
715 FaceNodesIds[0] = rInitialNodeId + Connectivities(
i,angular_partitions-1);
716 FaceNodesIds[1] = rInitialNodeId + Connectivities(
i,angular_partitions);
717 FaceNodesIds[2] = rInitialNodeId + Connectivities(
i+1,angular_partitions-1);
726 for(
unsigned int j=0;
j<3;
j++)
732 pFace = Kratos::make_shared<Triangle3D3<NodeType>>(FaceNodes);
733 pElement = Kratos::make_intrusive<Element>(ElementId, pFace, pProperties);
736 pElement->Set(ACTIVE,
false);
737 pComputingModelPart->AddElement(pElement);
Base class for all Elements.
Definition: element.h:60
Geometry base class.
Definition: geometry.h:71
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
SubModelPartIterator SubModelPartsEnd()
Definition: model_part.h:1708
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
SizeType NumberOfProperties(IndexType ThisIndex=0) const
Returns the number of properties of the mesh.
Definition: model_part.cpp:575
bool IsSubModelPart() const
Definition: model_part.h:1893
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
NodeType::Pointer pGetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:421
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
void AddElement(ElementType::Pointer pNewElement, IndexType ThisIndex=0)
Definition: model_part.cpp:917
ModelPart & GetParentModelPart()
Definition: model_part.cpp:2124
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
const std::string PrettyPrintJsonString() const
This method returns a string with the corresponding text to the equivalent *.json file (this version ...
Definition: kratos_parameters.cpp:415
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void reserve(size_type dim)
Definition: pointer_vector.h:319
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
void RotateVector3(const TVector3_A &a, TVector3_B &b) const
Definition: quaternion.h:325
static Quaternion FromRotationVector(double rx, double ry, double rz)
Definition: quaternion.h:427
Short class definition.
Definition: spatial_bounding_box.hpp:48
bool mRigidBodyCenterSupplied
Definition: spatial_bounding_box.hpp:1150
void CalculateOrthonormalBase(PointType &rDirectionVectorX, PointType &rDirectionVectorY, PointType &rDirectionVectorZ)
Definition: spatial_bounding_box.hpp:1408
void ComputeContactTangent(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo)
Definition: spatial_bounding_box.hpp:1274
NodeType::Pointer CreateNode(ModelPart &rModelPart, PointType &rPoint, const unsigned int &rNodeId)
Definition: spatial_bounding_box.hpp:1357
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1314
static unsigned int GetMaxElementId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1334
BoundingBoxVariables mBox
Definition: spatial_bounding_box.hpp:1152
virtual SpatialBoundingBox & operator=(SpatialBoundingBox const &rOther)
Assignment operator.
Definition: spatial_bounding_box.hpp:540
Short class definition.
Definition: sphere_bounding_box.hpp:57
virtual void GetParametricDirections(BoundingBoxParameters &rValues, Vector &rT1, Vector &rT2) override
Definition: sphere_bounding_box.hpp:269
bool IsInside(const PointType &rPoint, double &rCurrentTime, double Radius=0) override
Definition: sphere_bounding_box.hpp:226
SphereBoundingBox & operator=(SphereBoundingBox const &rOther)
Assignment operator.
Definition: sphere_bounding_box.hpp:186
SphereBoundingBox(Parameters CustomParameters)
Definition: sphere_bounding_box.hpp:92
SphereBoundingBox(SphereBoundingBox const &rOther)
Copy constructor.
Definition: sphere_bounding_box.hpp:200
bool ContactSearch(const PointType &rPoint, const double &rRadius)
Definition: sphere_bounding_box.hpp:494
bool ContactSearch(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo)
Definition: sphere_bounding_box.hpp:530
Quaternion< double > QuaternionType
Definition: sphere_bounding_box.hpp:70
ModelPart::NodesContainerType NodesContainerType
Definition: sphere_bounding_box.hpp:68
NodesContainerType::Pointer NodesContainerTypePointer
Definition: sphere_bounding_box.hpp:69
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: sphere_bounding_box.hpp:456
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: sphere_bounding_box.hpp:450
void CreateBoundingBoxBoundaryMesh(ModelPart &rModelPart, int linear_partitions=4, int angular_partitions=4) override
Definition: sphere_bounding_box.hpp:300
virtual std::string Info() const override
Turn back information as a string.
Definition: sphere_bounding_box.hpp:444
SphereBoundingBox()
Default constructor.
Definition: sphere_bounding_box.hpp:79
ModelPart::NodeType NodeType
Definition: sphere_bounding_box.hpp:67
ModelPart::ElementType ElementType
Definition: sphere_bounding_box.hpp:71
array_1d< double, 3 > PointType
Definition: sphere_bounding_box.hpp:66
bool IsInside(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: sphere_bounding_box.hpp:252
KRATOS_CLASS_POINTER_DEFINITION(SphereBoundingBox)
Pointer definition of SphereBoundingBox.
virtual ~SphereBoundingBox()
Destructor.
Definition: sphere_bounding_box.hpp:210
ElementType::GeometryType GeometryType
Definition: sphere_bounding_box.hpp:72
void CreateSphereBoundaryMesh(ModelPart &rModelPart, const unsigned int &rInitialNodeId, const unsigned int &angular_partitions)
Definition: sphere_bounding_box.hpp:576
SphereBoundingBox(PointType Center, double Radius, PointType Velocity, int Convexity)
Definition: sphere_bounding_box.hpp:154
BOOST_UBLAS_INLINE size_type size() const
Definition: array_1d.h:370
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
Definition: spatial_bounding_box.hpp:61
void SetContactFace(int ContactFace)
Definition: spatial_bounding_box.hpp:178
PointType & GetTangent()
Definition: spatial_bounding_box.hpp:189
double & GetGapNormal()
Definition: spatial_bounding_box.hpp:193
const PointType & GetPoint()
Definition: spatial_bounding_box.hpp:181
PointType & GetNormal()
Definition: spatial_bounding_box.hpp:188
int Convexity
Definition: spatial_bounding_box.hpp:210
PointType Velocity
Definition: spatial_bounding_box.hpp:221
PointType LowerPoint
Definition: spatial_bounding_box.hpp:218
double Radius
Definition: spatial_bounding_box.hpp:211
void Initialize()
Definition: spatial_bounding_box.hpp:229
PointType Center
Definition: spatial_bounding_box.hpp:219
PointType UpperPoint
Definition: spatial_bounding_box.hpp:217
void SetInitialValues()
Definition: spatial_bounding_box.hpp:253