Skip to content

Commit d3d5d92

Browse files
committed
check size of values in (un)fix dcs
1 parent 9cb3fd3 commit d3d5d92

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

BioFVM/BioFVM_microenvironment.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ void Microenvironment::fix_substrate_at_voxel( int substrate_index, int voxel_in
232232

233233
void Microenvironment::fix_substrates_at_voxel( int voxel_index , std::vector<double>& new_values )
234234
{
235+
if (new_values.size() != dirichlet_value_vectors[voxel_index].size())
236+
{
237+
std::cerr << "Error: Incorrect number of values passed in to fix_substrates_at_voxel. Expected " << dirichlet_value_vectors[voxel_index].size() << " values, but got " << new_values.size() << "." << std::endl;
238+
return;
239+
}
235240
dirichlet_value_vectors[voxel_index] = new_values;
236241
return fix_substrates_at_voxel( voxel_index );
237242
}
@@ -258,7 +263,7 @@ void Microenvironment::fix_substrate_at_voxels( int substrate_index, std::vector
258263
{
259264
if (new_values.size() != voxel_indices.size())
260265
{
261-
std::cerr << "Error: new_values size does not match voxel_indices size in Microenvironment::fix_substrate_at_voxels" << std::endl;
266+
std::cerr << "Error: new_values size (" << new_values.size() << ") does not match voxel_indices size (" << voxel_indices.size() << ") in Microenvironment::fix_substrate_at_voxels" << std::endl;
262267
return;
263268
}
264269
for( unsigned int i=0 ; i < voxel_indices.size() ; i++ )
@@ -730,7 +735,7 @@ int Microenvironment::find_existing_density_index( std::string name )
730735
int i = find_density_index( name );
731736
if( i != -1 )
732737
{ return i; }
733-
std::cout << "Error: density named " << name << " not found." << std::endl;
738+
std::cerr << "Error: density named " << name << " not found." << std::endl;
734739
exit(-1);
735740
}
736741

BioFVM/BioFVM_microenvironment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ class Microenvironment
241241
void fix_substrate_at_voxels( int substrate_index, std::vector<int>& voxel_indices, double new_value );
242242
void fix_substrate_at_voxels( int substrate_index, std::vector<int>& voxel_indices, std::vector<double>& new_values );
243243
void fix_substrate_at_voxels( int substrate_index, std::vector<int>& voxel_indices );
244-
void fix_substrates_at_voxel( int voxel_ind, std::vector<double>& new_values );
245-
void fix_substrates_at_voxel( int voxel_ind );
244+
void fix_substrates_at_voxel( int voxel_index, std::vector<double>& new_values );
245+
void fix_substrates_at_voxel( int voxel_index );
246246

247247
void unfix_substrate_at_voxel( std::string substrate, int voxel_index );
248248
void unfix_substrate_at_voxels( std::string substrate, std::vector<int>& voxel_indices );

0 commit comments

Comments
 (0)