Forked from
ogs / ogs
12063 commits behind the upstream repository.
-
Dmitri Naumov authoredDmitri Naumov authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
OGS2VTK.cpp 2.09 KiB
/**
* @file OGS2VTK.cpp
* @author Thomas Fischer
* @date Jan 24, 2013
* @brief Converts OGS mesh into VTK mesh.
*
* @copyright
* Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#include <string>
#include <memory>
#include <tclap/CmdLine.h>
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/Mesh.h"
int main (int argc, char* argv[])
{
TCLAP::CmdLine cmd(
"Converts OGS mesh into VTK mesh.\n\n"
"OpenGeoSys-6 software, version " +
GitInfoLib::GitInfo::ogs_version +
".\n"
"Copyright (c) 2012-2020, OpenGeoSys Community "
"(http://www.opengeosys.org)",
' ', GitInfoLib::GitInfo::ogs_version);
TCLAP::ValueArg<std::string> mesh_in(
"i", "mesh-input-file",
"the name of the file containing the input mesh", true, "",
"file name of input mesh");
cmd.add(mesh_in);
TCLAP::ValueArg<std::string> mesh_out(
"o", "mesh-output-file",
"the name of the file the mesh will be written to", true, "",
"file name of output mesh");
cmd.add(mesh_out);
TCLAP::ValueArg<bool> use_ascii_arg(
"", "ascii_output",
"Use ascii format for data in the vtu output. Due to possible rounding "
"the ascii output could result in lower accuracy.",
false, false, "boolean value");
cmd.add(use_ascii_arg);
cmd.parse(argc, argv);
std::unique_ptr<MeshLib::Mesh const> mesh(
MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
if (!mesh)
{
return EXIT_FAILURE;
}
INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
mesh->getNumberOfElements());
auto const data_mode =
use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
MeshLib::IO::writeVtu(*mesh, mesh_out.getValue(), data_mode);
return EXIT_SUCCESS;
}