Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/PhysiCell_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,9 @@ void delete_cell( int index )
// released internalized substrates (as of 1.5.x releases)
pDeleteMe->release_internalized_substrates();

// new Dec 2, 2025
pDeleteMe->remove_self_from_attackers();

// performance goal: don't delete in the middle -- very expensive reallocation
// alternative: copy last element to index position, then shrink vector by 1 at the end O(constant)

Expand Down Expand Up @@ -3433,6 +3436,15 @@ void Cell::remove_all_spring_attachments( void )
return;
}

void Cell::remove_self_from_attackers( void )
{
for (Cell* pCell : phenotype.cell_interactions.attacked_by)
{
pCell->phenotype.cell_interactions.pAttackTarget = NULL;
}
phenotype.cell_interactions.attacked_by.clear();
return;
}

void attach_cells( Cell* pCell_1, Cell* pCell_2 )
{
Expand Down
1 change: 1 addition & 0 deletions core/PhysiCell_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class Cell : public Basic_Agent
void attach_cell_as_spring( Cell* pAddMe ); // done
void detach_cell_as_spring( Cell* pRemoveMe ); // done
void remove_all_spring_attachments( void ); // done
void remove_self_from_attackers( void );

// I want to eventually deprecate this, by ensuring that
// critical BioFVM and PhysiCell data elements are synced when they are needed
Expand Down
1 change: 1 addition & 0 deletions core/PhysiCell_phenotype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ Cell_Interactions::Cell_Interactions()
immunogenicities = {1};

pAttackTarget = NULL;
attacked_by = std::vector<Cell*>{};
total_damage_delivered = 0.0;

attack_duration = 30.0; // a typical attack duration for a T cell using perforin/granzyme is ~30 minutes
Expand Down
1 change: 1 addition & 0 deletions core/PhysiCell_phenotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ class Cell_Interactions
double attack_damage_rate;

Cell* pAttackTarget;
std::vector<Cell*> attacked_by;
double total_damage_delivered;

double attack_duration;
Expand Down
10 changes: 10 additions & 0 deletions core/PhysiCell_standard_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "PhysiCell_standard_models.h"
#include "PhysiCell_cell.h"
#include "../modules/PhysiCell_pathology.h"
#include <algorithm>

namespace PhysiCell{

Expand Down Expand Up @@ -1267,6 +1268,7 @@ void standard_cell_cell_interactions( Cell* pCell, Phenotype& phenotype, double
if( UniformRandom() < probability )
{
pCell->phenotype.cell_interactions.pAttackTarget = pTarget;
pTarget->phenotype.cell_interactions.attacked_by.push_back(pCell);
attacked = true;
/*
std::cout << "********* ********* ******** start atack **** " << PhysiCell_globals.current_time << std::endl;
Expand Down Expand Up @@ -1345,6 +1347,14 @@ void standard_cell_cell_interactions( Cell* pCell, Phenotype& phenotype, double
detach_cells_as_spring(pCell,pTarget);

pCell->phenotype.cell_interactions.pAttackTarget = NULL;
pTarget->phenotype.cell_interactions.attacked_by.erase(
std::remove(
pTarget->phenotype.cell_interactions.attacked_by.begin(),
pTarget->phenotype.cell_interactions.attacked_by.end(),
pCell),
pTarget->phenotype.cell_interactions.attacked_by.end()
);

}
}

Expand Down
Loading