-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12297 from KratosMultiphysics/feature/voxel-mesh-…
…modeler [Core] Add Voxel Mesh Generation Modeler
- Loading branch information
Showing
68 changed files
with
7,831 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
kratos/modeler/coloring/color_and_intersect_with_cells_in_touch.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
kratos/modeler/coloring/color_and_intersect_with_cells_in_touch.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
38
kratos/modeler/coloring/color_cell_faces_between_colors.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
||
} |
Oops, something went wrong.