diff --git a/.github/workflows/test-vtk.yml b/.github/workflows/test-vtk.yml index e710f092..6b6e0b40 100644 --- a/.github/workflows/test-vtk.yml +++ b/.github/workflows/test-vtk.yml @@ -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 @@ -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: | @@ -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}" \ @@ -92,21 +104,25 @@ 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: | @@ -114,3 +130,4 @@ jobs: --server-args="-screen 0 1024x768x24" \ ctest -j $(nproc) -L PyChaste --output-on-failure working-directory: build + shell: bash -el {0} diff --git a/CMakeLists.txt b/CMakeLists.txt index e58e6191..5b58848c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/WrapPython.cmake b/WrapPython.cmake index ae8c70ea..376976e6 100644 --- a/WrapPython.cmake +++ b/WrapPython.cmake @@ -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 "") @@ -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() diff --git a/src/visualization/CellPopulationPyChasteActorGenerator.cpp b/src/visualization/CellPopulationPyChasteActorGenerator.cpp index acebae1c..94d8cd0b 100644 --- a/src/visualization/CellPopulationPyChasteActorGenerator.cpp +++ b/src/visualization/CellPopulationPyChasteActorGenerator.cpp @@ -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 #include #include @@ -145,7 +110,7 @@ void CellPopulationPyChasteActorGenerator::AddCaBasedCellPopulationActor(vt vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); boost::shared_ptr > p_ca_population = - boost::dynamic_pointer_cast >(mpCellPopulation); + boost::dynamic_pointer_cast >(mpCellPopulation); if(p_ca_population && mShowPottsMeshEdges) { diff --git a/src/visualization/VtkScene.cpp b/src/visualization/VtkScene.cpp index 478a9c52..2ea30cb7 100644 --- a/src/visualization/VtkScene.cpp +++ b/src/visualization/VtkScene.cpp @@ -34,6 +34,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include +#include #include #include #include @@ -115,14 +116,14 @@ VtkScene::VtkScene() mHasStarted(false), mAddAnnotations(false), mOutputFrequency(1), - mpCellPopulationGenerator(boost::shared_ptr >(new CellPopulationPyChasteActorGenerator())) + mpCellPopulationGenerator(boost::make_shared >()) { mpRenderer->SetBackground(1.0, 1.0, 1.0); mpRenderWindow->AddRenderer(mpRenderer); mpRenderWindow->SetSize(800.0, 600.0); mpRenderWindowInteractor->SetRenderWindow(mpRenderWindow); - vtkSmartPointer style = vtkSmartPointer::New(); + auto style = vtkSmartPointer::New(); mpRenderWindowInteractor->SetInteractorStyle( style ); } @@ -186,7 +187,6 @@ void VtkScene::ResetRenderer(unsigned time_step) { mpRenderer->RemoveActor(p_actor); } - mpRenderer->Clear(); if(mpCellPopulationGenerator) { @@ -269,9 +269,10 @@ void VtkScene::Start() mpRenderWindow->SetOffScreenRendering(1); } - if(mSaveAsImages or mSaveAsAnimation) + if(mSaveAsImages || mSaveAsAnimation) { mpRenderWindow->SetOffScreenRendering(1); + mpRenderWindow->Render(); mWindowToImageFilter->SetInput(mpRenderWindow); mWindowToImageFilter->Update(); } diff --git a/src/visualization/VtkScene.hpp b/src/visualization/VtkScene.hpp index 82d64eaa..bb71c9ab 100644 --- a/src/visualization/VtkScene.hpp +++ b/src/visualization/VtkScene.hpp @@ -41,8 +41,15 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -VTK_MODULE_INIT(vtkRenderingOpenGL2); -VTK_MODULE_INIT(vtkRenderingFreeType); +#if VTK_MAJOR_VERSION >= 6 +# include +# if VTK_MAJOR_VERSION == 6 + VTK_MODULE_INIT(vtkRenderingOpenGL); +# else + VTK_MODULE_INIT(vtkRenderingOpenGL2); +# endif + VTK_MODULE_INIT(vtkRenderingFreeType); +#endif #include #include #include diff --git a/test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py b/test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py index 0469e81a..3a29b05b 100644 --- a/test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py +++ b/test/python/cell_based/tutorials/TestImmersedBoundaryTutorial.py @@ -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. @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/test/visualization/TestVtkSceneWithCaBased.hpp b/test/visualization/TestVtkSceneWithCaBased.hpp index c10b79dc..31ee878c 100644 --- a/test/visualization/TestVtkSceneWithCaBased.hpp +++ b/test/visualization/TestVtkSceneWithCaBased.hpp @@ -33,8 +33,8 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TESTVTKSCENEWITHCABASEDPOPULATION_HPP_ -#define TESTVTKSCENEWITHCABASEDPOPULATION_HPP_ +#ifndef TEST_VTK_SCENE_WITH_CA_BASED_HPP_ +#define TEST_VTK_SCENE_WITH_CA_BASED_HPP_ #include #include "CheckpointArchiveTypes.hpp" @@ -77,7 +77,7 @@ class TestVtkSceneWithCaBasedPopulation : public AbstractCellBasedTestSuite void Test2dCaBasedPopulation() { - OutputFileHandler file_handler1 = OutputFileHandler("TestVtkSceneWithCaBasedPopulation/2d"); + OutputFileHandler file_handler = OutputFileHandler("TestVtkSceneWithCaBasedPopulation/2d"); PottsMeshGenerator<2> generator(10, 0, 0, 10, 0, 0); boost::shared_ptr > p_mesh = generator.GetMesh(); @@ -94,16 +94,15 @@ class TestVtkSceneWithCaBasedPopulation : public AbstractCellBasedTestSuite cells_generator.GenerateBasic(cells, location_indices.size()); // Create cell population - boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new CaBasedCellPopulation<2> (*p_mesh, cells, location_indices)); + auto p_cell_population = boost::make_shared >(*p_mesh, cells, location_indices); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<2>); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetSaveAsImages(true); - p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); + p_scene->SetOutputFilePath(file_handler.GetOutputDirectoryFullPath()+"/cell_population"); p_scene->GetCellPopulationActorGenerator()->SetShowPottsMeshEdges(true); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<2>); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start(); @@ -132,15 +131,15 @@ class TestVtkSceneWithCaBasedPopulation : public AbstractCellBasedTestSuite // Create cell population boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new CaBasedCellPopulation<3> (*p_mesh, cells, location_indices)); + boost::make_shared >(*p_mesh, cells, location_indices); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<3>); + boost::shared_ptr > p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetSaveAsImages(true); p_scene->GetCellPopulationActorGenerator()->SetShowPottsMeshEdges(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<3>); + boost::shared_ptr > p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start(); @@ -153,4 +152,5 @@ class TestVtkSceneWithCaBasedPopulation : public AbstractCellBasedTestSuite } }; -#endif + +#endif //TEST_VTK_SCENE_WITH_CA_BASED_HPP_