OGS
convertToLinearMesh.cpp File Reference
#include "MeshToolsLib/MeshEditing/ConvertToLinearMesh.h"
#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.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 19 of file convertToLinearMesh.cpp.

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