BioDynaMo  v1.05.159-3be850bb
octree_environment.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_ENVIRONMENT_OCTREE_ENVIRONMENT_
16 #define CORE_ENVIRONMENT_OCTREE_ENVIRONMENT_
17 
18 #include "core/agent/agent_uid.h"
22 #include "core/simulation.h"
23 
24 namespace bdm {
25 
29  public:
31 
32  size_t size() const { return rm_->GetNumAgents(); }
33 
34  const Real3& operator[](size_t idx) const {
36  return rm_->GetAgent(ah)->GetPosition();
37  }
38 
40  ResourceManager* rm_ = nullptr;
41 };
42 
44  public:
45  struct UnibnImpl;
46 
48 
49  ~OctreeEnvironment() override;
50 
51  std::array<int32_t, 6> GetDimensions() const override;
52 
53  std::array<int32_t, 2> GetDimensionThresholds() const override;
54 
56 
58 
59  void Clear() override;
60 
62  const Agent& query, real_t squared_radius) override;
63 
64  void ForEachNeighbor(Functor<void, Agent*>& lambda, const Agent& query,
65  void* criteria) override;
66 
68  const Real3& query_position, real_t squared_radius,
69  const Agent* query_agent = nullptr) override;
70 
71  protected:
72  void UpdateImplementation() override;
73 
74  private:
75  // Hide unibn-specific types from header (pimpl idiom)
76  std::unique_ptr<UnibnImpl> impl_;
80  std::array<int32_t, 6> grid_dimensions_;
83  std::array<int32_t, 2> threshold_dimensions_;
84 
85  void RoundOffGridDimensions(const std::array<real_t, 6>& grid_dimensions);
86 
87  void CheckGridGrowth();
88 };
89 
90 } // namespace bdm
91 
92 #endif // CORE_ENVIRONMENT_OCTREE_ENVIRONMENT_
ResourceManager * rm_
const Real3 & operator[](size_t idx) const
AgentFlatIdxMap flat_idx_map_
AgentHandle GetAgentHandle(uint64_t idx) const
Contains code required by all agents.
Definition: agent.h:79
virtual const Real3 & GetPosition() const =0
LoadBalanceInfo * GetLoadBalanceInfo() override
NeighborMutexBuilder * GetNeighborMutexBuilder() override
std::unique_ptr< UnibnImpl > impl_
void RoundOffGridDimensions(const std::array< real_t, 6 > &grid_dimensions)
std::array< int32_t, 2 > GetDimensionThresholds() const override
std::array< int32_t, 6 > grid_dimensions_
AgentContainer * container_
void UpdateImplementation() override
std::array< int32_t, 2 > threshold_dimensions_
std::array< int32_t, 6 > GetDimensions() const override
void ForEachNeighbor(Functor< void, Agent *, real_t > &lambda, const Agent &query, real_t squared_radius) override
Agent * GetAgent(const AgentUid &uid)
size_t GetNumAgents(int numa_node=-1) const
ResourceManager * GetResourceManager()
Returns the ResourceManager instance.
Definition: simulation.cc:244
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
Definition: agent.cc:39
double real_t
Definition: real_t.h:21