OGS
convertToLinearMesh.cpp
Go to the documentation of this file.
1
11
12#include <tclap/CmdLine.h>
13
14#include <memory>
15#include <string>
16
17#include "BaseLib/Logging.h"
18#include "BaseLib/MPI.h"
20#include "InfoLib/GitInfo.h"
23#include "MeshLib/Mesh.h"
24
25int main(int argc, char* argv[])
26{
27 TCLAP::CmdLine cmd(
28 "Convert a non-linear mesh to a linear mesh.\n\n"
29 "OpenGeoSys-6 software, version " +
31 ".\n"
32 "Copyright (c) 2012-2025, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
35 TCLAP::ValueArg<std::string> input_arg("i", "input-mesh-file",
36 "Input (.vtu | .msh) mesh file",
37 true, "", "INPUT_FILE");
38 cmd.add(input_arg);
39 TCLAP::ValueArg<std::string> output_arg("o", "output-mesh-file",
40 "Output (.vtu | .msh) mesh file",
41 true, "", "OUTPUT_FILE");
42 cmd.add(output_arg);
43 auto log_level_arg = BaseLib::makeLogLevelArg();
44 cmd.add(log_level_arg);
45
46 cmd.parse(argc, argv);
47
48 BaseLib::MPI::Setup mpi_setup(argc, argv);
49 BaseLib::initOGSLogger(log_level_arg.getValue());
50
51 std::unique_ptr<MeshLib::Mesh> mesh(
52 MeshLib::IO::readMeshFromFile(input_arg.getValue()));
53 if (!mesh)
54 {
55 return EXIT_FAILURE;
56 }
57 if (!mesh->hasNonlinearElement())
58 {
59 ERR("The input mesh is linear. Exit.");
60 return EXIT_FAILURE;
61 }
62
63 INFO("Converting to a linear order mesh");
64 std::unique_ptr<MeshLib::Mesh> new_mesh(
65 MeshToolsLib::convertToLinearMesh(*mesh, mesh->getName() + "_linear"));
66
67 INFO("Save the new mesh into a file");
68 MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
69
70 return EXIT_SUCCESS;
71}
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:48
Definition of the Mesh class.
int main(int argc, char *argv[])
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
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)
Definition of readMeshFromFile function.