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