OGS
anonymous_namespace{ProjectData.cpp} Namespace Reference

Functions

void readGeometry (std::string const &fname, GeoLib::GEOObjects &geo_objects)
 
std::unique_ptr< MeshLib::MeshreadSingleMesh (BaseLib::ConfigTree const &mesh_config_parameter, std::string const &directory)
 
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes (BaseLib::ConfigTree const &config, std::string const &directory)
 
std::vector< GeoLib::NamedRasterreadRasters (BaseLib::ConfigTree const &config, std::string const &raster_directory, GeoLib::MinMaxPoints const &min_max_points)
 

Function Documentation

◆ readGeometry()

void anonymous_namespace{ProjectData.cpp}::readGeometry ( std::string const & fname,
GeoLib::GEOObjects & geo_objects )

Definition at line 155 of file ProjectData.cpp.

156{
157 DBUG("Reading geometry file '{:s}'.", fname);
158 GeoLib::IO::BoostXmlGmlInterface gml_reader(geo_objects);
159 gml_reader.readFile(fname);
160}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30

References DBUG(), and GeoLib::IO::BoostXmlGmlInterface::readFile().

Referenced by readMeshes().

◆ readMeshes()

std::vector< std::unique_ptr< MeshLib::Mesh > > anonymous_namespace{ProjectData.cpp}::readMeshes ( BaseLib::ConfigTree const & config,
std::string const & directory )
Input File Parameter
prj__meshes
Input File Parameter
prj__meshes__mesh
Input File Parameter
prj__geometry
Input File Parameter
prj__mesh
Input File Parameter
prj__geometry
Input File Parameter
prj__zero_mesh_field_data_by_material_ids

Definition at line 194 of file ProjectData.cpp.

196{
197 std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
198
199 GeoLib::GEOObjects geoObjects;
200
202 auto optional_meshes = config.getConfigSubtreeOptional("meshes");
203 if (optional_meshes)
204 {
205 DBUG("Reading multiple meshes.");
207 auto const configs = optional_meshes->getConfigParameterList("mesh");
208 std::transform(configs.begin(), configs.end(),
209 std::back_inserter(meshes),
210 [&directory](auto const& mesh_config)
211 { return readSingleMesh(mesh_config, directory); });
212 if (auto const geometry_file_name =
214 config.getConfigParameterOptional<std::string>("geometry"))
215 {
216 std::string const geometry_file =
217 BaseLib::copyPathToFileName(*geometry_file_name, directory);
218 readGeometry(geometry_file, geoObjects);
219 }
220 }
221 else
222 { // Read single mesh with geometry.
223 meshes.push_back(
225 readSingleMesh(config.getConfigParameter("mesh"), directory));
226
227 std::string const geometry_file = BaseLib::copyPathToFileName(
229 config.getConfigParameter<std::string>("geometry"),
230 directory);
231 readGeometry(geometry_file, geoObjects);
232 }
233
234 { // generate meshes from geometries
235 std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
237 bool const multiple_nodes_allowed = false;
238 auto additional_meshes =
240 geoObjects, *meshes[0], std::move(search_length_algorithm),
241 multiple_nodes_allowed);
242
243 std::move(begin(additional_meshes), end(additional_meshes),
244 std::back_inserter(meshes));
245 }
246
247 auto mesh_names = MeshLib::views::names | ranges::to<std::vector>() |
248 ranges::actions::sort;
249 auto const sorted_names = meshes | mesh_names;
250 auto const unique_names = meshes | mesh_names | ranges::actions::unique;
251 if (unique_names.size() < sorted_names.size())
252 {
253 WARN(
254 "Mesh names aren't unique. From project file read mesh names are:");
255 for (auto const& name : meshes | MeshLib::views::names)
256 {
257 INFO("- {}", name);
258 }
259 }
260
261 auto const zero_mesh_field_data_by_material_ids =
263 config.getConfigParameterOptional<std::vector<int>>(
264 "zero_mesh_field_data_by_material_ids");
265 if (zero_mesh_field_data_by_material_ids)
266 {
267 WARN(
268 "Tag 'zero_mesh_field_data_by_material_ids` is experimental. Its "
269 "name may be changed, or it may be removed due to its "
270 "corresponding feature becomes a single tool. Please use it with "
271 "care!");
273 *meshes[0], *zero_mesh_field_data_by_material_ids);
274 }
275
277
278 return meshes;
279}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
Container class for geometric objects.
Definition GEOObjects.h:57
std::string copyPathToFileName(const std::string &file_name, const std::string &source)
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const &geo_objects, MeshLib::Mesh const &mesh, std::unique_ptr< SearchLength > search_length_algorithm, bool const multiple_nodes_allowed)
constexpr ranges::views::view_closure names
For an element of a range view return its name.
Definition Mesh.h:229
void setMeshSpaceDimension(std::vector< std::unique_ptr< Mesh > > const &meshes)
void zeroMeshFieldDataByMaterialIDs(MeshLib::Mesh &mesh, std::vector< int > const &selected_material_ids)
std::unique_ptr< MeshLib::Mesh > readSingleMesh(BaseLib::ConfigTree const &mesh_config_parameter, std::string const &directory)
void readGeometry(std::string const &fname, GeoLib::GEOObjects &geo_objects)

References MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects(), BaseLib::copyPathToFileName(), MeshGeoToolsLib::createSearchLengthAlgorithm(), DBUG(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigParameterOptional(), BaseLib::ConfigTree::getConfigSubtreeOptional(), INFO(), MeshLib::views::names, readGeometry(), readSingleMesh(), MeshLib::setMeshSpaceDimension(), WARN(), and MeshToolsLib::zeroMeshFieldDataByMaterialIDs().

◆ readRasters()

std::vector< GeoLib::NamedRaster > anonymous_namespace{ProjectData.cpp}::readRasters ( BaseLib::ConfigTree const & config,
std::string const & raster_directory,
GeoLib::MinMaxPoints const & min_max_points )
Input File Parameter
prj__rasters
Input File Parameter
prj__rasters__raster

Definition at line 281 of file ProjectData.cpp.

284{
285 INFO("readRasters ...");
286 std::vector<GeoLib::NamedRaster> named_rasters;
287
289 auto optional_rasters = config.getConfigSubtreeOptional("rasters");
290 if (optional_rasters)
291 {
293 auto const configs = optional_rasters->getConfigSubtreeList("raster");
294 std::transform(
295 configs.begin(), configs.end(), std::back_inserter(named_rasters),
296 [&raster_directory, &min_max_points](auto const& raster_config)
297 {
298 return GeoLib::IO::readRaster(raster_config, raster_directory,
299 min_max_points);
300 });
301 }
302 INFO("readRasters done");
303 return named_rasters;
304}

References BaseLib::ConfigTree::getConfigSubtreeOptional(), and INFO().

◆ readSingleMesh()

std::unique_ptr< MeshLib::Mesh > anonymous_namespace{ProjectData.cpp}::readSingleMesh ( BaseLib::ConfigTree const & mesh_config_parameter,
std::string const & directory )
Input File Parameter
prj__meshes__mesh__axially_symmetric
Input File Parameter
prj__mesh__axially_symmetric

Definition at line 162 of file ProjectData.cpp.

165{
166 std::string const mesh_file = BaseLib::copyPathToFileName(
167 mesh_config_parameter.getValue<std::string>(), directory);
168 DBUG("Reading mesh file '{:s}'.", mesh_file);
169
170 auto mesh = std::unique_ptr<MeshLib::Mesh>(MeshLib::IO::readMeshFromFile(
171 mesh_file, true /* compute_element_neighbors */));
172 if (!mesh)
173 {
174 OGS_FATAL("Could not read mesh from '{:s}' file. No mesh added.",
175 mesh_file);
176 }
177
178#ifdef DOXYGEN_DOCU_ONLY
180 mesh_config_parameter.getConfigAttributeOptional<bool>("axially_symmetric");
181#endif // DOXYGEN_DOCU_ONLY
182
183 if (auto const axially_symmetric =
185 mesh_config_parameter.getConfigAttributeOptional<bool>(
186 "axially_symmetric"))
187 {
188 mesh->setAxiallySymmetric(*axially_symmetric);
189 }
190
191 return mesh;
192}
#define OGS_FATAL(...)
Definition Error.h:26
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)

References BaseLib::copyPathToFileName(), DBUG(), BaseLib::ConfigTree::getConfigAttributeOptional(), BaseLib::ConfigTree::getValue(), OGS_FATAL, and MeshLib::IO::readMeshFromFile().

Referenced by readMeshes().