OGS
convertGEO.cpp
Go to the documentation of this file.
1
11#include <tclap/CmdLine.h>
12
13#include <string>
14#include <vector>
15
18#include "BaseLib/Logging.h"
19#include "BaseLib/MPI.h"
21#include "GeoLib/GEOObjects.h"
22#include "InfoLib/GitInfo.h"
23
24int main(int argc, char* argv[])
25{
26 TCLAP::CmdLine cmd(
27 "Converts OGS geometry file into another file format. "
28 "Currently *.gml (OGS6 XML-based format) and *.gli (OGS5 format) "
29 "formats are supported.\n\n"
30 "OpenGeoSys-6 software, version " +
32 ".\n"
33 "Copyright (c) 2012-2025, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
36 TCLAP::ValueArg<std::string> argInputFileName(
37 "i", "input-file",
38 "Input (.gml|.gli). The name of the geometry file to be converted",
39 true, "", "INPUT_FILE");
40 cmd.add(argInputFileName);
41 TCLAP::ValueArg<std::string> argOutputFileName(
42 "o", "output-file",
43 "Output. The name of the new geometry file whose file format is "
44 "guessed from "
45 "its file extension",
46 true, "", "OUTPUT_FILE");
47 cmd.add(argOutputFileName);
48
49 TCLAP::ValueArg<std::string> gmsh_path_arg(
50 "g", "gmsh-path", "Input (.msh). The path to the gmsh binary file",
51 false, "", "INPUT_FILE");
52 cmd.add(gmsh_path_arg);
53 auto log_level_arg = BaseLib::makeLogLevelArg();
54 cmd.add(log_level_arg);
55 cmd.parse(argc, argv);
56
57 BaseLib::MPI::Setup mpi_setup(argc, argv);
58 BaseLib::initOGSLogger(log_level_arg.getValue());
59
60 GeoLib::GEOObjects geoObjects;
61 FileIO::readGeometryFromFile(argInputFileName.getValue(), geoObjects,
62 gmsh_path_arg.getValue());
63 auto const geo_names = geoObjects.getGeometryNames();
64 assert(geo_names.size() == 1);
65
66 FileIO::writeGeometryToFile(geo_names[0], geoObjects,
67 argOutputFileName.getValue());
68
69 return EXIT_SUCCESS;
70}
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[])
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
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