Skip to content

Commit

Permalink
Microenvironment::update_density and Parameters<T>::update_parameter …
Browse files Browse the repository at this point in the history
…through an error, if one tries to update a density or parameter that not already exists.
  • Loading branch information
elmbeech committed Sep 25, 2024
1 parent 47c3cc3 commit 252f029
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions BioFVM/BioFVM_microenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ void Microenvironment::update_density( std::string name , std::string units )
int density_index = find_density_index( name );
if ( density_index == -1 )
{
// add density
return Microenvironment::add_density( name , units );
std::cout << "Error: density named " << name << " does not exist. Cannot update density!" << std::endl;
exit(-1);
}

// update units
Expand All @@ -583,8 +583,8 @@ void Microenvironment::update_density( std::string name , std::string units, dou
int density_index = find_density_index( name );
if ( density_index == -1 )
{
// add density
return Microenvironment::add_density( name , units, diffusion_constant, decay_rate );
std::cout << "Error: density named " << name << " does not exist. Cannot update density!" << std::endl;
exit(-1);
}

// update units
Expand Down
12 changes: 6 additions & 6 deletions modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ void Parameters<T>::update_parameter( std::string my_name , T my_value )
auto it = name_to_index_map.find(my_name);

if (it == name_to_index_map.end()) {
// generate new variable
return Parameters::add_parameter(my_name, my_value);
std::cout << "Error: parameter named " << my_name << " does not exist. Cannot update the parameter!" << std::endl;
exit(-1);
}

// change value
Expand All @@ -550,8 +550,8 @@ void Parameters<T>::update_parameter( std::string my_name , T my_value , std::st
auto it = name_to_index_map.find(my_name);

if (it == name_to_index_map.end()) {
// generate new variable
return Parameters::add_parameter(my_name, my_value, my_units);
std::cout << "Error: parameter named " << my_name << " does not exist. Cannot update the parameter!" << std::endl;
exit(-1);
}

// change value and unit
Expand All @@ -570,8 +570,8 @@ void Parameters<T>::update_parameter( Parameter<T> param )
auto it = name_to_index_map.find(param.name);

if (it == name_to_index_map.end()) {
// generate new variable
return Parameters::add_parameter(param);
std::cout << "Error: parameter named " << my_name << " does not exist. Cannot update the parameter!" << std::endl;
exit(-1);
}

// change value and unit
Expand Down

0 comments on commit 252f029

Please sign in to comment.