119int main(
int argc,
char* argv[])
122 "Creates boundary conditions for mesh nodes along polylines."
123 "The documentation is available at "
124 "https://docs.opengeosys.org/docs/tools/model-preparation/"
125 "create-boundary-conditions-along-a-polyline.\n\n"
126 "OpenGeoSys-6 software, version " +
129 "Copyright (c) 2012-2026, OpenGeoSys Community "
130 "(http://www.opengeosys.org)",
132 TCLAP::SwitchArg gml_arg(
"",
"gml",
"Write found nodes to gml file.");
135 TCLAP::ValueArg<std::string> output_base_fname(
136 "o",
"output-base-file-name",
137 "Output. The base name of the file the output (geometry (gli) and "
139 "condition (bc)) will be written to",
140 true,
"",
"BASE_FILENAME_OUTPUT");
141 cmd.add(output_base_fname);
143 std::vector<std::string> allowed_types_vector{
"LIQUID_FLOW",
145 TCLAP::ValuesConstraint<std::string> allowed_types(allowed_types_vector);
146 TCLAP::ValueArg<std::string> bc_type(
148 "the process type the boundary condition will be written for currently "
149 "LIQUID_FLOW (primary variable PRESSURE1) and GROUNDWATER_FLOW "
150 "(primary variable HEAD, default) are supported, ",
151 true,
"", &allowed_types);
154 TCLAP::ValueArg<double> search_length_arg(
155 "s",
"search-length",
"The size of the search length ",
false,
156 std::numeric_limits<double>::epsilon(),
"SEARCH_LENGTH");
157 cmd.add(search_length_arg);
159 TCLAP::ValueArg<std::string> geometry_fname(
160 "i",
"input-geometry",
161 "Input (.gml | .gli). The name of the input file containing the "
163 true,
"",
"INPUT_FILE");
164 cmd.add(geometry_fname);
166 TCLAP::ValueArg<std::string> mesh_arg(
168 "Input (.vtu). The name of the input file containing the mesh",
true,
172 TCLAP::ValueArg<std::string> gmsh_path_arg(
173 "g",
"gmsh-path",
"Input (.msh). The path to the gmsh binary",
false,
175 cmd.add(gmsh_path_arg);
178 cmd.add(log_level_arg);
179 cmd.parse(argc, argv);
185 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
186 std::unique_ptr<MeshLib::Mesh> subsurface_mesh(
189 INFO(
"Extracting top surface of mesh '{:s}' ... ", mesh_arg.getValue());
190 Eigen::Vector3d
const dir({0, 0, -1});
191 double const angle(90);
192 std::unique_ptr<MeshLib::Mesh> surface_mesh(
196 subsurface_mesh.reset(
nullptr);
201 gmsh_path_arg.getValue());
207 std::vector<GeoLib::Polyline*>
const* plys(
211 ERR(
"Could not get vector of polylines out of geometry '{:s}'.",
216 auto search_length_strategy =
217 std::make_unique<MeshGeoToolsLib::SearchLength>();
218 if (search_length_arg.isSet())
220 search_length_strategy.reset(
226 *surface_mesh, std::move(search_length_strategy),
228 for (std::size_t k(0); k < plys->size(); k++)
235 std::string polyline_name(
"Polyline-" + std::to_string(k));
242 if (geo_names.empty())
244 ERR(
"Did not find mesh nodes along polylines.");
248 std::string merge_name(
"AllMeshNodesAlongPolylines");
251 merge_name = geo_names[0];
255 auto const& merged_pnts(pnt_vec->
getVector());
257 std::vector<GeoLib::Point> pnts_with_id;
258 const std::size_t n_merged_pnts(merged_pnts.size());
259 for (std::size_t k(0); k < n_merged_pnts; ++k)
261 pnts_with_id.emplace_back(*(merged_pnts[k]), k);
264 std::sort(pnts_with_id.begin(), pnts_with_id.end(),
266 { return p0 < p1; });
268 double const eps(std::numeric_limits<double>::epsilon());
269 std::vector<GeoLib::Point*> surface_pnts;
273 surface_pnts.push_back(
276 std::string element_name;
278 name_id_map[element_name] = 0;
280 for (std::size_t k(1); k < n_merged_pnts; ++k)
284 if (std::abs(p0[0] - p1[0]) > eps || std::abs(p0[1] - p1[1]) > eps)
286 surface_pnts.push_back(
288 std::string element_name;
290 name_id_map[element_name] = surface_pnts.size() - 1;
295 "-MeshNodesAlongPolylines");
296 geometry_sets.
addPointVec(std::move(surface_pnts), surface_name,
297 std::move(name_id_map), 1e-6);
300 std::string
const base_fname(
303 bc_type.getValue(), gml_arg.getValue());