Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VTK8 #69

Merged
merged 22 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
760aca8
#23 clarify pychaste vtk required components
kwabenantim Apr 23, 2024
00d2730
#23 relax cmake vtk parallel mpi constraint
kwabenantim May 8, 2024
c1d03fb
#23 update vtk6 config
kwabenantim May 10, 2024
2b13b5f
#23 update cmake find python vars
kwabenantim May 14, 2024
78a917a
Merge branch 'develop' into 23-support-vtk8
kwabenantim May 14, 2024
78181c2
Merge branch 'develop' into 23-support-vtk8
kwabenantim May 14, 2024
d6819e0
#23 switch vtk test workflow to micromamba
kwabenantim May 14, 2024
0d79111
#23 cache mamba workflow downloads
kwabenantim May 14, 2024
4589de3
#23 install conda packages to test-env
kwabenantim May 14, 2024
99cc4b4
#23 adding conda channels to vtk test
kwabenantim May 14, 2024
2ba2a52
#23 update vtk workflow spec syntax
kwabenantim May 14, 2024
7af7c7a
#23 cache vtk conda test env
kwabenantim May 14, 2024
da0ccce
#23 disable micromamba run shell
kwabenantim May 14, 2024
c15d8ff
#23 add fftw to vtk test dependencies
kwabenantim May 14, 2024
0c1d5f3
#23 fix conda cmake paths
kwabenantim May 14, 2024
4fe667d
#23 find python3 executable
kwabenantim May 14, 2024
6ec3ab4
#23 add matplotlib and numpy to tests
kwabenantim May 15, 2024
206820d
#23 render window before image filter
kwabenantim May 15, 2024
d4ebca6
#23 remove redundant header text
kwabenantim May 15, 2024
eb3de86
#23 update TestVtkSceneWithCaBased
kwabenantim May 15, 2024
d5fc9e7
#23 no renderer clear
kwabenantim May 16, 2024
579aea9
#23 update immersed boundary tutorial
kwabenantim May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 47 additions & 30 deletions .github/workflows/test-vtk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
matrix:
vtk-version: ["8.2", "9.2"]

defaults:
run:
shell: bash -el {0}

steps:
- name: checkout chaste
uses: actions/checkout@v4
Expand All @@ -39,34 +35,50 @@ jobs:
sudo apt-get update
sudo apt-get install -y cmake g++ xvfb

- name: setup conda
uses: conda-incubator/setup-miniconda@v3
- name: setup conda environment
uses: mamba-org/setup-micromamba@v1
with:
auto-update-conda: true
use-mamba: true
miniforge-variant: Mambaforge
miniforge-version: latest
channels: pychaste,conda-forge
micromamba-version: latest
generate-run-shell: false
init-shell: bash
condarc: |
channels:
- conda-forge
- pychaste
environment-name: test-env
create-args: >-
boost-cpp
fftw
hdf5=[build=*mpi_mpich*]
matplotlib
metis
mpich
notebook
numpy
parmetis
petsc
petsc4py
pip
setuptools
six
sundials
tbb-devel
vtk=${{ matrix.vtk-version }}
wheel
xerces-c
xsd
xvfbwrapper
xorg-libxext
cache-environment: true
post-cleanup: 'all'

- name: install pychaste conda dependencies
- name: fix cmake paths
run: |
mamba install -n test \
boost-cpp \
hdf5="*=*mpi_mpich*" \
metis \
mpich \
notebook \
parmetis \
petsc \
petsc4py \
six \
sundials \
vtk=${{ matrix.vtk-version }} \
tbb-devel \
xerces-c \
xsd \
xvfbwrapper \
xorg-libxext
find $CONDA_PREFIX \
-type f \
-name '*.cmake' \
-exec sed -i.bak 's|/usr/lib64/libXext.so|libXext.so|g' {} \;
shell: bash -el {0}

- name: make build directory
run: |
Expand All @@ -79,7 +91,7 @@ jobs:

cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPython3_EXECUTABLE=$(which python) \
-DPython3_EXECUTABLE=$(which python3) \
-DCMAKE_LIBRARY_PATH="${CONDA_PREFIX}/lib" \
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
-DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
Expand All @@ -92,25 +104,30 @@ jobs:
-DXSD_EXECUTABLE="${CONDA_PREFIX}/bin/xsd" \
../Chaste/
working-directory: build
shell: bash -el {0}

- name: build pychaste
run: |
cmake --build . --parallel $(nproc) --target project_PyChaste
working-directory: build
shell: bash -el {0}

- name: build pychaste python module
run: |
cmake --build . --parallel $(nproc) --target project_PyChaste_Python
working-directory: build
shell: bash -el {0}

- name: install pychaste
run: |
pip install .
working-directory: build/projects/PyChaste/python
shell: bash -el {0}

- name: run tests
run: |
xvfb-run \
--server-args="-screen 0 1024x768x24" \
ctest -j $(nproc) -L PyChaste --output-on-failure
working-directory: build
shell: bash -el {0}
27 changes: 22 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,29 @@ find_package(Chaste COMPONENTS cell_based)

# PyChaste needs some additional VTK libraries
if(VTK_MAJOR_VERSION LESS_EQUAL 6)
find_package(VTK COMPONENTS vtkWrappingPythonCore vtkIOImage vtkIOMovie vtkRenderingAnnotation vtkRenderingFreeType
vtkRenderingFreeTypeOpenGL vtkRenderingCore
vtkRenderingOpenGL vtkInteractionStyle REQUIRED)
find_package(VTK REQUIRED COMPONENTS
vtkInteractionStyle
vtkIOImage
vtkIOMovie
vtkRenderingAnnotation
vtkRenderingCore
vtkRenderingFreeType
vtkRenderingOpenGL
vtkWrappingPythonCore
)
else()
find_package(VTK COMPONENTS vtkWrappingPythonCore vtkParallelCore vtkParallelMPI vtkIOImage vtkIOMovie vtkRenderingAnnotation
vtkRenderingFreeType vtkRenderingOpenGL2 vtkRenderingCore vtkFiltersProgrammable vtkFiltersVerdict vtkInteractionStyle REQUIRED)
find_package(VTK REQUIRED COMPONENTS
vtkFiltersProgrammable
vtkFiltersVerdict
vtkInteractionStyle
vtkIOImage
vtkIOMovie
vtkRenderingAnnotation
vtkRenderingCore
vtkRenderingFreeType
vtkRenderingOpenGL2
vtkWrappingPythonCore
)
endif()

list(APPEND Chaste_INCLUDES ${VTK_INCLUDE_DIRS})
Expand Down
4 changes: 2 additions & 2 deletions WrapPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/pybind11/include)

add_subdirectory(dynamic/pybind11)
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${PYTHON3_INCLUDE_DIRS})

######### Build the Python modules ######################
set (PYCHASTE_PYTHON_AUTO_MODULES "")
Expand Down Expand Up @@ -124,7 +124,7 @@ foreach(val RANGE ${len2})
PREFIX "${PYTHON_MODULE_PREFIX}" SUFFIX ".so")
target_compile_features(_chaste_project_PyChaste_${python_module} PRIVATE cxx_range_for)
# order is important, pybind and python come first
target_link_libraries(_chaste_project_PyChaste_${python_module} pybind11::module ${PYTHON_LIBRARIES} ${Chaste_THIRD_PARTY_LIBRARIES} ${Chaste_LIBRARIES} ${PYCHASTE_SHARED_LIB})
target_link_libraries(_chaste_project_PyChaste_${python_module} pybind11::module ${PYTHON3_LIBRARIES} ${Chaste_THIRD_PARTY_LIBRARIES} ${Chaste_LIBRARIES} ${PYCHASTE_SHARED_LIB})
add_dependencies(_chaste_project_PyChaste_${python_module} chaste_project_PyChaste)
endforeach()

Expand Down
37 changes: 1 addition & 36 deletions src/visualization/CellPopulationPyChasteActorGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,6 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

/*

Copyright (c) 2005-2024, University of Oxford.
All rights reserved.

University of Oxford means the Chancellor, Masters and Scholars of the
University of Oxford, having an administrative office at Wellington
Square, Oxford OX1 2JD, UK.

This file is CellPopulation of Chaste.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the University of Oxford nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A CellPopulationICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <vtkPoints.h>
Expand Down Expand Up @@ -145,7 +110,7 @@ void CellPopulationPyChasteActorGenerator<DIM>::AddCaBasedCellPopulationActor(vt
vtkSmartPointer<vtkGeometryFilter> p_geom_filter = vtkSmartPointer<vtkGeometryFilter>::New();

boost::shared_ptr<CaBasedCellPopulation<DIM> > p_ca_population =
boost::dynamic_pointer_cast<CaBasedCellPopulation<DIM> >(mpCellPopulation);
boost::dynamic_pointer_cast<CaBasedCellPopulation<DIM> >(mpCellPopulation);

if(p_ca_population && mShowPottsMeshEdges)
{
Expand Down
9 changes: 5 additions & 4 deletions src/visualization/VtkScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <boost/lexical_cast.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <vtkWindowToImageFilter.h>
#include <vtkPNGWriter.h>
#include <vtkPoints.h>
Expand Down Expand Up @@ -115,14 +116,14 @@ VtkScene<DIM>::VtkScene()
mHasStarted(false),
mAddAnnotations(false),
mOutputFrequency(1),
mpCellPopulationGenerator(boost::shared_ptr<CellPopulationPyChasteActorGenerator<DIM> >(new CellPopulationPyChasteActorGenerator<DIM>()))
mpCellPopulationGenerator(boost::make_shared<CellPopulationPyChasteActorGenerator<DIM> >())
{
mpRenderer->SetBackground(1.0, 1.0, 1.0);
mpRenderWindow->AddRenderer(mpRenderer);
mpRenderWindow->SetSize(800.0, 600.0);
mpRenderWindowInteractor->SetRenderWindow(mpRenderWindow);

vtkSmartPointer<customMouseInteractorStyle> style = vtkSmartPointer<customMouseInteractorStyle>::New();
auto style = vtkSmartPointer<customMouseInteractorStyle>::New();
mpRenderWindowInteractor->SetInteractorStyle( style );
}

Expand Down Expand Up @@ -186,7 +187,6 @@ void VtkScene<DIM>::ResetRenderer(unsigned time_step)
{
mpRenderer->RemoveActor(p_actor);
}
mpRenderer->Clear();

if(mpCellPopulationGenerator)
{
Expand Down Expand Up @@ -269,9 +269,10 @@ void VtkScene<DIM>::Start()
mpRenderWindow->SetOffScreenRendering(1);
}

if(mSaveAsImages or mSaveAsAnimation)
if(mSaveAsImages || mSaveAsAnimation)
{
mpRenderWindow->SetOffScreenRendering(1);
mpRenderWindow->Render();
mWindowToImageFilter->SetInput(mpRenderWindow);
mWindowToImageFilter->Update();
}
Expand Down
11 changes: 9 additions & 2 deletions src/visualization/VtkScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vtkVersion.h>
#include <vtkOggTheoraWriter.h>
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkRenderingFreeType);
#if VTK_MAJOR_VERSION >= 6
# include <vtkAutoInit.h>
# if VTK_MAJOR_VERSION == 6
VTK_MODULE_INIT(vtkRenderingOpenGL);
# else
VTK_MODULE_INIT(vtkRenderingOpenGL2);
# endif
VTK_MODULE_INIT(vtkRenderingFreeType);
#endif
#include <vtkSmartPointer.h>
#include <vtkRenderer.h>
#include <vtkLookupTable.h>
Expand Down
25 changes: 6 additions & 19 deletions test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ def test_simple_immersed_boundary_simulation(self):

## Setup the simulation environment in the notebook

SetupNotebookTest()

## Set the start time for the simulation

SimulationTime.Instance().SetStartTime(0.0)
# JUPYTER_SETUP

## Next, we define the necessary geometry by generating a mesh to
## contain a single cell.
Expand Down Expand Up @@ -212,7 +208,7 @@ def test_simple_immersed_boundary_simulation(self):

## Reset the simulation environment in the notebook

TearDownNotebookTest()
# JUPYTER_TEARDOWN

## ### 2. Adding More Cells

Expand All @@ -222,11 +218,7 @@ def test_multicell_immersed_boundary_simulation(self):

## Setup the simulation environment in the notebook

SetupNotebookTest()

## Set the start time for the simulation

SimulationTime.Instance().SetStartTime(0.0)
# JUPYTER_SETUP

## We can use the mesh generator to generate multiple cells. The first
## parameter of the mesh generator constructor controls the number of
Expand Down Expand Up @@ -335,7 +327,7 @@ def test_multicell_immersed_boundary_simulation(self):

## Reset the simulation environment in the notebook

TearDownNotebookTest()
# JUPYTER_TEARDOWN

## ### 3. Adding Fluid Sources
## Now that we are familiar with how to generate the cells, we will
Expand All @@ -347,11 +339,7 @@ def test_fluid_source_immersed_boundary_simulation(self):

## Setup the simulation environment in the notebook

SetupNotebookTest()

## Set the start time for the simulation

SimulationTime.Instance().SetStartTime(0.0)
# JUPYTER_SETUP

## We begin by constructing a fluid source object:

Expand Down Expand Up @@ -457,8 +445,7 @@ def test_fluid_source_immersed_boundary_simulation(self):
nb_manager.vtk_show(scene, height=300)

## Reset the simulation environment in the notebook

TearDownNotebookTest()
# JUPYTER_TEARDOWN

## #### Further Exercises
## * Try integrating a different cell cycle model to introduce cell
Expand Down
Loading
Loading