Skip to content

Commit

Permalink
Merge pull request MathCancer#122 from rheiland/development
Browse files Browse the repository at this point in the history
fix fwrite of orientation vec
  • Loading branch information
MathCancer authored Mar 17, 2023
2 parents ef881df + e3558e4 commit 814cc85
Show file tree
Hide file tree
Showing 7 changed files with 1,117 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/PhysiCell_cell_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ void Cell_Container::add_agent_to_outer_voxel(Cell* agent)

void Cell_Container::remove_agent_from_voxel(Cell* agent, int voxel_index)
{
if (voxel_index < 0)
{
return;
}
int delete_index = 0;
while( agent_grid[voxel_index][ delete_index ] != agent )
{
Expand Down
2 changes: 1 addition & 1 deletion modules/PhysiCell_MultiCellDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std::
// name = "calcified_fraction";
std::fwrite( &( pCell->phenotype.volume.calcified_fraction ) , sizeof(double) , 1 , fp );
// name = "orientation";
std::fwrite( &( pCell->state.orientation ) , sizeof(double) , 3 , fp );
std::fwrite( pCell->state.orientation.data() , sizeof(double) , 3 , fp );
// name = "polarity";
std::fwrite( &( pCell->phenotype.geometry.polarity ) , sizeof(double) , 1 , fp );

Expand Down
309 changes: 309 additions & 0 deletions unit_tests/custom_voxel_values/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
VERSION := $(shell grep . VERSION.txt | cut -f1 -d:)
PROGRAM_NAME := test_voxel_values

CC := g++
# CC := g++-mp-7 # typical macports compiler name
# CC := g++-7 # typical homebrew compiler name

# Check for environment definitions of compiler
# e.g., on CC = g++-7 on OSX
ifdef PHYSICELL_CPP
CC := $(PHYSICELL_CPP)
endif

ARCH := native # best auto-tuning
# ARCH := core2 # a reasonably safe default for most CPUs since 2007
# ARCH := corei7
# ARCH := corei7-avx # earlier i7
# ARCH := core-avx-i # i7 ivy bridge or newer
# ARCH := core-avx2 # i7 with Haswell or newer
# ARCH := nehalem
# ARCH := westmere
# ARCH := sandybridge # circa 2011
# ARCH := ivybridge # circa 2012
# ARCH := haswell # circa 2013
# ARCH := broadwell # circa 2014
# ARCH := skylake # circa 2015
# ARCH := bonnell
# ARCH := silvermont
# ARCH := skylake-avx512
# ARCH := nocona #64-bit pentium 4 or later

# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11
CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11

ifeq ($(OS),Windows_NT)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
UNAME_P := $(shell uname -p)
var := $(shell which $(CC) | xargs file)
ifeq ($(lastword $(var)),arm64)
CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11
endif
endif
endif

COMPILE_COMMAND := $(CC) $(CFLAGS)

BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \
BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o

PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \
PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \
PhysiCell_signal_behavior.o

PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \
PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o

# put your custom objects here (they should be in the custom_modules directory)

PhysiCell_custom_module_OBJECTS := custom.o

pugixml_OBJECTS := pugixml.o

PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS)
ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS)

# compile the project

all: main.cpp $(ALL_OBJECTS)
$(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp
make name

name:
@echo ""
@echo "Executable name is" $(PROGRAM_NAME)
@echo ""

# PhysiCell core components

PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp

PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp

PhysiCell_cell.o: ./core/PhysiCell_cell.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp

PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp

PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp

PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp

PhysiCell_custom.o: ./core/PhysiCell_custom.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp

PhysiCell_constants.o: ./core/PhysiCell_constants.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp

PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp

# BioFVM core components (needed by PhysiCell)

BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp

BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp

BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp

BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp

BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp

BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp

BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp

BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp

BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp
$(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp

pugixml.o: ./BioFVM/pugixml.cpp
$(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp

# standard PhysiCell modules

PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp

PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp

PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp

PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp

PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp

PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp

PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp
$(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp

PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp
$(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp

# user-defined PhysiCell modules

custom.o: ./custom_modules/custom.cpp
$(COMPILE_COMMAND) -c ./custom_modules/custom.cpp

# cleanup

reset:
rm -f *.cpp
cp ./sample_projects/Makefile-default Makefile
rm -f ./custom_modules/*
touch ./custom_modules/empty.txt
touch ALL_CITATIONS.txt
touch ./core/PhysiCell_cell.cpp
rm ALL_CITATIONS.txt
cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml
touch ./config/empty.csv
rm -f ./config/*.csv

clean:
rm -f *.o
rm -f $(PROGRAM_NAME)*

data-cleanup:
rm -rf ./output
mkdir ./output
touch ./output/empty.txt

# archival

checkpoint:
zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/*

zip:
zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/*
cp latest.zip $$(date +%b_%d_%Y_%H%M).zip
cp latest.zip VERSION_$(VERSION).zip
mv *.zip archives/

tar:
tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/*
cp latest.tar $$(date +%b_%d_%Y_%H%M).tar
cp latest.tar VERSION_$(VERSION).tar
mv *.tar archives/

unzip:
cp ./archives/latest.zip .
unzip latest.zip

untar:
cp ./archives/latest.tar .
tar -xzf latest.tar

# easier animation

FRAMERATE := 24
OUTPUT := output

jpeg:
@magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt
@magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt
@expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt
@expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt
@echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt
@magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg
rm -f __H*.txt __W*.txt __resize.txt

gif:
magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif

movie:
ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4

# upgrade rules

SOURCE := PhysiCell_upgrade.zip
get-upgrade:
@echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt
@echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt
rm -f VER.txt
$$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip)
rm -f DL_FILE.txt

PhysiCell_upgrade.zip:
make get-upgrade

upgrade: $(SOURCE)
unzip $(SOURCE) PhysiCell/VERSION.txt
mv -f PhysiCell/VERSION.txt .
unzip $(SOURCE) PhysiCell/core/*
cp -r PhysiCell/core/* core
unzip $(SOURCE) PhysiCell/modules/*
cp -r PhysiCell/modules/* modules
unzip $(SOURCE) PhysiCell/sample_projects/*
cp -r PhysiCell/sample_projects/* sample_projects
unzip $(SOURCE) PhysiCell/BioFVM/*
cp -r PhysiCell/BioFVM/* BioFVM
unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf
mv -f PhysiCell/documentation/User_Guide.pdf documentation
rm -f -r PhysiCell
rm -f $(SOURCE)

#===================================================================
#------------- 1.10.5 addition to save user projects --------------
# useage: make save PROJ=your_project_name
PROJ := my_project
save:
echo "Saving project as $(PROJ) ... "
mkdir -p ./user_projects
mkdir -p ./user_projects/$(PROJ)
mkdir -p ./user_projects/$(PROJ)/custom_modules
mkdir -p ./user_projects/$(PROJ)/config
cp main.cpp ./user_projects/$(PROJ)
cp Makefile ./user_projects/$(PROJ)
cp VERSION.txt ./user_projects/$(PROJ)
cp ./config/* ./user_projects/$(PROJ)/config
cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules

# useage: make load PROJ=your_project_name
load:
echo "Loading project from $(PROJ) ... "
cp ./user_projects/$(PROJ)/main.cpp .
cp ./user_projects/$(PROJ)/Makefile .
cp ./user_projects/$(PROJ)/config/* ./config/
cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/

# useage: make share PROJ=your_project_name
share:
@echo "Preparing your project for sharing from $(PROJ) ... "
@echo " "
zip -r $(PROJ)_$$(date +%b_%d_%Y_%H%M).zip ./user_projects/$(PROJ)/*
@echo "Project saved in $(PROJ)_$$(date +%b_%d_%Y_%H%M).zip."
@echo "It can be unzipped (or use tar -xvf) in a PhysiCell root directory."
@echo " "

# sci_package: make sci_package PROJ=your_project_name
sci_package:
@echo "Preparing your project for scientific archival from $(PROJ) ... "
@echo " "
touch output/empty.txt
zip -r $(PROJ)_packaged_$$(date +%b_%d_%Y_%H%M).zip main.cpp Makefile ./config/* ./BioFVM/* VERSION.txt ./custom_modules/* ./core/* ./addons/* ./licenses/* ./modules/* ./output/empty.txt
@echo "Project saved in $(PROJ)_packaged_$$(date +%b_%d_%Y_%H%M).zip."
@echo "It is fully self-contained and can be distributed as a separate GitHub repository."
@echo " "
Loading

0 comments on commit 814cc85

Please sign in to comment.