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 27 of file appendLinesAlongPolyline.cpp.

28{
29 TCLAP::CmdLine cmd(
30 "Append line elements into a mesh.\n\n"
31 "OpenGeoSys-6 software, version " +
33 ".\n"
34 "Copyright (c) 2012-2024, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37 TCLAP::ValueArg<std::string> mesh_in(
38 "i", "mesh-input-file",
39 "the name of the file containing the input mesh", true, "",
40 "file name of input mesh");
41 cmd.add(mesh_in);
42 TCLAP::ValueArg<std::string> mesh_out(
43 "o", "mesh-output-file",
44 "the name of the file the mesh will be written to", true, "",
45 "file name of output mesh");
46 cmd.add(mesh_out);
47 TCLAP::ValueArg<std::string> geoFileArg(
48 "g", "geo-file",
49 "the name of the geometry file which contains polylines", true, "",
50 "the name of the geometry file");
51 cmd.add(geoFileArg);
52
53 TCLAP::ValueArg<std::string> gmsh_path_arg("", "gmsh-path",
54 "the path to the gmsh binary",
55 false, "", "path as string");
56 cmd.add(gmsh_path_arg);
57
58 // parse arguments
59 cmd.parse(argc, argv);
60
61#ifdef USE_PETSC
62 MPI_Init(&argc, &argv);
63#endif
64
65 // read GEO objects
66 GeoLib::GEOObjects geo_objs;
67 FileIO::readGeometryFromFile(geoFileArg.getValue(), geo_objs,
68 gmsh_path_arg.getValue());
69
70 auto const geo_names = geo_objs.getGeometryNames();
71 if (geo_names.empty())
72 {
73 ERR("No geometries found.");
74#ifdef USE_PETSC
75 MPI_Finalize();
76#endif
77 return EXIT_FAILURE;
78 }
79 const GeoLib::PolylineVec* ply_vec(
80 geo_objs.getPolylineVecObj(geo_names[0]));
81 if (!ply_vec)
82 {
83 ERR("Could not find polylines in geometry '{:s}'.", geo_names.front());
84#ifdef USE_PETSC
85 MPI_Finalize();
86#endif
87 return EXIT_FAILURE;
88 }
89
90 // read a mesh
92 mesh_in.getValue(), true /* compute_element_neighbors */));
93 if (!mesh)
94 {
95 ERR("Mesh file '{:s}' not found", mesh_in.getValue());
96#ifdef USE_PETSC
97 MPI_Finalize();
98#endif
99 return EXIT_FAILURE;
100 }
101 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
102 mesh->getNumberOfElements());
103
104 // add line elements
105 std::unique_ptr<MeshLib::Mesh> new_mesh =
107 INFO("Mesh created: {:d} nodes, {:d} elements.",
108 new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
109
110 MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue());
111
112#ifdef USE_PETSC
113 MPI_Finalize();
114#endif
115 return EXIT_SUCCESS;
116}
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...
Definition TemplateVec.h:38
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().