75 using ValueType = std::pair<const VariableData*, void*>;
100 mData.push_back(
ValueType(
i->first,
i->first->Clone(
i->second)));
106 for(
iterator i = mData.begin() ;
i != mData.end() ; ++
i)
107 i->first->Delete(
i->second);
121 template<
class TDataType>
124 return GetValue<TDataType>(rThisVariable);
134 template<
class TDataType>
137 return GetValue<TDataType>(rThisVariable);
147 template<
class TDataType>
150 return GetValue<TDataType>(rThisVariable);
160 template<
class TDataType>
163 return GetValue<TDataType>(rThisVariable);
173 template<
class TDataType>
176 return GetValue<TDataType>(rThisVariable);
186 template<
class TDataType>
189 return GetValue<TDataType>(rThisVariable);
199 template<
class TDataType>
202 return GetValue<TDataType>(rThisVariable);
211 return mData.begin();
220 return mData.begin();
252 mData.push_back(
ValueType(
i->first,
i->first->Clone(
i->second)));
267 template<
class TDataType>
270 typename ContainerType::iterator
i;
272 if ((
i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.
SourceKey()))) != mData.end())
277 KRATOS_ERROR <<
"attempting to do a GetValue for: " << rThisVariable <<
" unfortunately the variable is not in the database and the operations is not threadsafe (this function is being called from within a parallel region)" << std::endl;
281 mData.push_back(
ValueType(p_source_variable,p_source_variable->Clone(p_source_variable->pZero())));
283 return *(
static_cast<TDataType*
>(mData.back().second) + rThisVariable.
GetComponentIndex());
293 template<
class TDataType>
296 typename ContainerType::const_iterator
i;
298 if ((
i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.
SourceKey()))) != mData.end())
299 return *(
static_cast<const TDataType*
>(
i->second) + rThisVariable.
GetComponentIndex());
301 return rThisVariable.
Zero();
319 template<
class TDataType>
322 typename ContainerType::iterator
i;
324 if ((
i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.
SourceKey()))) != mData.end()) {
328 mData.push_back(
ValueType(p_source_variable,p_source_variable->Clone(p_source_variable->pZero())));
329 *(
static_cast<TDataType*
>(mData.back().second) + rThisVariable.
GetComponentIndex()) = rValue;
338 template<
class TDataType>
341 typename ContainerType::iterator
i;
343 if ((
i = std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.
SourceKey()))) != mData.end()) {
344 i->first->Delete(
i->second);
354 for(ContainerType::iterator
i = mData.begin() ;
i != mData.end() ;
i++)
355 i->first->Delete(
i->second);
381 template<
class TDataType>
384 return (std::find_if(mData.begin(), mData.end(), IndexCheck(rThisVariable.
SourceKey())) != mData.end());
393 return mData.empty();
404 virtual std::string
Info()
const
406 return std::string(
"data value container");
415 rOStream <<
"data value container";
427 i->first->Print(
i->second, rOStream);
428 rOStream << std::endl;
483 explicit IndexCheck(std::size_t I) : mI(I) {}
490 bool operator()(
const ValueType& I)
492 return I.first->SourceKey() == mI;
528 virtual void save(
Serializer& rSerializer)
const;
568 rOStream << std::endl;
Container for storing data values associated with variables.
Definition: data_value_container.h:63
TDataType & operator[](const Variable< TDataType > &rThisVariable)
Index operator for retrieving a data value by a Variable.
Definition: data_value_container.h:187
std::vector< ValueType > ContainerType
Type of the container used for variables.
Definition: data_value_container.h:78
virtual ~DataValueContainer()
Destructor.
Definition: data_value_container.h:104
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
TDataType & operator[](const VariableData &rThisVariable)
Index operator for retrieving a data value by a VariableData.
Definition: data_value_container.h:161
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
DataValueContainer & operator=(const DataValueContainer &rOther)
Assignment operator for copying data from another DataValueContainer.
Definition: data_value_container.h:247
SizeType Size()
Gets the size of the data container.
Definition: data_value_container.h:308
virtual std::string Info() const
Retrieves a string representation of the data value container.
Definition: data_value_container.h:404
DataValueContainer()
Default constructor.
Definition: data_value_container.h:94
ContainerType::iterator iterator
Type of the container used for variables.
Definition: data_value_container.h:81
virtual void PrintInfo(std::ostream &rOStream) const
Outputs a brief description of the data value container to a given stream.
Definition: data_value_container.h:413
const_iterator begin() const
Const iterator pointing to the beginning of the container.
Definition: data_value_container.h:218
ContainerType::const_iterator const_iterator
Type of the container used for variables.
Definition: data_value_container.h:84
const TDataType & operator()(const VariableData &rThisVariable) const
Accessor operator for retrieving a data value by a VariableData.
Definition: data_value_container.h:122
ContainerType::size_type SizeType
Type of the container used for variables.
Definition: data_value_container.h:87
const TDataType & operator()(const Variable< TDataType > &rThisVariable) const
Accessor operator for retrieving a data value by a Variable (const version).
Definition: data_value_container.h:148
const TDataType & GetValue(const Variable< TDataType > &rThisVariable) const
Gets the value associated with a given variable (const version).
Definition: data_value_container.h:294
void Clear()
Clears the entire data container.
Definition: data_value_container.h:352
iterator end()
Iterator pointing to the end of the container.
Definition: data_value_container.h:227
const TDataType & operator[](const VariableData &rThisVariable) const
Index operator for retrieving a data value by a VariableData (const version).
Definition: data_value_container.h:174
DataValueContainer(DataValueContainer const &rOther)
Copy constructor.
Definition: data_value_container.h:97
std::pair< const VariableData *, void * > ValueType
Type of the container used for variables.
Definition: data_value_container.h:75
KRATOS_DEFINE_LOCAL_FLAG(OVERWRITE_OLD_VALUES)
Define local flag.
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
TDataType & operator()(const Variable< TDataType > &rThisVariable)
Accessor operator for retrieving a data value by a Variable.
Definition: data_value_container.h:135
const_iterator end() const
Const iterator pointing to the end of the container.
Definition: data_value_container.h:236
const TDataType & operator[](const Variable< TDataType > &rThisVariable) const
Index operator for retrieving a data value by a Variable (const version).
Definition: data_value_container.h:200
iterator begin()
Iterator pointing to the beginning of the container.
Definition: data_value_container.h:209
KRATOS_CLASS_POINTER_DEFINITION(DataValueContainer)
Pointer definition of DataValueContainer.
static int IsInParallel()
Wrapper for omp_in_parallel().
Definition: openmp_utils.h:122
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
This class is the base of variables and variable's components which contains their common data.
Definition: variable_data.h:49
KeyType GetComponentIndex() const
Returns the component index.
Definition: variable_data.h:227
KeyType SourceKey() const
Definition: variable_data.h:192
const VariableData & GetSourceVariable() const
Definition: variable_data.h:232
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
const TDataType & Zero() const
This method returns the zero value of the variable type.
Definition: variable.h:346
#define KRATOS_ERROR
Definition: exception.h:161
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
integer i
Definition: TensorModule.f:17
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247