OGS
convertToLinearMesh.cpp File Reference

Detailed Description

Definition in file convertToLinearMesh.cpp.

#include "MeshLib/MeshEditing/ConvertToLinearMesh.h"
#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
Include dependency graph for convertToLinearMesh.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 22 of file convertToLinearMesh.cpp.

23 {
24  TCLAP::CmdLine cmd(
25  "Convert a non-linear mesh to a linear mesh.\n\n"
26  "OpenGeoSys-6 software, version " +
28  ".\n"
29  "Copyright (c) 2012-2021, OpenGeoSys Community "
30  "(http://www.opengeosys.org)",
32  TCLAP::ValueArg<std::string> input_arg(
33  "i", "input-mesh-file", "input mesh file", true, "", "string");
34  cmd.add(input_arg);
35  TCLAP::ValueArg<std::string> output_arg(
36  "o", "output-mesh-file", "output mesh file", true, "", "string");
37  cmd.add(output_arg);
38 
39  cmd.parse(argc, argv);
40 
41  std::unique_ptr<MeshLib::Mesh> mesh(
42  MeshLib::IO::readMeshFromFile(input_arg.getValue()));
43  if (!mesh)
44  {
45  return EXIT_FAILURE;
46  }
47  if (!mesh->hasNonlinearElement())
48  {
49  ERR("The input mesh is linear. Exit.");
50  return EXIT_FAILURE;
51  }
52 
53  INFO("Converting to a linear order mesh");
54  std::unique_ptr<MeshLib::Mesh> new_mesh(
55  MeshLib::convertToLinearMesh(*mesh, mesh->getName() + "_linear"));
56 
57  INFO("Save the new mesh into a file");
58  MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
59 
60  return EXIT_SUCCESS;
61 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
void ERR(char const *fmt, Args const &... args)
Definition: Logging.h:42
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)
std::unique_ptr< MeshLib::Mesh > convertToLinearMesh(MeshLib::Mesh const &org_mesh, std::string const &new_mesh_name)

References MeshLib::convertToLinearMesh(), ERR(), INFO(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeMeshToFile().