26{
27 TCLAP::CmdLine cmd(
28 "Moves the points of a geometry by a given displacement vector\n\n"
29 "OpenGeoSys-6 software, version " +
31 ".\n"
32 "Copyright (c) 2012-2024, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
35 TCLAP::ValueArg<double> z_arg("z", "z", "displacement in z direction",
36 false, 0.0, "z-displacement");
37 cmd.add(z_arg);
38 TCLAP::ValueArg<double> y_arg("y", "y", "displacement in y direction",
39 false, 0.0, "y-displacement");
40 cmd.add(y_arg);
41 TCLAP::ValueArg<double> x_arg("x", "x", "displacement in x direction",
42 false, 0.0, "x-displacement");
43 cmd.add(x_arg);
44 TCLAP::ValueArg<std::string> geo_output_arg(
45 "o", "output", "output geometry file (*.gml)", true, "", "output file");
46 cmd.add(geo_output_arg);
47 TCLAP::ValueArg<std::string> geo_input_arg(
48 "i", "input", "input geometry file (*.gml)", true, "", "input file");
49 cmd.add(geo_input_arg);
50 cmd.parse(argc, argv);
51
52#ifdef USE_PETSC
53 MPI_Init(&argc, &argv);
54#endif
55
58 try
59 {
60 if (!xml.readFile(geo_input_arg.getValue()))
61 {
62#ifdef USE_PETSC
63 MPI_Finalize();
64#endif
65 return EXIT_FAILURE;
66 }
67 }
68 catch (std::runtime_error const& err)
69 {
70 ERR(
"Failed to read file `{:s}'.", geo_input_arg.getValue());
71 ERR(
"{:s}", err.what());
72#ifdef USE_PETSC
73 MPI_Finalize();
74#endif
75 return EXIT_FAILURE;
76 }
77
78 Eigen::Vector3d displacement = Eigen::Vector3d::Zero();
79 if (x_arg.isSet())
80 {
81 displacement[0] = x_arg.getValue();
82 }
83 if (y_arg.isSet())
84 {
85 displacement[1] = y_arg.getValue();
86 }
87 if (z_arg.isSet())
88 {
89 displacement[2] = z_arg.getValue();
90 }
91
93
94 std::vector<GeoLib::Point*> const* point_vec =
96 std::size_t const n_points = point_vec->size();
97 for (std::size_t i = 0; i < n_points; ++i)
98 {
99 for (std::size_t c = 0;
c < 3; ++
c)
100 {
101 (*(*point_vec)[i])[c] += displacement[c];
102 }
103 }
104
105 xml.export_name = geo_name;
107 geo_output_arg.getValue());
108
109#ifdef USE_PETSC
110 MPI_Finalize();
111#endif
112 return EXIT_SUCCESS;
113}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const std::vector< Point * > * getPointVec(const std::string &name) const
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
GITINFOLIB_EXPORT const std::string ogs_version