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