OGS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
OGS2VTK.cpp File Reference

Detailed Description

Converts OGS mesh into VTK mesh.

Author
Thomas Fischer
Date
Jan 24, 2013

Definition in file OGS2VTK.cpp.

#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "BaseLib/MPI.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 25 of file OGS2VTK.cpp.

26{
27 TCLAP::CmdLine cmd(
28 "Converts OGS mesh into VTK mesh.\n\n"
29 "OpenGeoSys-6 software, version " +
31 ".\n"
32 "Copyright (c) 2012-2025, 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 TCLAP::SwitchArg use_ascii_arg(
46 "", "ascii_output",
47 "Write VTU output in ASCII format. Due to possible rounding the ascii "
48 "output could result in lower accuracy.");
49 cmd.add(use_ascii_arg);
50 cmd.parse(argc, argv);
51
52 BaseLib::MPI::Setup mpi_setup(argc, argv);
53
54 std::unique_ptr<MeshLib::Mesh const> mesh(
55 MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
56 if (!mesh)
57 {
58 return EXIT_FAILURE;
59 }
60 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
61 mesh->getNumberOfElements());
62
63 auto const data_mode =
64 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
65
66 MeshLib::IO::writeVtu(*mesh, mesh_out.getValue(), data_mode);
67
68 return EXIT_SUCCESS;
69}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
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(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeVtu().