OGS
Properties.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <cstdlib>
16#include <string>
17#include <map>
18
19
20#include "Location.h"
21
22#include "PropertyVector.h"
23
24namespace MeshLib
25{
26
36{
37public:
51 template <typename T>
52 PropertyVector<T>* createNewPropertyVector(std::string_view name,
53 MeshItemType mesh_item_type,
54 std::size_t n_components = 1);
55
72 template <typename T>
74 std::string const& name,
75 std::size_t n_prop_groups,
76 std::vector<std::size_t> const& item2group_mapping,
77 MeshItemType mesh_item_type,
78 std::size_t n_components = 1);
79
83 template <typename T>
84 bool existsPropertyVector(std::string_view name) const;
85
88 template <typename T>
89 bool existsPropertyVector(std::string_view name,
90 MeshItemType const mesh_item_type,
91 int const number_of_components) const;
92
95 template <typename T>
96 PropertyVector<T> const* getPropertyVector(std::string_view name) const;
97
100 template <typename T>
101 PropertyVector<T>* getPropertyVector(std::string_view name);
102
106 template <typename T>
107 PropertyVector<T> const* getPropertyVector(std::string_view name,
108 MeshItemType const item_type,
109 int const n_components) const;
110
114 template <typename T>
115 PropertyVector<T>* getPropertyVector(std::string_view name,
116 MeshItemType const item_type,
117 int const n_components);
118
119 void removePropertyVector(std::string_view name);
120
124 bool hasPropertyVector(std::string_view name) const;
125
130 template <typename T>
131 bool hasPropertyVector(std::string const& name,
132 MeshItemType const item_type) const;
133
134 std::vector<std::string> getPropertyVectorNames() const;
135 std::vector<std::string> getPropertyVectorNames(
136 MeshLib::MeshItemType t) const;
137
143 std::vector<std::size_t> const& exclude_elem_ids,
144 std::vector<std::size_t> const& exclude_node_ids) const;
145
150 std::vector<MeshItemType> const& exclude_mesh_item_types) const;
151
152 Properties() = default;
153
154 Properties(Properties const& properties);
155 Properties(Properties&& properties) = default;
156 Properties& operator=(Properties const& properties);
157 Properties& operator=(Properties&& properties) = default;
158
159 ~Properties();
160
161 std::map<std::string, PropertyVectorBase*>::const_iterator begin() const;
162 std::map<std::string, PropertyVectorBase*>::const_iterator end() const;
163 std::map<std::string, PropertyVectorBase*>::iterator begin();
164 std::map<std::string, PropertyVectorBase*>::iterator end();
165 std::map<std::string, PropertyVectorBase*>::size_type size() const;
166 // Counts properties of given mesh item type.
167 std::map<std::string, PropertyVectorBase*>::size_type size(
168 MeshItemType const mesh_item_type) const;
170private:
173 std::map<std::string, PropertyVectorBase*> _properties;
174}; // end class
175
181template <typename Function>
182void applyToPropertyVectors(Properties const& properties, Function f);
183
188constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
189{
190 switch (mesh_item_type)
191 {
193 return "bulk_node_ids";
194 break;
196 return "bulk_element_ids";
197 break;
199 return "bulk_edge_ids";
200 break;
202 return "bulk_face_ids";
203 break;
205 OGS_FATAL("MeshItemType::IntegrationPoint is not handled.");
206 return "";
207 break;
208 default:
209 OGS_FATAL(
210 "Unknown mesh item type. At the moment only for mesh item "
211 "types 'Node', 'Cell', and 'Face' mapping names are "
212 "specified.");
213 return "";
214 }
215}
216
217#include "Properties-impl.h"
218
219} // 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:36
Properties & operator=(Properties &&properties)=default
std::vector< std::string > getPropertyVectorNames() const
std::map< std::string, PropertyVectorBase * > _properties
Definition Properties.h:173
bool hasPropertyVector(std::string_view name) const
bool existsPropertyVector(std::string_view name) const
Definition Properties.h:74
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:35
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:188
MeshItemType
Definition Location.h:21
void applyToPropertyVectors(Properties const &properties, Function f)
Definition Properties.h:246