OGS
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 "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 24 of file OGS2VTK.cpp.

25 {
26  TCLAP::CmdLine cmd(
27  "Converts OGS mesh into VTK mesh.\n\n"
28  "OpenGeoSys-6 software, version " +
30  ".\n"
31  "Copyright (c) 2012-2021, OpenGeoSys Community "
32  "(http://www.opengeosys.org)",
34  TCLAP::ValueArg<std::string> mesh_in(
35  "i", "mesh-input-file",
36  "the name of the file containing the input mesh", true, "",
37  "file name of input mesh");
38  cmd.add(mesh_in);
39  TCLAP::ValueArg<std::string> mesh_out(
40  "o", "mesh-output-file",
41  "the name of the file the mesh will be written to", true, "",
42  "file name of output mesh");
43  cmd.add(mesh_out);
44  TCLAP::SwitchArg use_ascii_arg(
45  "", "ascii_output",
46  "Write VTU output in ASCII format. Due to possible rounding the ascii "
47  "output could result in lower accuracy.");
48  cmd.add(use_ascii_arg);
49  cmd.parse(argc, argv);
50 
51  std::unique_ptr<MeshLib::Mesh const> mesh(
52  MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
53  if (!mesh)
54  {
55  return EXIT_FAILURE;
56  }
57  INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
58  mesh->getNumberOfElements());
59 
60  auto const data_mode =
61  use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
62 
63  MeshLib::IO::writeVtu(*mesh, mesh_out.getValue(), data_mode);
64 
65  return EXIT_SUCCESS;
66 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
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)

References INFO(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeVtu().