32int main(
int argc,
char* argv[])
35 "Extracts a 2D surface from a 3D input mesh by specifying a normal "
36 "vector and an angle. (The surface normal (0, 0, 0) will extract the "
37 "complete outer boundary of the 3D mesh.)\n"
38 "An extensive documentation can be found at "
39 "https://docs.opengeosys.org/docs/tools/meshing-submeshes/"
41 "OpenGeoSys-6 software, version " +
44 "Copyright (c) 2012-2024, OpenGeoSys Community "
45 "(http://www.opengeosys.org)",
47 TCLAP::SwitchArg use_ascii_arg(
"",
"ascii-output",
48 "If the switch is set use ascii instead of "
49 "binary format for data in the vtu output.",
51 cmd.add(use_ascii_arg);
52 TCLAP::ValueArg<double> angle_arg(
54 "tolerated angle (in degrees) between given normal and element normal",
55 false, 90,
"floating point value");
57 TCLAP::ValueArg<double> z(
"z",
"z-component",
"z component of the normal",
58 false, -1.0,
"floating point value");
60 TCLAP::ValueArg<double> y(
"y",
"y-component",
"y component of the normal",
61 false, 0,
"floating point value");
63 TCLAP::ValueArg<double> x(
"x",
"x-component",
"x component of the normal",
64 false, 0,
"floating point value");
66 TCLAP::ValueArg<std::string> mesh_out(
67 "o",
"mesh-output-file",
68 "the name of the file the surface mesh should be written to",
false,
"",
69 "file name of output mesh");
71 TCLAP::ValueArg<std::string> mesh_in(
72 "i",
"mesh-input-file",
73 "the name of the file containing the input mesh",
true,
"",
74 "file name of input mesh");
76 cmd.parse(argc, argv);
79 MPI_Init(&argc, &argv);
83 mesh_in.getValue(),
true ));
87 ERR(
"Error reading mesh file.");
94 if (mesh->getDimension() != 3)
96 ERR(
"Surfaces can currently only be extracted from 3D meshes.");
103 INFO(
"Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
104 mesh->getNumberOfElements());
107 Eigen::Vector3d
const dir({x.getValue(), y.getValue(), z.getValue()});
108 double const angle(angle_arg.getValue());
109 std::unique_ptr<MeshLib::Mesh> surface_mesh(
115 std::string out_fname(mesh_out.getValue());
116 if (out_fname.empty())
121 auto const data_mode =
122 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;