OGS
convertGEO.cpp
Go to the documentation of this file.
1
11#include <tclap/CmdLine.h>
12
13#ifdef USE_PETSC
14#include <mpi.h>
15#endif
16
17#include <string>
18#include <vector>
19
22#include "GeoLib/GEOObjects.h"
23#include "InfoLib/GitInfo.h"
24
25int main(int argc, char* argv[])
26{
27 TCLAP::CmdLine cmd(
28 "Converts OGS geometry file into another file format. "
29 "Currently *.gml (OGS6 XML-based format) and *.gli (OGS5 format) "
30 "formats are supported.\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> argInputFileName(
38 "i", "input-file", "the name of the geometry file to be converted",
39 true, "", "file name");
40 cmd.add(argInputFileName);
41 TCLAP::ValueArg<std::string> argOutputFileName(
42 "o", "output-file",
43 "the name of the new geometry file whose file format is guessed from "
44 "its file extension",
45 true, "", "file name");
46 cmd.add(argOutputFileName);
47
48 TCLAP::ValueArg<std::string> gmsh_path_arg("g", "gmsh-path",
49 "the path to the gmsh binary",
50 false, "", "path as string");
51 cmd.add(gmsh_path_arg);
52 cmd.parse(argc, argv);
53
54#ifdef USE_PETSC
55 MPI_Init(&argc, &argv);
56#endif
57
58 GeoLib::GEOObjects geoObjects;
59 FileIO::readGeometryFromFile(argInputFileName.getValue(), geoObjects,
60 gmsh_path_arg.getValue());
61 auto const geo_names = geoObjects.getGeometryNames();
62 assert(geo_names.size() == 1);
63
64 FileIO::writeGeometryToFile(geo_names[0], geoObjects,
65 argOutputFileName.getValue());
66
67#ifdef USE_PETSC
68 MPI_Finalize();
69#endif
70 return EXIT_SUCCESS;
71}
Definition of the GEOObjects class.
Git information.
Container class for geometric objects.
Definition GEOObjects.h:57
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
int main(int argc, char *argv[])
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
void writeGeometryToFile(std::string const &geo_name, GeoLib::GEOObjects &geo_objs, std::string const &fname)
GITINFOLIB_EXPORT const std::string ogs_version