18 std::size_t n_components)
22 ERR(
"A property of the name '{:s}' is already assigned to the mesh.",
27 std::make_pair(std::string(name),
36 std::size_t n_property_values, std::size_t n_components)
41 ERR(
"A property of the name '{:s}' is already assigned to the mesh.",
48 mesh_item_type, n_components))));
54 std::string
const& name,
55 std::size_t n_prop_groups,
56 std::vector<std::size_t>
const& item2group_mapping,
58 std::size_t n_components)
63 ERR(
"A property of the name '{:s}' already assigned to the mesh.",
69 for (std::size_t k(0); k<item2group_mapping.size(); k++) {
70 std::size_t
const group_id (item2group_mapping[k]);
71 if (group_id >= n_prop_groups) {
72 ERR(
"The mapping to property {:d} for item {:d} is not in the "
73 "correct range [0,{:d}).",
74 group_id, k, n_prop_groups);
81 std::pair<std::string, PropertyVectorBase*>(
84 item2group_mapping, name, mesh_item_type, n_components)
107 int const number_of_components)
const
109 auto const it =
_properties.find(std::string(name));
116 if (property ==
nullptr)
118 WARN(
"Property {} exists but does not have the requested type {}.",
119 name,
typeid(T).name());
122 if (property->getMeshItemType() != mesh_item_type)
125 "Property {} exists but does not have the requested mesh item type "
130 if (property->getNumberOfGlobalComponents() != number_of_components)
133 "Property {} exists but does not have the requested number of "
135 name, number_of_components);
143 std::string_view name)
const
146 const_cast<Properties*
>(
this)->getPropertyVector<T>(name));
156 "A PropertyVector with the specified name '{:s}' is not available.",
162 "The PropertyVector '{:s}' has a different type than the requested "
173 auto const it =
_properties.find(std::string(name));
182 return (property ==
nullptr) ? false
189 int const n_components)
const
191 auto const it =
_properties.find(std::string(name));
195 "A PropertyVector with name '{:s}' does not exist in the mesh.",
200 if (property ==
nullptr)
203 "Could not cast the data type of the PropertyVector '{:s}' (type: "
204 "'{:s}') to the requested data type '{:s}'.",
205 name,
typeid(
decltype(*it->second)).name(),
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);
228 int const n_components)
230 auto const it =
_properties.find(std::string(name));
234 "A PropertyVector with name '{:s}' does not exist in the mesh.",
239 if (property ==
nullptr)
242 "Could not cast the data type of the PropertyVector '{:s}' to "
243 "requested data type.",
246 if (property->getMeshItemType() != item_type)
249 "The PropertyVector '{:s}' has type '{:s}'. A '{:s}' field is "
253 if (property->getNumberOfGlobalComponents() != n_components)
256 "PropertyVector '{:s}' has {:d} components, {:d} components are "
258 name, property->getNumberOfGlobalComponents(), n_components);
263template <
typename Function>
266 for (
auto [name, property] : properties)
273 bool success = f(
double{}, property) || f(
float{}, property) ||
274 f(
int{}, property) || f(
unsigned{}, property) ||
275 f(
long{}, property) ||
276 f(
static_cast<unsigned long>(0), property) ||
277 f(std::size_t{}, property) || f(
char{}, property) ||
278 f(
static_cast<unsigned char>(0), property);
281 OGS_FATAL(
"Could not apply function to PropertyVector '{:s}'.",
282 property->getPropertyName());
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
void applyToPropertyVectors(Properties const &properties, Function f)
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
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.