BioDynaMo  v1.05.120-25dc9790
default_ops.cc
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 
25 
26 namespace bdm {
27 
28 BDM_REGISTER_OP(BoundSpace, "bound space", kCpu);
29 
30 BDM_REGISTER_OP(ContinuumOp, "continuum", kCpu);
31 
32 // By default run load balancing only in the first iteration.
33 BDM_REGISTER_OP_WITH_FREQ(LoadBalancingOp, "load balancing", kCpu,
34  std::numeric_limits<uint32_t>::max());
35 
36 BDM_REGISTER_OP(MechanicalForcesOp, "mechanical forces", kCpu);
37 
38 #ifdef USE_CUDA
39 BDM_REGISTER_OP(MechanicalForcesOpCuda, "mechanical forces", kCuda);
40 #endif
41 
42 BDM_REGISTER_OP(DividingCellOp, "DividingCellOp", kCpu);
43 
44 #if defined(USE_OPENCL) && !defined(__ROOTCLING__)
45 BDM_REGISTER_OP(MechanicalForcesOpOpenCL, "mechanical forces", kOpenCl);
46 #endif
47 
50 
51  void operator()(Agent* agent) override { agent->UpdateStaticness(); }
52 };
53 
54 BDM_REGISTER_OP(UpdateStaticnessOp, "update staticness", kCpu);
55 
58 
59  void operator()(Agent* agent) override { agent->PropagateStaticness(); }
60 };
61 
62 BDM_REGISTER_OP(PropagateStaticnessAgentOp, "propagate staticness agentop",
63  kCpu);
64 
65 struct BehaviorOp : public AgentOperationImpl {
67 
68  void operator()(Agent* agent) override { agent->RunBehaviors(); }
69 };
70 
71 BDM_REGISTER_OP(BehaviorOp, "behavior", kCpu);
72 
75 
76  void operator()(Agent* agent) override { agent->RunDiscretization(); }
77 };
78 
79 BDM_REGISTER_OP(DiscretizationOp, "discretization", kCpu);
80 
83 
84  void operator()() override {
85  auto* sim = Simulation::GetActive();
86  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
87  all_exec_ctxts[0]->SetupIterationAll(all_exec_ctxts);
88  sim->GetEnvironment()->Update();
89  }
90 };
91 
92 BDM_REGISTER_OP(SetUpIterationOp, "set up iteration", kCpu);
93 
96 
97  void operator()() override {
98  auto* sim = Simulation::GetActive();
99  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
100  all_exec_ctxts[0]->TearDownIterationAll(all_exec_ctxts);
101  }
102 };
103 
104 BDM_REGISTER_OP(TearDownIterationOp, "tear down iteration", kCpu);
105 
108 
109  void operator()() override {
111  }
112 };
113 
114 BDM_REGISTER_OP(UpdateTimeSeriesOp, "update time series", kCpu);
115 
118 
119  void operator()() override {
120  auto* sim = Simulation::GetActive();
121  sim->GetEnvironment()->ForcedUpdate();
122  }
123 };
124 
125 BDM_REGISTER_OP(UpdateEnvironmentOp, "update environment", kCpu);
126 
127 BDM_REGISTER_OP(VisualizationOp, "visualize", kCpu);
128 
131 
132  void operator()() override {
133  if (!Simulation::GetActive()->GetParam()->detect_static_agents) {
134  return;
135  }
136  auto function = L2F(
137  [](Agent* agent, AgentHandle) { agent->PropagateStaticness(true); });
139  auto* param = Simulation::GetActive()->GetParam();
140  rm->ForEachAgentParallel(param->scheduling_batch_size, function);
141  }
142 };
143 
144 BDM_REGISTER_OP(PropagateStaticnessOp, "propagate staticness", kCpu);
145 
146 } // namespace bdm
dividing_cell_op.h
bdm::Agent::RunBehaviors
void RunBehaviors()
Execute all behaviorsq.
Definition: agent.cc:146
bdm::UpdateEnvironmentOp::operator()
void operator()() override
Definition: default_ops.cc:119
bdm::UpdateTimeSeriesOp::BDM_OP_HEADER
BDM_OP_HEADER(UpdateTimeSeriesOp)
bdm::Simulation::GetTimeSeries
experimental::TimeSeries * GetTimeSeries()
Definition: simulation.cc:287
bdm
Definition: agent.cc:39
bdm::PropagateStaticnessOp::BDM_OP_HEADER
BDM_OP_HEADER(PropagateStaticnessOp)
operation.h
bdm::BehaviorOp::operator()
void operator()(Agent *agent) override
Definition: default_ops.cc:68
bdm::TearDownIterationOp
Definition: default_ops.cc:94
bdm::SetUpIterationOp::operator()
void operator()() override
Definition: default_ops.cc:84
bdm::PropagateStaticnessAgentOp
Definition: default_ops.cc:56
bdm::PropagateStaticnessAgentOp::BDM_OP_HEADER
BDM_OP_HEADER(PropagateStaticnessAgentOp)
bdm::UpdateStaticnessOp::BDM_OP_HEADER
BDM_OP_HEADER(UpdateStaticnessOp)
bdm::BDM_REGISTER_OP
BDM_REGISTER_OP(BoundSpace, "bound space", kCpu)
bdm::kCpu
@ kCpu
Definition: operation.h:31
mechanical_forces_op_cuda.h
bdm::UpdateStaticnessOp::operator()
void operator()(Agent *agent) override
Definition: default_ops.cc:51
bdm::L2F
LambdaFunctor< decltype(&TLambda::operator())> L2F(const TLambda &l)
Definition: functor.h:110
bdm::SetUpIterationOp::BDM_OP_HEADER
BDM_OP_HEADER(SetUpIterationOp)
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::experimental::TimeSeries::Update
void Update()
Adds a new data point to all time series with a collector.
Definition: time_series.cc:368
bdm::PropagateStaticnessOp
Definition: default_ops.cc:129
bdm::SetUpIterationOp
Definition: default_ops.cc:81
bdm::PropagateStaticnessAgentOp::operator()
void operator()(Agent *agent) override
Definition: default_ops.cc:59
continuum_op.h
time_series.h
bdm::TearDownIterationOp::operator()
void operator()() override
Definition: default_ops.cc:97
bdm::DiscretizationOp::BDM_OP_HEADER
BDM_OP_HEADER(DiscretizationOp)
bdm::Simulation::GetResourceManager
ResourceManager * GetResourceManager()
Returns the ResourceManager instance.
Definition: simulation.cc:244
bdm::AgentOperationImpl
Interface for implementing an operation.
Definition: operation.h:76
bdm::UpdateTimeSeriesOp
Definition: default_ops.cc:106
bdm::Agent::RunDiscretization
virtual void RunDiscretization()
Definition: agent.cc:117
load_balancing_op.h
bdm::BehaviorOp
Definition: default_ops.cc:65
mechanical_forces_op_opencl.h
bdm::PropagateStaticnessOp::operator()
void operator()() override
Definition: default_ops.cc:132
bdm::UpdateEnvironmentOp
Definition: default_ops.cc:116
bdm::kOpenCl
@ kOpenCl
Definition: operation.h:31
bound_space_op.h
visualization_op.h
bdm::DiscretizationOp
Definition: default_ops.cc:73
bdm::TearDownIterationOp::BDM_OP_HEADER
BDM_OP_HEADER(TearDownIterationOp)
bdm::Agent::UpdateStaticness
void UpdateStaticness()
Definition: agent.cc:111
mechanical_forces_op.h
bdm::Simulation::GetParam
const Param * GetParam() const
Returns the simulation parameters.
Definition: simulation.cc:254
bdm::kCuda
@ kCuda
Definition: operation.h:31
bdm::UpdateEnvironmentOp::BDM_OP_HEADER
BDM_OP_HEADER(UpdateEnvironmentOp)
bdm::Agent::PropagateStaticness
void PropagateStaticness(bool beginning=false)
Definition: agent.cc:77
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
bdm::DiscretizationOp::operator()
void operator()(Agent *agent) override
Definition: default_ops.cc:76
bdm::BDM_REGISTER_OP_WITH_FREQ
BDM_REGISTER_OP_WITH_FREQ(LoadBalancingOp, "load balancing", kCpu, std::numeric_limits< uint32_t >::max())
bdm::StandaloneOperationImpl
Interface for implementing an operation that should run on a GPU.
Definition: operation.h:86
bdm::UpdateStaticnessOp
Definition: default_ops.cc:48
bdm::BehaviorOp::BDM_OP_HEADER
BDM_OP_HEADER(BehaviorOp)
bdm::UpdateTimeSeriesOp::operator()
void operator()() override
Definition: default_ops.cc:109
bdm::AgentHandle
Definition: agent_handle.h:29