Skip to content

Latest commit

 

History

History
79 lines (55 loc) · 5.72 KB

README.md

File metadata and controls

79 lines (55 loc) · 5.72 KB

Introduction to the Chaste C++ interface

This repository was created for the 2023 Chaste workshop in Oxford and then adapted for the 2025 Nottingham workshop. It introduces some simple examples of vertex model simulations, and then examples of how simulations can be customised by writing new C++ classes.

Structure

The simulations are found in the following test suite:

The custom Chaste classes are defined in the following files:

Chaste user projects

  • There are a few ways to use Chaste's source code. Professional C++ developers may wish to link to Chaste as an external C++ library rather than use the User Project framework described below. People new to C++ may be tempted to directly alter code in the Chaste source folders; this should generally be avoided as we won't know whether any problems you may run into are down to Chaste or your changes to it!

  • Instead of these options, 'User Projects' allow you to use Chaste source code and have the benefit of using the Chaste build/testing framework, by putting User Projects under the projects folder. User Projects work exactly like new Chaste modules (global, heart, cell_based, etc.) and can depend on any of the Chaste modules (or indeed other User Projects). We tend to supply User Projects to accompany and reproduce research articles.

  • Instructions on how to create your own User Project from a 'template' project can also be found here. Alternatively, if you're using Chaste via Docker, you can run the provided script new_project.sh (in the scripts directory) and pass the name that you want to call your project e.g. new_project.sh my_chaste_proj.

  • ⚠️ When you create a new user project, make sure you run the setup_project.py script to ensure it relies on the correct Chaste libraries.

  • Once you have created the repository on GitHub (with the same name) and committed some changes, use the following commands to push your project to GitHub:

    git remote add origin https://github.com/<username>/my_chaste_proj.git
    git push -u origin main
    
  • If the above command gives you the error fatal: remote origin already exists, then instead use the commands:

    git remote set-url origin https://github.com/<username>/my_chaste_proj.git
    git push -u origin main
    
  • Your project and its revision history is now safely stored on GitHub.

Practical session

1. User project structure & set up

  • Look through the structure of the user project and make sure you understand what all the files are there for.
  • Note how the various classes in the src directory inherit from the base Chaste library classes.
  • Set up the workshop user project
    • From your ubuntu terminal (for windows, linux/macosx use native terminal), navigate into your Chaste directory, then the projects directory using the command cd projects
    • Clone this repository into the projects directory using the command git clone https://github.com/Chaste/IntroToChasteCpp2025.git
    • Navigate back to your build directory
    • Configure cmake to build your project using cmake ../src -DChaste_ENABLE_project_IntroToChasteCpp2025=ON -DChaste_ENABLE_project_IntroToChasteCpp2025_TESTING=ON from the build directory
    • Build the project! make project_IntroToChasteCpp2025

2. Run the test suite

  • Read through the code in test/TestCustomVertexSimulations.hpp and make sure you undersand what it is doing.
  • Compile and run the test suite in test/TestCustomVertexSimulations.hpp. If you followed the previous instructions, the tests should be built already. You will need to re-run make project_IntroToChasteCpp2025 each time you make changes. To run the tests, use the command ctest -V -R TestCustomVertexSimulations
  • Open the output in ParaView and see what each simulation has produced.
    • Download the output files from the output directory in vscode
    • Follow the instructions from the slides to view the outputs

3. Read though the custom classes

  • Look at the code in the src directory and make sure you understand it.
  • Make some modifications to one or more of those classes, and see how that modification affects the output of the relevant test.

4. Make a custom class

  • Create a custom class. This might be a division rule, force, or simulation modifier similar to the existing custom classes, or, it could be something different such as a new cell writer.

5. Write a node based simulation with a custom class

6. Try creating your own user project!

  • Create your own project repo on GitHub from the user project template https://github.com/Chaste/template_project
  • Clone your project into the projects directory
  • Run the setup_project.py script
  • Add a test file and write your own test that runs a cell-based simulation