OGS
MeshLib::Properties Class Reference

Detailed Description

Property manager on mesh items. Class Properties manages scalar, vector or matrix properties. For instance in groundwater flow porosity is a scalar property and permeabilty can be stored as a tensor property. Properties are assigned to mesh items, i.e. Node or Element objects. The createNewPropertyVector() method first creates a PropertyVector of template type T (scalar, vector or matrix). This class stores the PropertyVector, accessible by a combination of the name and the type of the mesh item (Node or Element).

Definition at line 32 of file Properties.h.

#include <Properties.h>

Public Member Functions

template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
 
template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string_view name, MeshItemType mesh_item_type, std::size_t n_property_values, std::size_t n_components)
 
template<typename T >
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)
 
template<typename T >
bool existsPropertyVector (std::string_view name) const
 
template<typename T >
bool existsPropertyVector (std::string_view name, MeshItemType const mesh_item_type, int const number_of_components) const
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string_view name) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string_view name)
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string_view name, MeshItemType const item_type, int const n_components) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string_view name, MeshItemType const item_type, int const n_components)
 
void removePropertyVector (std::string_view name)
 
bool hasPropertyVector (std::string_view name) const
 
template<typename T >
bool hasPropertyVector (std::string_view name, MeshItemType const item_type) const
 
std::vector< std::string > getPropertyVectorNames () const
 
std::vector< std::string > getPropertyVectorNames (MeshLib::MeshItemType t) const
 
Properties excludeCopyProperties (std::vector< std::size_t > const &exclude_elem_ids, std::vector< std::size_t > const &exclude_node_ids) const
 
Properties excludeCopyProperties (std::vector< MeshItemType > const &exclude_mesh_item_types) const
 
 Properties ()=default
 
 Properties (Properties const &properties)
 
 Properties (Properties &&properties)=default
 
Propertiesoperator= (Properties const &properties)
 
Propertiesoperator= (Properties &&properties)=default
 
 ~Properties ()
 
std::map< std::string, PropertyVectorBase * >::const_iterator begin () const
 
std::map< std::string, PropertyVectorBase * >::const_iterator end () const
 
std::map< std::string, PropertyVectorBase * >::iterator begin ()
 
std::map< std::string, PropertyVectorBase * >::iterator end ()
 
std::map< std::string, PropertyVectorBase * >::size_type size () const
 
std::map< std::string, PropertyVectorBase * >::size_type size (MeshItemType const mesh_item_type) const
 
template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string_view name, MeshItemType mesh_item_type, std::size_t n_components)
 
template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string_view name, MeshItemType mesh_item_type, std::size_t n_property_values, std::size_t n_components)
 
template<typename T >
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)
 
template<typename T >
bool existsPropertyVector (std::string_view name) const
 
template<typename T >
bool existsPropertyVector (std::string_view name, MeshItemType const mesh_item_type, int const number_of_components) const
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string_view name) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string_view name)
 
template<typename T >
bool hasPropertyVector (std::string_view name, MeshItemType const item_type) const
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string_view name, MeshItemType const item_type, int const n_components) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string_view name, MeshItemType const item_type, int const n_components)
 

Private Attributes

std::map< std::string, PropertyVectorBase * > _properties
 

Constructor & Destructor Documentation

◆ Properties() [1/3]

MeshLib::Properties::Properties ( )
default

◆ Properties() [2/3]

MeshLib::Properties::Properties ( Properties const & properties)

Definition at line 103 of file Properties.cpp.

104 : _properties(properties._properties)
105{
106 for (auto& name_vector_pair : _properties)
107 {
108 PropertyVectorBase* t(name_vector_pair.second->clone({}));
109 name_vector_pair.second = t;
110 }
111}
std::map< std::string, PropertyVectorBase * > _properties
Definition Properties.h:176

References _properties.

◆ Properties() [3/3]

MeshLib::Properties::Properties ( Properties && properties)
default

◆ ~Properties()

MeshLib::Properties::~Properties ( )

Definition at line 132 of file Properties.cpp.

133{
134 for (auto name_vector_pair : _properties)
135 {
136 delete name_vector_pair.second;
137 }
138}

References _properties.

Member Function Documentation

◆ begin() [1/2]

std::map< std::string, PropertyVectorBase * >::iterator MeshLib::Properties::begin ( )

Definition at line 152 of file Properties.cpp.

153{
154 return _properties.begin();
155}

References _properties.

◆ begin() [2/2]

std::map< std::string, PropertyVectorBase * >::const_iterator MeshLib::Properties::begin ( ) const

Definition at line 140 of file Properties.cpp.

142{
143 return _properties.cbegin();
144}

References _properties.

Referenced by size().

◆ createNewPropertyVector() [1/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::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 )

Definition at line 53 of file Properties-impl.h.

59{
60 // check if there is already a PropertyVector with the same name
61 auto it(_properties.find(name));
62 if (it != _properties.end()) {
63 ERR("A property of the name '{:s}' already assigned to the mesh.",
64 name);
65 return nullptr;
66 }
67
68 // check entries of item2group_mapping for consistence
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);
75 return nullptr;
76 }
77 }
78
79 auto entry_info(
80 _properties.insert(
81 std::pair<std::string, PropertyVectorBase*>(
82 name,
83 new PropertyVector<T>(n_prop_groups,
84 item2group_mapping, name, mesh_item_type, n_components)
85 )
86 )
87 );
88 return static_cast<PropertyVector<T>*>((entry_info.first)->second);
89}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:48

References ERR().

◆ createNewPropertyVector() [2/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::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 )

Method creates a PropertyVector if a PropertyVector with the same name and the same type T was not already created before. In case there exists already such a PropertyVector a nullptr is returned. This method is used if only a small number of distinct property values in a property exist (e.g. mapping property groups to elements). In this case a mapping between mesh items and properties (stored on the heap), see the parameter item2group_mapping, is required.

Template Parameters
Ttype of the property value
Parameters
namethe name of the property
n_prop_groupsnumber of distinct property groups
item2group_mappingthe mapping between mesh item and the property group
mesh_item_typefor instance node or element assigned properties
n_componentsnumber of components for each tuple
Returns
A pointer to a PropertyVector on success and a nullptr otherwise.

◆ createNewPropertyVector() [3/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::createNewPropertyVector ( std::string_view name,
MeshItemType mesh_item_type,
std::size_t n_components )

Definition at line 16 of file Properties-impl.h.

19{
20 auto it(_properties.find(std::string(name)));
21 if (it != _properties.end()) {
22 ERR("A property of the name '{:s}' is already assigned to the mesh.",
23 name);
24 return nullptr;
25 }
26 auto entry_info(_properties.insert(
27 std::make_pair(std::string(name),
28 new PropertyVector<T>(std::string(name), mesh_item_type,
29 n_components))));
30 return static_cast<PropertyVector<T>*>((entry_info.first)->second);
31}

References ERR().

◆ createNewPropertyVector() [4/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::createNewPropertyVector ( std::string_view name,
MeshItemType mesh_item_type,
std::size_t n_components = 1 )

Method creates a PropertyVector if a PropertyVector with the same name and the same type T was not already created before. In case there exists already such a PropertyVector a nullptr is returned. There are two versions of this method. This method is used when every mesh item at hand has its own property value, i.e. \(n\) mesh item and \(n\) different property values. The user has to ensure the correct usage of the vector later on.

Template Parameters
Ttype of the property value
Parameters
namethe name of the property
mesh_item_typefor instance node or element assigned properties
n_componentsnumber of components for each tuple
Returns
A pointer to a PropertyVector on success and a nullptr otherwise.

Referenced by CreateStructuredGridDialog::accept(), MeshLib::addPropertyToMesh(), ApplicationUtils::addVtkGhostTypeProperty(), castPropertyVectorToPropertyVector(), MeshToolsLib::RasterToMesh::convert(), MeshLib::VtkMeshConverter::convertTypedArray(), copyDoubleValuedFieldDataToPointCloud(), anonymous_namespace{MeshRevision.cpp}::copyProperties(), ApplicationUtils::copyPropertyVector(), MeshLib::IO::NodePartitionedMeshReader::createPropertyVectorPart(), MeshLib::IO::NodePartitionedMeshReader::createSpecificPropertyVectorPart(), MeshToolsLib::MeshLayerMapper::createStaticLayers(), LayeredMeshGenerator::getMesh(), MeshLib::IO::Legacy::MeshIO::loadMeshFromFile(), main(), MeshToolsLib::MeshGenerator::VoxelGridFromMesh::mapArray(), FileIO::Gocad::GocadAsciiReader::parseProperties(), FileIO::Gocad::GocadAsciiReader::readData(), FileIO::GMSH::readGMSHMesh(), FileIO::GMSInterface::readMesh(), FileIO::SwmmInterface::readSwmmInputToLineMesh(), FileIO::TetGenInterface::readTetGenMesh(), MeshToolsLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh(), and writeDataToMesh().

◆ createNewPropertyVector() [5/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::createNewPropertyVector ( std::string_view name,
MeshItemType mesh_item_type,
std::size_t n_property_values,
std::size_t n_components )

Definition at line 34 of file Properties-impl.h.

37{
38 auto it(_properties.find(std::string(name)));
39 if (it != _properties.end())
40 {
41 ERR("A property of the name '{:s}' is already assigned to the mesh.",
42 name);
43 return nullptr;
44 }
45 auto entry_info(_properties.insert(std::make_pair(
46 std::string(name),
47 new PropertyVector<T>(n_property_values, std::string(name),
48 mesh_item_type, n_components))));
49 return static_cast<PropertyVector<T>*>((entry_info.first)->second);
50}

References ERR().

◆ createNewPropertyVector() [6/6]

template<typename T >
PropertyVector< T > * MeshLib::Properties::createNewPropertyVector ( std::string_view name,
MeshItemType mesh_item_type,
std::size_t n_property_values,
std::size_t n_components )

◆ end() [1/2]

std::map< std::string, PropertyVectorBase * >::iterator MeshLib::Properties::end ( )

Definition at line 157 of file Properties.cpp.

158{
159 return _properties.end();
160}

References _properties.

◆ end() [2/2]

std::map< std::string, PropertyVectorBase * >::const_iterator MeshLib::Properties::end ( ) const

Definition at line 146 of file Properties.cpp.

148{
149 return _properties.cend();
150}

References _properties.

Referenced by size().

◆ excludeCopyProperties() [1/2]

Properties MeshLib::Properties::excludeCopyProperties ( std::vector< MeshItemType > const & exclude_mesh_item_types) const

copy all PropertyVector objects stored in the (internal) map but PropertyVector objects with the given MeshItemType are excluded.

Definition at line 81 of file Properties.cpp.

83{
84 Properties new_properties;
85 for (auto name_vector_pair : _properties)
86 {
87 if (std::find(exclude_mesh_item_types.begin(),
88 exclude_mesh_item_types.end(),
89 name_vector_pair.second->getMeshItemType()) !=
90 exclude_mesh_item_types.end())
91 {
92 continue;
93 }
94
95 std::vector<std::size_t> const exclude_positions{};
96 new_properties._properties.insert(
97 std::make_pair(name_vector_pair.first,
98 name_vector_pair.second->clone(exclude_positions)));
99 }
100 return new_properties;
101}

References _properties.

◆ excludeCopyProperties() [2/2]

Properties MeshLib::Properties::excludeCopyProperties ( std::vector< std::size_t > const & exclude_elem_ids,
std::vector< std::size_t > const & exclude_node_ids ) const

copy all PropertyVector objects stored in the (internal) map but only those nodes/elements of a PropertyVector whose ids are not in the vectors exclude_*_ids.

Definition at line 57 of file Properties.cpp.

60{
61 Properties exclude_copy;
62 for (auto name_vector_pair : _properties)
63 {
64 if (name_vector_pair.second->getMeshItemType() == MeshItemType::Cell)
65 {
66 exclude_copy._properties.insert(std::make_pair(
67 name_vector_pair.first,
68 name_vector_pair.second->clone(exclude_elem_ids)));
69 }
70 else if (name_vector_pair.second->getMeshItemType() ==
72 {
73 exclude_copy._properties.insert(std::make_pair(
74 name_vector_pair.first,
75 name_vector_pair.second->clone(exclude_node_ids)));
76 }
77 }
78 return exclude_copy;
79}

References _properties, MeshLib::Cell, and MeshLib::Node.

Referenced by MeshToolsLib::convertToLinearMesh(), MeshToolsLib::createQuadraticOrderMesh(), MeshToolsLib::removeElements(), and MeshToolsLib::removeNodes().

◆ existsPropertyVector() [1/4]

template<typename T >
bool MeshLib::Properties::existsPropertyVector ( std::string_view name) const

Definition at line 92 of file Properties-impl.h.

93{
94 auto it(_properties.find(std::string(name)));
95 // Check that a PropertyVector with the appropriate name exists.
96 if (it == _properties.end())
97 {
98 return false;
99 }
100 // Check that the PropertyVector has the correct data type.
101 return dynamic_cast<PropertyVector<T> const*>(it->second) != nullptr;
102}

◆ existsPropertyVector() [2/4]

◆ existsPropertyVector() [3/4]

template<typename T >
bool MeshLib::Properties::existsPropertyVector ( std::string_view name,
MeshItemType const mesh_item_type,
int const number_of_components ) const

Definition at line 105 of file Properties-impl.h.

108{
109 auto const it = _properties.find(std::string(name));
110 if (it == _properties.end())
111 {
112 return false;
113 }
114
115 auto property = dynamic_cast<PropertyVector<T>*>(it->second);
116 if (property == nullptr)
117 {
118 WARN("Property {} exists but does not have the requested type {}.",
119 name, typeid(T).name());
120 return false;
121 }
122 if (property->getMeshItemType() != mesh_item_type)
123 {
124 WARN(
125 "Property {} exists but does not have the requested mesh item type "
126 "{}.",
127 name, toString(mesh_item_type));
128 return false;
129 }
130 if (property->getNumberOfGlobalComponents() != number_of_components)
131 {
132 WARN(
133 "Property {} exists but does not have the requested number of "
134 "components {}",
135 name, number_of_components);
136 return false;
137 }
138 return true;
139}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:42
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition MeshEnums.h:36

References WARN().

◆ existsPropertyVector() [4/4]

template<typename T >
bool MeshLib::Properties::existsPropertyVector ( std::string_view name,
MeshItemType const mesh_item_type,
int const number_of_components ) const

Checks if a property vector with given type T, name, mesh_item_type, and number_of_components exists.

◆ getPropertyVector() [1/8]

template<typename T >
PropertyVector< T > * MeshLib::Properties::getPropertyVector ( std::string_view name)

Definition at line 150 of file Properties-impl.h.

151{
152 auto it(_properties.find(std::string(name)));
153 if (it == _properties.end())
154 {
155 OGS_FATAL(
156 "A PropertyVector with the specified name '{:s}' is not available.",
157 name);
158 }
159 if (!dynamic_cast<PropertyVector<T>*>(it->second))
160 {
161 OGS_FATAL(
162 "The PropertyVector '{:s}' has a different type than the requested "
163 "PropertyVector.",
164 name);
165 }
166 return dynamic_cast<PropertyVector<T>*>(it->second);
167}
#define OGS_FATAL(...)
Definition Error.h:26

References OGS_FATAL.

◆ getPropertyVector() [2/8]

template<typename T >
PropertyVector< T > * MeshLib::Properties::getPropertyVector ( std::string_view name)

Returns a property vector with given name or aborts calling OGS_FATAL if no such property vector exists.

◆ getPropertyVector() [3/8]

template<typename T >
PropertyVector< T > const * MeshLib::Properties::getPropertyVector ( std::string_view name) const

Definition at line 142 of file Properties-impl.h.

144{
145 return const_cast<PropertyVector<T> const*>(
146 const_cast<Properties*>(this)->getPropertyVector<T>(name));
147}
PropertyVector< T > const * getPropertyVector(std::string_view name) const

◆ getPropertyVector() [4/8]

template<typename T >
PropertyVector< T > const * MeshLib::Properties::getPropertyVector ( std::string_view name) const

Returns a property vector with given name or aborts calling OGS_FATAL if no such property vector exists.

Referenced by MeshLib::ElementStatus::ElementStatus(), ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< DisplacementDim >::HydroMechanicsProcess(), ProcessLib::LIE::PostProcessTool::PostProcessTool(), ProcessLib::LIE::SmallDeformation::SmallDeformationProcess< DisplacementDim >::SmallDeformationProcess(), ProcessLib::addBulkMeshPropertyToSubMesh(), MeshToolsLib::addLayerToMesh(), MeshLib::bulkElementIDs(), MeshLib::bulkNodeIDs(), castPropertyVectorToPropertyVector(), MeshToolsLib::ElementValueModification::condense(), anonymous_namespace{MeshRevision.cpp}::copyProperties(), copyPropertyVector(), ParameterLib::createGroupBasedParameter(), ParameterLib::createMeshElementParameter(), ParameterLib::createMeshNodeParameter(), ParameterLib::createRandomFieldMeshElementParameter(), extractMatGroup(), getRegularElements(), getSurfaceIntegratedValuesForNodes(), MeshToolsLib::Mesh2MeshPropertyInterpolation::interpolateElementPropertiesToNodeProperties(), MeshToolsLib::MeshGenerator::VoxelGridFromMesh::mapArray(), MeshLib::materialIDs(), MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged(), FileIO::Gocad::GocadAsciiReader::parseElements(), FileIO::Gocad::GocadAsciiReader::parseLineSegments(), ApplicationUtils::NodeWiseMeshPartitioner::partitionOtherMesh(), ApplicationUtils::NodeWiseMeshPartitioner::renumberBulkIdsProperty(), reorderProperty(), MeshToolsLib::ElementValueModification::replace(), MeshGeoToolsLib::resetMeshElementProperty(), MeshLib::scaleMeshPropertyVector(), MeshLib::ElementSearch::searchByPropertyValueRange(), MeshToolsLib::ElementValueModification::setByElementType(), setMaterialIDs(), MeshToolsLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh(), anonymous_namespace{IdentifySubdomainMesh.cpp}::updateOrCheckExistingSubdomainProperty(), MeshLib::IO::Legacy::MeshIO::write(), FileIO::TetGenInterface::write2dElements(), FileIO::TetGenInterface::write3dElements(), and MeshLib::IO::VtuInterface::writeVTU().

◆ getPropertyVector() [5/8]

template<typename T >
PropertyVector< T > * MeshLib::Properties::getPropertyVector ( std::string_view name,
MeshItemType const item_type,
int const n_components )

Definition at line 226 of file Properties-impl.h.

229{
230 auto const it = _properties.find(std::string(name));
231 if (it == _properties.end())
232 {
233 OGS_FATAL(
234 "A PropertyVector with name '{:s}' does not exist in the mesh.",
235 name);
236 }
237
238 auto property = dynamic_cast<PropertyVector<T>*>(it->second);
239 if (property == nullptr)
240 {
241 OGS_FATAL(
242 "Could not cast the data type of the PropertyVector '{:s}' to "
243 "requested data type.",
244 name);
245 }
246 if (property->getMeshItemType() != item_type)
247 {
248 OGS_FATAL(
249 "The PropertyVector '{:s}' has type '{:s}'. A '{:s}' field is "
250 "requested.",
251 name, toString(property->getMeshItemType()), toString(item_type));
252 }
253 if (property->getNumberOfGlobalComponents() != n_components)
254 {
255 OGS_FATAL(
256 "PropertyVector '{:s}' has {:d} components, {:d} components are "
257 "needed.",
258 name, property->getNumberOfGlobalComponents(), n_components);
259 }
260 return property;
261}

References OGS_FATAL.

◆ getPropertyVector() [6/8]

template<typename T >
PropertyVector< T > * MeshLib::Properties::getPropertyVector ( std::string_view name,
MeshItemType const item_type,
int const n_components )

Non-const version of getPropertyVector returns a property vector with given name, item_type and number_of_components or calls OGS_FATAL if no such property vector exists.

◆ getPropertyVector() [7/8]

template<typename T >
PropertyVector< T > const * MeshLib::Properties::getPropertyVector ( std::string_view name,
MeshItemType const item_type,
int const n_components ) const

Definition at line 187 of file Properties-impl.h.

190{
191 auto const it = _properties.find(std::string(name));
192 if (it == _properties.end())
193 {
194 OGS_FATAL(
195 "A PropertyVector with name '{:s}' does not exist in the mesh.",
196 name);
197 }
198
199 auto property = dynamic_cast<PropertyVector<T>*>(it->second);
200 if (property == nullptr)
201 {
202 OGS_FATAL(
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(),
206 typeid(PropertyVector<T>).name());
207 }
208 if (property->getMeshItemType() != item_type)
209 {
210 OGS_FATAL(
211 "The PropertyVector '{:s}' has type '{:s}'. A '{:s}' field is "
212 "requested.",
213 name, toString(property->getMeshItemType()), toString(item_type));
214 }
215 if (property->getNumberOfGlobalComponents() != n_components)
216 {
217 OGS_FATAL(
218 "PropertyVector '{:s}' has {:d} components, {:d} components are "
219 "needed.",
220 name, property->getNumberOfGlobalComponents(), n_components);
221 }
222 return property;
223}

References OGS_FATAL.

◆ getPropertyVector() [8/8]

template<typename T >
PropertyVector< T > const * MeshLib::Properties::getPropertyVector ( std::string_view name,
MeshItemType const item_type,
int const n_components ) const

Returns a property vector with given name, item_type and number_of_components or aborts calling OGS_FATAL if no such property vector exists.

◆ getPropertyVectorNames() [1/2]

std::vector< std::string > MeshLib::Properties::getPropertyVectorNames ( ) const

Definition at line 34 of file Properties.cpp.

35{
36 std::vector<std::string> names;
37 std::transform(_properties.begin(), _properties.end(),
38 std::back_inserter(names),
39 [](auto const& pair) { return std::string(pair.first); });
40 return names;
41}
constexpr ranges::views::view_closure names
For an element of a range view return its name.
Definition Mesh.h:231

References _properties.

Referenced by anonymous_namespace{MeshRevision.cpp}::copyProperties(), OGSMesh::getDataArrayNames(), main(), and ProcessLib::Output::prepareSubmesh().

◆ getPropertyVectorNames() [2/2]

std::vector< std::string > MeshLib::Properties::getPropertyVectorNames ( MeshLib::MeshItemType t) const

Definition at line 43 of file Properties.cpp.

45{
46 std::vector<std::string> names;
47 for (auto p : _properties)
48 {
49 if (p.second->getMeshItemType() == t)
50 {
51 names.push_back(std::string(p.first));
52 }
53 }
54 return names;
55}

References _properties.

◆ hasPropertyVector() [1/3]

bool MeshLib::Properties::hasPropertyVector ( std::string_view name) const

Check if a PropertyVector accessible by the name is already stored within the Properties object.

Parameters
namethe name of the property (for instance porosity)

Definition at line 29 of file Properties.cpp.

30{
31 return _properties.find(std::string(name)) != _properties.end();
32}

References _properties.

Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool(), ProcessLib::checkParametersOfDirichletBoundaryCondition(), and ApplicationUtils::NodeWiseMeshPartitioner::renumberBulkIdsProperty().

◆ hasPropertyVector() [2/3]

template<typename T >
bool MeshLib::Properties::hasPropertyVector ( std::string_view name,
MeshItemType const item_type ) const

Definition at line 170 of file Properties-impl.h.

172{
173 auto const it = _properties.find(std::string(name));
174
175 if (it == _properties.end())
176 {
177 return false;
178 }
179
180 auto property = dynamic_cast<PropertyVector<T>*>(it->second);
181
182 return (property == nullptr) ? false
183 : property->getMeshItemType() == item_type;
184}

References MeshLib::PropertyVectorBase::getMeshItemType().

◆ hasPropertyVector() [3/3]

template<typename T >
bool MeshLib::Properties::hasPropertyVector ( std::string_view name,
MeshItemType const item_type ) const

Check if a PropertyVector accessible by the name and by the item type is already stored within the Properties object.

Parameters
namethe name of the property, e.g. porosity.
item_typethe type of mesh entity, e.g. CELL.

◆ operator=() [1/2]

Properties & MeshLib::Properties::operator= ( Properties && properties)
default

◆ operator=() [2/2]

Properties & MeshLib::Properties::operator= ( Properties const & properties)

Definition at line 113 of file Properties.cpp.

114{
115 if (&properties == this)
116 {
117 return *this;
118 }
119
120 _properties = properties._properties;
121 std::vector<std::size_t> exclude_positions;
122 for (auto& name_vector_pair : _properties)
123 {
124 PropertyVectorBase* t(
125 name_vector_pair.second->clone(exclude_positions));
126 name_vector_pair.second = t;
127 }
128
129 return *this;
130}

References _properties.

◆ removePropertyVector()

void MeshLib::Properties::removePropertyVector ( std::string_view name)

Definition at line 17 of file Properties.cpp.

18{
19 auto it(_properties.find(std::string(name)));
20 if (it == _properties.end())
21 {
22 WARN("A property of the name '{:s}' does not exist.", name);
23 return;
24 }
25 delete it->second;
26 _properties.erase(it);
27}

References _properties, and WARN().

◆ size() [1/2]

std::map< std::string, PropertyVectorBase * >::size_type MeshLib::Properties::size ( ) const

Definition at line 162 of file Properties.cpp.

163{
164 return _properties.size();
165}

References _properties.

Referenced by ApplicationUtils::writeProperties().

◆ size() [2/2]

std::map< std::string, PropertyVectorBase * >::size_type MeshLib::Properties::size ( MeshItemType const mesh_item_type) const

Definition at line 167 of file Properties.cpp.

169{
170 return count_if(begin(), end(),
171 [&](auto const p)
172 { return p.second->getMeshItemType() == mesh_item_type; });
173}
std::map< std::string, PropertyVectorBase * >::const_iterator begin() const
std::map< std::string, PropertyVectorBase * >::const_iterator end() const

References begin(), and end().

Member Data Documentation

◆ _properties

std::map<std::string, PropertyVectorBase*> MeshLib::Properties::_properties
private

A mapping from property's name to the stored object of any type. See addProperty() and getProperty() documentation.

Definition at line 176 of file Properties.h.

Referenced by Properties(), ~Properties(), begin(), begin(), end(), end(), excludeCopyProperties(), excludeCopyProperties(), getPropertyVectorNames(), getPropertyVectorNames(), hasPropertyVector(), operator=(), removePropertyVector(), and size().


The documentation for this class was generated from the following files: