27 std::vector<std::size_t>
const& exclude_positions)
const = 0;
38 std::size_t n_components)
54template <
typename PROP_VAL_TYPE>
67 PROP_VAL_TYPE&
getComponent(std::size_t tuple_index,
int component)
86 std::vector<std::size_t>
const& exclude_positions)
const override
96 std::size_t
size()
const {
return std::vector<PROP_VAL_TYPE>::size(); }
106 std::size_t n_components)
107 : std::vector<PROP_VAL_TYPE>(),
120 std::string
const& property_name,
122 std::size_t n_components)
123 : std::vector<PROP_VAL_TYPE>(n_property_values * n_components),
148 for (
auto v : _values)
158 return _values[std::vector<std::size_t>::operator[](
id)];
163 return _values[std::vector<std::size_t>::operator[](
id)];
168 if (_n_components != 1)
171 "Single-component version of initPropertyValue() is called "
172 "for a multi-components PropertyVector<T*>");
176 _values[group_id] = p;
181 if (_n_components !=
static_cast<int>(values.size()))
184 "The size of provided values in initPropertyValue() is "
185 "not same as the number of components in PropertyVector<T*>");
188 auto* p =
new T[values.size()];
189 for (
unsigned i = 0; i < values.size(); i++)
193 _values[group_id] = p;
198 return std::vector<std::size_t>::size();
205 return _n_components * std::vector<std::size_t>::size();
209 std::vector<std::size_t>
const& exclude_positions)
const override
213 _values.size() / _n_components,
215 _property_name, _mesh_item_type, _n_components));
217 for (std::size_t j(0); j < _values.size(); j++)
219 std::vector<T> values(_values[j], _values[j] + _n_components);
220 t->initPropertyValue(j, values);
228 assert(component < _n_components);
229 assert(tuple_index < getNumberOfTuples());
230 const double* p = this->operator[](tuple_index);
234 "No data found in the property vector {:s} "
235 "for the tuple index {:d} and component {:d}",
236 getPropertyName(), tuple_index, component);
254 std::vector<std::size_t>
256 std::string
const& property_name,
258 std::size_t n_components)
259 : std::vector<std::size_t>(std::move(item2group_mapping)),
261 _values(n_prop_groups * n_components)
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
virtual PropertyVectorBase * clone(std::vector< std::size_t > const &exclude_positions) const =0
MeshItemType getMeshItemType() const
MeshItemType const _mesh_item_type
PropertyVectorBase(std::string property_name, MeshItemType mesh_item_type, std::size_t n_components)
virtual ~PropertyVectorBase()=default
std::string const _property_name
int getNumberOfGlobalComponents() const
std::string const & getPropertyName() const
T const & getComponent(std::size_t tuple_index, int component) const
Returns the value for the given component stored in the given tuple.
PropertyVectorBase * clone(std::vector< std::size_t > const &exclude_positions) const override
std::vector< T * > _values
T *& operator[](std::size_t id)
void initPropertyValue(std::size_t group_id, std::vector< T > const &values)
PropertyVector(std::size_t n_prop_groups, std::vector< std::size_t > item2group_mapping, std::string const &property_name, MeshItemType mesh_item_type, std::size_t n_components)
The constructor taking meta information for the data.
T *const & operator[](std::size_t id) const
~PropertyVector() override
Destructor ensures the deletion of the heap-constructed objects.
void initPropertyValue(std::size_t group_id, T const &value)
std::size_t getNumberOfTuples() const
PropertyVector(std::size_t n_property_values, std::string const &property_name, MeshItemType mesh_item_type, std::size_t n_components)
The constructor taking meta information for the data.
PROP_VAL_TYPE & getComponent(std::size_t tuple_index, int component)
Returns the value for the given component stored in the given tuple.
PropertyVector(std::string const &property_name, MeshItemType mesh_item_type, std::size_t n_components)
The constructor taking meta information for the data.
std::size_t getNumberOfTuples() const
PropertyVectorBase * clone(std::vector< std::size_t > const &exclude_positions) const override
PROP_VAL_TYPE const & getComponent(std::size_t tuple_index, int component) const
Returns the value for the given component stored in the given tuple.
std::vector< T > excludeObjectCopy(std::vector< T > const &src_vec, std::vector< std::size_t > const &exclude_positions)