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>
50 MeshItemType mesh_item_type,
51 std::size_t n_components = 1);
52
69 template <typename T>
71 std::string const& name,
72 std::size_t n_prop_groups,
73 std::vector<std::size_t> const& item2group_mapping,
74 MeshItemType mesh_item_type,
75 std::size_t n_components = 1);
76
80 template <typename T>
81 bool existsPropertyVector(std::string_view name) const;
82
85 template <typename T>
86 bool existsPropertyVector(std::string_view name,
87 MeshItemType const mesh_item_type,
88 int const number_of_components) const;
89
92 template <typename T>
93 PropertyVector<T> const* getPropertyVector(std::string_view name) const;
94
97 template <typename T>
98 PropertyVector<T>* getPropertyVector(std::string_view name);
99
103 template <typename T>
104 PropertyVector<T> const* getPropertyVector(std::string_view name,
105 MeshItemType const item_type,
106 int const n_components) const;
107
111 template <typename T>
112 PropertyVector<T>* getPropertyVector(std::string_view name,
113 MeshItemType const item_type,
114 int const n_components);
115
116 void removePropertyVector(std::string_view name);
117
121 bool hasPropertyVector(std::string_view name) const;
122
127 template <typename T>
128 bool hasPropertyVector(std::string const& name,
129 MeshItemType const item_type) const;
130
131 std::vector<std::string> getPropertyVectorNames() const;
132 std::vector<std::string> getPropertyVectorNames(
133 MeshLib::MeshItemType t) const;
134
140 std::vector<std::size_t> const& exclude_elem_ids,
141 std::vector<std::size_t> const& exclude_node_ids) const;
142
147 std::vector<MeshItemType> const& exclude_mesh_item_types) const;
148
149 Properties() = default;
150
151 Properties(Properties const& properties);
152 Properties(Properties&& properties) = default;
153 Properties& operator=(Properties const& properties);
154 Properties& operator=(Properties&& properties) = default;
155
156 ~Properties();
157
158 std::map<std::string, PropertyVectorBase*>::const_iterator begin() const;
159 std::map<std::string, PropertyVectorBase*>::const_iterator end() const;
160 std::map<std::string, PropertyVectorBase*>::iterator begin();
161 std::map<std::string, PropertyVectorBase*>::iterator end();
162 std::map<std::string, PropertyVectorBase*>::size_type size() const;
163 // Counts properties of given mesh item type.
164 std::map<std::string, PropertyVectorBase*>::size_type size(
165 MeshItemType const mesh_item_type) const;
166
167private:
170 std::map<std::string, PropertyVectorBase*> _properties;
171}; // end class
172
178template <typename Function>
179void applyToPropertyVectors(Properties const& properties, Function f);
180
185constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
186{
187 switch (mesh_item_type)
188 {
190 return "bulk_node_ids";
191 break;
193 return "bulk_element_ids";
194 break;
196 return "bulk_edge_ids";
197 break;
199 return "bulk_face_ids";
200 break;
202 OGS_FATAL("MeshItemType::IntegrationPoint is not handled.");
203 return "";
204 break;
205 default:
206 OGS_FATAL(
207 "Unknown mesh item type {:s}. At the moment mapping names only "
208 "for mesh item types 'Node', 'Cell', 'Edge', and 'Face' are "
209 "specified.",
210 MeshLib::toString(mesh_item_type));
211 return "";
212 }
213}
214
215#include "Properties-impl.h"
216
217} // 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
bool hasPropertyVector(std::string const &name, MeshItemType const item_type) const
bool existsPropertyVector(std::string_view name, MeshItemType const mesh_item_type, int const number_of_components) const
Properties & operator=(Properties &&properties)=default
std::vector< std::string > getPropertyVectorNames() const
std::map< std::string, PropertyVectorBase * > _properties
Definition Properties.h:170
bool hasPropertyVector(std::string_view name) const
bool existsPropertyVector(std::string_view name) const
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)
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 > * getPropertyVector(std::string_view name)
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)
PropertyVector< T > const * getPropertyVector(std::string_view name, MeshItemType const item_type, int const n_components) const
PropertyVector< T > * getPropertyVector(std::string_view name, MeshItemType const item_type, int const n_components)
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
Definition Properties.h:185
void applyToPropertyVectors(Properties const &properties, Function f)
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition MeshEnums.h:36