Skip to content

Commit 98e266d

Browse files
authored
Merge pull request #69 from Chaste/23-support-vtk8
Support VTK8
2 parents 0fea8c3 + 579aea9 commit 98e266d

File tree

8 files changed

+104
-110
lines changed

8 files changed

+104
-110
lines changed

.github/workflows/test-vtk.yml

+47-30
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ jobs:
1515
matrix:
1616
vtk-version: ["8.2", "9.2"]
1717

18-
defaults:
19-
run:
20-
shell: bash -el {0}
21-
2218
steps:
2319
- name: checkout chaste
2420
uses: actions/checkout@v4
@@ -39,34 +35,50 @@ jobs:
3935
sudo apt-get update
4036
sudo apt-get install -y cmake g++ xvfb
4137
42-
- name: setup conda
43-
uses: conda-incubator/setup-miniconda@v3
38+
- name: setup conda environment
39+
uses: mamba-org/setup-micromamba@v1
4440
with:
45-
auto-update-conda: true
46-
use-mamba: true
47-
miniforge-variant: Mambaforge
48-
miniforge-version: latest
49-
channels: pychaste,conda-forge
41+
micromamba-version: latest
42+
generate-run-shell: false
43+
init-shell: bash
44+
condarc: |
45+
channels:
46+
- conda-forge
47+
- pychaste
48+
environment-name: test-env
49+
create-args: >-
50+
boost-cpp
51+
fftw
52+
hdf5=[build=*mpi_mpich*]
53+
matplotlib
54+
metis
55+
mpich
56+
notebook
57+
numpy
58+
parmetis
59+
petsc
60+
petsc4py
61+
pip
62+
setuptools
63+
six
64+
sundials
65+
tbb-devel
66+
vtk=${{ matrix.vtk-version }}
67+
wheel
68+
xerces-c
69+
xsd
70+
xvfbwrapper
71+
xorg-libxext
72+
cache-environment: true
73+
post-cleanup: 'all'
5074

51-
- name: install pychaste conda dependencies
75+
- name: fix cmake paths
5276
run: |
53-
mamba install -n test \
54-
boost-cpp \
55-
hdf5="*=*mpi_mpich*" \
56-
metis \
57-
mpich \
58-
notebook \
59-
parmetis \
60-
petsc \
61-
petsc4py \
62-
six \
63-
sundials \
64-
vtk=${{ matrix.vtk-version }} \
65-
tbb-devel \
66-
xerces-c \
67-
xsd \
68-
xvfbwrapper \
69-
xorg-libxext
77+
find $CONDA_PREFIX \
78+
-type f \
79+
-name '*.cmake' \
80+
-exec sed -i.bak 's|/usr/lib64/libXext.so|libXext.so|g' {} \;
81+
shell: bash -el {0}
7082

7183
- name: make build directory
7284
run: |
@@ -79,7 +91,7 @@ jobs:
7991
8092
cmake \
8193
-DCMAKE_BUILD_TYPE=Release \
82-
-DPython3_EXECUTABLE=$(which python) \
94+
-DPython3_EXECUTABLE=$(which python3) \
8395
-DCMAKE_LIBRARY_PATH="${CONDA_PREFIX}/lib" \
8496
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
8597
-DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
@@ -92,25 +104,30 @@ jobs:
92104
-DXSD_EXECUTABLE="${CONDA_PREFIX}/bin/xsd" \
93105
../Chaste/
94106
working-directory: build
107+
shell: bash -el {0}
95108

96109
- name: build pychaste
97110
run: |
98111
cmake --build . --parallel $(nproc) --target project_PyChaste
99112
working-directory: build
113+
shell: bash -el {0}
100114

101115
- name: build pychaste python module
102116
run: |
103117
cmake --build . --parallel $(nproc) --target project_PyChaste_Python
104118
working-directory: build
119+
shell: bash -el {0}
105120

106121
- name: install pychaste
107122
run: |
108123
pip install .
109124
working-directory: build/projects/PyChaste/python
125+
shell: bash -el {0}
110126

111127
- name: run tests
112128
run: |
113129
xvfb-run \
114130
--server-args="-screen 0 1024x768x24" \
115131
ctest -j $(nproc) -L PyChaste --output-on-failure
116132
working-directory: build
133+
shell: bash -el {0}

CMakeLists.txt

+22-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,29 @@ find_package(Chaste COMPONENTS cell_based)
3434

3535
# PyChaste needs some additional VTK libraries
3636
if(VTK_MAJOR_VERSION LESS_EQUAL 6)
37-
find_package(VTK COMPONENTS vtkWrappingPythonCore vtkIOImage vtkIOMovie vtkRenderingAnnotation vtkRenderingFreeType
38-
vtkRenderingFreeTypeOpenGL vtkRenderingCore
39-
vtkRenderingOpenGL vtkInteractionStyle REQUIRED)
37+
find_package(VTK REQUIRED COMPONENTS
38+
vtkInteractionStyle
39+
vtkIOImage
40+
vtkIOMovie
41+
vtkRenderingAnnotation
42+
vtkRenderingCore
43+
vtkRenderingFreeType
44+
vtkRenderingOpenGL
45+
vtkWrappingPythonCore
46+
)
4047
else()
41-
find_package(VTK COMPONENTS vtkWrappingPythonCore vtkParallelCore vtkParallelMPI vtkIOImage vtkIOMovie vtkRenderingAnnotation
42-
vtkRenderingFreeType vtkRenderingOpenGL2 vtkRenderingCore vtkFiltersProgrammable vtkFiltersVerdict vtkInteractionStyle REQUIRED)
48+
find_package(VTK REQUIRED COMPONENTS
49+
vtkFiltersProgrammable
50+
vtkFiltersVerdict
51+
vtkInteractionStyle
52+
vtkIOImage
53+
vtkIOMovie
54+
vtkRenderingAnnotation
55+
vtkRenderingCore
56+
vtkRenderingFreeType
57+
vtkRenderingOpenGL2
58+
vtkWrappingPythonCore
59+
)
4360
endif()
4461

4562
list(APPEND Chaste_INCLUDES ${VTK_INCLUDE_DIRS})

WrapPython.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ endif()
6060
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/pybind11/include)
6161

6262
add_subdirectory(dynamic/pybind11)
63-
include_directories(${PYTHON_INCLUDE_DIRS})
63+
include_directories(${PYTHON3_INCLUDE_DIRS})
6464

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

src/visualization/CellPopulationPyChasteActorGenerator.cpp

+1-36
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,6 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
3434
*/
3535

36-
/*
37-
38-
Copyright (c) 2005-2024, University of Oxford.
39-
All rights reserved.
40-
41-
University of Oxford means the Chancellor, Masters and Scholars of the
42-
University of Oxford, having an administrative office at Wellington
43-
Square, Oxford OX1 2JD, UK.
44-
45-
This file is CellPopulation of Chaste.
46-
47-
Redistribution and use in source and binary forms, with or without
48-
modification, are permitted provided that the following conditions are met:
49-
* Redistributions of source code must retain the above copyright notice,
50-
this list of conditions and the following disclaimer.
51-
* Redistributions in binary form must reproduce the above copyright notice,
52-
this list of conditions and the following disclaimer in the documentation
53-
and/or other materials provided with the distribution.
54-
* Neither the name of the University of Oxford nor the names of its
55-
contributors may be used to endorse or promote products derived from this
56-
software without specific prior written permission.
57-
58-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
59-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A CellPopulationICULAR PURPOSE
61-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
62-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
64-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
67-
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68-
69-
*/
70-
7136
#include <algorithm>
7237
#include <boost/lexical_cast.hpp>
7338
#include <vtkPoints.h>
@@ -145,7 +110,7 @@ void CellPopulationPyChasteActorGenerator<DIM>::AddCaBasedCellPopulationActor(vt
145110
vtkSmartPointer<vtkGeometryFilter> p_geom_filter = vtkSmartPointer<vtkGeometryFilter>::New();
146111

147112
boost::shared_ptr<CaBasedCellPopulation<DIM> > p_ca_population =
148-
boost::dynamic_pointer_cast<CaBasedCellPopulation<DIM> >(mpCellPopulation);
113+
boost::dynamic_pointer_cast<CaBasedCellPopulation<DIM> >(mpCellPopulation);
149114

150115
if(p_ca_population && mShowPottsMeshEdges)
151116
{

src/visualization/VtkScene.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
*/
3535

3636
#include <boost/lexical_cast.hpp>
37+
#include <boost/smart_ptr/make_shared.hpp>
3738
#include <vtkWindowToImageFilter.h>
3839
#include <vtkPNGWriter.h>
3940
#include <vtkPoints.h>
@@ -115,14 +116,14 @@ VtkScene<DIM>::VtkScene()
115116
mHasStarted(false),
116117
mAddAnnotations(false),
117118
mOutputFrequency(1),
118-
mpCellPopulationGenerator(boost::shared_ptr<CellPopulationPyChasteActorGenerator<DIM> >(new CellPopulationPyChasteActorGenerator<DIM>()))
119+
mpCellPopulationGenerator(boost::make_shared<CellPopulationPyChasteActorGenerator<DIM> >())
119120
{
120121
mpRenderer->SetBackground(1.0, 1.0, 1.0);
121122
mpRenderWindow->AddRenderer(mpRenderer);
122123
mpRenderWindow->SetSize(800.0, 600.0);
123124
mpRenderWindowInteractor->SetRenderWindow(mpRenderWindow);
124125

125-
vtkSmartPointer<customMouseInteractorStyle> style = vtkSmartPointer<customMouseInteractorStyle>::New();
126+
auto style = vtkSmartPointer<customMouseInteractorStyle>::New();
126127
mpRenderWindowInteractor->SetInteractorStyle( style );
127128
}
128129

@@ -186,7 +187,6 @@ void VtkScene<DIM>::ResetRenderer(unsigned time_step)
186187
{
187188
mpRenderer->RemoveActor(p_actor);
188189
}
189-
mpRenderer->Clear();
190190

191191
if(mpCellPopulationGenerator)
192192
{
@@ -269,9 +269,10 @@ void VtkScene<DIM>::Start()
269269
mpRenderWindow->SetOffScreenRendering(1);
270270
}
271271

272-
if(mSaveAsImages or mSaveAsAnimation)
272+
if(mSaveAsImages || mSaveAsAnimation)
273273
{
274274
mpRenderWindow->SetOffScreenRendering(1);
275+
mpRenderWindow->Render();
275276
mWindowToImageFilter->SetInput(mpRenderWindow);
276277
mWindowToImageFilter->Update();
277278
}

src/visualization/VtkScene.hpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4141
#include <vtkVersion.h>
4242
#include <vtkOggTheoraWriter.h>
4343
#include <vtkAutoInit.h>
44-
VTK_MODULE_INIT(vtkRenderingOpenGL2);
45-
VTK_MODULE_INIT(vtkRenderingFreeType);
44+
#if VTK_MAJOR_VERSION >= 6
45+
# include <vtkAutoInit.h>
46+
# if VTK_MAJOR_VERSION == 6
47+
VTK_MODULE_INIT(vtkRenderingOpenGL);
48+
# else
49+
VTK_MODULE_INIT(vtkRenderingOpenGL2);
50+
# endif
51+
VTK_MODULE_INIT(vtkRenderingFreeType);
52+
#endif
4653
#include <vtkSmartPointer.h>
4754
#include <vtkRenderer.h>
4855
#include <vtkLookupTable.h>

test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ def test_simple_immersed_boundary_simulation(self):
9999

100100
## Setup the simulation environment in the notebook
101101

102-
SetupNotebookTest()
103-
104-
## Set the start time for the simulation
105-
106-
SimulationTime.Instance().SetStartTime(0.0)
102+
# JUPYTER_SETUP
107103

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

213209
## Reset the simulation environment in the notebook
214210

215-
TearDownNotebookTest()
211+
# JUPYTER_TEARDOWN
216212

217213
## ### 2. Adding More Cells
218214

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

223219
## Setup the simulation environment in the notebook
224220

225-
SetupNotebookTest()
226-
227-
## Set the start time for the simulation
228-
229-
SimulationTime.Instance().SetStartTime(0.0)
221+
# JUPYTER_SETUP
230222

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

336328
## Reset the simulation environment in the notebook
337329

338-
TearDownNotebookTest()
330+
# JUPYTER_TEARDOWN
339331

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

348340
## Setup the simulation environment in the notebook
349341

350-
SetupNotebookTest()
351-
352-
## Set the start time for the simulation
353-
354-
SimulationTime.Instance().SetStartTime(0.0)
342+
# JUPYTER_SETUP
355343

356344
## We begin by constructing a fluid source object:
357345

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

459447
## Reset the simulation environment in the notebook
460-
461-
TearDownNotebookTest()
448+
# JUPYTER_TEARDOWN
462449

463450
## #### Further Exercises
464451
## * Try integrating a different cell cycle model to introduce cell

0 commit comments

Comments
 (0)