11 _gatheredDataPointer(nullptr) {
23 assertion( not container.empty() or _gatheredDataPointer==
nullptr );
24 if (_gatheredDataPointer!=
nullptr) {
25 logDebug(
"scatter()",
"scatter " << container.size() <<
" element(s)" );
26 const int oldSize = container.size();
28 for (
int i=0; i<oldSize; i++) {
29 container.push_back(
new T( _gatheredDataPointer[i]) );
32 _gatheredDataPointer =
nullptr;
40 _gatheredDataPointer =
nullptr;
47 assertion( not container.empty() or _gatheredDataPointer==
nullptr );
48 if (_gatheredDataPointer==
nullptr) {
52 logDebug(
"scatterAndUpdateIterator()",
"scatter " << container.size() <<
" element(s)" );
55 typename Container::iterator result;
57 for (
auto oldContainerIterator: container) {
58 newContainer.push_back(
new T(*oldContainerIterator) );
59 if (oldContainerIterator==*p) {
60 result = newContainer.end();
66 container.splice( container.begin(), newContainer );
68 _gatheredDataPointer =
nullptr;
77 assertion( not container.empty() or _gatheredDataPointer==
nullptr );
78 if (_gatheredDataPointer==
nullptr and not container.empty()) {
79 logDebug(
"gather()",
"gather " << container.size() <<
" element(s)" );
82 for (
auto& p: container) {
83 _gatheredDataPointer[entry] = *p;
88 typename Container::iterator p = container.begin();
89 for (
int entry=0; entry<container.size(); entry++) {
90 *p = _gatheredDataPointer + entry;
99 return _gatheredDataPointer!=
nullptr;
105 assertion( not container.empty() or _gatheredDataPointer==
nullptr );
106 if ( isGathered() ) {
112 container.push_back(newCopy);
#define logDebug(methodName, logMacroMessageStream)
void freeMemory(void *data, MemoryLocation location, int device=accelerator::Device::HostDevice)
Free memory.
@ Heap
Create data on the heap of the local device.
Memory pool offering continuous global memory for a particle species.
Container::iterator scatterAndUpdateIterator(const typename Container::iterator &p)
Scatter the data if not scattered yet and return the updated iterator.
VertexWiseContinuousMemoryPool()
static bool requestCompleteScatter()
Recommend complete scatter.
static tarch::logging::Log _log
void scatter()
If the data are scattered already, nothing is to be done.
bool isGathered() const
Is the vertex data gathered.
void clearAndReset()
Clears the underlying list of pointers and resets _gatheredDataPointer to nullptr.
void replace(typename Container::iterator p, T *newCopy)
Replace particle.
void gather()
Gather the particle.
std::list< T * > Container