10 #if !defined(KRATOS_SPLIT_ELEMENTS_PROCESS_H_INCLUDED)
11 #define KRATOS_SPLIT_ELEMENTS_PROCESS_H_INCLUDED
80 : mrModelPart(rModelPart)
101 std::cout <<
" Execute() in SplitElementsProcess" << std::endl;
121 std::string
Info()
const override
123 return "SplitElementsProcess";
129 rOStream <<
"SplitElementsProcess";
140 if ((i_mp->Is(ACTIVE) && i_mp->Is(SOLID)) || (i_mp->Is(ACTIVE) && i_mp->Is(FLUID)))
143 std::string ComputingModelPartName;
144 ComputingModelPartName = i_mp->Name();
149 double criticalVolume = 0.5 * modelPartVolume /
double(rComputingModelPart.
Elements().size());
151 for (ElementsContainerType::iterator i_elem = rComputingModelPart.
Elements().begin(); i_elem != rComputingModelPart.
Elements().end(); i_elem++)
153 unsigned int numFreeSurface = 0;
154 unsigned int numRigid = 0;
156 const unsigned int numNodes = i_elem->GetGeometry().
size();
157 for (
unsigned int i = 0;
i < numNodes;
i++)
159 if (vertices[
i].
Is(FREE_SURFACE) || vertices[
i].
Is(ISOLATED))
163 else if (vertices[
i].
Is(RIGID))
171 double elementalVolume = i_elem->GetGeometry().Area();
175 if (numRigid > 0 && numFreeSurface == 0 && vertices.
size() > 2 && elementalVolume > criticalVolume)
177 i_elem->Set(ACTIVE,
false);
181 i_elem->Set(ACTIVE,
true);
186 std::cout <<
"split_element_process not yet implemented for quadratic elements" << std::endl;
191 double elementalVolume = 0;
192 if (i_elem->GetGeometry().WorkingSpaceDimension() == 3)
193 elementalVolume = i_elem->GetGeometry().Volume();
196 if (numRigid == 0 && (numRigid + numFreeSurface) == vertices.
size() && vertices.
size() > 3 && elementalVolume > criticalVolume)
198 i_elem->Set(ACTIVE,
false);
202 i_elem->Set(ACTIVE,
true);
207 std::cout <<
"split_element_process not yet implemented for quadratic elements" << std::endl;
212 for (ElementsContainerType::iterator i_elem = rComputingModelPart.
Elements().begin(); i_elem != rComputingModelPart.
Elements().end(); i_elem++)
214 if (i_elem->IsNot(ACTIVE))
217 bool addedNode =
false;
219 if (addedNode ==
true)
221 unsigned int rElementId = 0;
222 ModelPart::PropertiesType::Pointer pProp = i_elem->pGetProperties();
228 Element::Pointer newElement = i_elem->Create(rElementId, firstGeom, pProp);
229 newElement->Set(ACTIVE,
true);
230 newElement->Set(FLUID);
231 newElement->Set(TO_ERASE);
232 newElement->Initialize(rCurrentProcessInfo);
237 newElement = i_elem->Create(rElementId, secondGeom, pProp);
238 newElement->Set(ACTIVE,
true);
239 newElement->Set(FLUID);
240 newElement->Set(TO_ERASE);
241 newElement->Initialize(rCurrentProcessInfo);
246 newElement = i_elem->Create(rElementId, thirdGeom, pProp);
247 newElement->Set(ACTIVE,
true);
248 newElement->Set(FLUID);
249 newElement->Set(TO_ERASE);
250 newElement->Initialize(rCurrentProcessInfo);
258 Element::Pointer newElement = i_elem->Create(rElementId, firstGeom, pProp);
259 newElement->Set(ACTIVE,
true);
260 newElement->Set(FLUID);
261 newElement->Set(TO_ERASE);
262 newElement->Initialize(rCurrentProcessInfo);
267 newElement = i_elem->Create(rElementId, secondGeom, pProp);
268 newElement->Set(ACTIVE,
true);
269 newElement->Set(FLUID);
270 newElement->Set(TO_ERASE);
271 newElement->Initialize(rCurrentProcessInfo);
276 newElement = i_elem->Create(rElementId, thirdGeom, pProp);
277 newElement->Set(ACTIVE,
true);
278 newElement->Set(FLUID);
279 newElement->Set(TO_ERASE);
280 newElement->Initialize(rCurrentProcessInfo);
285 newElement = i_elem->Create(rElementId, fourthGeom, pProp);
286 newElement->Set(ACTIVE,
true);
287 newElement->Set(FLUID);
288 newElement->Set(TO_ERASE);
289 newElement->Initialize(rCurrentProcessInfo);
295 i_elem->Set(ACTIVE,
true);
305 rComputingModelPart.
Nodes().Unique();
306 rComputingModelPart.
Elements().Unique();
315 template <
class TDataType>
320 while (
i != endit && (
i)->Id() != (candidate)->Id())
326 v.push_back(candidate);
331 ElementsContainerType::iterator i_elem,
336 unsigned int numNodes = vertices.
size();
337 std::vector<std::vector<double>> ElementPointCoordinates(numNodes);
338 std::vector<double> PointCoordinates(3);
340 unsigned int masterNode = 0;
341 for (
unsigned int i = 0;
i < vertices.
size();
i++)
343 rPoint += vertices[
i].Coordinates() /
double(numNodes);
344 PointCoordinates[0] = vertices[
i].X();
345 PointCoordinates[1] = vertices[
i].Y();
346 PointCoordinates[2] = vertices[
i].Z();
347 ElementPointCoordinates[
i] = PointCoordinates;
348 if (vertices[
i].
IsNot(RIGID))
353 PointCoordinates[0] = rPoint[0];
354 PointCoordinates[1] = rPoint[1];
355 PointCoordinates[2] = rPoint[2];
358 ModelPart::NodeType::Pointer newNode = i_mp->CreateNewNode(rNodeId, rPoint[0], rPoint[1], rPoint[2]);
363 for (ModelPart::NodeType::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
367 (p_new_dof)->FreeDof();
371 std::vector<double> ShapeFunctionsN;
372 VariablesList &variables_list = i_mp->GetNodalSolutionStepVariablesList();
375 newNode->SetSolutionStepVariablesList(vertices[masterNode].pGetVariablesList());
378 newNode->SetBufferSize(vertices[masterNode].GetBufferSize());
380 newNode->Reset(FREE_SURFACE);
381 bool is_inside =
false;
383 if (is_inside ==
true)
386 DataTransferUtilities.
Interpolate(i_elem->GetGeometry(), ShapeFunctionsN, variables_list, newNode,
alpha);
387 newNode->Set(TO_ERASE);
388 newNode->Set(ACTIVE);
391 newNode->X0() = newNode->X() - displacement[0];
392 newNode->Y0() = newNode->Y() - displacement[1];
393 newNode->Z0() = newNode->Z() - displacement[2];
396 for (
unsigned int spn = 0; spn < numNodes; spn++)
398 this->AddUniquePointer<Node>(rN, i_elem->GetGeometry()(spn));
401 i_mp->Nodes().push_back(newNode);
419 temporal_nodes.reserve(mrModelPart.
Nodes().size());
420 temporal_nodes.swap(mrModelPart.
Nodes());
421 mrModelPart.
Nodes().clear();
423 for (NodesContainerType::iterator i_node = temporal_nodes.begin(); i_node != temporal_nodes.end(); i_node++)
425 if (i_node->IsNot(TO_ERASE))
427 (mrModelPart.
Nodes()).push_back(*(i_node.base()));
430 mrModelPart.
Nodes().Sort();
433 temporal_elements.reserve(mrModelPart.
Elements().size());
434 temporal_elements.swap(mrModelPart.
Elements());
436 for (ElementsContainerType::iterator i_elem = temporal_elements.begin(); i_elem != temporal_elements.end(); i_elem++)
438 if (i_elem->IsNot(TO_ERASE))
440 (mrModelPart.
Elements()).push_back(*(i_elem.base()));
533 rOStream << std::endl;
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
Short class definition.
Definition: mesh_data_transfer_utilities.hpp:46
void Interpolate(Geometry< Node > &geom, const std::vector< double > &N, VariablesList &rVariablesList, Node::Pointer pnode, double alpha=1.0)
Definition: mesh_data_transfer_utilities.cpp:1435
Short class definition.
Definition: mesher_utilities.hpp:49
double ComputeModelPartVolume(ModelPart &rModelPart)
Definition: mesher_utilities.cpp:228
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
static unsigned int GetMaxElementId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1481
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
SubModelPartIterator SubModelPartsEnd()
Definition: model_part.h:1708
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Definition: pointer_vector.h:255
The base class for all processes in Kratos.
Definition: process.h:49
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: process.h:210
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Short class definition.
Definition: split_elements_process.hpp:65
void AddUniquePointer(GlobalPointersVector< TDataType > &v, const typename TDataType::WeakPointer candidate)
Definition: split_elements_process.hpp:316
SplitElementsProcess(ModelPart &rModelPart, int EchoLevel)
Default constructor.
Definition: split_elements_process.hpp:78
std::string Info() const override
Turn back information as a string.
Definition: split_elements_process.hpp:121
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: split_elements_process.hpp:127
KRATOS_CLASS_POINTER_DEFINITION(SplitElementsProcess)
Pointer definition of SplitElementsProcess.
void operator()()
Definition: split_elements_process.hpp:90
void ExecuteInitialize() override
This function is designed for being called at the beginning of the computations right after reading t...
Definition: split_elements_process.hpp:132
void ExecuteFinalize() override
This function is designed for being called at the end of the computations.
Definition: split_elements_process.hpp:413
ModelPart::NodeType::Pointer CreateAndAddNewNodeToSubModelPart(ModelPart::SubModelPartIterator i_mp, ElementsContainerType::iterator i_elem, PointsArrayType vertices, bool &addedNode)
Definition: split_elements_process.hpp:330
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: split_elements_process.hpp:99
virtual ~SplitElementsProcess()
Destructor.
Definition: split_elements_process.hpp:86
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
A three node 2D triangle geometry with linear shape functions.
Definition: triangle_2d_3.h:74
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
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:60
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:59
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
ModelPart::ElementsContainerType ElementsContainerType
Definition: clear_contact_conditions_mesher_process.hpp:43
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
GeometryType::PointsArrayType PointsArrayType
Definition: settle_model_structure_process.hpp:48
v
Definition: generate_convection_diffusion_explicit_element.py:114
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
integer i
Definition: TensorModule.f:17