Commit de8259b3 authored by Kirill Terekhov's avatar Kirill Terekhov

Some fixes in edge collapse algorithm, some more fixes will follow

parent 060d0851
Pipeline #168 failed with stages
in 10 minutes and 6 seconds
......@@ -2,6 +2,7 @@ project(GridGen)
add_executable(FixFaults fix_faults.cpp)
add_executable(FixTiny fix_tiny.cpp)
add_executable(FixTinyCollapse fix_tiny_collapse.cpp)
add_executable(UniteFaces unite_faces.cpp)
add_executable(Dual dual.cpp)
add_executable(Tetra tetra.cpp)
......@@ -31,6 +32,17 @@ add_executable(glue_faces glue_faces.cpp)
add_executable(check_collapse check_collapse.cpp)
add_library(FractureLib fracture.cpp fracture.h)
target_link_libraries(FixTinyCollapse inmost)
if(USE_MPI)
message("linking FixTinyCollapse with MPI")
target_link_libraries(FixTinyCollapse ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(FixTinyCollapse PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS FixTinyCollapse EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(split_faces inmost)
if(USE_MPI)
message("linking split_faces with MPI")
......@@ -94,6 +106,7 @@ endif(USE_MPI)
install(TARGETS UniteFaces EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Dual inmost)
if(USE_MPI)
message("linking Dual with MPI")
......@@ -115,6 +128,8 @@ endif(USE_MPI)
install(TARGETS Tetra EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Slice inmost)
if(USE_MPI)
message("linking Slice with MPI")
......@@ -126,6 +141,7 @@ endif(USE_MPI)
install(TARGETS Slice EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(SliceFunc inmost)
if(USE_MPI)
message("linking SliceFunc with MPI")
......@@ -137,6 +153,7 @@ endif(USE_MPI)
install(TARGETS SliceFunc EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(SplitNonplanar inmost)
if(USE_MPI)
message("linking SplitNonplanar with MPI")
......@@ -148,6 +165,7 @@ endif(USE_MPI)
install(TARGETS SplitNonplanar EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(CollapseDegenerate inmost)
if(USE_MPI)
message("linking CollapseDegenerate with MPI")
......@@ -159,6 +177,7 @@ endif(USE_MPI)
install(TARGETS CollapseDegenerate EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Bnd2Stl inmost)
if(USE_MPI)
message("linking Bnd2Stl with MPI")
......@@ -169,6 +188,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Bnd2Stl EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Sector inmost)
if(USE_MPI)
message("linking Sector with MPI")
......@@ -179,6 +199,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Sector EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Sew inmost)
if(USE_MPI)
message("linking Sew with MPI")
......@@ -189,6 +210,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Sew EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Scale inmost)
if(USE_MPI)
message("linking Scale with MPI")
......@@ -200,6 +222,7 @@ endif(USE_MPI)
install(TARGETS Scale EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Move inmost)
if(USE_MPI)
message("linking Move with MPI")
......@@ -210,6 +233,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Move EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(Convert inmost)
if(USE_MPI)
message("linking Convert with MPI")
......@@ -220,6 +244,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Convert EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(SameMeshDifference inmost)
if(USE_MPI)
message("linking SameMeshDifference with MPI")
......@@ -230,6 +255,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS SameMeshDifference EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(MeshDifference inmost)
if(USE_MPI)
message("linking MeshDifference with MPI")
......@@ -290,6 +316,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS hex_mesh EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
target_link_libraries(kershaw_mesh inmost)
if(USE_MPI)
message("linking kershaw_mesh with MPI")
......@@ -330,6 +357,7 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS sinusoidal_mesh EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools)
set_property(TARGET FractureLib PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/fracture.h")
install(TARGETS FractureLib EXPORT inmost-targets
......
#include "inmost.h"
using namespace INMOST;
int main(int argc, char ** argv)
{
if (argc < 2)
{
std::cout << "Usage: " << argv[0] << " mesh [mesh_out=grid.vtk]" << std::endl;
return -1;
}
std::string grid_out = "grid.vtk";
if (argc > 2) grid_out = std::string(argv[2]);
Mesh m;
m.Load(argv[1]);
Mesh::GeomParam table;
table[MEASURE] = CELL;
m.PrepareGeometricData(table);
std::cout << "Start:" << std::endl;
std::cout << "Cells: " << m.NumberOfCells() << std::endl;
std::cout << "Faces: " << m.NumberOfFaces() << std::endl;
std::cout << "Edges: " << m.NumberOfEdges() << std::endl;
double tt = Timer();
MarkerType collapse = m.CreateMarker();
int ncells = 0;
#pragma omp parallel for reduction(+:ncells)
for(int k = 0; k < m.CellLastLocalID(); ++k) if( m.isValidCell(k) )
{
Cell c = m.CellByLocalID(k);
ElementArray<Cell> around = c.BridgeAdjacencies2Cell(FACE);
double vol0 = c.Volume(), vol = vol0;
for(unsigned l = 0; l < around.size(); ++l)
vol += around[l].Volume();
if( vol0 / vol < 0.03 )
{
c.SetMarker(collapse);
ncells++;
}
}
std::cout << "collapse cells: " << ncells << std::endl;
int nedges = 0;
#pragma omp parallel for reduction(+:nedges)
for(int k = 0; k < m.EdgeLastLocalID(); ++k) if( m.isValidEdge(k) )
{
Edge e = m.EdgeByLocalID(k);
ElementArray<Cell> around = e.getCells();
for(unsigned l = 0; l < around.size(); ++l)
if( around[l].GetMarker(collapse) )
{
e.SetMarker(collapse);
nedges++;
break;
}
}
std::cout << "collapse edges: " << nedges << std::endl;
int ncollapsed = 0;
for(int k = 0; k < m.EdgeLastLocalID(); ++k) if( m.isValidEdge(k) )
{
Edge e = m.EdgeByLocalID(k);
if( e.GetMarker(collapse) )
{
Edge::CollapseEdge(e,0);
ncollapsed++;
if( ncollapsed % 100 == 0 )
m.Save("collapsed.vtk");
if( !Element::CheckConnectivity(&m) )
{
std::cout << "connectivity is bad" << std::endl;
throw -1;
}
}
}
std::cout << "Time to fix tiny:" << Timer() - tt << std::endl;
std::cout << "Cells: " << m.NumberOfCells() << std::endl;
std::cout << "Faces: " << m.NumberOfFaces() << std::endl;
std::cout << "Edges: " << m.NumberOfEdges() << std::endl;
m.Save(grid_out);
return 0;
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment