OGS
convertGEO.cpp File Reference

Detailed Description

Definition in file convertGEO.cpp.

#include <tclap/CmdLine.h>
#include <mpi.h>
#include <string>
#include <vector>
#include "Applications/FileIO/readGeometryFromFile.h"
#include "Applications/FileIO/writeGeometryToFile.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 25 of file convertGEO.cpp.

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