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-2024, OpenGeoSys Community "
32 "(http://www.opengeosys.org)",
34 TCLAP::ValueArg<std::string> mesh_in(
35 "i", "mesh-input-file",
36 "the name of the file containing the input mesh", true, "",
37 "file name of input mesh");
38 cmd.add(mesh_in);
39 TCLAP::ValueArg<std::string> mesh_out(
40 "o", "mesh-output-file",
41 "the name of the file the mesh will be written to", true, "",
42 "file name of output mesh");
43 cmd.add(mesh_out);
44 TCLAP::ValueArg<std::string> geoFileArg(
45 "g", "geo-file",
46 "the name of the geometry file which contains polylines", true, "",
47 "the name of the geometry file");
48 cmd.add(geoFileArg);
49
50 TCLAP::ValueArg<std::string> gmsh_path_arg("", "gmsh-path",
51 "the path to the gmsh binary",
52 false, "", "path as string");
53 cmd.add(gmsh_path_arg);
54
55 // parse arguments
56 cmd.parse(argc, argv);
57
58 BaseLib::MPI::Setup mpi_setup(argc, argv);
59
60 // read GEO objects
61 GeoLib::GEOObjects geo_objs;
62 FileIO::readGeometryFromFile(geoFileArg.getValue(), geo_objs,
63 gmsh_path_arg.getValue());
64
65 auto const geo_names = geo_objs.getGeometryNames();
66 if (geo_names.empty())
67 {
68 ERR("No geometries found.");
69 return EXIT_FAILURE;
70 }
71 const GeoLib::PolylineVec* ply_vec(
72 geo_objs.getPolylineVecObj(geo_names[0]));
73 if (!ply_vec)
74 {
75 ERR("Could not find polylines in geometry '{:s}'.", geo_names.front());
76 return EXIT_FAILURE;
77 }
78
79 // read a mesh
81 mesh_in.getValue(), true /* compute_element_neighbors */));
82 if (!mesh)
83 {
84 ERR("Mesh file '{:s}' not found", mesh_in.getValue());
85 return EXIT_FAILURE;
86 }
87 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
88 mesh->getNumberOfElements());
89
90 // add line elements
91 std::unique_ptr<MeshLib::Mesh> new_mesh =
93 INFO("Mesh created: {:d} nodes, {:d} elements.",
94 new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
95
96 MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue());
97
98 return EXIT_SUCCESS;
99}
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().