OGS
createQuadraticMesh.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include <tclap/CmdLine.h>
5
6#include <memory>
7#include <string>
8
9#include "BaseLib/Logging.h"
10#include "BaseLib/MPI.h"
12#include "InfoLib/GitInfo.h"
15#include "MeshLib/Mesh.h"
17
18int main(int argc, char* argv[])
19{
20 TCLAP::CmdLine cmd(
21 "Create quadratic order mesh.\n\n"
22 "OpenGeoSys-6 software, version " +
24 ".\n"
25 "Copyright (c) 2012-2026, OpenGeoSys Community "
26 "(http://www.opengeosys.org)",
28
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 TCLAP::SwitchArg add_centre_node_arg("c", "add-centre-node",
38 "add centre node", false);
39 cmd.add(add_centre_node_arg);
40
41 auto log_level_arg = BaseLib::makeLogLevelArg();
42 cmd.add(log_level_arg);
43 cmd.parse(argc, argv);
44
45 BaseLib::MPI::Setup mpi_setup(argc, argv);
46 BaseLib::initOGSLogger(log_level_arg.getValue());
47
48 std::unique_ptr<MeshLib::Mesh> mesh(
49 MeshLib::IO::readMeshFromFile(input_arg.getValue()));
50 if (!mesh)
51 {
52 return EXIT_FAILURE;
53 }
54
55 INFO("Create a quadratic order mesh");
57 *mesh, add_centre_node_arg.getValue()));
58
59 INFO("Save the new mesh into a file");
60 MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue());
61
62 return EXIT_SUCCESS;
63}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
int main(int argc, char *argv[])
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 > createQuadraticOrderMesh(MeshLib::Mesh const &linear_mesh, bool const add_centre_node)