PhysiCell icon indicating copy to clipboard operation
PhysiCell copied to clipboard

DC function standardization

Open drbergman opened this issue 1 year ago • 1 comments

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):

  • add_dirichlet_node does not update dirichlet_activation_vectors and thus cannot be used to start applying a DC
  • update_dirichlet_node( int voxel_index , int substrate_index , double new_value ) does do this but...
  • update_dirichlet_node( int voxel_index , std::vector<double>& new_value ) does not

drbergman avatar Feb 26 '24 19:02 drbergman

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.

rheiland avatar Feb 26 '24 20:02 rheiland