OGS
MeshElementParameter.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
7#include "MeshLib/Mesh.h"
8
9namespace ParameterLib
10{
11std::unique_ptr<ParameterBase> createMeshElementParameter(
12 std::string const& name, BaseLib::ConfigTree const& config,
13 MeshLib::Mesh const& mesh)
14{
16 config.checkConfigParameter("type", "MeshElement");
17 auto const field_name =
19 config.getConfigParameter<std::string>("field_name");
20 DBUG("Using field_name {:s}", field_name);
21
22 // TODO other data types than only double
23 auto const& property =
24 mesh.getProperties().getPropertyVector<double>(field_name);
25
26 if (property->getMeshItemType() != MeshLib::MeshItemType::Cell)
27 {
28 OGS_FATAL("The mesh property `{:s}' is not an element property.",
29 field_name);
30 }
31
32 return std::make_unique<MeshElementParameter<double>>(name, mesh,
33 *property);
34}
35
36} // namespace ParameterLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Properties & getProperties()
Definition Mesh.h:125
PropertyVector< T > const * getPropertyVector(std::string_view name) const
std::unique_ptr< ParameterBase > createMeshElementParameter(std::string const &name, BaseLib::ConfigTree const &config, MeshLib::Mesh const &mesh)