OGS
convertGEO.cpp File Reference

Detailed Description

Definition in file convertGEO.cpp.

#include <tclap/CmdLine.h>
#include <string>
#include <vector>
#include "Applications/FileIO/readGeometryFromFile.h"
#include "Applications/FileIO/writeGeometryToFile.h"
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.h"
#include "GeoLib/GEOObjects.h"
#include "InfoLib/GitInfo.h"
Include dependency graph for convertGEO.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 convertGEO.cpp.

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}
Container class for geometric objects.
Definition GEOObjects.h:57
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
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

References GeoLib::GEOObjects::getGeometryNames(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, FileIO::readGeometryFromFile(), and FileIO::writeGeometryToFile().