OGS
convertToLinearMesh.cpp File Reference

Detailed Description

Definition in file convertToLinearMesh.cpp.

#include "MeshToolsLib/MeshEditing/ConvertToLinearMesh.h"
#include <tclap/CmdLine.h>
#include <mpi.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 26 of file convertToLinearMesh.cpp.

27{
28 TCLAP::CmdLine cmd(
29 "Convert a non-linear mesh to a linear mesh.\n\n"
30 "OpenGeoSys-6 software, version " +
32 ".\n"
33 "Copyright (c) 2012-2024, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
36 TCLAP::ValueArg<std::string> input_arg(
37 "i", "input-mesh-file", "input mesh file", true, "", "string");
38 cmd.add(input_arg);
39 TCLAP::ValueArg<std::string> output_arg(
40 "o", "output-mesh-file", "output mesh file", true, "", "string");
41 cmd.add(output_arg);
42
43 cmd.parse(argc, argv);
44
45#ifdef USE_PETSC
46 MPI_Init(&argc, &argv);
47#endif
48
49 std::unique_ptr<MeshLib::Mesh> mesh(
50 MeshLib::IO::readMeshFromFile(input_arg.getValue()));
51 if (!mesh)
52 {
53#ifdef USE_PETSC
54 MPI_Finalize();
55#endif
56 return EXIT_FAILURE;
57 }
58 if (!mesh->hasNonlinearElement())
59 {
60 ERR("The input mesh is linear. Exit.");
61#ifdef USE_PETSC
62 MPI_Finalize();
63#endif
64 return EXIT_FAILURE;
65 }
66
67 INFO("Converting to a linear order mesh");
68 std::unique_ptr<MeshLib::Mesh> new_mesh(
69 MeshToolsLib::convertToLinearMesh(*mesh, mesh->getName() + "_linear"));
70
71 INFO("Save the new mesh into a file");
72 MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
73
74#ifdef USE_PETSC
75 MPI_Finalize();
76#endif
77 return EXIT_SUCCESS;
78}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)
std::unique_ptr< MeshLib::Mesh > convertToLinearMesh(MeshLib::Mesh const &mesh, std::string const &new_mesh_name)

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