8#ifndef SRC_PARTICLECONTAINER_PARTICLECELLBASE_H_
9#define SRC_PARTICLECONTAINER_PARTICLECELLBASE_H_
12#include "molecules/Molecule.h"
13#include "CellBorderAndFlagManager.h"
16#include <quicksched.h>
28 virtual void deallocateAllParticles() = 0;
52 virtual bool deleteMoleculeByIndex(
size_t index) = 0;
54 virtual int getMoleculeCount()
const = 0;
56 virtual void preUpdateLeavingMolecules() = 0;
60 virtual void postUpdateLeavingMolecules() = 0;
62 virtual void getRegion(
double lowCorner[3],
double highCorner[3], std::vector<Molecule*> &particlePtrs,
bool removeFromContainer =
false) = 0;
64 virtual void buildSoACaches() = 0;
66 virtual void increaseMoleculeStorage(
size_t numMols) = 0;
68 virtual bool testPointInCell(
const double point[3])
const {
69 double boxMin[3] = {getBoxMin(0), getBoxMin(1), getBoxMin(2)};
70 double boxMax[3] = {getBoxMax(0), getBoxMax(1), getBoxMax(2)};
71 return boxMin[0] <= point[0] && boxMin[1] <= point[1] && boxMin[2] <= point[2] &&
72 point[0] < boxMax[0] && point[1] < boxMax[1] && point[2] < boxMax[2];
75 virtual bool testInBox(
const Molecule& particle)
const {
76 double boxMin[3] = {getBoxMin(0), getBoxMin(1), getBoxMin(2)};
77 double boxMax[3] = {getBoxMax(0), getBoxMax(1), getBoxMax(2)};
78 return particle.
inBox(boxMin, boxMax);
81 virtual size_t getMoleculeVectorDynamicSize()
const = 0;
83 virtual void prefetchForForce()
const {}
85 unsigned long initCubicGrid(std::array<unsigned long, 3> numMoleculesPerDimension, std::array<double, 3> simBoxLength,
Random & RNG);
91 virtual void moleculesAtNew(
size_t i,
Molecule *& multipurposePointer) = 0;
92 virtual void moleculesAtConstNew(
size_t i,
Molecule *& multipurposePointer)
const = 0;
94 virtual void getLeavingMolecules(std::vector<Molecule> & appendBuffer) {
100 bool isHaloCell() const final {
101 return _cellBorderAndFlagManager.isHaloCell(
_cellIndex);
103 bool isBoundaryCell() const final {
104 return _cellBorderAndFlagManager.isBoundaryCell(
_cellIndex);
106 bool isInnerCell() const final {
107 return _cellBorderAndFlagManager.isInnerCell(
_cellIndex);
109 bool isInnerMostCell() const final {
110 return _cellBorderAndFlagManager.isInnerMostCell(
_cellIndex);
113 void assignCellToHaloRegion() { mardyn_assert(isHaloCell()); }
114 void assignCellToBoundaryRegion() { mardyn_assert(isBoundaryCell()); }
115 void assignCellToInnerRegion() { mardyn_assert(isInnerCell()); }
116 void assignCellToInnerMostAndInnerRegion() { mardyn_assert(isInnerMostCell() and isInnerCell()); }
118 void skipCellFromHaloRegion() { mardyn_assert(not isHaloCell()); }
119 void skipCellFromBoundaryRegion() { mardyn_assert(not isBoundaryCell()); }
120 void skipCellFromInnerRegion() { mardyn_assert(not isInnerCell()); }
121 void skipCellFromInnerMostRegion() { mardyn_assert(not isInnerMostCell()); }
123 double getBoxMin(
int d)
const {
124 return _cellBorderAndFlagManager.getBoundingBoxMin(
_cellIndex, d);
126 double getBoxMax(
int d)
const {
127 return _cellBorderAndFlagManager.getBoundingBoxMax(
_cellIndex, d);
130 std::array<double, 3> getBoxMinArray()
const {
131 std::array<double, 3> ret{getBoxMin(0), getBoxMin(1), getBoxMin(2)};
135 std::array<double, 3> getBoxMaxArray()
const {
136 std::array<double, 3> ret{getBoxMax(0), getBoxMax(1), getBoxMax(2)};
140 void setBoxMin(
const double b[3]) {
141 for (
int d = 0; d < 3; ++d) {
142 mardyn_assert(getBoxMin(d) == b[d]);
145 void setBoxMax(
const double b[3]) {
146 for (
int d = 0; d < 3; ++d) {
147 mardyn_assert(getBoxMax(d) == b[d]);
152 qsched_res_t getRescourceId()
const {
156 void setResourceId(qsched_res_t resourceId){
157 _resourceId = resourceId;
160 qsched_task_t getTaskId()
const {
164 void setTaskId(qsched_task_t taskId){
178 qsched_res_t _resourceId;
179 qsched_task_t _taskId;
Definition: CellBorderAndFlagManager.h:19
unsigned long _cellIndex
the index of a cell. On one process every index must be unique.
Definition: Cell.h:35
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
virtual bool inBox(const double l[3], const double u[3]) const
test whether molecule is inside a cuboid region
Definition: MoleculeInterface.h:300
ParticleCellBase defines the interface for cells used by the LinkedCells data structure to store mole...
Definition: ParticleCellBase.h:23
virtual bool findMoleculeByID(size_t &index, unsigned long molid) const =0
Find the index of a molecule in a cell based on its molecule ID.
virtual bool isEmpty() const =0
Check if current cell contains no molecules.
virtual bool addParticle(Molecule &particle, bool checkWhetherDuplicate=false)=0
Add a particle to the cell.
bool isNotEmpty() const
Check if current cell contains molecules.
Definition: ParticleCellBase.h:44
bool deleteMoleculeByID(unsigned long molid)
Remove moleulce from the cell based on molecule ID.
Definition: ParticleCellBase.cpp:23