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] Add Voxel Mesh Generation Modeler #12297

Merged
merged 38 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6d8847a
Adding utility function to add ordered nodes in batch to modelpart
jcotela Apr 16, 2024
45bf136
Add Voxel mesh generator modeler
jcotela Apr 16, 2024
220a28f
Add cpp tests
jcotela Apr 17, 2024
b7cec84
Adding python tests
jcotela Apr 17, 2024
9fe8d30
Use new factory format
jcotela Apr 17, 2024
0030a7a
Adding missing interface to Operation
jcotela Apr 18, 2024
f11c9e5
Merge master
jcotela Apr 19, 2024
3be5c90
Fix headers
loumalouomega Apr 22, 2024
d131e13
Merge branch 'master' into feature/voxel-mesh-modeler
loumalouomega Apr 22, 2024
4c0501f
Fix non-deallocated pointer and debug output
jcotela Apr 22, 2024
5515036
Missing const
jcotela Apr 22, 2024
bebd81c
Merge master
jcotela Apr 23, 2024
5f1f338
Typo
jcotela Apr 23, 2024
b5fc155
Fix warning message
jcotela May 7, 2024
c816e34
Remove unused function
jcotela May 7, 2024
9eba80f
Use existing modeler capabilities to create new modelparts
jcotela May 7, 2024
d819776
Remove unused friend
jcotela May 7, 2024
55ef57d
Merge branch 'master' into feature/voxel-mesh-modeler
loumalouomega May 7, 2024
8825367
Fix runtime error if BOOST_UBLAS_TYPE_CHECK is enabled
jcotela May 8, 2024
cc71737
Moving coloring to source files
loumalouomega May 9, 2024
9ecc213
Fix unity compilation
loumalouomega May 9, 2024
6f3ec98
Refactor source/header for entity generation
loumalouomega May 9, 2024
5b3b33f
More source/header refactor
loumalouomega May 9, 2024
82b371b
Defining destructors
jcotela May 13, 2024
aaa9bd6
Removing unused code from old factory implementation
jcotela May 13, 2024
1e0269f
Use existing function instead of duplicating code
jcotela May 13, 2024
5551164
Apply suggestions from code review
jcotela May 13, 2024
de8d1f7
simplify bool operation
jcotela May 13, 2024
0147cc9
Removing output
jcotela May 13, 2024
cec8cd6
Missing semicolon
jcotela May 13, 2024
936d1ad
Delete auxiliary file
jcotela May 13, 2024
c676e88
Suggestion
loumalouomega May 14, 2024
47a7e55
style
jcotela May 14, 2024
0e549f0
Rewrite loop conditions to avoid cast to int
jcotela May 14, 2024
d188d0e
Merge branch 'feature/voxel-mesh-modeler' of github.com:KratosMultiph…
jcotela May 14, 2024
f85ebc1
Using std::size_t and parallel_utilities loops where possible
jcotela May 14, 2024
5492eb3
Review suggestions in find contacts in skin
jcotela May 14, 2024
5542da6
Remove unused types
jcotela May 14, 2024
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
2 changes: 2 additions & 0 deletions kratos/includes/kratos_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "modeler/serial_model_part_combinator_modeler.h"
#include "modeler/combine_model_part_modeler.h"
#include "modeler/connectivity_preserve_modeler.h"
#include "modeler/voxel_mesh_generator_modeler.h"

namespace Kratos {
///@name Kratos Classes
Expand Down Expand Up @@ -495,6 +496,7 @@ class KRATOS_API(KRATOS_CORE) KratosApplication {
const SerialModelPartCombinatorModeler mSerialModelPartCombinatorModeler;
const CombineModelPartModeler mCombineModelPartModeler;
const ConnectivityPreserveModeler mConnectivityPreserveModeler;
const VoxelMeshGeneratorModeler mVoxelMeshGeneratorModeler;

// Base constitutive law definition
const ConstitutiveLaw mConstitutiveLaw;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

// System includes

// External includes

// Project includes
#include "geometries/geometry.h"
#include "color_and_intersect_with_cells_in_touch.h"

namespace Kratos {

ColorAndIntersectWithCellsInTouch::ColorAndIntersectWithCellsInTouch(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters):
VoxelMesherColoring(rModeler, ColoringParameters)
{}


void ColorAndIntersectWithCellsInTouch::Apply() const
{
auto parameters = GetParameters();
auto& r_model_part = GetModelPart(parameters["model_part_name"].GetString());

const int inside_color = parameters["color"].GetInt();
const std::string input_entities = parameters["input_entities"].GetString();

auto& r_skin_intersections = GetIntersections(inside_color);

if (input_entities == "elements") {
for(auto& r_geometrical_object : r_model_part.Elements()) {
auto& r_geometry = r_geometrical_object.GetGeometry();
CheckGeometryType(r_geometry.GetGeometryType());
ApplyColorToCellsInTouchWithGeometryAndComputeIntersection(r_geometry, inside_color, r_skin_intersections);
}
} else if(input_entities == "conditions") {
for(auto& r_geometrical_object : r_model_part.Conditions()) {
auto& r_geometry = r_geometrical_object.GetGeometry();
CheckGeometryType(r_geometry.GetGeometryType());
ApplyColorToCellsInTouchWithGeometryAndComputeIntersection(r_geometry, inside_color, r_skin_intersections);
}
} else if(input_entities == "geometries") {
for(auto& r_geometry : r_model_part.Geometries()) {
CheckGeometryType(r_geometry.GetGeometryType());
ApplyColorToCellsInTouchWithGeometryAndComputeIntersection(r_geometry, inside_color, r_skin_intersections);
}
} else {
KRATOS_ERROR << "The input_entities " << parameters["input_entities"] << " is not supported. The supported input_entities are elements and conditions" << std::endl;
}
}


Parameters ColorAndIntersectWithCellsInTouch::GetDefaultParameters() const {
return Parameters(R"({
"type" : "Undefined_coloring_type",
"model_part_name": "Undefined",
"color": -1,
"cell_color": -1,
"input_entities": "elements",
"outside_color": 0
})");
}


void ColorAndIntersectWithCellsInTouch::ApplyColorToCellsInTouchWithGeometryAndComputeIntersection(
const Element::GeometryType& rGeometry,
int InsideColor,
Internals::SkinIntersection& rSkinIntersection) const
{
auto& r_colors = GetMeshColors();

auto p_work_geometry = rSkinIntersection.ConvertToWorkGeometry(rGeometry);
array_1d<std::size_t, 3> min_position(3,0);
array_1d<std::size_t, 3> max_position(3,0);
r_colors.CalculateOuterMinMaxNodePositions(rGeometry, min_position, max_position);
for(std::size_t k = min_position[2] ; k < max_position[2] ; k++){
for(std::size_t j = min_position[1] ; j < max_position[1] ; j++){
for(std::size_t i = min_position[0] ; i < max_position[0] ; i++){
Point cell_min_point = r_colors.GetPoint(i,j,k);
Point cell_max_point = r_colors.GetPoint(i+1,j+1,k+1);
if(rGeometry.HasIntersection(cell_min_point,cell_max_point)){
r_colors.GetElementalColor(i,j,k) = InsideColor;

rSkinIntersection.ComputeCutInsideCell(p_work_geometry, cell_min_point, cell_max_point, i, j, k);
}
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

#pragma once

// System includes

// External includes

// Project includes
#include "geometries/geometry.h"
#include "voxel_mesher_coloring.h"

namespace Kratos {

class ColorAndIntersectWithCellsInTouch: public VoxelMesherColoring {

public:
ColorAndIntersectWithCellsInTouch(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters);

~ColorAndIntersectWithCellsInTouch() override = default;

void Apply() const override;

Parameters GetDefaultParameters() const override;

private:

void ApplyColorToCellsInTouchWithGeometryAndComputeIntersection(
const Geometry<Node>& rGeometry,
int InsideColor,
Internals::SkinIntersection& rSkinIntersection) const;

};

}
67 changes: 67 additions & 0 deletions kratos/modeler/coloring/color_cell_faces.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

// System includes

// External includes

// Project includes
#include "geometries/geometry.h"
#include "color_cell_faces.h"

namespace Kratos {

ColorCellFaces::ColorCellFaces(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters):
VoxelMesherColoring(rModeler, ColoringParameters)
{}


void ColorCellFaces::Apply() const
{
auto parameters = GetParameters();
auto& r_model_part = GetModelPart(parameters["model_part_name"].GetString());
CartesianMeshColors& r_colors = GetMeshColors();

const int outside_color = parameters["outside_color"].GetInt();
const int interface_color = parameters["color"].GetInt();
const int cell_color = parameters["cell_color"].GetInt();
const std::string input_entities = parameters["input_entities"].GetString();

array_1d< std::size_t, 3 > min_ray_position{0, 0, 0};
array_1d< std::size_t, 3 > max_ray_position{0, 0, 0};

r_colors.CalculateMinMaxCenterOfElementPositions(r_model_part.Nodes(), min_ray_position, max_ray_position);
r_colors.InitializeRays(min_ray_position, max_ray_position, "center_of_elements");

if(input_entities == "elements") {
for(auto& element : r_model_part.Elements()) {
Element::GeometryType& r_geometry = element.GetGeometry();
CheckGeometryType(r_geometry.GetGeometryType());
r_colors.AddGeometry(r_geometry, false);
}
} else if(input_entities == "conditions") {
for(auto& condition : r_model_part.Conditions()) {
auto& r_geometry = condition.GetGeometry();
CheckGeometryType(r_geometry.GetGeometryType());
r_colors.AddGeometry(r_geometry, false);
}
} else if(input_entities == "geometries") {
for(auto& r_geometry : r_model_part.Geometries()) {
CheckGeometryType(r_geometry.GetGeometryType());
r_colors.AddGeometry(r_geometry, false);
}
}

r_colors.CalculateElementalFaceColors(min_ray_position, max_ray_position, interface_color, outside_color, cell_color);
}

}
35 changes: 35 additions & 0 deletions kratos/modeler/coloring/color_cell_faces.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

#pragma once

// System includes

// External includes

// Project includes
#include "voxel_mesher_coloring.h"

namespace Kratos {

class ColorCellFaces: public VoxelMesherColoring {

public:
ColorCellFaces(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters);

~ColorCellFaces() override = default;

void Apply() const override;

};

}
38 changes: 38 additions & 0 deletions kratos/modeler/coloring/color_cell_faces_between_colors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

// System includes

// External includes

// Project includes
#include "geometries/geometry.h"
#include "color_cell_faces_between_colors.h"

namespace Kratos {

ColorCellFacesBetweenColors::ColorCellFacesBetweenColors(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters):
VoxelMesherColoring(rModeler, ColoringParameters)
{}


void ColorCellFacesBetweenColors::Apply() const
{
Parameters parameters = GetParameters();
const int outside_color = parameters["outside_color"].GetInt();
const int interface_color = parameters["color"].GetInt();
const int cell_color = parameters["cell_color"].GetInt();

GetMeshColors().CalculateElementalFaceColorsBetweenColors(interface_color, outside_color, cell_color);
}

}
34 changes: 34 additions & 0 deletions kratos/modeler/coloring/color_cell_faces_between_colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
//

#pragma once

// System includes

// External includes

// Project includes
#include "voxel_mesher_coloring.h"

namespace Kratos {

class ColorCellFacesBetweenColors: public VoxelMesherColoring {

public:
ColorCellFacesBetweenColors(VoxelMeshGeneratorModeler& rModeler, Parameters ColoringParameters);

~ColorCellFacesBetweenColors() override = default;

void Apply() const override;
};

}
Loading
Loading