30{
31 TCLAP::CmdLine cmd(
32 "Scales a property of a mesh.\n\n"
33 "OpenGeoSys-6 software, version " +
35 ".\n"
36 "Copyright (c) 2012-2024, OpenGeoSys Community "
37 "(http://www.opengeosys.org)",
39
40 TCLAP::ValueArg<std::string> out_mesh_arg(
41 "o",
42 "out-mesh",
43 "the mesh is stored to a file of this name",
44 true,
45 "",
46 "filename for mesh output");
47 cmd.add(out_mesh_arg);
48
49 TCLAP::ValueArg<std::string> property_arg(
50 "p",
51 "property-name",
52 "the name of the property the values are stored for",
53 true,
54 "",
55 "property name as string");
56 cmd.add(property_arg);
57
58 TCLAP::ValueArg<std::string> mesh_arg(
59 "m", "mesh", "the mesh is read from this file", true, "", "file name");
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
73 cmd.parse(argc, argv);
74
75#ifdef USE_PETSC
76 MPI_Init(&argc, &argv);
77#endif
78
79 std::unique_ptr<MeshLib::Mesh> mesh(
81
83 if (unit_arg.getValue() == "m/s")
84 {
86 }
87 else if (unit_arg.getValue() == "mm/a")
88 {
89 scale = 1e-3 / (365.25 * 86400);
90 }
91 else if (unit_arg.getValue() == "mm/month")
92 {
93 scale = 1e-3 * (12.0 / (365.25 * 86400));
94 }
95
97
99
100#ifdef USE_PETSC
101 MPI_Finalize();
102#endif
103 return EXIT_SUCCESS;
104}
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)