-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecm_Csp_update.cpp
More file actions
36 lines (30 loc) · 1.35 KB
/
ecm_Csp_update.cpp
File metadata and controls
36 lines (30 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* ecm_Csp_update
*
* Purpose:
* Refresh each ECM voxel concentration array from the global macro property buffer.
*
* Inputs:
* - Agent variable: grid_lin_id
* - Environment macro property: C_SP_MACRO
*
* Outputs:
* - Updated per-agent C_sp array
*
* Notes:
* This is the synchronization bridge from macro-level concentration updates
* back into per-agent concentration variables.
*/
FLAMEGPU_AGENT_FUNCTION(ecm_Csp_update, flamegpu::MessageNone, flamegpu::MessageNone) {
//Get agent variables (agent calling the function)
int agent_id = FLAMEGPU->getVariable<int>("id");
int agent_grid_lin_id = FLAMEGPU->getVariable<int>("grid_lin_id");
//printf("ECM agent %d at grid_lin_id %d updating C_sp from MACRO property \n", agent_id, agent_grid_lin_id);
const uint8_t N_SPECIES = 2; // WARNING: this variable must be hard coded to have the same value as the one defined in the main python function.
const uint32_t ECM_POPULATION_SIZE = 9261; // WARNING: this variable must be hard coded to have the same value as the one defined in the main python function.
auto C_SP_MACRO = FLAMEGPU->environment.getMacroProperty<float, N_SPECIES, ECM_POPULATION_SIZE>("C_SP_MACRO");
for (int i = 0; i < N_SPECIES; i++) {
FLAMEGPU->setVariable<float, N_SPECIES>("C_sp", i, (float)C_SP_MACRO[i][agent_grid_lin_id]);
}
return flamegpu::ALIVE;
}