OGS
VTK2OGS.cpp
Go to the documentation of this file.
1
14// STL
15#include <tclap/CmdLine.h>
16
17#ifdef USE_PETSC
18#include <mpi.h>
19#endif
20
21#include <string>
22
23#include "InfoLib/GitInfo.h"
26#include "MeshLib/Mesh.h"
27
28int main(int argc, char* argv[])
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}
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the MeshIO class.
Definition of the Mesh class.
int main(int argc, char *argv[])
Definition VTK2OGS.cpp:28
Implementation of the VtuInterface class.
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)
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:100
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:45
GITINFOLIB_EXPORT const std::string ogs_version