11 std::size_t n_components)
16 ERR(
"A property of the name '{:s}' is already assigned to the mesh.",
21 std::make_pair(std::string(name),
30 std::size_t n_property_values, std::size_t n_components)
35 ERR(
"A property of the name '{:s}' is already assigned to the mesh.",
42 mesh_item_type, n_components))));
58 WARN(
"Property '{}' exists but does not have the requested type {}.",
69 int const number_of_components)
const
71 auto const it =
_properties.find(std::string(name));
78 if (property ==
nullptr)
80 WARN(
"Property {} exists but does not have the requested type {}.",
84 if (property->getMeshItemType() != mesh_item_type)
87 "Property {} exists but does not have the requested mesh item type "
92 if (property->getNumberOfGlobalComponents() != number_of_components)
95 "Property {} exists but does not have the requested number of "
97 name, number_of_components);
105 std::string_view name)
const
108 const_cast<Properties*
>(
this)->getPropertyVector<T>(name));
118 "A PropertyVector with the specified name '{:s}' is not available.",
124 "The PropertyVector '{:s}' has a different type than the requested "
135 auto const it =
_properties.find(std::string(name));
144 return (property ==
nullptr) ? false
151 int const n_components)
const
153 auto const it =
_properties.find(std::string(name));
157 "A PropertyVector with name '{:s}' does not exist in the mesh.",
162 if (property ==
nullptr)
165 "Could not cast the data type of the PropertyVector '{:s}' (type: "
166 "'{:s}') to the requested data type '{:s}'.",
170 if (property->getMeshItemType() != item_type)
173 "The PropertyVector '{:s}' has type '{:s}'. A '{:s}' field is "
177 if (property->getNumberOfGlobalComponents() != n_components)
180 "PropertyVector '{:s}' has {:d} components, {:d} components are "
182 name, property->getNumberOfGlobalComponents(), n_components);
190 int const n_components)
192 auto const it =
_properties.find(std::string(name));
196 "A PropertyVector with name '{:s}' does not exist in the mesh.",
201 if (property ==
nullptr)
204 "Could not cast the data type of the PropertyVector '{:s}' to "
205 "requested data type.",
208 if (property->getMeshItemType() != item_type)
211 "The PropertyVector '{:s}' has type '{:s}'. A '{:s}' field is "
215 if (property->getNumberOfGlobalComponents() != n_components)
218 "PropertyVector '{:s}' has {:d} components, {:d} components are "
220 name, property->getNumberOfGlobalComponents(), n_components);
225template <
typename Function>
228 for (
auto [name, property] : properties)
235 bool success = f(
double{}, property) || f(
float{}, property) ||
236 f(
int{}, property) || f(
unsigned{}, property) ||
237 f(
long{}, property) ||
238 f(
static_cast<unsigned long>(0), property) ||
239 f(std::size_t{}, property) || f(
char{}, property) ||
240 f(
static_cast<unsigned char>(0), property);
243 OGS_FATAL(
"Could not apply function to PropertyVector '{:s}'.",
244 property->getPropertyName());
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
std::map< std::string, PropertyVectorBase * > _properties
bool hasPropertyVector(std::string_view name) const
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
PropertyVector< T > const * getPropertyVector(std::string_view name) const
MeshItemType getMeshItemType() const
std::string typeToString()
void applyToPropertyVectors(Properties const &properties, Function f)
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.