OGS
VTK2OGS.cpp
Go to the documentation of this file.
1
14// STL
15#include <tclap/CmdLine.h>
16
17#include <string>
18
19#include "BaseLib/MPI.h"
20#include "InfoLib/GitInfo.h"
23#include "MeshLib/Mesh.h"
24
25int main(int argc, char* argv[])
26{
27 TCLAP::CmdLine cmd(
28 "Converts VTK mesh into OGS mesh.\n\n"
29 "OpenGeoSys-6 software, version " +
31 ".\n"
32 "Copyright (c) 2012-2024, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
35 TCLAP::ValueArg<std::string> mesh_in(
36 "i", "mesh-input-file",
37 "the name of the file containing the input mesh", true, "",
38 "file name of input mesh");
39 cmd.add(mesh_in);
40 TCLAP::ValueArg<std::string> mesh_out(
41 "o", "mesh-output-file",
42 "the name of the file the mesh will be written to", true, "",
43 "file name of output mesh");
44 cmd.add(mesh_out);
45 cmd.parse(argc, argv);
46
47 BaseLib::MPI::Setup mpi_setup(argc, argv);
48
49 MeshLib::Mesh* mesh(
50 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
51 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
52 mesh->getNumberOfElements());
53
55 meshIO.setMesh(mesh);
56 BaseLib::IO::writeStringToFile(meshIO.writeToString(), mesh_out.getValue());
57
58 return EXIT_SUCCESS;
59}
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:25
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