OGS
anonymous_namespace{ProjectData.cpp} Namespace Reference

Detailed Description

Implementation of the project data class.

Author
Karsten Rink
Date
2010-08-25

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 &project_directory)
 
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes (BaseLib::ConfigTree const &config, std::string const &project_directory)
 
std::optional< ParameterLib::CoordinateSystemparseLocalCoordinateSystem (std::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
 

Function Documentation

◆ parseLocalCoordinateSystem()

std::optional<ParameterLib::CoordinateSystem> anonymous_namespace{ProjectData.cpp}::parseLocalCoordinateSystem ( std::optional< BaseLib::ConfigTree > const &  config,
std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &  parameters 
)
Input File Parameter:
prj__local_coordinate_system__basis_vector_0
Input File Parameter:
prj__local_coordinate_system__basis_vector_1
Input File Parameter:
prj__local_coordinate_system__basis_vector_2

Definition at line 224 of file ProjectData.cpp.

227 {
228  if (!config)
229  {
230  return {};
231  }
232 
233  DBUG("Reading coordinate system configuration.");
234 
235  //
236  // Fetch the first basis vector; its length defines the dimension.
237  //
238  auto const& basis_vector_0 = ParameterLib::findParameter<double>(
239  *config,
241  "basis_vector_0", parameters, 0 /* any dimension */);
242  int const dimension = basis_vector_0.getNumberOfGlobalComponents();
243 
244  // check dimension
245  if (dimension != 2 && dimension != 3)
246  {
247  OGS_FATAL(
248  "Basis vector parameter '{:s}' must have two or three components, "
249  "but it has {:d}.",
250  basis_vector_0.name, dimension);
251  }
252 
253  //
254  // Fetch the second basis vector, which must be of the same dimension as the
255  // first one.
256  //
257  auto const& basis_vector_1 = ParameterLib::findParameter<double>(
258  *config,
260  "basis_vector_1", parameters, dimension);
261 
262  //
263  // For two dimensions, we are done; construct coordinate system;
264  //
265  if (dimension == 2)
266  {
267  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1};
268  }
269 
270  //
271  // Parse the third vector, for three dimensions.
272  //
273  auto const& basis_vector_2 = ParameterLib::findParameter<double>(
274  *config,
276  "basis_vector_2", parameters, dimension);
277  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1,
278  basis_vector_2};
279 }
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27

References DBUG(), and OGS_FATAL.

Referenced by ProjectData::ProjectData().

◆ readGeometry()

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

Definition at line 133 of file ProjectData.cpp.

134 {
135  DBUG("Reading geometry file '{:s}'.", fname);
136  GeoLib::IO::BoostXmlGmlInterface gml_reader(geo_objects);
137  gml_reader.readFile(fname);
138 }

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

◆ readMeshes()

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

Definition at line 172 of file ProjectData.cpp.

174 {
175  std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
176 
178  auto optional_meshes = config.getConfigSubtreeOptional("meshes");
179  if (optional_meshes)
180  {
181  DBUG("Reading multiple meshes.");
183  auto const configs = optional_meshes->getConfigParameterList("mesh");
184  std::transform(
185  configs.begin(), configs.end(), std::back_inserter(meshes),
186  [&project_directory](auto const& mesh_config)
187  { return readSingleMesh(mesh_config, project_directory); });
188  }
189  else
190  { // Read single mesh with geometry.
191  WARN(
192  "Consider switching from mesh and geometry input to multiple "
193  "meshes input. See "
194  "https://www.opengeosys.org/docs/tools/meshing-submeshes/"
195  "constructmeshesfromgeometry/ tool for conversion.");
197  meshes.push_back(readSingleMesh(config.getConfigParameter("mesh"),
199 
200  std::string const geometry_file = BaseLib::copyPathToFileName(
202  config.getConfigParameter<std::string>("geometry"),
204  GeoLib::GEOObjects geoObjects;
205  readGeometry(geometry_file, geoObjects);
206 
207  std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
209  bool const multiple_nodes_allowed = false;
210  auto additional_meshes =
212  geoObjects, *meshes[0], std::move(search_length_algorithm),
213  multiple_nodes_allowed);
214 
215  std::move(begin(additional_meshes), end(additional_meshes),
216  std::back_inserter(meshes));
217  }
218 
220 
221  return meshes;
222 }
void WARN(char const *fmt, Args const &... args)
Definition: Logging.h:37
Container class for geometric objects.
Definition: GEOObjects.h:61
std::unique_ptr< GeoLib::GEOObjects > readGeometry(std::string const &filename)
std::string copyPathToFileName(const std::string &file_name, const std::string &source)
Definition: FileTools.cpp:196
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)
void setMeshSpaceDimension(std::vector< std::unique_ptr< Mesh >> const &meshes)
std::string project_directory
The directory where the prj file resides.
Definition: FileTools.cpp:27
std::unique_ptr< MeshLib::Mesh > readSingleMesh(BaseLib::ConfigTree const &mesh_config_parameter, std::string const &project_directory)

References MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects(), BaseLib::copyPathToFileName(), MeshGeoToolsLib::createSearchLengthAlgorithm(), DBUG(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigSubtreeOptional(), anonymous_namespace{FileTools.cpp}::project_directory, readGeometry(), readSingleMesh(), MeshLib::setMeshSpaceDimension(), and WARN().

◆ readSingleMesh()

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

Definition at line 140 of file ProjectData.cpp.

143 {
144  std::string const mesh_file = BaseLib::copyPathToFileName(
145  mesh_config_parameter.getValue<std::string>(), project_directory);
146  DBUG("Reading mesh file '{:s}'.", mesh_file);
147 
148  auto mesh = std::unique_ptr<MeshLib::Mesh>(
149  MeshLib::IO::readMeshFromFile(mesh_file));
150  if (!mesh)
151  {
152  OGS_FATAL("Could not read mesh from '{:s}' file. No mesh added.",
153  mesh_file);
154  }
155 
156 #ifdef DOXYGEN_DOCU_ONLY
158  mesh_config_parameter.getConfigAttributeOptional<bool>("axially_symmetric");
159 #endif // DOXYGEN_DOCU_ONLY
160 
161  if (auto const axially_symmetric =
163  mesh_config_parameter.getConfigAttributeOptional<bool>(
164  "axially_symmetric"))
165  {
166  mesh->setAxiallySymmetric(*axially_symmetric);
167  }
168 
169  return mesh;
170 }
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)

References BaseLib::copyPathToFileName(), DBUG(), BaseLib::ConfigTree::getConfigAttributeOptional(), BaseLib::ConfigTree::getValue(), OGS_FATAL, anonymous_namespace{FileTools.cpp}::project_directory, and MeshLib::IO::readMeshFromFile().

Referenced by readMeshes().