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/MPI.h"
18#include "InfoLib/GitInfo.h"
21#include "MeshLib/Mesh.h"
22
23int main(int argc, char* argv[])
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}
Git information.
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
Definition of the Mesh class.
int main(int argc, char *argv[])
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.