Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
37f6843
Adds json support for conformal mesher in launcher. Modifies conforma…
Alberto-o Oct 21, 2025
35377db
If conformalMesher options are not given, default are taken from the …
Alberto-o Oct 22, 2025
45d99b3
Adds conformal json files
Alberto-o Oct 22, 2025
fe1a586
Adds dynamic extension to the mesh file, depending on mesher used
Alberto-o Oct 23, 2025
cb55b5c
Repo updates
Alberto-o Oct 28, 2025
000c861
Minor update
Alberto-o Oct 31, 2025
b694c5b
Refactor findCommonNeighborsVertices to handle missing cell elements …
ashybabashyba Nov 3, 2025
fc39c70
Refactor getSelectiveMesh to improve boundary checking for structured…
ashybabashyba Nov 4, 2025
d7d79bf
Enhance getSelectiveMesh to support spliting triangles when a surface…
ashybabashyba Nov 6, 2025
98a7b38
Refactor getSelectiveMesh to improve vertex comparison logic and stre…
ashybabashyba Nov 6, 2025
84f901d
Refactor getSelectiveMesh to optimize element removal and enhance red…
ashybabashyba Nov 7, 2025
6791dbe
Add test for selective structurer to split lines with neighboring tri…
ashybabashyba Nov 7, 2025
0124dbc
Refactor getSelectiveMesh to correct vertex orientation logic and upd…
ashybabashyba Nov 10, 2025
2709640
Refactor getSelectiveMesh to streamline element processing and introd…
ashybabashyba Nov 10, 2025
2cfb095
Refactor findCommonNeighborsVertices to handle missing cell elements …
ashybabashyba Nov 3, 2025
6427a79
Refactor getSelectiveMesh to improve boundary checking for structured…
ashybabashyba Nov 4, 2025
b713cbd
Enhance getSelectiveMesh to support spliting triangles when a surface…
ashybabashyba Nov 6, 2025
9738333
Refactor getSelectiveMesh to improve vertex comparison logic and stre…
ashybabashyba Nov 6, 2025
5233c8f
Refactor getSelectiveMesh to optimize element removal and enhance red…
ashybabashyba Nov 7, 2025
ee66b39
Add test for selective structurer to split lines with neighboring tri…
ashybabashyba Nov 7, 2025
93c4373
Refactor getSelectiveMesh to correct vertex orientation logic and upd…
ashybabashyba Nov 10, 2025
cbc941a
Refactor getSelectiveMesh to streamline element processing and introd…
ashybabashyba Nov 10, 2025
7ea6e3c
Merge
ashybabashyba Nov 10, 2025
ef97b39
Merge pull request #58 from ashybabashyba/conformal_selective_structu…
Alberto-o Nov 10, 2025
7c2f4d7
Merge branch 'dev' into enhancement/conformal_selective_structuring
Alberto-o Nov 11, 2025
07cdb43
Fixes staircase naming in PR
Alberto-o Nov 11, 2025
5ac9e7a
Minor
Alberto-o Nov 11, 2025
4a99b70
fix conflicts
Alberto-o Nov 11, 2025
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
66 changes: 62 additions & 4 deletions src/app/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "vtkIO.h"

#include "meshers/StaircaseMesher.h"
#include "meshers/ConformalMesher.h"
#include "utils/GridTools.h"

#include <boost/program_options.hpp>
Expand All @@ -11,12 +12,13 @@
#include <filesystem>
#include <fstream>
#include <array>

#include <memory>

namespace meshlib::app {

using namespace vtkIO;


namespace po = boost::program_options;

Grid parseGridFromJSON(const nlohmann::json &j)
Expand Down Expand Up @@ -61,6 +63,59 @@ Mesh readMesh(const std::string &fn)
return res;
}


std::string readMesherType(const std::string &fn)
{
nlohmann::json j;
{
std::ifstream i(fn);
i >> j;
}
if (j["mesher"].contains("type")) {
return j["mesher"]["type"];
} else {
return meshlib::app::staircase_mesher;
}
}

std::string readExtension(const std::string &fn)
{
auto mesherType = readMesherType(fn);
if (mesherType == meshlib::app::staircase_mesher) {
return "str";
} else if (mesherType == meshlib::app::conformal_mesher) {
return "cmsh";
} else {
throw std::runtime_error("Unsupported mesher type");
}
}

meshlib::meshers::ConformalMesherOptions readConformalMesherOptions(const std::string &fn)
{
nlohmann::json j;
{
std::ifstream i(fn);
i >> j;
}
meshlib::meshers::ConformalMesherOptions res;
if (j["mesher"].contains("options")) {
res.snapperOptions.edgePoints = j["mesher"]["options"]["edgePoints"];
res.snapperOptions.forbiddenLength = j["mesher"]["options"]["forbiddenLength"];
}
return res;
}
std::unique_ptr<meshlib::meshers::MesherBase> buildMesher(const Mesh &in, const std::string &fn)
{
auto mesherType = readMesherType(fn);
if (mesherType == meshlib::app::staircase_mesher) {
return std::make_unique<meshlib::meshers::StaircaseMesher>(meshlib::meshers::StaircaseMesher{in});
} else if (mesherType == meshlib::app::conformal_mesher) {
return std::make_unique<meshlib::meshers::ConformalMesher>(meshlib::meshers::ConformalMesher{in, readConformalMesherOptions(fn)});
} else {
throw std::runtime_error("Unsupported mesher type");
}
}

int launcher(int argc, const char* argv[])
{
po::options_description desc("Allowed options");
Expand All @@ -84,13 +139,16 @@ int launcher(int argc, const char* argv[])

Mesh mesh = readMesh(inputFilename);


// Mesh
meshlib::meshers::StaircaseMesher mesher{mesh};
Mesh resultMesh = mesher.mesh();
auto mesher = buildMesher(mesh, inputFilename);
Mesh resultMesh = mesher->mesh();

std::filesystem::path outputFolder = getFolder(inputFilename);
auto basename = getBasename(inputFilename);
exportMeshToVTU(outputFolder / (basename + ".tessellator.str.vtk"), resultMesh);
auto extension = readExtension(inputFilename);

exportMeshToVTU(outputFolder / (basename + ".tessellator." + extension + ".vtk"), resultMesh);
exportGridToVTU(outputFolder / (basename + ".tessellator.grid.vtk"), resultMesh.grid);

return EXIT_SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions src/app/launcher.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#pragma once

#include "types/Mesh.h"
#include <string>

namespace meshlib::app {

const std::string conformal_mesher ("conformal");
const std::string staircase_mesher ("staircase");

int launcher(int argc, const char* argv[]);

}
Loading
Loading