22#include "Vector/vector_dist.hpp"
45 static bool pack() {
return true;}
109 req += 2*
sizeof(size_t) +
size +
str.size()+1;
117 static bool noPointers()
153 memcpy(t_ptr2,
str.c_str(),
str.size());
156 t_ptr2[
str.size()] = 0;
201 str = std::string(ptr_src2);
324int main(
int argc,
char* argv[])
343 openfpm_init(&argc,&argv);
349 size_t bc[2]={PERIODIC,PERIODIC};
355 constexpr int my_s1 = 0;
358 constexpr int my_s2 = 1;
363 vd(4096,domain,bc,g);
391 auto it = vd.getDomainIterator();
398 vd.getPos(p)[0] = (float)rand() / RAND_MAX;
401 vd.getPos(p)[1] = (float)rand() / RAND_MAX;
408 vd.getProp<my_s1>(p).size = 32;
409 vd.getProp<my_s1>(p).ptr =
new char[32];
410 strcpy(vd.getProp<my_s1>(p).ptr,pt.
toString().c_str());
413 vd.getProp<my_s1>(p).str = std::string(pt.
toString());
415 vd.getProp<my_s1>(p).v.add(1);
416 vd.getProp<my_s1>(p).v.add(2);
417 vd.getProp<my_s1>(p).v.add(3);
423 vd.getProp<my_s2>(p).size = 32;
424 vd.getProp<my_s2>(p).ptr =
new char[32];
425 strcpy(vd.getProp<my_s2>(p).ptr,pt.
toString().c_str());
428 vd.getProp<my_s2>(p).str = std::string(pt.
toString());
430 vd.getProp<my_s2>(p).v.add(1);
431 vd.getProp<my_s2>(p).v.add(2);
432 vd.getProp<my_s2>(p).v.add(3);
433 vd.getProp<my_s2>(p).v.add(4);
464 vd.ghost_get<my_s1,my_s2>();
486 vd.write(
"particles");
505 size_t fg = vd.size_local();
513 for ( ; fg < vd.size_local()+4 ; fg++)
516 std::cout <<
"my_struct1:" << std::endl;
517 std::cout <<
"C-string: " << vd.getProp<my_s1>(fg).ptr << std::endl;
518 std::cout <<
"Cpp-string: " << vd.getProp<my_s1>(fg).str << std::endl;
520 for (
size_t i = 0 ; i < vd.getProp<my_s1>(fg).v.size() ; i++)
521 std::cout <<
"Element: " << i <<
" " << vd.getProp<my_s1>(fg).v.get(i) << std::endl;
524 std::cout <<
"my_struct2" << std::endl;
525 std::cout <<
"C-string: " << vd.getProp<my_s2>(fg).ptr << std::endl;
526 std::cout <<
"Cpp-string: " << vd.getProp<my_s2>(fg).str << std::endl;
528 for (
size_t i = 0 ; i < vd.getProp<my_s2>(fg).v.size() ; i++)
529 std::cout <<
"Element: " << i <<
" " << vd.getProp<my_s2>(fg).v.get(i) << std::endl;
This class represent an N-dimensional box.
void * getPointerOffset(size_t offset)
Get the base memory pointer increased with an offset.
virtual void * getPointer()
Return the pointer of the last allocation.
virtual bool allocate(size_t sz)
Allocate a chunk of memory.
virtual size_t size() const
Get the size of the LAST allocated memory.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
This class implement the point shape in an N-dimensional space.
std::string toString() const
Return the string with the point coordinate.
size_t getOffset()
Return the actual counter.
void addOffset(size_t off)
Increment the offset pointer by off.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
return if true the aggregate type T has a property that has a complex packing(serialization) method
static bool pack()
Functions to check if the packing object is complex.
my_struct(const my_struct &my)
Copy constructor.
my_struct & operator=(const my_struct &my)
This is fundamental to avoid crash, otherwise.
openfpm::vector< int > v
vector
my_struct(my_struct &&my)
Copy constructor from temporal object.
void pack(ExtPreAlloc< Memory > &mem, Pack_stat &sts) const
Serialize the data structure.
my_struct & operator=(my_struct &&my)
This is fundamental to avoid crash, otherwise.
void packRequest(size_t &req) const
Serialization request.
std::string str
C++ string.
char * ptr
C string pointer.
size_t size
C string size.
void unpack(ExtPreAlloc< Memory > &mem, Unpack_stat &ps)
De-serialize the data structure.