BioDynaMo  v1.05.120-25dc9790
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_
bdm::OctreeEnvironment::Clear
void Clear() override
Definition: octree_environment.cc:144
bdm::Environment::NeighborMutexBuilder
Definition: environment.h:103
bdm::AgentFlatIdxMap::GetAgentHandle
AgentHandle GetAgentHandle(uint64_t idx) const
Definition: agent_flat_idx_map.h:63
bdm::ResourceManager::GetNumAgents
size_t GetNumAgents(int numa_node=-1) const
Definition: resource_manager.h:256
agent_uid.h
bdm::OctreeEnvironment::GetNeighborMutexBuilder
NeighborMutexBuilder * GetNeighborMutexBuilder() override
Definition: octree_environment.cc:140
bdm::ResourceManager::GetAgent
Agent * GetAgent(const AgentUid &uid)
Definition: resource_manager.h:103
bdm::OctreeEnvironment::impl_
std::unique_ptr< UnibnImpl > impl_
Definition: octree_environment.h:76
bdm
Definition: agent.cc:39
bdm::OctreeEnvironment::UpdateImplementation
void UpdateImplementation() override
Definition: octree_environment.cc:39
bdm::OctreeEnvironment::RoundOffGridDimensions
void RoundOffGridDimensions(const std::array< real_t, 6 > &grid_dimensions)
Definition: octree_environment.cc:150
bdm::OctreeEnvironment::container_
AgentContainer * container_
Definition: octree_environment.h:77
bdm::AgentContainer::operator[]
const Real3 & operator[](size_t idx) const
Definition: octree_environment.h:34
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::AgentContainer::rm_
ResourceManager * rm_
Definition: octree_environment.h:40
bdm::LoadBalanceInfo
Definition: load_balance_info.h:24
bdm::AgentContainer
Definition: octree_environment.h:28
bdm::AgentContainer::flat_idx_map_
AgentFlatIdxMap flat_idx_map_
Definition: octree_environment.h:39
bdm::OctreeEnvironment::ForEachNeighbor
void ForEachNeighbor(Functor< void, Agent *, real_t > &lambda, const Agent &query, real_t squared_radius) override
Definition: octree_environment.cc:88
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::AgentContainer::AgentContainer
AgentContainer()
Definition: octree_environment.h:30
bdm::OctreeEnvironment::GetLoadBalanceInfo
LoadBalanceInfo * GetLoadBalanceInfo() override
Definition: octree_environment.cc:132
bdm::Functor< void, Agent *, real_t >
bdm::OctreeEnvironment::threshold_dimensions_
std::array< int32_t, 2 > threshold_dimensions_
Definition: octree_environment.h:83
bdm::OctreeEnvironment::OctreeEnvironment
OctreeEnvironment()
Definition: octree_environment.cc:27
bdm::OctreeEnvironment::GetDimensionThresholds
std::array< int32_t, 2 > GetDimensionThresholds() const override
Definition: octree_environment.cc:128
bdm::Simulation::GetResourceManager
ResourceManager * GetResourceManager()
Returns the ResourceManager instance.
Definition: simulation.cc:244
bdm::ResourceManager
Definition: resource_manager.h:53
agent_flat_idx_map.h
math_array.h
bdm::OctreeEnvironment::CheckGridGrowth
void CheckGridGrowth()
Definition: octree_environment.cc:160
environment.h
bdm::AgentContainer::size
size_t size() const
Definition: octree_environment.h:32
simulation.h
bdm::AgentFlatIdxMap
Definition: agent_flat_idx_map.h:41
bdm::MathArray< real_t, 3 >
bdm::Environment
Definition: environment.h:30
bdm::Agent::GetPosition
virtual const Real3 & GetPosition() const =0
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
bdm::OctreeEnvironment
Definition: octree_environment.h:43
bdm::OctreeEnvironment::grid_dimensions_
std::array< int32_t, 6 > grid_dimensions_
Definition: octree_environment.h:80
bdm::OctreeEnvironment::GetDimensions
std::array< int32_t, 6 > GetDimensions() const override
Definition: octree_environment.cc:124
bdm::OctreeEnvironment::~OctreeEnvironment
~OctreeEnvironment() override
Definition: octree_environment.cc:34
bdm::OctreeEnvironment::UnibnImpl
Definition: octree_environment.cc:23
bdm::AgentHandle
Definition: agent_handle.h:29