15 #ifndef CORE_OPERATION_BOUND_SPACE_OP_H_
16 #define CORE_OPERATION_BOUND_SPACE_OP_H_
32 if (mode == Param::BoundSpaceMode::kClosed) {
34 for (
int i = 0; i < 3; i++) {
38 }
else if (pos[i] >= rb) {
46 }
else if (mode == Param::BoundSpaceMode::kTorus) {
47 auto length = rb - lb;
48 for (
auto& el : pos) {
50 auto d = std::abs(lb - el);
52 d = std::fmod(d, length);
56 auto d = std::abs(el - rb);
58 d = std::fmod(d, length);
74 if (param->bound_space) {
Contains code required by all agents.
virtual const Real3 & GetPosition() const =0
virtual void SetPosition(const Real3 &pos)=0
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
const Param * GetParam() const
Returns the simulation parameters.
void ApplyBoundingBox(Agent *agent, Param::BoundSpaceMode mode, real_t lb, real_t rb)
Interface for implementing an operation.
BDM_OP_HEADER(BoundSpace)
void operator()(Agent *agent) override