128int main(
int argc,
char* argv[])
131 "Creates boundary conditions for mesh nodes along polylines."
132 "The documentation is available at "
133 "https://docs.opengeosys.org/docs/tools/model-preparation/"
134 "create-boundary-conditions-along-a-polyline.\n\n"
135 "OpenGeoSys-6 software, version " +
138 "Copyright (c) 2012-2025, OpenGeoSys Community "
139 "(http://www.opengeosys.org)",
141 TCLAP::SwitchArg gml_arg(
"",
"gml",
"Write found nodes to gml file.");
144 TCLAP::ValueArg<std::string> output_base_fname(
145 "o",
"output-base-file-name",
146 "Output. The base name of the file the output (geometry (gli) and "
148 "condition (bc)) will be written to",
149 true,
"",
"BASE_FILENAME_OUTPUT");
150 cmd.add(output_base_fname);
152 std::vector<std::string> allowed_types_vector{
"LIQUID_FLOW",
154 TCLAP::ValuesConstraint<std::string> allowed_types(allowed_types_vector);
155 TCLAP::ValueArg<std::string> bc_type(
157 "the process type the boundary condition will be written for currently "
158 "LIQUID_FLOW (primary variable PRESSURE1) and GROUNDWATER_FLOW "
159 "(primary variable HEAD, default) are supported, ",
160 true,
"", &allowed_types);
163 TCLAP::ValueArg<double> search_length_arg(
164 "s",
"search-length",
"The size of the search length ",
false,
165 std::numeric_limits<double>::epsilon(),
"SEARCH_LENGTH");
166 cmd.add(search_length_arg);
168 TCLAP::ValueArg<std::string> geometry_fname(
169 "i",
"input-geometry",
170 "Input (.gml | .gli). The name of the input file containing the "
172 true,
"",
"INPUT_FILE");
173 cmd.add(geometry_fname);
175 TCLAP::ValueArg<std::string> mesh_arg(
177 "Input (.vtu). The name of the input file containing the mesh",
true,
181 TCLAP::ValueArg<std::string> gmsh_path_arg(
182 "g",
"gmsh-path",
"Input (.msh). The path to the gmsh binary",
false,
184 cmd.add(gmsh_path_arg);
187 cmd.add(log_level_arg);
188 cmd.parse(argc, argv);
194 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
195 std::unique_ptr<MeshLib::Mesh> subsurface_mesh(
198 INFO(
"Extracting top surface of mesh '{:s}' ... ", mesh_arg.getValue());
199 Eigen::Vector3d
const dir({0, 0, -1});
200 double const angle(90);
201 std::unique_ptr<MeshLib::Mesh> surface_mesh(
205 subsurface_mesh.reset(
nullptr);
210 gmsh_path_arg.getValue());
216 std::vector<GeoLib::Polyline*>
const* plys(
220 ERR(
"Could not get vector of polylines out of geometry '{:s}'.",
225 auto search_length_strategy =
226 std::make_unique<MeshGeoToolsLib::SearchLength>();
227 if (search_length_arg.isSet())
229 search_length_strategy.reset(
235 *surface_mesh, std::move(search_length_strategy),
237 for (std::size_t k(0); k < plys->size(); k++)
244 std::string polyline_name(
"Polyline-" + std::to_string(k));
251 if (geo_names.empty())
253 ERR(
"Did not find mesh nodes along polylines.");
257 std::string merge_name(
"AllMeshNodesAlongPolylines");
260 merge_name = geo_names[0];
264 auto const& merged_pnts(pnt_vec->
getVector());
266 std::vector<GeoLib::Point> pnts_with_id;
267 const std::size_t n_merged_pnts(merged_pnts.size());
268 for (std::size_t k(0); k < n_merged_pnts; ++k)
270 pnts_with_id.emplace_back(*(merged_pnts[k]), k);
273 std::sort(pnts_with_id.begin(), pnts_with_id.end(),
275 { return p0 < p1; });
277 double const eps(std::numeric_limits<double>::epsilon());
278 std::vector<GeoLib::Point*> surface_pnts;
282 surface_pnts.push_back(
285 std::string element_name;
287 name_id_map[element_name] = 0;
289 for (std::size_t k(1); k < n_merged_pnts; ++k)
293 if (std::abs(p0[0] - p1[0]) > eps || std::abs(p0[1] - p1[1]) > eps)
295 surface_pnts.push_back(
297 std::string element_name;
299 name_id_map[element_name] = surface_pnts.size() - 1;
304 "-MeshNodesAlongPolylines");
305 geometry_sets.
addPointVec(std::move(surface_pnts), surface_name,
306 std::move(name_id_map), 1e-6);
309 std::string
const base_fname(
312 bc_type.getValue(), gml_arg.getValue());