10 #if !defined(KRATOS_GENERATE_NEW_NODES_MESHER_PROCESS_H_INCLUDED )
11 #define KRATOS_GENERATE_NEW_NODES_MESHER_PROCESS_H_INCLUDED
70 : mrModelPart(rModelPart),
71 mrRemesh(rRemeshingParameters)
102 std::cout<<
" [ GENERATE NEW NODES: "<<std::endl;
105 std::cout<<
" ModelPart Supplied do not corresponds to the Meshing Domain: ("<<mrModelPart.
Name()<<
" != "<<mrRemesh.
SubModelPartName<<
")"<<std::endl;
110 std::vector<NodeType::Pointer > list_of_new_nodes;
112 this->GenerateNewNodes(mrModelPart, list_of_new_nodes);
115 std::cout <<
" [ GENERATED NODES: ( added: " << mrRemesh.
Info->InsertedNodes <<
" ) ]"<<std::endl;
119 if( list_of_new_nodes.size() > 0)
120 this->ProjectVariablesToNewNodes( mrModelPart, list_of_new_nodes );
123 for(std::vector<NodeType::Pointer>::iterator it = list_of_new_nodes.begin(); it!=list_of_new_nodes.end(); ++it)
125 this->SetNewNodeVariables(mrModelPart,(*it));
129 this->SetNodesToModelPart(mrModelPart, list_of_new_nodes);
132 std::cout<<
" GENERATE NEW NODES ]; "<<std::endl;
154 std::string
Info()
const override
156 return "GenerateNewNodesMesherProcess";
162 rOStream <<
"GenerateNewNodesMesherProcess";
206 void GenerateNewNodes(
ModelPart& rModelPart, std::vector<NodeType::Pointer>& list_of_nodes)
210 NodeType::Pointer pNode;
224 ModelPart::ElementsContainerType::iterator element_begin = rModelPart.
ElementsBegin();
225 const unsigned int dimension = element_begin->GetGeometry().WorkingSpaceDimension();
233 if (OutNumberOfPoints > InNumberOfPoints)
235 for(
int i = InNumberOfPoints;
i<OutNumberOfPoints; ++
i)
239 xc = OutPointList[base];
240 yc = OutPointList[base+1];
243 zc=OutPointList[base+2];
246 pNode = Kratos::make_intrusive<Node>(
id,
xc,
yc, zc );
257 pNode->SetSolutionStepVariablesList(&rVariablesList);
263 for(Node::DofsContainerType::iterator i_dof = ReferenceDofs.begin(); i_dof != ReferenceDofs.end(); ++i_dof)
268 (pNewDof)->FreeDof();
271 list_of_nodes.push_back(pNode);
281 mrRemesh.
Info->InsertedNodes = OutNumberOfPoints-InNumberOfPoints;
290 void ProjectVariablesToNewNodes(ModelPart& rModelPart, std::vector<NodeType::Pointer >& list_of_new_nodes)
297 typedef Node::Pointer PointPointerType;
303 typedef Bucket<3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType;
304 typedef Tree< KDTreePartition<BucketType> > KdtreeType;
307 unsigned int bucket_size = 20;
308 KdtreeType NodesTree(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
312 std::vector<double> ShapeFunctionsN;
313 std::vector<VariablesListDataValueContainer> VariablesListVector(list_of_new_nodes.size());
315 VariablesList& rVariablesList = rModelPart.GetNodalSolutionStepVariablesList();
319 Node center(0,0.0,0.0,0.0);
321 unsigned int MaximumNumberOfPointsInRadius = list_of_new_nodes.size();
322 std::vector<Node::Pointer> PointsInRadius (MaximumNumberOfPointsInRadius);
323 std::vector<double> PointsInRadiusDistances (MaximumNumberOfPointsInRadius);
326 ModelPart::ElementsContainerType::iterator element_begin = rModelPart.ElementsBegin();
327 const unsigned int nds = element_begin->GetGeometry().size();
329 std::vector<std::vector<double> > ElementPointCoordinates(nds);
330 std::vector<double> PointCoordinates(3);
331 std::fill( PointCoordinates.begin(), PointCoordinates.end(), 0.0 );
332 std::fill( ElementPointCoordinates.begin(), ElementPointCoordinates.end(), PointCoordinates );
334 for(ModelPart::ElementsContainerType::const_iterator ie = rModelPart.ElementsBegin();
335 ie != rModelPart.ElementsEnd(); ++ie)
339 for(
unsigned int i=0;
i<ie->GetGeometry().size(); ++
i)
341 PointCoordinates[0] = ie->GetGeometry()[
i].X();
342 PointCoordinates[1] = ie->GetGeometry()[
i].Y();
343 PointCoordinates[2] = ie->GetGeometry()[
i].Z();
345 ElementPointCoordinates[
i] = PointCoordinates;
348 std::fill( PointCoordinates.begin(), PointCoordinates.end(), 0.0 );
349 MeshDataTransferUtilities DataTransferUtilities;
350 DataTransferUtilities.CalculateCenterAndSearchRadius( ElementPointCoordinates, PointCoordinates,
radius );
353 center.X() = PointCoordinates[0];
354 center.Y() = PointCoordinates[1];
355 center.Z() = PointCoordinates[2];
357 double Radius =
radius * 1.01;
358 int NumberOfPointsInRadius = NodesTree.SearchInRadius (center, Radius, PointsInRadius.begin(), PointsInRadiusDistances.begin(), MaximumNumberOfPointsInRadius);
362 for(std::vector<Node::Pointer>::iterator it_found = PointsInRadius.begin(); it_found != (PointsInRadius.begin() + NumberOfPointsInRadius) ; ++it_found)
365 PointCoordinates[0] = (*it_found)->X();
366 PointCoordinates[1] = (*it_found)->Y();
367 PointCoordinates[2] = (*it_found)->Z();
371 if(is_inside ==
true)
374 DataTransferUtilities.Interpolate( ie->GetGeometry(), ShapeFunctionsN, rVariablesList, *(it_found),
alpha );
387 virtual void SetNewNodeVariables(ModelPart& rModelPart, NodeType::Pointer& pNode)
392 pNode->SetValue(MODEL_PART_NAME,rModelPart.Name());
395 const array_1d<double,3>& Displacement = pNode->FastGetSolutionStepValue(DISPLACEMENT);
396 pNode->X0() = pNode->X() - Displacement[0];
397 pNode->Y0() = pNode->Y() - Displacement[1];
398 pNode->Z0() = pNode->Z() - Displacement[2];
401 if ( pNode->SolutionStepsDataHas(CONTACT_FORCE) )
402 pNode->FastGetSolutionStepValue(CONTACT_FORCE).clear();
412 void SetNodesToModelPart(ModelPart& rModelPart, std::vector<NodeType::Pointer>& list_of_nodes)
416 if(list_of_nodes.size()){
419 for(std::vector<NodeType::Pointer>::iterator i_node = list_of_nodes.begin(); i_node!= list_of_nodes.end(); ++i_node)
421 rModelPart.Nodes().push_back(*(i_node));
478 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
Dof * Pointer
Pointer definition of Dof.
Definition: dof.h:93
Refine Mesh Elements Process 2D and 3D.
Definition: generate_new_nodes_mesher_process.hpp:49
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: generate_new_nodes_mesher_process.hpp:86
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: generate_new_nodes_mesher_process.hpp:97
virtual ~GenerateNewNodesMesherProcess()
Destructor.
Definition: generate_new_nodes_mesher_process.hpp:78
ConditionType::GeometryType GeometryType
Definition: generate_new_nodes_mesher_process.hpp:60
KRATOS_CLASS_POINTER_DEFINITION(GenerateNewNodesMesherProcess)
Pointer definition of Process.
GenerateNewNodesMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: generate_new_nodes_mesher_process.hpp:67
void PrintData(std::ostream &rOStream) const override
Print object's data.s.
Definition: generate_new_nodes_mesher_process.hpp:166
ModelPart::NodeType NodeType
Definition: generate_new_nodes_mesher_process.hpp:57
std::string Info() const override
Turn back information as a string.
Definition: generate_new_nodes_mesher_process.hpp:154
ModelPart::PropertiesType PropertiesType
Definition: generate_new_nodes_mesher_process.hpp:59
ModelPart::ConditionType ConditionType
Definition: generate_new_nodes_mesher_process.hpp:58
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: generate_new_nodes_mesher_process.hpp:160
Geometry base class.
Definition: geometry.h:71
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
static bool CalculatePosition(const std::vector< std::vector< double >> &rPointCoordinates, const std::vector< double > &rCenter, std::vector< double > &rShapeFunctionsN)
Definition: mesher_utilities.hpp:1272
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
std::string & Name()
Definition: model_part.h:1811
IndexType GetBufferSize() const
This method gets the suffer size of the model part database.
Definition: model_part.h:1876
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Holds a list of variables and their position in VariablesListDataValueContainer.
Definition: variables_list.h:50
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
DistanceVector::iterator DistanceIterator
Definition: internal_variables_interpolation_process.h:56
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
PointVector::iterator PointIterator
Definition: internal_variables_interpolation_process.h:54
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
float radius
Definition: mesh_to_mdpa_converter.py:18
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
integer i
Definition: TensorModule.f:17
int & GetNumberOfPoints()
Definition: mesher_utilities.hpp:182
double * GetPointList()
Definition: mesher_utilities.hpp:177
Definition: mesher_utilities.hpp:631
MeshingInfoParameters::Pointer Info
Definition: mesher_utilities.hpp:681
MeshContainer InMesh
Definition: mesher_utilities.hpp:674
MeshContainer OutMesh
Definition: mesher_utilities.hpp:675
bool InputInitializedFlag
Definition: mesher_utilities.hpp:661
std::string SubModelPartName
Definition: mesher_utilities.hpp:642
std::vector< int > NodalPreIds
Definition: mesher_utilities.hpp:668
unsigned int NodeMaxId
Definition: mesher_utilities.hpp:666