42 template<
class TDataType>
61 mDataPointer =
nullptr;
62 #ifdef KRATOS_USING_MPI
78 TDataType* DataPointer,
80 ) : mDataPointer(DataPointer)
81 #ifdef KRATOS_USING_MPI
85 #ifndef KRATOS_USING_MPI
86 KRATOS_DEBUG_ERROR_IF(Rank != 0) <<
"Trying to construct a global pointer with rank different from zero when kratos is not in MPI mode " << std::endl;
97 ) : mDataPointer(DataPointer.
get())
98 #ifdef KRATOS_USING_MPI
102 #ifndef KRATOS_USING_MPI
103 KRATOS_DEBUG_ERROR_IF(Rank != 0) <<
"Trying to construct a global pointer with rank different from zero when kratos is not in MPI mode " << std::endl;
112 Kratos::intrusive_ptr<TDataType>& DataPointer,
114 ) : mDataPointer(DataPointer.
get())
115 #ifdef KRATOS_USING_MPI
119 #ifndef KRATOS_USING_MPI
120 KRATOS_DEBUG_ERROR_IF(Rank != 0) <<
"Trying to construct a global pointer with rank different from zero when kratos is not in MPI mode " << std::endl;
131 ) : mDataPointer(DataPointer.lock().
get())
132 #ifdef KRATOS_USING_MPI
136 #ifndef KRATOS_USING_MPI
137 KRATOS_DEBUG_ERROR_IF(Rank != 0) <<
"Trying to construct a global pointer with rank different from zero when kratos is not in MPI mode " << std::endl;
145 GlobalPointer(std::unique_ptr<TDataType> DataPointer,
int Rank = 0) =
delete;
152 : mDataPointer(rOther.mDataPointer)
153 #ifdef KRATOS_USING_MPI
154 , mRank(rOther.mRank)
164 : mDataPointer(
std::move(rOther.mDataPointer))
165 #ifdef KRATOS_USING_MPI
166 , mRank(
std::move(rOther.mRank))
184 mDataPointer = rOther.mDataPointer;
185 #ifdef KRATOS_USING_MPI
186 mRank = rOther.mRank;
196 return *mDataPointer;
204 return *mDataPointer;
230 #ifdef KRATOS_USING_MPI
233 return this->
get() == rOther.
get();
253 TDataType
const*
get()
const {
264 #ifdef KRATOS_USING_MPI
278 #ifdef KRATOS_USING_MPI
291 void save(
char * buffer)
const {
318 std::stringstream buffer;
319 buffer <<
"GlobalPointer" ;
326 rOStream <<
"GlobalPointer";
332 rOStream <<
"GlobalPointer from Rank: " <<
GetRank() <<
" contains: \n";
333 mDataPointer->PrintData(rOStream);
349 TDataType* mDataPointer;
350 #ifdef KRATOS_USING_MPI
381 if(rSerializer.
Is(Serializer::SHALLOW_GLOBAL_POINTERS_SERIALIZATION)) {
382 rSerializer.
save(
"D",
reinterpret_cast<std::size_t
>(mDataPointer));
384 rSerializer.
save(
"D", mDataPointer);
386 #ifdef KRATOS_USING_MPI
387 rSerializer.
save(
"R", mRank);
397 if(rSerializer.Is(Serializer::SHALLOW_GLOBAL_POINTERS_SERIALIZATION)) {
399 rSerializer.load(
"D",
tmp);
400 mDataPointer =
reinterpret_cast<TDataType*
>(
tmp);
402 rSerializer.load(
"D", mDataPointer);
404 #ifdef KRATOS_USING_MPI
405 rSerializer.load(
"R", mRank);
416 template <
class TDataType>
426 std::size_t
seed = 0;
428 #ifdef KRATOS_USING_MPI
439 template<
class TDataType >
449 #ifdef KRATOS_USING_MPI
450 return ( &(*pGp1) == &(*pGp2) && pGp1.
GetRank() == pGp2.
GetRank() );
452 return ( &(*pGp1) == &(*pGp2) );
462 template<
class TDataType >
472 #ifdef KRATOS_USING_MPI
475 return (pGp1.
get() < pGp2.
get());
481 template<
class TDataType >
487 template<
class TDataType >
492 rOStream << reinterpret_cast<const std::size_t>(&*rThis) <<
" : " << rThis.
GetRank();
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
bool Is(Flags const &rOtherFlag) const
Definition: serializer.h:946
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
TDataType const * operator->() const
Arrow operator for const GlobalPointer.
Definition: global_pointer.h:219
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: global_pointer.h:330
std::string Info() const
Turn back information as a string.
Definition: global_pointer.h:316
GlobalPointer(const GlobalPointer &rOther)
Copy constructor for GlobalPointer.
Definition: global_pointer.h:151
int GetRank() const
Returns the rank of the global pointer.
Definition: global_pointer.h:262
TDataType const * get() const
Get a const pointer to the data.
Definition: global_pointer.h:253
GlobalPointer(Kratos::weak_ptr< TDataType > DataPointer, int Rank=0)
Constructor by Kratos::weak_ptr.
Definition: global_pointer.h:128
TDataType element_type
Definition of element type.
Definition: global_pointer.h:50
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: global_pointer.h:324
void SetRank(const int Rank)
Sets the rank of the global pointer.
Definition: global_pointer.h:276
TDataType & operator*()
Dereference operator for non-const GlobalPointer.
Definition: global_pointer.h:195
bool operator==(const GlobalPointer &rOther)
Overloads the '==' operator to compare two GlobalPointer objects of the same template type....
Definition: global_pointer.h:228
bool operator()(const GlobalPointer< TDataType > &pGp1, const GlobalPointer< TDataType > &pGp2) const
The () operator.
Definition: global_pointer.h:470
void HashCombine(HashType &Seed, const TClassType &Value)
This method creates an "unique" hash for the input value.
Definition: key_hash.h:56
std::size_t operator()(const GlobalPointer< TDataType > &pGp) const
The () operator for hashing a GlobalPointer.
Definition: global_pointer.h:424
GlobalPointer(TDataType Data)=delete
Constructor by Data.
bool operator()(const GlobalPointer< TDataType > &pGp1, const GlobalPointer< TDataType > &pGp2) const
The () operator.
Definition: global_pointer.h:447
void load(char *buffer)
Restores the GlobalPoiter with the data from the buffer.
Definition: global_pointer.h:299
GlobalPointer & operator=(const GlobalPointer &rOther)
Assignment operator for GlobalPointer.
Definition: global_pointer.h:183
GlobalPointer(Kratos::intrusive_ptr< TDataType > &DataPointer, int Rank=0)
Constructor by Kratos::intrusive_ptr.
Definition: global_pointer.h:111
GlobalPointer(Kratos::shared_ptr< TDataType > DataPointer, int Rank=0)
Constructor by Kratos::shared_ptr.
Definition: global_pointer.h:94
GlobalPointer(std::unique_ptr< TDataType > DataPointer, int Rank=0)=delete
Constructor by std::unique_ptr.
GlobalPointer()
Default constructor.
Definition: global_pointer.h:60
TDataType const & operator*() const
Dereference operator for const GlobalPointer.
Definition: global_pointer.h:203
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
TDataType * operator->()
Arrow operator for non-const GlobalPointer.
Definition: global_pointer.h:211
friend class Serializer
Friend class Serializer for handling serialization.
Definition: global_pointer.h:373
GlobalPointer(const GlobalPointer &&rOther)
Move constructor for GlobalPointer.
Definition: global_pointer.h:163
TDataType * get()
Get a non-const pointer to the data.
Definition: global_pointer.h:245
void save(char *buffer) const
Fills buffer with the GlobalPoiter data.
Definition: global_pointer.h:291
GlobalPointer(TDataType *DataPointer, int Rank=0)
Constructor by DataPointer.
Definition: global_pointer.h:77
~GlobalPointer()=default
Destructor.
int seed
Definition: GenerateWind.py:138
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::weak_ptr< T > weak_ptr
Definition: smart_pointers.h:30
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
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
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
namespace
Definition: array_1d.h:793
This is a key compare between two pointers to the object object.
Definition: global_pointer.h:464
This is a key comparer between two dof pointers checking for equal keys.
Definition: global_pointer.h:441
Template struct for hashing GlobalPointer instances.
Definition: global_pointer.h:418