OGS
scaleProperty.cpp File Reference

Detailed Description

Definition in file scaleProperty.cpp.

#include <tclap/CmdLine.h>
#include <algorithm>
#include <cmath>
#include <memory>
#include <numeric>
#include "BaseLib/MPI.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Utils/scaleMeshPropertyVector.h"
Include dependency graph for scaleProperty.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 26 of file scaleProperty.cpp.

27{
28 TCLAP::CmdLine cmd(
29 "Scales a property of a mesh.\n\n"
30 "OpenGeoSys-6 software, version " +
32 ".\n"
33 "Copyright (c) 2012-2025, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
36
37 TCLAP::ValueArg<std::string> out_mesh_arg(
38 "o",
39 "out-mesh",
40 "Output (.vtu). The output mesh is stored to a file of this name",
41 true,
42 "",
43 "OUTPUT_FILE");
44 cmd.add(out_mesh_arg);
45
46 TCLAP::ValueArg<std::string> property_arg(
47 "p",
48 "property-name",
49 "the name of the property the values are stored for",
50 true,
51 "",
52 "PROP_NAME");
53 cmd.add(property_arg);
54
55 TCLAP::ValueArg<std::string> mesh_arg(
56 "m", "mesh", "Input (.vtu). The input mesh is read from this file",
57 true, "", "INPUT_FILE");
58 cmd.add(mesh_arg);
59
60 std::vector<std::string> allowed_units{"mm/a", "mm/month", "m/s"};
61 TCLAP::ValuesConstraint<std::string> allowed_units_constraints{
62 allowed_units};
63 TCLAP::ValueArg<std::string> unit_arg("u",
64 "input-unit",
65 "input unit of the data",
66 true,
67 "m/s",
68 &allowed_units_constraints);
69 cmd.add(unit_arg);
70
71 cmd.parse(argc, argv);
72
73 BaseLib::MPI::Setup mpi_setup(argc, argv);
74
75 std::unique_ptr<MeshLib::Mesh> mesh(
76 MeshLib::IO::readMeshFromFile(mesh_arg.getValue()));
77
78 double scale(1.0);
79 if (unit_arg.getValue() == "m/s")
80 {
81 scale = 1.0;
82 }
83 else if (unit_arg.getValue() == "mm/a")
84 {
85 scale = 1e-3 / (365.25 * 86400);
86 }
87 else if (unit_arg.getValue() == "mm/month")
88 {
89 scale = 1e-3 * (12.0 / (365.25 * 86400));
90 }
91
92 MeshLib::scaleMeshPropertyVector(*mesh, property_arg.getValue(), scale);
93
94 MeshLib::IO::writeMeshToFile(*mesh, out_mesh_arg.getValue());
95
96 return EXIT_SUCCESS;
97}
GITINFOLIB_EXPORT const std::string ogs_version
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:44
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)
void scaleMeshPropertyVector(MeshLib::Mesh &mesh, std::string const &property_name, double factor)

References GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), MeshLib::scaleMeshPropertyVector(), and MeshLib::IO::writeMeshToFile().