8#ifndef SRC_PARALLEL_COMMUNICATIONBUFFER_H_
9#define SRC_PARALLEL_COMMUNICATIONBUFFER_H_
11#include "molecules/MoleculeForwardDeclaration.h"
12#include "utils/mardyn_assert.h"
20#define LS1_SEND_UNIQUE_ID_FOR_HALO_COPIES
39 friend class CommunicationBufferTest;
45 size_t getDynamicSize();
49 void resizeForAppendingLeavingMolecules(
unsigned long numMols);
50 void resizeForAppendingHaloMolecules(
unsigned long numMols);
51 void resizeForAppendingForceMolecules(
unsigned long numMols);
53 unsigned char * getDataForSending();
54 size_t getNumElementsForSending();
55 void resizeForRawBytes(
unsigned long numBytes);
58 void addLeavingMolecule(
size_t indexOfMolecule,
const Molecule& m);
59 void addHaloMolecule(
size_t indexOfMolecule,
const Molecule& m);
60 void addForceMolecule(
size_t indexOfMolecule,
const Molecule& m);
63 void readLeavingMolecule(
size_t indexOfMolecule,
Molecule& m)
const;
64 void readHaloMolecule(
size_t indexOfMolecule,
Molecule& m)
const;
65 void readForceMolecule(
size_t indexOfMolecule,
Molecule& m)
const;
67 void resizeForReceivingMolecules(
unsigned long& numLeaving,
unsigned long& numHalo);
68 void resizeForReceivingMolecules(
unsigned long& numForces);
70 size_t getNumHalo()
const {
74 size_t getNumLeaving()
const {
78 size_t getNumForces()
const {
82 static MPI_Datatype getMPIDataType() {
87 static size_t _numBytesHalo;
88 static size_t _numBytesLeaving;
89 static size_t _numBytesForces;
91 enum class ParticleType_t {HALO=0, LEAVING=1, FORCE=3};
92 size_t getStartPosition(ParticleType_t
type,
size_t indexOfMolecule)
const;
98 size_t emplaceValue(
size_t indexInBytes, T passByValue);
101 size_t readValue(
size_t indexInBytes, T& passByReference)
const;
103 typedef unsigned char byte_t;
104 std::vector<byte_t> _buffer;
105 size_t _numLeaving, _numHalo, _numForces;
109inline size_t CommunicationBuffer::emplaceValue(
size_t indexInBytes, T passByValue) {
110 const size_t numBytesOfT =
sizeof(T);
111 size_t ret = indexInBytes + numBytesOfT;
113 mardyn_assert(_buffer.size() >= ret);
115 const byte_t * pointer =
reinterpret_cast<byte_t *
> (&passByValue);
116 for (
size_t i = 0; i < numBytesOfT; ++i) {
117 _buffer[indexInBytes + i] = pointer[i];
124inline size_t CommunicationBuffer::readValue(
size_t indexInBytes, T& passByReference)
const {
125 const size_t numBytesOfT =
sizeof(T);
126 size_t ret = indexInBytes + numBytesOfT;
128 mardyn_assert(_buffer.size() >= ret);
130 byte_t * pointer =
reinterpret_cast<byte_t *
> (&passByReference);
131 for (
size_t i = 0; i < numBytesOfT; ++i) {
132 pointer[i] = _buffer[indexInBytes + i];
Definition: CommunicationBuffer.h:37
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
Enumeration class corresponding to the type schema type.
Definition: vtk-unstructured.h:1746