OGS
VTK2OGS.cpp File Reference

Detailed Description

Converts VTK mesh into OGS mesh.

Author
Norihiro Watanabe
Date
Aug 07, 2013

Definition in file VTK2OGS.cpp.

#include <tclap/CmdLine.h>
#include <mpi.h>
#include <string>
#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 28 of file VTK2OGS.cpp.

29{
30 TCLAP::CmdLine cmd(
31 "Converts VTK mesh into OGS mesh.\n\n"
32 "OpenGeoSys-6 software, version " +
34 ".\n"
35 "Copyright (c) 2012-2024, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
38 TCLAP::ValueArg<std::string> mesh_in(
39 "i", "mesh-input-file",
40 "the name of the file containing the input mesh", true, "",
41 "file name of input mesh");
42 cmd.add(mesh_in);
43 TCLAP::ValueArg<std::string> mesh_out(
44 "o", "mesh-output-file",
45 "the name of the file the mesh will be written to", true, "",
46 "file name of output mesh");
47 cmd.add(mesh_out);
48 cmd.parse(argc, argv);
49
50#ifdef USE_PETSC
51 MPI_Init(&argc, &argv);
52#endif
53
54 MeshLib::Mesh* mesh(
55 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
56 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
57 mesh->getNumberOfElements());
58
60 meshIO.setMesh(mesh);
61 BaseLib::IO::writeStringToFile(meshIO.writeToString(), mesh_out.getValue());
62
63#ifdef USE_PETSC
64 MPI_Finalize();
65#endif
66 return EXIT_SUCCESS;
67}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
std::string writeToString()
Writes the object to a string.
Definition Writer.cpp:31
Interface for handling mesh files from OGS-5 and below. (*.msh files)
Definition MeshIO.h:37
void setMesh(const MeshLib::Mesh *mesh)
Set mesh for writing.
Definition MeshIO.cpp:439
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:45
GITINFOLIB_EXPORT const std::string ogs_version

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