31 "Extracts a 2D surface from a 3D input mesh by specifying a normal "
32 "vector and an angle. (The surface normal (0, 0, 0) will extract the "
33 "complete outer boundary of the 3D mesh.)\n"
34 "An extensive documentation can be found at "
35 "https://docs.opengeosys.org/docs/tools/meshing-submeshes/"
37 "OpenGeoSys-6 software, version " +
40 "Copyright (c) 2012-2021, OpenGeoSys Community "
41 "(http://www.opengeosys.org)",
43 TCLAP::SwitchArg use_ascii_arg(
"",
"ascii-output",
44 "If the switch is set use ascii instead of "
45 "binary format for data in the vtu output.",
47 cmd.add(use_ascii_arg);
48 TCLAP::ValueArg<std::string> face_prop_name(
49 "f",
"face-property-name",
50 "the name of the data array the surface face id of the subsurface/bulk "
51 "element will be stored to",
52 false,
"bulk_face_ids",
"string");
53 cmd.add(face_prop_name);
54 TCLAP::ValueArg<std::string> element_prop_name(
55 "e",
"element-property-name",
56 "the name of the data array the subsurface/bulk element id will be "
58 false,
"bulk_element_ids",
"string");
59 cmd.add(element_prop_name);
60 TCLAP::ValueArg<std::string> node_prop_name(
61 "n",
"node-property-name",
62 "the name of the data array the subsurface/bulk node id will be stored "
64 false,
"bulk_node_ids",
"string");
65 cmd.add(node_prop_name);
66 TCLAP::ValueArg<double> angle_arg(
68 "tolerated angle (in degrees) between given normal and element normal",
69 false, 90,
"floating point value");
71 TCLAP::ValueArg<double> z(
"z",
"z-component",
"z component of the normal",
72 false, -1.0,
"floating point value");
74 TCLAP::ValueArg<double> y(
"y",
"y-component",
"y component of the normal",
75 false, 0,
"floating point value");
77 TCLAP::ValueArg<double> x(
"x",
"x-component",
"x component of the normal",
78 false, 0,
"floating point value");
80 TCLAP::ValueArg<std::string> mesh_out(
81 "o",
"mesh-output-file",
82 "the name of the file the surface mesh should be written to",
false,
"",
83 "file name of output mesh");
85 TCLAP::ValueArg<std::string> mesh_in(
86 "i",
"mesh-input-file",
87 "the name of the file containing the input mesh",
true,
"",
88 "file name of input mesh");
90 cmd.parse(argc, argv);
92 std::unique_ptr<MeshLib::Mesh const> mesh(
97 ERR(
"Error reading mesh file.");
101 if (mesh->getDimension() != 3)
103 ERR(
"Surfaces can currently only be extracted from 3D meshes.");
107 INFO(
"Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
108 mesh->getNumberOfElements());
111 Eigen::Vector3d
const dir({x.getValue(), y.getValue(), z.getValue()});
112 double const angle(angle_arg.getValue());
113 std::unique_ptr<MeshLib::Mesh> surface_mesh(
115 *mesh, dir, angle, node_prop_name.getValue(),
116 element_prop_name.getValue(), face_prop_name.getValue()));
118 std::string out_fname(mesh_out.getValue());
119 if (out_fname.empty())
124 auto const data_mode =
125 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
std::string dropFileExtension(std::string const &filename)
GITINFOLIB_EXPORT const std::string ogs_version
int writeVtu(MeshLib::Mesh const &mesh, std::string const &file_name, int const data_mode)
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)