| 648 | } |
| 649 | |
| 650 | void cResourceCount::ModifyCell(cAvidaContext& ctx, const Apto::Array<double> & res_change, int cell_id) |
| 651 | { |
| 652 | assert(resource_count.GetSize() == res_change.GetSize()); |
| 653 | |
| 654 | DoUpdates(ctx); |
| 655 | for (int i = 0; i < resource_count.GetSize(); i++) { |
| 656 | if (!IsSpatialResource(i)) { |
| 657 | resource_count[i] += res_change[i]; |
| 658 | assert(resource_count[i] >= 0.0); |
| 659 | } else { |
| 660 | double temp = spatial_resource_count[i]->Element(cell_id).GetAmount(); |
| 661 | spatial_resource_count[i]->Rate(cell_id, res_change[i]); |
| 662 | /* Ideally the state of the cell's resource should not be set till |
| 663 | the end of the update so that all processes (inflow, outflow, |
| 664 | diffision, gravity and organism demand) have the same weight. However |
| 665 | waiting can cause problems with negative resources so we allow |
| 666 | the organism demand to work immediately on the state of the resource */ |
| 667 | |
| 668 | spatial_resource_count[i]->State(cell_id); |
| 669 | if(spatial_resource_count[i]->Element(cell_id).GetAmount() != temp){ |
| 670 | spatial_resource_count[i]->SetModified(true); |
| 671 | } |
| 672 | assert(spatial_resource_count[i]->Element(cell_id).GetAmount() >= 0.0); |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | double cResourceCount::Get(cAvidaContext& ctx, int res_id) const |
| 678 | { |
no test coverage detected