OGS
convertToLinearMesh.cpp File Reference

Detailed Description

Definition in file convertToLinearMesh.cpp.

#include "MeshToolsLib/MeshEditing/ConvertToLinearMesh.h"
#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "BaseLib/MPI.h"
#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 23 of file convertToLinearMesh.cpp.

24{
25 TCLAP::CmdLine cmd(
26 "Convert a non-linear mesh to a linear mesh.\n\n"
27 "OpenGeoSys-6 software, version " +
29 ".\n"
30 "Copyright (c) 2012-2025, OpenGeoSys Community "
31 "(http://www.opengeosys.org)",
33 TCLAP::ValueArg<std::string> input_arg("i", "input-mesh-file",
34 "Input (.vtu | .msh) mesh file",
35 true, "", "INPUT_FILE");
36 cmd.add(input_arg);
37 TCLAP::ValueArg<std::string> output_arg("o", "output-mesh-file",
38 "Output (.vtu | .msh) mesh file",
39 true, "", "OUTPUT_FILE");
40 cmd.add(output_arg);
41
42 cmd.parse(argc, argv);
43
44 BaseLib::MPI::Setup mpi_setup(argc, argv);
45
46 std::unique_ptr<MeshLib::Mesh> mesh(
47 MeshLib::IO::readMeshFromFile(input_arg.getValue()));
48 if (!mesh)
49 {
50 return EXIT_FAILURE;
51 }
52 if (!mesh->hasNonlinearElement())
53 {
54 ERR("The input mesh is linear. Exit.");
55 return EXIT_FAILURE;
56 }
57
58 INFO("Converting to a linear order mesh");
59 std::unique_ptr<MeshLib::Mesh> new_mesh(
60 MeshToolsLib::convertToLinearMesh(*mesh, mesh->getName() + "_linear"));
61
62 INFO("Save the new mesh into a file");
63 MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
64
65 return EXIT_SUCCESS;
66}
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().