Loading [MathJax]/extensions/tex2jax.js
OGS
Properties.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <cstdlib>
16#include <map>
17#include <string>
18
19#include "PropertyVector.h"
20
21namespace MeshLib
22{
23
33{
34public:
48 template <typename T>
49 PropertyVector<T>* createNewPropertyVector(std::string_view name,
50 MeshItemType mesh_item_type,
51 std::size_t n_components = 1);
52
53 template <typename T>
55 MeshItemType mesh_item_type,
56 std::size_t n_property_values,
57 std::size_t n_components);
58
75 template <typename T>
77 std::string const& name,
78 std::size_t n_prop_groups,
79 std::vector<std::size_t> const& item2group_mapping,
80 MeshItemType mesh_item_type,
81 std::size_t n_components = 1);
82
86 template <typename T>
87 bool existsPropertyVector(std::string_view name) const;
88
91 template <typename T>
92 bool existsPropertyVector(std::string_view name,
93 MeshItemType const mesh_item_type,
94 int const number_of_components) const;
95
98 template <typename T>
99 PropertyVector<T> const* getPropertyVector(std::string_view name) const;
100
103 template <typename T>
104 PropertyVector<T>* getPropertyVector(std::string_view name);
105
109 template <typename T>
110 PropertyVector<T> const* getPropertyVector(std::string_view name,
111 MeshItemType const item_type,
112 int const n_components) const;
113
117 template <typename T>
118 PropertyVector<T>* getPropertyVector(std::string_view name,
119 MeshItemType const item_type,
120 int const n_components);
121
122 void removePropertyVector(std::string_view name);
123
127 bool hasPropertyVector(std::string_view name) const;
128
133 template <typename T>
134 bool hasPropertyVector(std::string const& name,
135 MeshItemType const item_type) const;
136
137 std::vector<std::string> getPropertyVectorNames() const;
138 std::vector<std::string> getPropertyVectorNames(
139 MeshLib::MeshItemType t) const;
140
146 std::vector<std::size_t> const& exclude_elem_ids,
147 std::vector<std::size_t> const& exclude_node_ids) const;
148
153 std::vector<MeshItemType> const& exclude_mesh_item_types) const;
154
155 Properties() = default;
156
157 Properties(Properties const& properties);
158 Properties(Properties&& properties) = default;
159 Properties& operator=(Properties const& properties);
160 Properties& operator=(Properties&& properties) = default;
161
162 ~Properties();
163
164 std::map<std::string, PropertyVectorBase*>::const_iterator begin() const;
165 std::map<std::string, PropertyVectorBase*>::const_iterator end() const;
166 std::map<std::string, PropertyVectorBase*>::iterator begin();
167 std::map<std::string, PropertyVectorBase*>::iterator end();
168 std::map<std::string, PropertyVectorBase*>::size_type size() const;
169 // Counts properties of given mesh item type.
170 std::map<std::string, PropertyVectorBase*>::size_type size(
171 MeshItemType const mesh_item_type) const;
172
173private:
176 std::map<std::string, PropertyVectorBase*> _properties;
177}; // end class
178
184template <typename Function>
185void applyToPropertyVectors(Properties const& properties, Function f);
186
191constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
192{
193 switch (mesh_item_type)
194 {
196 return "bulk_node_ids";
197 break;
199 return "bulk_element_ids";
200 break;
202 return "bulk_edge_ids";
203 break;
205 return "bulk_face_ids";
206 break;
208 OGS_FATAL("MeshItemType::IntegrationPoint is not handled.");
209 return "";
210 break;
211 default:
212 OGS_FATAL(
213 "Unknown mesh item type {:s}. At the moment mapping names only "
214 "for mesh item types 'Node', 'Cell', 'Edge', and 'Face' are "
215 "specified.",
216 MeshLib::toString(mesh_item_type));
217 return "";
218 }
219}
220
221#include "Properties-impl.h"
222
223} // end namespace MeshLib
#define OGS_FATAL(...)
Definition Error.h:26
Implemenatiom of the template part of the class Properties.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition Properties.h:33
Properties & operator=(Properties &&properties)=default
std::vector< std::string > getPropertyVectorNames() const
std::map< std::string, PropertyVectorBase * > _properties
Definition Properties.h:176
bool hasPropertyVector(std::string_view name) const
bool existsPropertyVector(std::string_view name) const
Definition Properties.h:93
std::map< std::string, PropertyVectorBase * >::size_type size() const
Properties excludeCopyProperties(std::vector< std::size_t > const &exclude_elem_ids, std::vector< std::size_t > const &exclude_node_ids) const
std::map< std::string, PropertyVectorBase * >::const_iterator begin() const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
Definition Properties.h:17
PropertyVector< T > const * getPropertyVector(std::string_view name) const
std::map< std::string, PropertyVectorBase * >::const_iterator end() const
Properties(Properties &&properties)=default
void removePropertyVector(std::string_view name)
Properties & operator=(Properties const &properties)
PropertyVector< T > * createNewPropertyVector(std::string const &name, std::size_t n_prop_groups, std::vector< std::size_t > const &item2group_mapping, MeshItemType mesh_item_type, std::size_t n_components=1)
Definition Properties.h:54
PropertyVector< T > const * getPropertyVector(std::string_view name, MeshItemType const item_type, int const n_components) const
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
Definition Properties.h:191
void applyToPropertyVectors(Properties const &properties, Function f)
Definition Properties.h:265
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition MeshEnums.h:36