OGS
reviseMesh.cpp File Reference

Detailed Description

Definition in file reviseMesh.cpp.

#include <tclap/CmdLine.h>
#include <array>
#include <memory>
#include <string>
#include "BaseLib/FileTools.h"
#include "BaseLib/StringTools.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/MeshEditing/MeshRevision.h"
#include "MeshLib/Node.h"
Include dependency graph for reviseMesh.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 26 of file reviseMesh.cpp.

27 {
28  TCLAP::CmdLine cmd(
29  "Revises meshes by collapsing duplicate nodes, (optionally) removing "
30  "elements of lower dimension than the mesh itself, and subdividing "
31  "geometrically broken mesh elements.\n\n"
32  "OpenGeoSys-6 software, version " +
34  ".\n"
35  "Copyright (c) 2012-2021, OpenGeoSys Community "
36  "(http://www.opengeosys.org)",
38  TCLAP::ValueArg<unsigned> minDim_arg(
39  "d", "min-ele-dim",
40  "Minimum dimension of elements to be inserted into new mesh", false, 1,
41  "unsigned");
42  cmd.add(minDim_arg);
43 
44  TCLAP::ValueArg<double> eps_arg(
45  "e", "eps", "Minimum distance for nodes not to be collapsed", false,
46  std::numeric_limits<double>::epsilon(), "float");
47  cmd.add(eps_arg);
48 
49  TCLAP::ValueArg<std::string> output_arg(
50  "o", "output-mesh-file", "output mesh file", true, "", "string");
51  cmd.add(output_arg);
52 
53  TCLAP::ValueArg<std::string> input_arg(
54  "i", "input-mesh-file", "input mesh file", true, "", "string");
55  cmd.add(input_arg);
56  cmd.parse(argc, argv);
57 
58  // read a mesh file
59  std::unique_ptr<MeshLib::Mesh> org_mesh(
60  MeshLib::IO::readMeshFromFile(input_arg.getValue()));
61  if (!org_mesh)
62  {
63  return EXIT_FAILURE;
64  }
65  INFO("Mesh read: {:d} nodes, {:d} elements.", org_mesh->getNumberOfNodes(),
66  org_mesh->getNumberOfElements());
67 
68  // revise the mesh
69  INFO("Simplifying the mesh...");
70  MeshLib::MeshRevision const rev(const_cast<MeshLib::Mesh&>(*org_mesh));
71  unsigned int minDim =
72  (minDim_arg.isSet() ? minDim_arg.getValue() : org_mesh->getDimension());
73  std::unique_ptr<MeshLib::Mesh> new_mesh(
74  rev.simplifyMesh("revised_mesh", eps_arg.getValue(), minDim));
75 
76  // write into a file
77  if (new_mesh)
78  {
79  INFO("Revised mesh: {:d} nodes, {:d} elements.",
80  new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
81  MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
82  }
83 
84  return EXIT_SUCCESS;
85 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
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)

References INFO(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), MeshLib::MeshRevision::simplifyMesh(), and MeshLib::IO::writeMeshToFile().