MathCancer / PhysiCell

PhysiCell: Scientist end users should use latest release! Developers please fork the development branch and submit PRs to the dev branch. Thanks!
http://PhysiCell.org
130 stars 90 forks source link

DC function standardization #214

Open drbergman opened 4 months ago

drbergman commented 4 months ago

There are many functions provided in BioFVM_microenvironment.cpp designed for implementing Dirichlet conditions (DCs). However, there is inconsistency across what they do and the naming conventions shed little light on what their under-the-hood differences are. Case in point (and maybe even the whole enchilada):

rheiland commented 4 months ago

This goes back to https://github.com/MathCancer/PhysiCell/issues/124 and my refactor of BioFVM_microenvironment.{h/cpp} to fix the DC bug that you had reported then. However, my refactoring did not include making any changes to the two flavors of update_dirichlet_node (one for a scalar and one for a vector), i.e., this from 1.11.0 is the same as the current 1.13.1 version:

void Microenvironment::update_dirichlet_node( int voxel_index , std::vector<double>& new_value )
{
    mesh.voxels[voxel_index].is_Dirichlet = true; 
    dirichlet_value_vectors[voxel_index] = new_value; 

    return; 
}

void Microenvironment::update_dirichlet_node( int voxel_index , int substrate_index , double new_value )
{
    mesh.voxels[voxel_index].is_Dirichlet = true; 
    dirichlet_value_vectors[voxel_index][substrate_index] = new_value; 

    dirichlet_activation_vectors[voxel_index][substrate_index] = true; 

    return; 
}

We need to clearly define and document what updating an entire vector of DCs even means. Does "update" imply they will also always be activated, i.e., set true, or does it mean the values will be updated but not necessarily their activation? I remember spending a LOT of time on the bug fix earlier and just want to make sure we're in agreement on what to do now.

Fwiw, here's a comment from the User Guide (which is somewhat deprecated of course):

Note that turning on or off a Dirichlet condition for a substrate applies it at all Dirichlet nodes for which
is_dirichlet_node(int voxel_index) is true.