26{
27 TCLAP::CmdLine cmd(
28 "Tool extracts the boundary of the given mesh. The documentation is "
29 "available at "
30 "https://docs.opengeosys.org/docs/tools/meshing-submeshes/"
31 "extract-boundary.\n\n"
32 "OpenGeoSys-6 software, version " +
34 ".\n"
35 "Copyright (c) 2012-2026, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
38 TCLAP::ValueArg<std::string> mesh_in(
39 "i", "mesh-input-file",
40 "Input (.vtu). The name of the file containing the input mesh", true,
41 "", "INPUT_FILE");
42 cmd.add(mesh_in);
43 TCLAP::ValueArg<std::string> mesh_out(
44 "o", "mesh-output-file",
45 "Output (.vtu). The name of the file the surface mesh should be "
46 "written to",
47 false, "", "OUTPUT_FILE");
48 cmd.add(mesh_out);
49
50 TCLAP::SwitchArg use_ascii_arg("", "ascii-output",
51 "If the switch is set use ascii instead of "
52 "binary format for data in the vtu output.",
53 false);
54 cmd.add(use_ascii_arg);
55
57 cmd.add(log_level_arg);
58 cmd.parse(argc, argv);
59
62
64 mesh_in.getValue(), true ));
65
66 if (!mesh)
67 {
68 return EXIT_FAILURE;
69 }
70
71 INFO(
"Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
72 mesh->getNumberOfElements());
73
74
75 std::unique_ptr<MeshLib::Mesh> surface_mesh(
77 *mesh,
81
82 INFO(
"Created surface mesh: {:d} nodes, {:d} elements.",
83 surface_mesh->getNumberOfNodes(), surface_mesh->getNumberOfElements());
84
85 std::string out_fname(mesh_out.getValue());
86 if (out_fname.empty())
87 {
89 }
90
91 auto const data_mode =
92 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
93 auto const use_compression = true;
95 use_compression, data_mode) != 0)
96 {
97 return EXIT_FAILURE;
98 }
99 return EXIT_SUCCESS;
100}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
std::string dropFileExtension(std::string const &filename)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > output_variable_names, bool const use_compression, int const data_mode)
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)