20 #include <unordered_map>
78 using int64_t = __int64;
110 , mSubPropertiesList()
118 , mSubPropertiesList(SubPropertiesList)
124 , mData(rOther.mData)
125 , mTables(rOther.mTables)
126 , mSubPropertiesList(rOther.mSubPropertiesList)
128 for (
auto& r_item : rOther.mAccessors) {
129 const auto key = r_item.first;
130 const auto& rp_accessor = r_item.second;
131 mAccessors.emplace(key, rp_accessor->Clone());
146 mData = rOther.mData;
147 mTables = rOther.mTables;
148 mSubPropertiesList = rOther.mSubPropertiesList;
149 for (
auto& r_item : rOther.mAccessors) {
150 const auto key = r_item.first;
151 const auto& rp_accessor = r_item.second;
152 mAccessors.emplace(key, rp_accessor->Clone());
157 template<
class TVariableType>
158 typename TVariableType::Type&
operator()(
const TVariableType& rV)
163 template<
class TVariableType>
164 typename TVariableType::Type
const&
operator()(
const TVariableType& rV)
const
169 template<
class TVariableType>
170 typename TVariableType::Type&
operator[](
const TVariableType& rV)
175 template<
class TVariableType>
176 typename TVariableType::Type
const&
operator[](
const TVariableType& rV)
const
181 template<
class TVariableType>
182 typename TVariableType::Type&
operator()(
const TVariableType& rV,
Node& rThisNode)
187 template<
class TVariableType>
188 typename TVariableType::Type
const&
operator()(
const TVariableType& rV,
Node const& rThisNode)
const
193 template<
class TVariableType>
196 return GetValue(rV, rThisNode, SolutionStepIndex);
199 template<
class TVariableType>
200 typename TVariableType::Type
const&
operator()(
const TVariableType& rV,
Node const& rThisNode,
IndexType SolutionStepIndex)
const
202 return GetValue(rV, rThisNode, SolutionStepIndex);
205 template<
class TVariableType>
211 template<
class TVariableType>
212 typename TVariableType::Type
const&
operator()(
const TVariableType& rV,
Node const& rThisNode,
ProcessInfo const& rCurrentProcessInfo)
const
221 template<
class TVariableType>
227 template<
class TVariableType>
228 typename TVariableType::Type&
GetValue(
const TVariableType& rVariable)
233 template<
class TVariableType>
234 typename TVariableType::Type
const&
GetValue(
const TVariableType& rVariable)
const
240 template<
class TVariableType>
241 typename TVariableType::Type&
GetValue(
const TVariableType& rVariable,
Node& rThisNode)
243 if (mData.
Has(rVariable))
245 return rThisNode.
GetValue(rVariable);
248 template<
class TVariableType>
249 typename TVariableType::Type
const&
GetValue(
const TVariableType& rVariable,
Node const& rThisNode)
const
251 if (mData.
Has(rVariable))
253 return rThisNode.
GetValue(rVariable);
256 template<
class TVariableType>
257 typename TVariableType::Type&
GetValue(
const TVariableType& rVariable,
Node& rThisNode,
IndexType SolutionStepIndex)
259 if (mData.
Has(rVariable))
261 return rThisNode.
GetValue(rVariable, SolutionStepIndex);
264 template<
class TVariableType>
265 typename TVariableType::Type
const&
GetValue(
const TVariableType& rVariable,
Node const& rThisNode,
IndexType SolutionStepIndex)
const
267 if (mData.
Has(rVariable))
269 return rThisNode.
GetValue(rVariable, SolutionStepIndex);
275 template<
class TVariableType>
278 auto it_value = mAccessors.find(rVariable.Key());
279 if (it_value != mAccessors.end()) {
280 return (it_value->second)->GetValue(rVariable, *
this, rGeometry, rShapeFunctionVector, rProcessInfo);
286 template<
class TVariableType>
287 void SetValue(TVariableType
const& rV,
typename TVariableType::Type
const& rValue)
304 template <
class TVariableType>
307 mAccessors.emplace(rVariable.Key(), std::move(pAccessor));
318 template <
class TVariableType>
321 auto it_value = mAccessors.find(rVariable.Key());
323 <<
"Trying to retrieve inexisting accessor for '" << rVariable.Name() <<
"' in properties " <<
Id() <<
"." << std::endl;
324 return *(it_value->second);
335 template <
class TVariableType>
338 const auto it_value = mAccessors.find(rVariable.Key());
340 <<
"Trying to retrieve inexisting accessor for '" << rVariable.Name() <<
"' in properties " <<
Id() <<
"." << std::endl;
341 return *(it_value->second);
352 template <
class TVariableType>
355 const auto it_value = mAccessors.find(rVariable.Key());
357 <<
"Trying to retrieve inexisting accessor for '" << rVariable.Name() <<
"' in properties " <<
Id() <<
"." << std::endl;
358 return it_value->second;
369 template <
class TVariableType>
372 return (mAccessors.find(rVariable.Key()) == mAccessors.end()) ? false :
true;
375 template<
class TXVariableType,
class TYVariableType>
378 return mTables[
Key(XVariable.Key(), YVariable.Key())];
381 template<
class TXVariableType,
class TYVariableType>
382 TableType const&
GetTable(
const TXVariableType& XVariable,
const TYVariableType& YVariable)
const
384 return mTables.at(
Key(XVariable.Key(), YVariable.Key()));
387 template<
class TXVariableType,
class TYVariableType>
388 void SetTable(
const TXVariableType& XVariable,
const TYVariableType& YVariable,
TableType const& rThisTable)
390 mTables[
Key(XVariable.Key(), YVariable.Key())] = rThisTable;
395 return !mTables.empty();
403 int64_t
Key(std::size_t XKey, std::size_t YKey)
const
405 int64_t result_key = XKey;
406 result_key = result_key << 32;
417 return mSubPropertiesList.
size();
427 mSubPropertiesList.
insert(mSubPropertiesList.
begin(), pNewSubProperty);
437 return mSubPropertiesList.
find(SubPropertyIndex) != mSubPropertiesList.
end();
448 auto property_iterator = mSubPropertiesList.
find(SubPropertyIndex);
449 if (property_iterator != mSubPropertiesList.
end()) {
450 return *(property_iterator.base());
452 KRATOS_ERROR <<
"Subproperty ID: " << SubPropertyIndex <<
" is not defined on the current Properties ID: " << this->
Id() <<
" creating a new one with ID: " << SubPropertyIndex << std::endl;
465 auto property_iterator = mSubPropertiesList.
find(SubPropertyIndex);
466 if (property_iterator != mSubPropertiesList.
end()) {
467 return *(property_iterator.base());
469 KRATOS_ERROR <<
"Subproperty ID: " << SubPropertyIndex <<
" is not defined on the current Properties ID: " << this->
Id() <<
" creating a new one with ID: " << SubPropertyIndex << std::endl;
482 auto property_iterator = mSubPropertiesList.
find(SubPropertyIndex);
483 if (property_iterator != mSubPropertiesList.
end()) {
484 return *(property_iterator);
486 KRATOS_ERROR <<
"Subproperty ID: " << SubPropertyIndex <<
" is not defined on the current Properties ID: " << this->
Id() <<
" creating a new one with ID: " << SubPropertyIndex << std::endl;
499 if (mSubPropertiesList.
find(SubPropertyIndex) != mSubPropertiesList.
end()) {
500 return *(mSubPropertiesList.
find(SubPropertyIndex));
502 KRATOS_ERROR <<
"Subproperty ID: " << SubPropertyIndex <<
" is not defined on the current Properties ID: " << this->
Id() << std::endl;
512 return mSubPropertiesList;
521 return mSubPropertiesList;
530 mSubPropertiesList = rSubPropertiesList;
577 template<
class TVariableType>
578 bool Has(TVariableType
const& rThisVariable)
const
580 return mData.
Has(rThisVariable);
583 template<
class TXVariableType,
class TYVariableType>
584 bool HasTable(
const TXVariableType& XVariable,
const TYVariableType& YVariable)
const
586 return (mTables.find(
Key(XVariable.Key(), YVariable.Key())) != mTables.end());
594 std::string
Info()
const override
602 rOStream <<
"Properties";
609 rOStream <<
"Id : " << this->
Id() <<
"\n";
615 if (mTables.size() > 0) {
617 rOStream <<
"This properties contains " << mTables.size() <<
" tables\n";
618 for (
auto& r_table : mTables) {
619 rOStream <<
"Table key: " << r_table.first <<
"\n";
625 if (mSubPropertiesList.
size() > 0) {
627 rOStream <<
"\nThis properties contains " << mSubPropertiesList.
size() <<
" subproperties\n";
628 for (
auto& r_subprop : mSubPropertiesList) {
634 if (mAccessors.size() > 0) {
636 rOStream <<
"\nThis properties contains " << mAccessors.size() <<
" accessors\n";
637 for (
auto& r_entry : mAccessors) {
638 rOStream <<
"Accessor for variable key: " << r_entry.first <<
"\n";
708 void save(
Serializer& rSerializer)
const override
711 rSerializer.
save(
"Data", mData);
712 rSerializer.
save(
"Tables", mTables);
713 rSerializer.
save(
"SubPropertiesList", mSubPropertiesList);
714 std::vector<std::pair<const KeyType, Accessor*>> aux_accessors_container;
715 for (
auto& r_item : mAccessors) {
716 const auto key = r_item.first;
717 const auto& rp_accessor = r_item.second;
718 aux_accessors_container.push_back(std::make_pair(key, &(*rp_accessor)));
720 rSerializer.
save(
"Accessors", aux_accessors_container);
726 rSerializer.load(
"Data", mData);
727 rSerializer.load(
"Tables", mTables);
728 rSerializer.load(
"SubPropertiesList", mSubPropertiesList);
729 std::vector<std::pair<const KeyType, Accessor*>> aux_accessors_container;
730 rSerializer.load(
"Accessors", aux_accessors_container);
731 for (
auto& r_item : aux_accessors_container) {
732 const auto key = r_item.first;
733 const auto& rp_accessor = r_item.second;
734 mAccessors.emplace(key, rp_accessor->Clone());
772 rOStream << std::endl;
This class defines the way a certain property is accessed.
Definition: accessor.h:43
Container for storing data values associated with variables.
Definition: data_value_container.h:63
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
void Erase(const Variable< TDataType > &rThisVariable)
Erases the value associated with a given variable.
Definition: data_value_container.h:339
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
virtual void PrintData(std::ostream &rOStream) const
Outputs the detailed data contents of the data value container to a given stream.
Definition: data_value_container.h:423
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
bool IsEmpty() const
Checks if the data container is empty.
Definition: data_value_container.h:391
Geometry base class.
Definition: geometry.h:71
This object defines an indexed object.
Definition: indexed_object.h:54
IndexedObject & operator=(IndexedObject const &rOther)
Assignment operator.
Definition: indexed_object.h:86
IndexedObject(IndexType NewId=0)
Default constructor.
Definition: indexed_object.h:73
std::size_t IndexType
The definition of the index type.
Definition: indexed_object.h:63
IndexType Id() const
Definition: indexed_object.h:107
This class defines the node.
Definition: node.h:65
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
iterator insert(iterator Position, const TPointerType pData)
Inserts a pointer at the specified position.
Definition: pointer_vector_set.h:569
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
iterator find(const key_type &Key)
Find an element with the specified key.
Definition: pointer_vector_set.h:678
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
IndexType GetSolutionStepIndex() const
Definition: process_info.h:277
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Properties & GetSubProperties(const IndexType SubPropertyIndex)
This method gets the subproperty from the index corresponding to the property id.
Definition: properties.h:479
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: properties.h:600
TVariableType::Type & GetValue(const TVariableType &rVariable)
Definition: properties.h:228
TablesContainerType const & Tables() const
This method returns the tables (constant)
Definition: properties.h:568
ContainerType & Data()
This method returns the whole data container.
Definition: properties.h:541
TVariableType::Type & operator()(const TVariableType &rV, Node &rThisNode, IndexType SolutionStepIndex)
Definition: properties.h:194
~Properties() override
Destructor.
Definition: properties.h:136
Properties::Pointer pGetSubProperties(const IndexType SubPropertyIndex)
This method gets the subproperty from the index corresponding to the property id.
Definition: properties.h:445
SubPropertiesContainerType & GetSubProperties()
This method returns the whole list of subproperties.
Definition: properties.h:510
TVariableType::Type & operator()(const TVariableType &rV)
Definition: properties.h:158
void SetSubProperties(SubPropertiesContainerType &rSubPropertiesList)
This method set the whole list of subproperties.
Definition: properties.h:528
Properties(IndexType NewId, const SubPropertiesContainerType &SubPropertiesList)
Default of properties with subproperties.
Definition: properties.h:114
void AddSubProperties(Properties::Pointer pNewSubProperty)
This method insert a new property into the list of subproperties.
Definition: properties.h:424
std::size_t IndexType
Definition: properties.h:86
std::string Info() const override
Turn back information as a string.
Definition: properties.h:594
std::size_t NumberOfSubproperties() const
This method returns the number of subproperties.
Definition: properties.h:415
Properties(IndexType NewId=0)
Default constructor.
Definition: properties.h:106
void SetAccessor(const TVariableType &rVariable, AccessorPointerType pAccessor)
Set the Accessor object This method sets a variable-accessor pair in current properties accessor cont...
Definition: properties.h:305
IndexType KeyType
Definition: properties.h:90
SubPropertiesContainerType const & GetSubProperties() const
This method returns the whole list of subproperties.
Definition: properties.h:519
TVariableType::Type const & GetValue(const TVariableType &rVariable) const
Definition: properties.h:234
Properties(const Properties &rOther)
Copy constructor.
Definition: properties.h:122
bool Has(TVariableType const &rThisVariable) const
Definition: properties.h:578
int64_t Key(std::size_t XKey, std::size_t YKey) const
Definition: properties.h:403
const Properties & GetSubProperties(const IndexType SubPropertyIndex) const
This method gets the subproperty from the index corresponding to the property id (constant version)
Definition: properties.h:496
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: properties.h:606
TVariableType::Type & GetValue(const TVariableType &rVariable, Node &rThisNode)
Definition: properties.h:241
Accessor::UniquePointer AccessorPointerType
Definition: properties.h:92
Accessor & GetAccessor(const TVariableType &rVariable)
Get the Accessor object If exists, this method returns a pointer to the requested variable accessor I...
Definition: properties.h:319
bool IsEmpty() const
Definition: properties.h:398
void SetTable(const TXVariableType &XVariable, const TYVariableType &YVariable, TableType const &rThisTable)
Definition: properties.h:388
TableType const & GetTable(const TXVariableType &XVariable, const TYVariableType &YVariable) const
Definition: properties.h:382
TVariableType::Type & GetValue(const TVariableType &rVariable, Node &rThisNode, IndexType SolutionStepIndex)
Definition: properties.h:257
bool HasVariables() const
Definition: properties.h:292
TVariableType::Type const & GetValue(const TVariableType &rVariable, Node const &rThisNode, IndexType SolutionStepIndex) const
Definition: properties.h:265
TVariableType::Type & operator[](const TVariableType &rV)
Definition: properties.h:170
bool HasTables() const
Definition: properties.h:393
const Properties::Pointer pGetSubProperties(const IndexType SubPropertyIndex) const
This method gets the subproperty from the index corresponding to the property id (constant version)
Definition: properties.h:462
bool HasSubProperties(const IndexType SubPropertyIndex) const
This method checks if the subproperty exists from the index corresponding to the property id.
Definition: properties.h:435
void Erase(const TVariableType &rV)
Definition: properties.h:222
TVariableType::Type const & operator()(const TVariableType &rV, Node const &rThisNode, IndexType SolutionStepIndex) const
Definition: properties.h:200
PointerVectorSet< Properties, IndexedObject > SubPropertiesContainerType
Properties container. A vector set of properties with their Id's as key.
Definition: properties.h:99
TVariableType::Type const & operator()(const TVariableType &rV, Node const &rThisNode, ProcessInfo const &rCurrentProcessInfo) const
Definition: properties.h:212
KRATOS_CLASS_POINTER_DEFINITION(Properties)
Pointer definition of Properties.
TVariableType::Type const & operator()(const TVariableType &rV) const
Definition: properties.h:164
AccessorPointerType & pGetAccessor(const TVariableType &rVariable)
Get the Accessor object If exists, this method returns a pointer to the requested variable accessor I...
Definition: properties.h:353
bool HasTable(const TXVariableType &XVariable, const TYVariableType &YVariable) const
Definition: properties.h:584
Accessor & GetAccessor(const TVariableType &rVariable) const
Get the Accessor object If exists, this method returns a pointer to the requested variable accessor I...
Definition: properties.h:336
void SetValue(TVariableType const &rV, typename TVariableType::Type const &rValue)
Definition: properties.h:287
Properties & operator=(const Properties &rOther)
Assignment operator.
Definition: properties.h:143
std::unordered_map< KeyType, AccessorPointerType > AccessorsContainerType
Definition: properties.h:94
TablesContainerType & Tables()
This method returns the tables.
Definition: properties.h:559
TableType & GetTable(const TXVariableType &XVariable, const TYVariableType &YVariable)
Definition: properties.h:376
TVariableType::Type const & operator()(const TVariableType &rV, Node const &rThisNode) const
Definition: properties.h:188
TVariableType::Type GetValue(const TVariableType &rVariable, const GeometryType &rGeometry, const Vector &rShapeFunctionVector, const ProcessInfo &rProcessInfo) const
Definition: properties.h:276
friend class Serializer
Definition: properties.h:706
TVariableType::Type & operator()(const TVariableType &rV, Node &rThisNode, ProcessInfo const &rCurrentProcessInfo)
Definition: properties.h:206
bool HasAccessor(const TVariableType &rVariable) const
Check if current properties have an accessor This method checks if current properties have an accesso...
Definition: properties.h:370
TVariableType::Type & operator()(const TVariableType &rV, Node &rThisNode)
Definition: properties.h:182
TVariableType::Type const & operator[](const TVariableType &rV) const
Definition: properties.h:176
std::unordered_map< std::size_t, TableType > TablesContainerType
Definition: properties.h:96
ContainerType const & Data() const
This method returns the whole data container (constant)
Definition: properties.h:550
TVariableType::Type const & GetValue(const TVariableType &rVariable, Node const &rThisNode) const
Definition: properties.h:249
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
static void PrintDataWithIdentation(std::ostream &rOStream, const TClass &rThisClass, const std::string Identation="\t")
Prints the data of an object of type TClass to the given output stream with indentation.
Definition: string_utilities.h:129
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def load(f)
Definition: ode_solve.py:307
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247