diff --git a/src/app/launcher.cpp b/src/app/launcher.cpp index a66be16..22319b3 100644 --- a/src/app/launcher.cpp +++ b/src/app/launcher.cpp @@ -48,19 +48,14 @@ Mesh readMesh(const std::string &fn) std::filesystem::path objPathFromInput = j["object"]["filename"]; std::filesystem::path meshObjectPath = caseFolder / objPathFromInput; - std::cout << "Reading mesh groups from: " << meshObjectPath; + std::cout << "-- Reading mesh groups from: " << meshObjectPath; Mesh res = vtkIO::readMeshGroups(meshObjectPath); std::cout << "....... [OK]" << std::endl; - std::cout << "Reading grid from input file"; + std::cout << "-- Reading grid from input file"; res.grid = parseGridFromJSON(j["grid"]); std::cout << "....... [OK]" << std::endl; - std::cout << "Grid has " - << res.grid[0].size()-1 << "x" - << res.grid[1].size()-1 << "x" - << res.grid[2].size()-1 << " cells" << std::endl; - return res; } @@ -83,7 +78,7 @@ int launcher(int argc, const char* argv[]) // Input std::string inputFilename = vm["input"].as(); - std::cout << "Input file is: " << inputFilename << std::endl; + std::cout << "-- Input file is: " << inputFilename << std::endl; Mesh mesh = readMesh(inputFilename); @@ -97,7 +92,7 @@ int launcher(int argc, const char* argv[]) std::filesystem::path outputFolder = std::filesystem::path(inputFilename).parent_path(); auto basename = std::filesystem::path(inputFilename).stem().stem().string(); - meshlib::vtkIO::exportMeshToVTP(outputFolder / (basename + ".tessellator.out.vtp"), resultMesh); + meshlib::vtkIO::exportMeshToVTP(outputFolder / (basename + ".tessellator.str.vtp"), resultMesh); meshlib::vtkIO::exportGridToVTP(outputFolder / (basename + ".tessellator.grid.vtp"), resultMesh.grid); return EXIT_SUCCESS; diff --git a/src/meshers/MesherBase.cpp b/src/meshers/MesherBase.cpp index bb92f78..77e704d 100644 --- a/src/meshers/MesherBase.cpp +++ b/src/meshers/MesherBase.cpp @@ -60,12 +60,15 @@ void MesherBase::logGridSize(const Grid& g) log(msg.str(), 2); } -MesherBase::MesherBase(const Mesh& inputMesh) : originalGrid_{inputMesh.grid}{ - +MesherBase::MesherBase(const Mesh& inputMesh) : originalGrid_{inputMesh.grid} +{ + log("Input mesh information.", 1); logGridSize(inputMesh.grid); logNumberOfTriangles(countMeshElementsIf(inputMesh, isTriangle)); + log("Building enlarged grid.", 1); enlargedGrid_ = getEnlargedGridIncludingAllElements(inputMesh); + logGridSize(inputMesh.grid); } Mesh MesherBase::buildSurfaceMesh(const Mesh& inputMesh) { diff --git a/src/meshers/StructuredMesher.cpp b/src/meshers/StructuredMesher.cpp index cf6c895..0e0a7cb 100644 --- a/src/meshers/StructuredMesher.cpp +++ b/src/meshers/StructuredMesher.cpp @@ -18,12 +18,7 @@ using namespace core; using namespace meshTools; -Mesh StructuredMesher::buildSurfaceMesh(const Mesh& inputMesh, const Mesh & volumeSurface) -{ - auto resultMesh = MesherBase::buildSurfaceMesh(inputMesh); - mergeMesh(resultMesh, volumeSurface); - return resultMesh; -} + StructuredMesher::StructuredMesher(const Mesh& inputMesh, int decimalPlacesInCollapser) : MesherBase(inputMesh), @@ -34,8 +29,15 @@ StructuredMesher::StructuredMesher(const Mesh& inputMesh, int decimalPlacesInCol log("Processing surface mesh."); process(surfaceMesh_); + + log("Surface mesh built succesfully.", 1); +} - log("Initial hull mesh built succesfully."); +Mesh StructuredMesher::buildSurfaceMesh(const Mesh& inputMesh, const Mesh & volumeSurface) +{ + auto resultMesh = MesherBase::buildSurfaceMesh(inputMesh); + mergeMesh(resultMesh, volumeSurface); + return resultMesh; } void StructuredMesher::process(Mesh& mesh) const @@ -65,28 +67,24 @@ void StructuredMesher::process(Mesh& mesh) const logNumberOfQuads(countMeshElementsIf(mesh, isQuad)); logNumberOfLines(countMeshElementsIf(mesh, isLine)); - + log("Removing repeated elements.", 1); Cleaner::removeRepeatedElements(mesh); logNumberOfQuads(countMeshElementsIf(mesh, isQuad)); logNumberOfLines(countMeshElementsIf(mesh, isLine)); + + log("Recovering original grid size.", 1); + reduceGrid(mesh, originalGrid_); + + logNumberOfQuads(countMeshElementsIf(mesh, isQuad)); + logNumberOfLines(countMeshElementsIf(mesh, isLine)); + } Mesh StructuredMesher::mesh() const { - log("Building primal mesh."); - Mesh resultMesh{ surfaceMesh_ }; - - logNumberOfQuads(countMeshElementsIf(resultMesh, isQuad)); - logNumberOfLines(countMeshElementsIf(resultMesh, isLine)); - logNumberOfNodes(countMeshElementsIf(resultMesh, isNode)); - - reduceGrid(resultMesh, originalGrid_); - Cleaner::cleanCoords(resultMesh); - - log("Primal mesh built succesfully.", 1); - return resultMesh; + return surfaceMesh_; } } \ No newline at end of file diff --git a/test/app/launcherTest.cpp b/test/app/launcherTest.cpp index 555c565..8d66893 100644 --- a/test/app/launcherTest.cpp +++ b/test/app/launcherTest.cpp @@ -18,8 +18,18 @@ TEST_F(LauncherTest, prints_help) TEST_F(LauncherTest, launches_alhambra_case) { int ac = 3; - const char* av[] = { NULL, "-i", "testData/cases/alhambra.tessellator.json"}; + const char* av[] = { NULL, "-i", "testData/cases/alhambra/alhambra.tessellator.json"}; int exitCode; EXPECT_NO_THROW(exitCode = meshlib::app::launcher(ac, av)); EXPECT_EQ(exitCode, EXIT_SUCCESS); } + + +TEST_F(LauncherTest, launches_sphere_case) +{ + int ac = 3; + const char* av[] = { NULL, "-i", "testData/cases/sphere/sphere.tessellator.json"}; + int exitCode; + EXPECT_NO_THROW(exitCode = meshlib::app::launcher(ac, av)); + EXPECT_EQ(exitCode, EXIT_SUCCESS); +} \ No newline at end of file diff --git a/testData/cases/.gitignore b/testData/cases/.gitignore index 1263f1c..1eb9df1 100644 --- a/testData/cases/.gitignore +++ b/testData/cases/.gitignore @@ -1,2 +1,2 @@ -*tessellator.out.vtp +*tessellator.str.vtp *tessellator.grid.vtp \ No newline at end of file diff --git a/testData/cases/alhambra.tessellator.json b/testData/cases/alhambra/alhambra.tessellator.json similarity index 100% rename from testData/cases/alhambra.tessellator.json rename to testData/cases/alhambra/alhambra.tessellator.json diff --git a/testData/cases/alhambra.vtk b/testData/cases/alhambra/alhambra.vtk similarity index 100% rename from testData/cases/alhambra.vtk rename to testData/cases/alhambra/alhambra.vtk diff --git a/testData/cases/sphere/sphere.stl b/testData/cases/sphere/sphere.stl new file mode 100644 index 0000000..29885a1 Binary files /dev/null and b/testData/cases/sphere/sphere.stl differ diff --git a/testData/cases/sphere/sphere.tessellator.json b/testData/cases/sphere/sphere.tessellator.json new file mode 100644 index 0000000..d27b387 --- /dev/null +++ b/testData/cases/sphere/sphere.tessellator.json @@ -0,0 +1,10 @@ +{ + "grid": { + "numberOfCells": [100, 100, 100], + "boundingBox": [ + [-100.0, -100.0, -100.0], + [ 100.0, 100.0, 100.0] + ] + }, + "object": {"filename": "sphere.stl"} +} \ No newline at end of file