Skip to content

Commit 6cf4364

Browse files
authored
Merge pull request MathCancer#32 from MathCancer/development
Development
2 parents bccb5f8 + f7b0675 commit 6cf4364

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2181
-1878
lines changed

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Enable C++ support
2+
language: cpp
3+
4+
os: linux
5+
6+
# Compiler selection
7+
compiler:
8+
- g++
9+
10+
# Build steps
11+
script:
12+
- make
13+
- make reset
14+
- make biorobots-sample
15+
- make reset
16+
- make cancer-biorobots-sample
17+
- make reset
18+
- make cancer-immune-sample
19+
- make reset
20+
- make virus-macrophage-sample
21+
22+
notifications:
23+
email:
24+
recipients:
25+
26+
on_success: always # default: change (always, never)
27+
on_failure: always # default: always

BioFVM/BioFVM_microenvironment.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,29 @@ void Microenvironment::compute_all_gradient_vectors( void )
911911
{
912912
for( unsigned int j=0; j < mesh.y_coordinates.size() ; j++ )
913913
{
914+
// endcaps
915+
for( unsigned int q=0; q < number_of_densities() ; q++ )
916+
{
917+
int i = 0;
918+
int n = voxel_index(i,j,k);
919+
// x-derivative of qth substrate at voxel n
920+
gradient_vectors[n][q][0] = (*p_density_vectors)[n+thomas_i_jump][q];
921+
gradient_vectors[n][q][0] -= (*p_density_vectors)[n][q];
922+
gradient_vectors[n][q][0] /= mesh.dx;
923+
924+
gradient_vector_computed[n] = true;
925+
}
926+
for( unsigned int q=0; q < number_of_densities() ; q++ )
927+
{
928+
int i = mesh.x_coordinates.size()-1;
929+
int n = voxel_index(i,j,k);
930+
// x-derivative of qth substrate at voxel n
931+
gradient_vectors[n][q][0] = (*p_density_vectors)[n][q];
932+
gradient_vectors[n][q][0] -= (*p_density_vectors)[n-thomas_i_jump][q];
933+
gradient_vectors[n][q][0] /= mesh.dx;
934+
935+
gradient_vector_computed[n] = true;
936+
}
914937

915938
for( unsigned int i=1; i < mesh.x_coordinates.size()-1 ; i++ )
916939
{
@@ -934,6 +957,29 @@ void Microenvironment::compute_all_gradient_vectors( void )
934957
{
935958
for( unsigned int i=0; i < mesh.x_coordinates.size() ; i++ )
936959
{
960+
// endcaps
961+
for( unsigned int q=0; q < number_of_densities() ; q++ )
962+
{
963+
int j = 0;
964+
int n = voxel_index(i,j,k);
965+
// x-derivative of qth substrate at voxel n
966+
gradient_vectors[n][q][1] = (*p_density_vectors)[n+thomas_j_jump][q];
967+
gradient_vectors[n][q][1] -= (*p_density_vectors)[n][q];
968+
gradient_vectors[n][q][1] /= mesh.dy;
969+
970+
gradient_vector_computed[n] = true;
971+
}
972+
for( unsigned int q=0; q < number_of_densities() ; q++ )
973+
{
974+
int j = mesh.y_coordinates.size()-1;
975+
int n = voxel_index(i,j,k);
976+
// x-derivative of qth substrate at voxel n
977+
gradient_vectors[n][q][1] = (*p_density_vectors)[n][q];
978+
gradient_vectors[n][q][1] -= (*p_density_vectors)[n-thomas_j_jump][q];
979+
gradient_vectors[n][q][1] /= mesh.dy;
980+
981+
gradient_vector_computed[n] = true;
982+
}
937983

938984
for( unsigned int j=1; j < mesh.y_coordinates.size()-1 ; j++ )
939985
{
@@ -950,12 +996,39 @@ void Microenvironment::compute_all_gradient_vectors( void )
950996

951997
}
952998
}
999+
1000+
// don't bother computing z component if there is no z-directoin
1001+
if( mesh.z_coordinates.size() == 1 )
1002+
{ return; }
9531003

9541004
#pragma omp parallel for
9551005
for( unsigned int j=0; j < mesh.y_coordinates.size() ; j++ )
9561006
{
9571007
for( unsigned int i=0; i < mesh.x_coordinates.size() ; i++ )
9581008
{
1009+
// endcaps
1010+
for( unsigned int q=0; q < number_of_densities() ; q++ )
1011+
{
1012+
int k = 0;
1013+
int n = voxel_index(i,j,k);
1014+
// x-derivative of qth substrate at voxel n
1015+
gradient_vectors[n][q][2] = (*p_density_vectors)[n+thomas_k_jump][q];
1016+
gradient_vectors[n][q][2] -= (*p_density_vectors)[n][q];
1017+
gradient_vectors[n][q][2] /= mesh.dz;
1018+
1019+
gradient_vector_computed[n] = true;
1020+
}
1021+
for( unsigned int q=0; q < number_of_densities() ; q++ )
1022+
{
1023+
int k = mesh.z_coordinates.size()-1;
1024+
int n = voxel_index(i,j,k);
1025+
// x-derivative of qth substrate at voxel n
1026+
gradient_vectors[n][q][2] = (*p_density_vectors)[n][q];
1027+
gradient_vectors[n][q][2] -= (*p_density_vectors)[n-thomas_k_jump][q];
1028+
gradient_vectors[n][q][2] /= mesh.dz;
1029+
1030+
gradient_vector_computed[n] = true;
1031+
}
9591032

9601033
for( unsigned int k=1; k < mesh.z_coordinates.size()-1 ; k++ )
9611034
{
@@ -1006,6 +1079,10 @@ void Microenvironment::compute_gradient_vector( int n )
10061079
}
10071080
}
10081081

1082+
// don't bother computing y and z component if there is no y-direction. (1D)
1083+
if( mesh.y_coordinates.size() == 1 )
1084+
{ return; }
1085+
10091086
// d/dy
10101087
if( indices[1] > 0 && indices[1] < mesh.y_coordinates.size()-1 )
10111088
{
@@ -1018,6 +1095,10 @@ void Microenvironment::compute_gradient_vector( int n )
10181095
}
10191096
}
10201097

1098+
// don't bother computing z component if there is no z-direction (2D)
1099+
if( mesh.z_coordinates.size() == 1 )
1100+
{ return; }
1101+
10211102
// d/dz
10221103
if( indices[2] > 0 && indices[2] < mesh.z_coordinates.size()-1 )
10231104
{

BioFVM/BioFVM_solvers.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ void diffusion_decay_solver__constant_coefficients_explicit_uniform_mesh( Microe
8484
std::cout << std::endl << "Using solver: " << __FUNCTION__ << std::endl
8585
<< " (constant diffusion coefficient with explicit stepping, implicit decay, uniform mesh) ... " << std::endl << std::endl;
8686

87-
if( M.mesh.uniform_mesh == false )
88-
{ std::cout << "Error. This code is only supported for uniform meshes." << std::endl; }
87+
if( M.mesh.regular_mesh == false )
88+
{ std::cout << "Error. This code is only supported for regular meshes." << std::endl; }
8989

9090
precomputations_and_constants_done = true;
9191
}
@@ -95,9 +95,9 @@ void diffusion_decay_solver__constant_coefficients_explicit_uniform_mesh( Microe
9595

9696
void diffusion_decay_solver__constant_coefficients_LOD_3D( Microenvironment& M, double dt )
9797
{
98-
if( M.mesh.uniform_mesh == false || M.mesh.Cartesian_mesh == false )
98+
if( M.mesh.regular_mesh == false || M.mesh.Cartesian_mesh == false )
9999
{
100-
std::cout << "Error: This algorithm is written for uniform Cartesian meshes. Try: other solvers!" << std::endl << std::endl;
100+
std::cout << "Error: This algorithm is written for regular Cartesian meshes. Try: other solvers!" << std::endl << std::endl;
101101
return;
102102
}
103103

@@ -301,9 +301,9 @@ void diffusion_decay_solver__constant_coefficients_LOD_3D( Microenvironment& M,
301301

302302
void diffusion_decay_solver__constant_coefficients_LOD_2D( Microenvironment& M, double dt )
303303
{
304-
if( M.mesh.uniform_mesh == false )
304+
if( M.mesh.regular_mesh == false )
305305
{
306-
std::cout << "Error: This algorithm is written for uniform Cartesian meshes. Try: something else." << std::endl << std::endl;
306+
std::cout << "Error: This algorithm is written for regular Cartesian meshes. Try: something else." << std::endl << std::endl;
307307
return;
308308
}
309309

BioFVM/BioFVM_vector.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ std::vector<double> normalize( std::vector<double>& v )
199199

200200
for( unsigned int i=0; i < v.size(); i++ )
201201
{ output[i] /= norm ; }
202+
203+
// If the norm is small, normalizing doens't make sense.
204+
// Just set the entire vector to zero.
205+
static bool I_warned_you = false;
206+
if( norm <= 1e-16 )
207+
{
208+
if( I_warned_you == false )
209+
{
210+
std::cout << "Warning and FYI: Very small vector are normalized to 0 vector" << std::endl << std::endl;
211+
I_warned_you = true;
212+
}
213+
214+
for( unsigned int i=0; i < v.size(); i++ )
215+
{ output[i] = 0.0; }
216+
}
217+
202218
return output;
203219
}
204220

@@ -213,6 +229,22 @@ void normalize( std::vector<double>* v )
213229

214230
for( unsigned int i=0; i < v->size(); i++ )
215231
{ (*v)[i] /= norm ; }
232+
233+
// If the norm is small, normalizing doens't make sense.
234+
// Just set the entire vector to zero.
235+
static bool I_warned_you = false;
236+
if( norm <= 1e-16 )
237+
{
238+
if( I_warned_you == false )
239+
{
240+
std::cout << "Warning and FYI: Very small vectors are normalized to 0 vector" << std::endl << std::endl;
241+
I_warned_you = true;
242+
}
243+
244+
for( unsigned int i=0; i < v->size(); i++ )
245+
{ (*v)[i] = 0.0; }
246+
}
247+
216248
return;
217249
}
218250

CITATION.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
If you use PhysiCell in your project, please cite PhysiCell and the version
22
number, such as below:
33

4-
We implemented and solved the model using PhysiCell (Version 1.6.0) [1].
4+
We implemented and solved the model using PhysiCell (Version 1.6.1) [1].
55

66
[1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin,
77
PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu-
@@ -11,7 +11,7 @@ We implemented and solved the model using PhysiCell (Version 1.6.0) [1].
1111
Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM
1212
as below:
1313

14-
We implemented and solved the model using PhysiCell (Version 1.6.0) [1],
14+
We implemented and solved the model using PhysiCell (Version 1.6.1) [1],
1515
with BioFVM [2] to solve the transport equations.
1616

1717
[1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin,

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM
3838
BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o
3939

4040
PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \
41-
PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o
41+
PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o
4242

4343
PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \
4444
PhysiCell_pugixml.o PhysiCell_settings.o
@@ -61,6 +61,9 @@ all:
6161
make
6262

6363
# sample projects
64+
list-projects:
65+
@echo "Sample projects: template2D template3D biorobots-sample cancer-biorobots-sample heterogeneity-sample"
66+
@echo " cancer-immune-sample virus-macrophage-sample"
6467

6568
template2D:
6669
cp ./sample_projects/template2D/custom_modules/* ./custom_modules/
@@ -187,6 +190,9 @@ PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp
187190
PhysiCell_custom.o: ./core/PhysiCell_custom.cpp
188191
$(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp
189192

193+
PhysiCell_constants.o: ./core/PhysiCell_constants.cpp
194+
$(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp
195+
190196
# BioFVM core components (needed by PhysiCell)
191197

192198
BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp
@@ -264,6 +270,9 @@ data-cleanup:
264270
touch ./output/empty.txt
265271

266272
# archival
273+
274+
checkpoint:
275+
zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/*
267276

268277
zip:
269278
zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/*

0 commit comments

Comments
 (0)