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

Extend ExtractSurface tool #2387

Merged
merged 3 commits into from
Mar 4, 2019
Merged
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
41 changes: 41 additions & 0 deletions Applications/Utils/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,44 @@ AddTest(
TESTER diff
DIFF_DATA 00-raster.asc
)

AddTest(
NAME ExtractSurfaceLeft
PATH MeshLib/
EXECUTABLE ExtractSurface
EXECUTABLE_ARGS -i cube_1x1x1_hex_1e3_layers_10.vtu -o ${Data_BINARY_DIR}/MeshLib/Left.vtu -x 1 -y 0 -z 0 -a 25
REQUIREMENTS NOT OGS_USE_MPI
TESTER diff
DIFF_DATA Left.vtu
)

AddTest(
NAME ExtractSurfaceRight
PATH MeshLib/
EXECUTABLE ExtractSurface
EXECUTABLE_ARGS -i cube_1x1x1_hex_1e3_layers_10.vtu -o ${Data_BINARY_DIR}/MeshLib/Right.vtu -x -1 -y 0 -z 0 -a 25
REQUIREMENTS NOT OGS_USE_MPI
TESTER diff
DIFF_DATA Right.vtu
)

AddTest(
NAME ExtractSurfaceFront
PATH MeshLib/
EXECUTABLE ExtractSurface
EXECUTABLE_ARGS -i cube_1x1x1_hex_1e3_layers_10.vtu -o ${Data_BINARY_DIR}/MeshLib/Front.vtu -x 0 -y 1 -z 0 -a 25
REQUIREMENTS NOT OGS_USE_MPI
TESTER diff
DIFF_DATA Front.vtu
)

AddTest(
NAME ExtractSurfaceBack
PATH MeshLib/
EXECUTABLE ExtractSurface
EXECUTABLE_ARGS -i cube_1x1x1_hex_1e3_layers_10.vtu -o ${Data_BINARY_DIR}/MeshLib/Back.vtu -x 0 -y -1 -z 0 -a 25
REQUIREMENTS NOT OGS_USE_MPI
TESTER diff
TESTER diff
DIFF_DATA Back.vtu
)
16 changes: 15 additions & 1 deletion MeshLib/MeshSurfaceExtraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface(
}

// transmit the original subsurface element ids as a property
if (!subsfc_element_id_prop_name.empty()) {
if (!subsfc_element_id_prop_name.empty())
{
MeshLib::addPropertyToMesh(*result, subsfc_element_id_prop_name,
MeshLib::MeshItemType::Cell, 1,
element_ids_map);
Expand All @@ -156,6 +157,19 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface(
face_ids_map);
}

auto const* subsurface_material_ids(MeshLib::materialIDs(subsfc_mesh));
if (subsurface_material_ids)
{
std::vector<int> material_ids;
material_ids.reserve(sfc_elements.size());
for (auto bulk_id : element_ids_map)
{
material_ids.push_back((*subsurface_material_ids)[bulk_id]);
}
MeshLib::addPropertyToMesh(*result, "MaterialIDs",
MeshLib::MeshItemType::Cell, 1,
material_ids);
}
return result;
}

Expand Down
3 changes: 3 additions & 0 deletions Tests/Data/MeshLib/Back.vtu
Git LFS file not shown
3 changes: 3 additions & 0 deletions Tests/Data/MeshLib/Front.vtu
Git LFS file not shown
3 changes: 3 additions & 0 deletions Tests/Data/MeshLib/Left.vtu
Git LFS file not shown
3 changes: 3 additions & 0 deletions Tests/Data/MeshLib/Right.vtu
Git LFS file not shown
3 changes: 3 additions & 0 deletions Tests/Data/MeshLib/cube_1x1x1_hex_1e3_layers_10.vtu
Git LFS file not shown
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions web/content/docs/tools/meshing/extract-surface/index.pandoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ Extracted top, bottom and side surfaces:
- top `ExtractSurface -i Input.vtu -o TopSurface.vtu`
- bottom `ExtractSurface -i Input.vtu -o BottomSurface.vtu -x 0 -y 0 -z 1`
- side `ExtractSurface -i Input.vtu -o SideSurface.vtu -x 1 -y 1 -z 0 -a 45`

![](CubeFrontRightBackLeft.png)

The figure shows the extracted front, right, back, and left surfaces from the
cube that are colored by the corresponding subsurface material id. The material
ids transformed to the surfaces can be used for further boundary condition
preparations for instance employing paraviews threshold filter.