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

18{
19 TCLAP::CmdLine cmd(
20 "Converts VTK mesh into OGS 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 (.vtk). 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 (.msh). 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 cmd.parse(argc, argv);
40
41 BaseLib::MPI::Setup mpi_setup(argc, argv);
42 BaseLib::initOGSLogger(log_level_arg.getValue());
43
44 MeshLib::Mesh* mesh(
45 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
46 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
47 mesh->getNumberOfElements());
48
50 meshIO.setMesh(mesh);
51 BaseLib::IO::writeStringToFile(meshIO.writeToString(), mesh_out.getValue());
52
53 return EXIT_SUCCESS;
54}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
std::string writeToString()
Writes the object to a string.
Definition Writer.cpp:20
Interface for handling mesh files from OGS-5 and below. (*.msh files)
Definition MeshIO.h:26
void setMesh(const MeshLib::Mesh *mesh)
Set mesh for writing.
Definition MeshIO.cpp:427
static MeshLib::Mesh * readVTUFile(std::string const &file_name, bool const compute_element_neighbors=false)
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:34
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:56
GITINFOLIB_EXPORT const std::string ogs_version

References MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::VtuInterface::readVTUFile(), MeshLib::IO::Legacy::MeshIO::setMesh(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().