OGS
OGS2VTK.cpp File Reference
#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/Mesh.h"
Include dependency graph for OGS2VTK.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 17 of file OGS2VTK.cpp.

18{
19 TCLAP::CmdLine cmd(
20 "Converts OGS mesh into VTK mesh.\n\n"
21 "OpenGeoSys-6 software, version " +
23 ".\n"
24 "Copyright (c) 2012-2026, OpenGeoSys Community "
25 "(http://www.opengeosys.org)",
27 TCLAP::ValueArg<std::string> mesh_in(
28 "i", "mesh-input-file",
29 "Input (.msh). The name of the file containing the input mesh", true,
30 "", "INPUT_FILE");
31 cmd.add(mesh_in);
32 TCLAP::ValueArg<std::string> mesh_out(
33 "o", "mesh-output-file",
34 "Output (.vtk), The name of the file the mesh will be written to", true,
35 "", "OUTPUT_FILE");
36 cmd.add(mesh_out);
37 auto log_level_arg = BaseLib::makeLogLevelArg();
38 cmd.add(log_level_arg);
39 TCLAP::SwitchArg use_ascii_arg(
40 "", "ascii_output",
41 "Write VTU output in ASCII file. Due to possible rounding the ascii "
42 "output could result in lower accuracy");
43 cmd.add(use_ascii_arg);
44 cmd.parse(argc, argv);
45
46 BaseLib::MPI::Setup mpi_setup(argc, argv);
47 BaseLib::initOGSLogger(log_level_arg.getValue());
48
49 std::unique_ptr<MeshLib::Mesh const> mesh(
50 MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
51 if (!mesh)
52 {
53 return EXIT_FAILURE;
54 }
55 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
56 mesh->getNumberOfElements());
57
58 auto const data_mode =
59 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
60
61 MeshLib::IO::writeVtu(*mesh, mesh_out.getValue(), data_mode);
62
63 return EXIT_SUCCESS;
64}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:56
GITINFOLIB_EXPORT const std::string ogs_version
int writeVtu(MeshLib::Mesh const &mesh, std::string const &file_name, int const data_mode)
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)

References INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeVtu().