OGS
appendLinesAlongPolyline.cpp File Reference

Detailed Description

Definition in file appendLinesAlongPolyline.cpp.

Include dependency graph for appendLinesAlongPolyline.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 24 of file appendLinesAlongPolyline.cpp.

25{
26 TCLAP::CmdLine cmd(
27 "Append line elements into a mesh.\n\n"
28 "OpenGeoSys-6 software, version " +
30 ".\n"
31 "Copyright (c) 2012-2025, OpenGeoSys Community "
32 "(http://www.opengeosys.org)",
34 TCLAP::ValueArg<std::string> mesh_in(
35 "i", "mesh-input-file",
36 "Input (.vtu). The name of the file containing the input mesh", true,
37 "", "INPUT_FILE");
38 cmd.add(mesh_in);
39 TCLAP::ValueArg<std::string> mesh_out(
40 "o", "mesh-output-file",
41 "Output (.vtu | .msh). The name of the file the mesh will be written "
42 "to",
43 true, "", "OUTPUT_FILE");
44 cmd.add(mesh_out);
45 TCLAP::ValueArg<std::string> geoFileArg(
46 "g", "geo-file",
47 "Input (.gml). The name of the input geometry file which contains "
48 "polylines",
49 true, "", "INPUT_FILE");
50 cmd.add(geoFileArg);
51
52 TCLAP::ValueArg<std::string> gmsh_path_arg(
53 "", "gmsh-path", "Input (.msh). The path to the input gmsh binary file",
54 false, "", "INPUT_FILE");
55 cmd.add(gmsh_path_arg);
56
57 // parse arguments
58 cmd.parse(argc, argv);
59
60 BaseLib::MPI::Setup mpi_setup(argc, argv);
61
62 // read GEO objects
63 GeoLib::GEOObjects geo_objs;
64 FileIO::readGeometryFromFile(geoFileArg.getValue(), geo_objs,
65 gmsh_path_arg.getValue());
66
67 auto const geo_names = geo_objs.getGeometryNames();
68 if (geo_names.empty())
69 {
70 ERR("No geometries found.");
71 return EXIT_FAILURE;
72 }
73 const GeoLib::PolylineVec* ply_vec(
74 geo_objs.getPolylineVecObj(geo_names[0]));
75 if (!ply_vec)
76 {
77 ERR("Could not find polylines in geometry '{:s}'.", geo_names.front());
78 return EXIT_FAILURE;
79 }
80
81 // read a mesh
83 mesh_in.getValue(), true /* compute_element_neighbors */));
84 if (!mesh)
85 {
86 ERR("Mesh file '{:s}' not found", mesh_in.getValue());
87 return EXIT_FAILURE;
88 }
89 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
90 mesh->getNumberOfElements());
91
92 // add line elements
93 std::unique_ptr<MeshLib::Mesh> new_mesh =
95 INFO("Mesh created: {:d} nodes, {:d} elements.",
96 new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
97
98 MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue());
99
100 return EXIT_SUCCESS;
101}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
Container class for geometric objects.
Definition GEOObjects.h:57
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const PolylineVec * getPolylineVecObj(const std::string &name) const
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
GITINFOLIB_EXPORT const std::string ogs_version
std::unique_ptr< MeshLib::Mesh > appendLinesAlongPolylines(const MeshLib::Mesh &mesh, const GeoLib::PolylineVec &ply_vec)
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 > variable_output_names)

References MeshGeoToolsLib::appendLinesAlongPolylines(), ERR(), GeoLib::GEOObjects::getGeometryNames(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), GeoLib::GEOObjects::getPolylineVecObj(), INFO(), GitInfoLib::GitInfo::ogs_version, FileIO::readGeometryFromFile(), MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeMeshToFile().