OGS 6.3.0-179-g962fdcd4e.dirty.20200403132553
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 36 of file Properties.h.

#include <Properties.h>

Public Member Functions

template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string const &name, MeshItemType mesh_item_type, std::size_t n_components=1)
 
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 const &name) const
 
template<typename T >
bool existsPropertyVector (std::string const &property_name, MeshItemType const mesh_item_type, int const number_of_components) const
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string const &name) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string const &name)
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string const &name, MeshItemType const item_type, int const n_components) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string const &name, MeshItemType const item_type, int const n_components)
 
void removePropertyVector (std::string const &name)
 
bool hasPropertyVector (std::string const &name) 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 ()
 
template<typename T >
PropertyVector< T > * createNewPropertyVector (std::string const &name, MeshItemType mesh_item_type, 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 const &name) const
 
template<typename T >
bool existsPropertyVector (std::string const &name, MeshItemType const mesh_item_type, int const number_of_components) const
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string const &name) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string const &name)
 
template<typename T >
PropertyVector< T > const * getPropertyVector (std::string const &name, MeshItemType const item_type, int const n_components) const
 
template<typename T >
PropertyVector< T > * getPropertyVector (std::string const &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 106 of file Properties.cpp.

References _properties.

107  : _properties(properties._properties)
108 {
109  std::vector<std::size_t> exclude_positions;
110  for (auto& name_vector_pair : _properties)
111  {
112  PropertyVectorBase* t(
113  name_vector_pair.second->clone(exclude_positions));
114  name_vector_pair.second = t;
115  }
116 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ Properties() [3/3]

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

◆ ~Properties()

MeshLib::Properties::~Properties ( )

Definition at line 137 of file Properties.cpp.

References _properties.

138 {
139  for (auto name_vector_pair : _properties)
140  {
141  delete name_vector_pair.second;
142  }
143 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

Member Function Documentation

◆ createNewPropertyVector() [1/4]

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

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

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

◆ createNewPropertyVector() [2/4]

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 38 of file Properties-impl.h.

44 {
45  // check if there is already a PropertyVector with the same name and
46  // mesh_item_type
47  std::map<std::string, PropertyVectorBase*>::const_iterator it(
48  _properties.find(name)
49  );
50  if (it != _properties.end()) {
51  ERR("A property of the name '%s' already assigned to the mesh.",
52  name.c_str());
53  return nullptr;
54  }
55 
56  // check entries of item2group_mapping for consistence
57  for (std::size_t k(0); k<item2group_mapping.size(); k++) {
58  std::size_t const group_id (item2group_mapping[k]);
59  if (group_id >= n_prop_groups) {
60  ERR("The mapping to property %d for item %d is not in the correct range [0,%d).", group_id, k, n_prop_groups);
61  return nullptr;
62  }
63  }
64 
65  auto entry_info(
66  _properties.insert(
67  std::pair<std::string, PropertyVectorBase*>(
68  name,
69  new PropertyVector<T>(n_prop_groups,
70  item2group_mapping, name, mesh_item_type, n_components)
71  )
72  )
73  );
74  return static_cast<PropertyVector<T>*>((entry_info.first)->second);
75 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ createNewPropertyVector() [3/4]

template<typename T >
PropertyVector< T > * MeshLib::Properties::createNewPropertyVector ( std::string const &  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.

Definition at line 15 of file Properties.h.

Referenced by MeshLib::addPropertyToMesh(), castPropertyVectorToPropertyVector(), MeshLib::RasterToMesh::convert(), MeshLib::VtkMeshConverter::convertTypedArray(), ApplicationUtils::copyPropertyVector(), MeshLib::IO::NodePartitionedMeshReader::createPropertyVectorPart(), MeshLib::MeshLayerMapper::createStaticLayers(), ProcessLib::ThermalTwoPhaseFlowWithPP::createThermalTwoPhaseFlowWithPPProcess(), fillPropVec(), LayeredMeshGenerator::getMesh(), MeshLib::IO::Legacy::MeshIO::loadMeshFromFile(), mapArray(), FileIO::Gocad::GocadAsciiReader::parseProperties(), FileIO::Gocad::GocadAsciiReader::readData(), FileIO::GMSInterface::readGMS3DMMesh(), FileIO::GMSH::readGMSHMesh(), FileIO::SwmmInterface::readSwmmInputToLineMesh(), FileIO::TetGenInterface::readTetGenMesh(), MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh(), MeshLib::MeshRevision::simplifyMesh(), and writeDataToMesh().

26 {
27 
36 class Properties

◆ createNewPropertyVector() [4/4]

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.

Definition at line 39 of file Properties.h.

◆ excludeCopyProperties() [1/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 60 of file Properties.cpp.

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

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

63 {
64  Properties exclude_copy;
65  for (auto name_vector_pair : _properties)
66  {
67  if (name_vector_pair.second->getMeshItemType() == MeshItemType::Cell)
68  {
69  exclude_copy._properties.insert(std::make_pair(
70  name_vector_pair.first,
71  name_vector_pair.second->clone(exclude_elem_ids)));
72  }
73  else if (name_vector_pair.second->getMeshItemType() ==
75  {
76  exclude_copy._properties.insert(std::make_pair(
77  name_vector_pair.first,
78  name_vector_pair.second->clone(exclude_node_ids)));
79  }
80  }
81  return exclude_copy;
82 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ excludeCopyProperties() [2/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 84 of file Properties.cpp.

References _properties.

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

◆ existsPropertyVector() [1/4]

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

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

79 {
80  auto it(_properties.find(name));
81  // Check that a PropertyVector with the approriate name exists.
82  if (it == _properties.end())
83  {
84  return false;
85  }
86  // Check that the PropertyVector has the correct data type.
87  return dynamic_cast<PropertyVector<T> const*>(it->second) != nullptr;
88 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ existsPropertyVector() [2/4]

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

Checks if a property vector with given name and the given type exists.

Parameters
namename of the requested property vector

Definition at line 79 of file Properties.h.

Referenced by MeshElementRemovalDialog::accept(), MeshLib::addLayerToMesh(), MeshLib::VtkMappedMeshSource::addProperty(), MeshElementRemovalDialog::addScalarArrays(), ProcessLib::checkParametersOfDirichletBoundaryCondition(), ProcessLib::LIE::PostProcessTool::copyProperties(), ApplicationUtils::copyPropertyVector(), ProcessLib::RichardsComponentTransport::createPorousMediaProperties(), ProcessLib::LIE::PostProcessTool::createProperties(), ProcessLib::ThermalTwoPhaseFlowWithPP::createThermalTwoPhaseFlowWithPPProcess(), ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowWithPrhoProcess(), MeshLib::ElementStatus::ElementStatus(), fillPropVec(), ProcessLib::getIntegrationPointMetaData(), MeshLib::getOrCreateMeshProperty(), getSurfaceIntegratedValuesForNodes(), MeshLib::MeshInformation::getValueBounds(), ProcessLib::SmallDeformation::SmallDeformationProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::ThermoMechanics::ThermoMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::HydroMechanics::HydroMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), MeshLib::Mesh2MeshPropertyInterpolation::interpolateElementPropertiesToNodeProperties(), MeshLib::materialIDs(), MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged(), MeshLib::processPropertyVector(), MeshLib::scaleMeshPropertyVector(), MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh(), MeshLib::IO::Legacy::MeshIO::write(), FileIO::TetGenInterface::write2dElements(), FileIO::SHPInterface::write2dMeshToSHP(), and ApplicationUtils::writePropertyVectorBinary().

◆ existsPropertyVector() [3/4]

template<typename T >
bool MeshLib::Properties::existsPropertyVector ( std::string const &  property_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.

Definition at line 92 of file Properties.h.

◆ existsPropertyVector() [4/4]

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

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

94 {
95  auto const it = _properties.find(name);
96  if (it == _properties.end())
97  {
98  return false;
99  }
100 
101  auto property = dynamic_cast<PropertyVector<T>*>(it->second);
102  if (property == nullptr)
103  {
104  return false;
105  }
106  if (property->getMeshItemType() != mesh_item_type)
107  {
108  return false;
109  }
110  if (property->getNumberOfComponents() != number_of_components)
111  {
112  return false;
113  }
114  return true;
115 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVector() [1/8]

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

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

Definition at line 119 of file Properties.h.

Referenced by MeshLib::addLayerToMesh(), MeshLib::VtkMappedMeshSource::addProperty(), MeshElementRemovalDialog::addScalarArrays(), castPropertyVectorToPropertyVector(), MeshLib::ElementValueModification::condense(), ProcessLib::ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition(), MeshLib::convertToLinearMesh(), ProcessLib::LIE::PostProcessTool::copyProperties(), ApplicationUtils::copyPropertyVector(), ParameterLib::createGroupBasedParameter(), ParameterLib::createMeshElementParameter(), ParameterLib::createMeshNodeParameter(), ProcessLib::RichardsComponentTransport::createPorousMediaProperties(), ProcessLib::LIE::PostProcessTool::createProperties(), ProcessLib::ThermalTwoPhaseFlowWithPP::createThermalTwoPhaseFlowWithPPProcess(), ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowWithPrhoProcess(), MeshLib::ElementStatus::ElementStatus(), fillPropVec(), ProcessLib::PythonBoundaryCondition::getEssentialBCValues(), getSurfaceIntegratedValuesForNodes(), MeshLib::MeshInformation::getValueBounds(), anonymous_namespace{IdentifySubdomainMesh.cpp}::identifySubdomainMeshElements(), MeshLib::Mesh2MeshPropertyInterpolation::interpolateElementPropertiesToNodeProperties(), mapArray(), MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged(), FileIO::Gocad::GocadAsciiReader::parseElements(), FileIO::Gocad::GocadAsciiReader::parseLineSegments(), FileIO::Gocad::GocadAsciiReader::parseNodes(), ApplicationUtils::NodeWiseMeshPartitioner::partitionOtherMesh(), ProcessLib::LIE::PostProcessTool::PostProcessTool(), MeshLib::processPropertyVector(), MeshLib::ElementValueModification::replace(), MeshLib::scaleMeshPropertyVector(), MeshLib::ElementSearch::searchByPropertyValueRange(), MeshLib::ElementValueModification::setByElementType(), MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh(), ProcessLib::LIE::SmallDeformation::SmallDeformationProcess< DisplacementDim >::SmallDeformationProcess(), MeshLib::IO::Legacy::MeshIO::write(), FileIO::TetGenInterface::write2dElements(), FileIO::SHPInterface::write2dMeshToSHP(), FileIO::TetGenInterface::write3dElements(), and ApplicationUtils::writePropertyVectorBinary().

◆ getPropertyVector() [2/8]

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

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

Definition at line 140 of file Properties.h.

154  :
157  std::map<std::string, PropertyVectorBase*> _properties;
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVector() [3/8]

template<typename T >
PropertyVector< T > const * MeshLib::Properties::getPropertyVector ( std::string const &  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.

Definition at line 160 of file Properties.h.

◆ getPropertyVector() [4/8]

template<typename T >
PropertyVector< T > * MeshLib::Properties::getPropertyVector ( std::string const &  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.

Definition at line 196 of file Properties.h.

◆ getPropertyVector() [5/8]

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

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

References OGS_FATAL.

120 {
121  auto it(_properties.find(name));
122  if (it == _properties.end())
123  {
124  OGS_FATAL(
125  "The PropertyVector '%s' is not available in the mesh.",
126  name.c_str());
127  }
128  if (!dynamic_cast<PropertyVector<T> const*>(it->second))
129  {
130  OGS_FATAL(
131  "The PropertyVector '%s' has a different type than the requested "
132  "PropertyVector.",
133  name.c_str());
134  }
135  return dynamic_cast<PropertyVector<T> const*>(it->second);
136 }
#define OGS_FATAL(fmt,...)
Definition: Error.h:64
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVector() [6/8]

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

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

References OGS_FATAL.

140 {
141  auto it(_properties.find(name));
142  if (it == _properties.end())
143  {
144  OGS_FATAL(
145  "A PropertyVector with the specified name '%s' is not available.",
146  name.c_str());
147  }
148  if (!dynamic_cast<PropertyVector<T>*>(it->second))
149  {
150  OGS_FATAL(
151  "The PropertyVector '%s' has a different type than the requested "
152  "PropertyVector.",
153  name.c_str());
154  }
155  return dynamic_cast<PropertyVector<T>*>(it->second);
156 }
#define OGS_FATAL(fmt,...)
Definition: Error.h:64
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVector() [7/8]

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

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

References OGS_FATAL, and MaterialLib::Solids::MFront::toString().

162 {
163  auto const it = _properties.find(name);
164  if (it == _properties.end())
165  {
166  OGS_FATAL("A PropertyVector with name '%s' does not exist in the mesh.",
167  name.c_str());
168  }
169 
170  auto property = dynamic_cast<PropertyVector<T>*>(it->second);
171  if (property == nullptr)
172  {
173  OGS_FATAL(
174  "Could not cast the data type of the PropertyVector '%s' to "
175  "requested data type.",
176  name.c_str());
177  }
178  if (property->getMeshItemType() != item_type)
179  {
180  OGS_FATAL(
181  "The PropertyVector '%s' has type '%s'. A '%s' field is requested.",
182  name.c_str(), toString(property->getMeshItemType()),
183  toString(item_type));
184  }
185  if (property->getNumberOfComponents() != n_components)
186  {
187  OGS_FATAL(
188  "PropertyVector '%s' has %d components, %d components are needed.",
189  name.c_str(), property->getNumberOfComponents(), n_components);
190  }
191  return property;
192 }
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition: Location.h:28
#define OGS_FATAL(fmt,...)
Definition: Error.h:64
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVector() [8/8]

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

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

References OGS_FATAL, and MaterialLib::Solids::MFront::toString().

198 {
199  auto const it = _properties.find(name);
200  if (it == _properties.end())
201  {
202  OGS_FATAL("A PropertyVector with name '%s' does not exist in the mesh.",
203  name.c_str());
204  }
205 
206  auto property = dynamic_cast<PropertyVector<T>*>(it->second);
207  if (property == nullptr)
208  {
209  OGS_FATAL(
210  "Could not cast the data type of the PropertyVector '%s' to "
211  "requested data type.",
212  name.c_str());
213  }
214  if (property->getMeshItemType() != item_type)
215  {
216  OGS_FATAL(
217  "The PropertyVector '%s' has type '%s'. A '%s' field is requested.",
218  name.c_str(), toString(property->getMeshItemType()),
219  toString(item_type));
220  }
221  if (property->getNumberOfComponents() != n_components)
222  {
223  OGS_FATAL(
224  "PropertyVector '%s' has %d components, %d components are needed.",
225  name.c_str(), property->getNumberOfComponents(), n_components);
226  }
227  return property;
228 }
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition: Location.h:28
#define OGS_FATAL(fmt,...)
Definition: Error.h:64
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ getPropertyVectorNames() [1/2]

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

◆ getPropertyVectorNames() [2/2]

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

Definition at line 46 of file Properties.cpp.

References _properties.

48 {
49  std::vector<std::string> names;
50  for (auto p : _properties)
51  {
52  if (p.second->getMeshItemType() == t)
53  {
54  names.push_back(p.first);
55  }
56  }
57  return names;
58 }
static const double p
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ hasPropertyVector()

bool MeshLib::Properties::hasPropertyVector ( std::string const &  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 31 of file Properties.cpp.

References _properties.

Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool().

32 {
33  return _properties.find(name) != _properties.end();
34 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ operator=() [1/2]

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

Definition at line 118 of file Properties.cpp.

References _properties.

119 {
120  if (&properties == this)
121  {
122  return *this;
123  }
124 
125  _properties = properties._properties;
126  std::vector<std::size_t> exclude_positions;
127  for (auto& name_vector_pair : _properties)
128  {
129  PropertyVectorBase* t(
130  name_vector_pair.second->clone(exclude_positions));
131  name_vector_pair.second = t;
132  }
133 
134  return *this;
135 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

◆ operator=() [2/2]

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

◆ removePropertyVector()

void MeshLib::Properties::removePropertyVector ( std::string const &  name)

Definition at line 18 of file Properties.cpp.

References _properties.

Referenced by MeshLib::RasterToMesh::convert().

19 {
20  std::map<std::string, PropertyVectorBase*>::const_iterator it(
21  _properties.find(name)
22  );
23  if (it == _properties.end()) {
24  WARN("A property of the name '%s' does not exist.", name.c_str());
25  return;
26  }
27  delete it->second;
28  _properties.erase(it);
29 }
std::map< std::string, PropertyVectorBase * > _properties
Definition: Properties.h:157

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 157 of file Properties.h.

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


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