126int main(
int argc,
char* argv[])
129 "Creates boundary conditions for mesh nodes along polylines."
130 "The documentation is available at "
131 "https://docs.opengeosys.org/docs/tools/model-preparation/"
132 "create-boundary-conditions-along-a-polyline.\n\n"
133 "OpenGeoSys-6 software, version " +
136 "Copyright (c) 2012-2024, OpenGeoSys Community "
137 "(http://www.opengeosys.org)",
139 TCLAP::SwitchArg gml_arg(
"",
"gml",
"Write found nodes to gml file.");
142 TCLAP::ValueArg<std::string> output_base_fname(
143 "o",
"output-base-file-name",
144 "the base name of the file the output (geometry (gli) and boundary "
145 "condition (bc)) will be written to",
146 true,
"",
"file name");
147 cmd.add(output_base_fname);
149 TCLAP::ValueArg<std::string> bc_type(
151 "the process type the boundary condition will be written for currently "
152 "LIQUID_FLOW (primary variable PRESSURE1) and GROUNDWATER_FLOW "
153 "(primary variable HEAD, default) are supported",
155 "process type as string (LIQUID_FLOW or GROUNDWATER_FLOW (default))");
158 TCLAP::ValueArg<double> search_length_arg(
159 "s",
"search-length",
160 "The size of the search length. The default value is "
161 "std::numeric_limits<double>::epsilon()",
162 false, std::numeric_limits<double>::epsilon(),
"floating point number");
163 cmd.add(search_length_arg);
165 TCLAP::ValueArg<std::string> geometry_fname(
166 "i",
"input-geometry",
167 "the name of the file containing the input geometry",
true,
"",
169 cmd.add(geometry_fname);
171 TCLAP::ValueArg<std::string> mesh_arg(
172 "m",
"mesh-file",
"the name of the file containing the mesh",
true,
"",
176 TCLAP::ValueArg<std::string> gmsh_path_arg(
"g",
"gmsh-path",
177 "the path to the gmsh binary",
178 false,
"",
"path as string");
179 cmd.add(gmsh_path_arg);
181 cmd.parse(argc, argv);
186 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
187 std::unique_ptr<MeshLib::Mesh> subsurface_mesh(
190 INFO(
"Extracting top surface of mesh '{:s}' ... ", mesh_arg.getValue());
191 Eigen::Vector3d
const dir({0, 0, -1});
192 double const angle(90);
193 std::unique_ptr<MeshLib::Mesh> surface_mesh(
197 subsurface_mesh.reset(
nullptr);
202 gmsh_path_arg.getValue());
208 std::vector<GeoLib::Polyline*>
const* plys(
212 ERR(
"Could not get vector of polylines out of geometry '{:s}'.",
217 auto search_length_strategy =
218 std::make_unique<MeshGeoToolsLib::SearchLength>();
219 if (search_length_arg.isSet())
221 search_length_strategy.reset(
227 *surface_mesh, std::move(search_length_strategy),
229 for (std::size_t k(0); k < plys->size(); k++)
236 std::string polyline_name(
"Polyline-" + std::to_string(k));
243 if (geo_names.empty())
245 ERR(
"Did not find mesh nodes along polylines.");
249 std::string merge_name(
"AllMeshNodesAlongPolylines");
252 merge_name = geo_names[0];
256 auto const& merged_pnts(pnt_vec->
getVector());
258 std::vector<GeoLib::Point> pnts_with_id;
259 const std::size_t n_merged_pnts(merged_pnts.size());
260 for (std::size_t k(0); k < n_merged_pnts; ++k)
262 pnts_with_id.emplace_back(*(merged_pnts[k]), k);
265 std::sort(pnts_with_id.begin(), pnts_with_id.end(),
267 { return p0 < p1; });
269 double const eps(std::numeric_limits<double>::epsilon());
270 std::vector<GeoLib::Point*> surface_pnts;
274 surface_pnts.push_back(
277 std::string element_name;
279 name_id_map[element_name] = 0;
281 for (std::size_t k(1); k < n_merged_pnts; ++k)
285 if (std::abs(p0[0] - p1[0]) > eps || std::abs(p0[1] - p1[1]) > eps)
287 surface_pnts.push_back(
289 std::string element_name;
291 name_id_map[element_name] = surface_pnts.size() - 1;
296 "-MeshNodesAlongPolylines");
297 geometry_sets.
addPointVec(std::move(surface_pnts), surface_name,
298 std::move(name_id_map), 1e-6);
301 std::string
const base_fname(
304 bc_type.getValue(), gml_arg.getValue());