Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Remove push_back from voxel mesher #12956

Draft
wants to merge 5 commits into
base: pvs/remove_push_back/core/model_part
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// Project includes
#include "generate_conditions_with_face_color.h"
#include "includes/model_part.h"

namespace Kratos {

Expand Down Expand Up @@ -45,8 +46,8 @@ void GenerateConditionsWithFaceColor::Generate(ModelPart& rModelPart, Parameters

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

ModelPart::NodesContainerType new_nodes;
ModelPart::ConditionsContainerType new_conditions;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a curiosity but ... is this used at all?

std::vector<ModelPart::ConditionType::Pointer> new_conditions;
auto& r_prototype_condition = KratosComponents<Condition>::Get(
parameters["generated_entity"].GetString());

Expand All @@ -71,8 +72,8 @@ void GenerateConditionsWithFaceColor::Generate(ModelPart& rModelPart, Parameters
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddConditions(new_conditions.begin(), new_conditions.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddConditions(std::move(new_conditions));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void GenerateElementsWithCellColor::Generate(ModelPart& rModelPart, Parameters p

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

ModelPart::NodesContainerType new_nodes;
ModelPart::ElementsContainerType new_elements;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
std::vector<ModelPart::ElementType::Pointer> new_elements;

auto& r_prototype_element = KratosComponents<Element>::Get(
parameters["generated_entity"].GetString());
Expand All @@ -63,8 +63,8 @@ void GenerateElementsWithCellColor::Generate(ModelPart& rModelPart, Parameters p
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddElements(new_elements.begin(), new_elements.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddElements(std::move(new_elements));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void GenerateQuadraticElementsWithCellColor::Generate(ModelPart& rModelPart, Par

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

ModelPart::NodesContainerType new_nodes;
ModelPart::ElementsContainerType new_elements;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
std::vector<ModelPart::ElementType::Pointer> new_elements;

auto& r_prototype_element = KratosComponents<Element>::Get(
parameters["generated_entity"].GetString());
Expand All @@ -65,8 +65,8 @@ void GenerateQuadraticElementsWithCellColor::Generate(ModelPart& rModelPart, Par
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddElements(new_elements.begin(), new_elements.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddElements(std::move(new_elements));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// Project includes
#include "generate_stl_intersection_with_cells.h"
#include <utility>

namespace Kratos {

Expand Down Expand Up @@ -54,8 +55,8 @@ void GenerateStlIntersectionWithCells::Generate(ModelPart& rModelPart, Parameter
parameters["generated_entity"].GetString());
const SkinIntersection& r_intersections = GetIntersections(inside_color);

ModelPart::NodesContainerType new_nodes;
ModelPart::ElementsContainerType new_elements;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
std::vector<ModelPart::ElementType::Pointer> new_elements;

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

Expand All @@ -82,8 +83,8 @@ void GenerateStlIntersectionWithCells::Generate(ModelPart& rModelPart, Parameter
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddElements(new_elements.begin(), new_elements.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddElements(std::move(new_elements));
}

PointerVector<Node> GenerateStlIntersectionWithCells::GenerateCutGeometryNodes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void GenerateTetrahedralElementsWithCellColor::Generate(ModelPart& rModelPart, P

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

ModelPart::NodesContainerType new_nodes;
ModelPart::ElementsContainerType new_elements;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
std::vector<ModelPart::ElementType::Pointer> new_elements;

Element::NodesArrayType cell_nodes(8);
for (std::size_t k = 0; k < number_of_cells[2]; k++) {
Expand All @@ -61,12 +61,12 @@ void GenerateTetrahedralElementsWithCellColor::Generate(ModelPart& rModelPart, P
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddElements(new_elements.begin(), new_elements.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddElements(std::move(new_elements));
}

void GenerateTetrahedralElementsWithCellColor::CreateTetrahedraInCell(
ModelPart::ElementsContainerType& rElements,
std::vector<ModelPart::ElementType::Pointer>& rElements,
Element::NodesArrayType& rCellNodes,
const std::size_t StartId,
Properties::Pointer& pProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GenerateTetrahedralElementsWithCellColor: public VoxelMesherEntityGenerati
private:

void CreateTetrahedraInCell(
ModelPart::ElementsContainerType& rElements,
std::vector<ModelPart::ElementType::Pointer>& rElements,
Element::NodesArrayType& rCellNodes,
const std::size_t StartId,
Properties::Pointer& pProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void GenerateTriangularConditionsWithFaceColor::Generate(ModelPart& rModelPart,

array_1d<std::size_t, 3> number_of_cells = GetNumberOfCells();

ModelPart::NodesContainerType new_nodes;
ModelPart::ConditionsContainerType new_conditions;
std::vector<ModelPart::NodeType::Pointer> new_nodes;
std::vector<ModelPart::ConditionType::Pointer> new_conditions;
auto& r_prototype_condition = KratosComponents<Condition>::Get(
parameters["generated_entity"].GetString());

Expand Down Expand Up @@ -77,8 +77,8 @@ void GenerateTriangularConditionsWithFaceColor::Generate(ModelPart& rModelPart,
}
}

AddNodesToModelPart(rModelPart, new_nodes);
rModelPart.AddConditions(new_conditions.begin(), new_conditions.end());
rModelPart.AddNodes(std::move(new_nodes));
rModelPart.AddConditions(std::move(new_conditions));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// External includes

// Project includes
#include "includes/model_part.h"
#include "utilities/model_part_utils.h"

#include "voxel_mesher_entity_generation.h"
Expand Down Expand Up @@ -108,13 +109,6 @@ bool VoxelMesherEntityGeneration::IntersectionsGenerated(int Color) const {
}


void VoxelMesherEntityGeneration::AddNodesToModelPart(ModelPart& rModelPart, ModelPart::NodesContainerType& rNewNodes) const
{
rNewNodes.Unique();
ModelPartUtils::AddNodesFromOrderedContainer(rModelPart, rNewNodes.begin(), rNewNodes.end());
}


void VoxelMesherEntityGeneration::SetStartIds(ModelPart& rModelPart)
{
mrModeler.SetStartIds(rModelPart);
Expand Down Expand Up @@ -144,7 +138,7 @@ array_1d<std::size_t, 3> VoxelMesherEntityGeneration::GetNumberOfCells() const

Node::Pointer VoxelMesherEntityGeneration::GenerateOrRetrieveNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K)
Expand All @@ -155,7 +149,7 @@ Node::Pointer VoxelMesherEntityGeneration::GenerateOrRetrieveNode(

Node::Pointer VoxelMesherEntityGeneration::GenerateOrRetrieveQuadraticNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K)
Expand All @@ -173,7 +167,7 @@ Node::Pointer VoxelMesherEntityGeneration::GenerateNode(ModelPart& rModelPart, c
void VoxelMesherEntityGeneration::GetLinearCellNodes(
Element::NodesArrayType& rCellNodes,
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K)
Expand All @@ -192,7 +186,7 @@ void VoxelMesherEntityGeneration::GetLinearCellNodes(
void VoxelMesherEntityGeneration::GetQuadraticCellNodes(
Element::NodesArrayType& rCellNodes,
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class KRATOS_API(KRATOS_CORE) VoxelMesherEntityGeneration {

bool IntersectionsGenerated(int Color) const;

void AddNodesToModelPart(ModelPart& rModelPart, ModelPart::NodesContainerType& rNewNodes) const;

void SetStartIds(ModelPart& rModelPart);

std::size_t GetStartElementId() const;
Expand All @@ -81,14 +79,14 @@ class KRATOS_API(KRATOS_CORE) VoxelMesherEntityGeneration {

Node::Pointer GenerateOrRetrieveNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K);

Node::Pointer GenerateOrRetrieveQuadraticNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K);
Expand All @@ -98,15 +96,15 @@ class KRATOS_API(KRATOS_CORE) VoxelMesherEntityGeneration {
void GetLinearCellNodes(
Element::NodesArrayType& rCellNodes,
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K);

void GetQuadraticCellNodes(
Element::NodesArrayType& rCellNodes,
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K);
Expand Down
4 changes: 2 additions & 2 deletions kratos/modeler/voxel_mesh_generator_modeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ModelPart& VoxelMeshGeneratorModeler::CreateAndGetModelPart(std::string const& F

Node::Pointer VoxelMeshGeneratorModeler::GenerateOrRetrieveNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K
Expand All @@ -240,7 +240,7 @@ Node::Pointer VoxelMeshGeneratorModeler::GenerateOrRetrieveNode(

Node::Pointer VoxelMeshGeneratorModeler::GenerateOrRetrieveQuadraticNode(
ModelPart& rTheVolumeModelPart,
ModelPart::NodesContainerType& rThisNodes,
std::vector<ModelPart::NodeType::Pointer>& rThisNodes,
const std::size_t I,
const std::size_t J,
const std::size_t K
Expand Down
4 changes: 2 additions & 2 deletions kratos/modeler/voxel_mesh_generator_modeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ class KRATOS_API(KRATOS_CORE) VoxelMeshGeneratorModeler

void GenerateEntities(ModelPart& rTheVolumeModelPart, Parameters EntityGeneratorParameters);

Node::Pointer GenerateOrRetrieveNode(ModelPart& rTheVolumeModelPart, ModelPart::NodesContainerType& rThisNodes, const std::size_t I, const std::size_t J, const std::size_t K);
Node::Pointer GenerateOrRetrieveNode(ModelPart& rTheVolumeModelPart, std::vector<ModelPart::NodeType::Pointer>& rThisNodes, const std::size_t I, const std::size_t J, const std::size_t K);

Node::Pointer GenerateOrRetrieveQuadraticNode(ModelPart& rTheVolumeModelPart, ModelPart::NodesContainerType& rThisNodes, const std::size_t I, const std::size_t J, const std::size_t K);
Node::Pointer GenerateOrRetrieveQuadraticNode(ModelPart& rTheVolumeModelPart, std::vector<ModelPart::NodeType::Pointer>& rThisNodes, const std::size_t I, const std::size_t J, const std::size_t K);

Node::Pointer GenerateNode(ModelPart& rTheVolumeModelPart, const Point& rCoordinates);

Expand Down
74 changes: 0 additions & 74 deletions kratos/tests/cpp_tests/utilities/test_model_part_utilities.cpp

This file was deleted.

Loading