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