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
63 changes: 45 additions & 18 deletions core/PhysiCell_cell_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,8 @@ void Cell_Container::update_all_cells(double t, double phenotype_dt_ , double me
static double mechanics_dt_tolerance = 0.001 * mechanics_dt_;

// intracellular update. called for every diffusion_dt, but actually depends on the intracellular_dt of each cell (as it can be noisy)

#pragma omp parallel for
for( int i=0; i < (*all_cells).size(); i++ )
{
if( (*all_cells)[i]->is_out_of_domain == false && initialzed ) {

if( (*all_cells)[i]->phenotype.intracellular != NULL && (*all_cells)[i]->phenotype.intracellular->need_update())
{
if ((*all_cells)[i]->functions.pre_update_intracellular != NULL)
(*all_cells)[i]->functions.pre_update_intracellular( (*all_cells)[i], (*all_cells)[i]->phenotype , diffusion_dt_ );

(*all_cells)[i]->phenotype.intracellular->update( (*all_cells)[i], (*all_cells)[i]->phenotype , diffusion_dt_ );

if ((*all_cells)[i]->functions.post_update_intracellular != NULL)
(*all_cells)[i]->functions.post_update_intracellular( (*all_cells)[i], (*all_cells)[i]->phenotype , diffusion_dt_ );
}
}
}
if (initialzed)
{ update_all_cells_intracellular(); }

if( time_since_last_cycle > phenotype_dt_ - 0.5 * diffusion_dt_ || !initialzed )
{
Expand Down Expand Up @@ -318,6 +302,49 @@ void Cell_Container::update_all_cells(double t, double phenotype_dt_ , double me
return;
}

void Cell_Container::update_all_cells_intracellular( void )
{
bool anything_to_update = false; // Use a simple boolean for reduction
std::vector<bool> ready_to_update_intracellular = std::vector<bool>( (*all_cells).size(), false );

#pragma omp parallel for reduction(||:anything_to_update)
for( int i=0; i < (*all_cells).size(); i++ )
{
if( (*all_cells)[i]->is_out_of_domain == false ) {
if( (*all_cells)[i]->phenotype.intracellular != NULL && (*all_cells)[i]->phenotype.intracellular->need_update())
{
ready_to_update_intracellular[i] = true;
anything_to_update = true; // Set to true if any cell needs an update
if ((*all_cells)[i]->functions.pre_update_intracellular != NULL)
{
(*all_cells)[i]->functions.pre_update_intracellular((*all_cells)[i], (*all_cells)[i]->phenotype, diffusion_dt);
}
}
}
}

if (!anything_to_update)
{ return; }

#pragma omp parallel for
for ( int i=0; i < (*all_cells).size(); i++ )
{
if (ready_to_update_intracellular[i])
{
(*all_cells)[i]->phenotype.intracellular->update((*all_cells)[i], (*all_cells)[i]->phenotype, diffusion_dt);
}
}

#pragma omp parallel for
for ( int i=0; i < (*all_cells).size(); i++ )
{
if (ready_to_update_intracellular[i] && (*all_cells)[i]->functions.post_update_intracellular != NULL)
{
(*all_cells)[i]->functions.post_update_intracellular((*all_cells)[i], (*all_cells)[i]->phenotype, diffusion_dt);
}
}
}

void Cell_Container::register_agent( Cell* agent )
{
agent_grid[agent->get_current_mechanics_voxel_index()].push_back(agent);
Expand Down
4 changes: 3 additions & 1 deletion core/PhysiCell_cell_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class Cell_Container : public BioFVM::Agent_Container
void update_all_cells(double t);
void update_all_cells(double t, double dt);
void update_all_cells(double t, double phenotype_dt, double mechanics_dt);
void update_all_cells(double t, double phenotype_dt, double mechanics_dt, double diffusion_dt );
void update_all_cells(double t, double phenotype_dt, double mechanics_dt, double diffusion_dt );

void update_all_cells_intracellular( void );

void register_agent( Cell* agent );
void add_agent_to_outer_voxel(Cell* agent);
Expand Down
Loading