In this tutorial we show how Chaste can be used to generate simulations
that can be viewed in Paraview, and how to use Paraview itself. Four examples
are provided: the first two use a MeshBasedCellPopulation (a cell-centre model
based on a Delaunay triangulation description of cell neighbours);
the third uses a NodeBasedCellPopulation (a cell-centre model based on an
‘overlapping spheres’ description of cell neighbours); and the fourth uses a
VertexBasedCellPopulation (in which each cell is represented by a polygon).
To be able to view these simulations, we must first have
downloaded and installed VTK and Paraview, and updated our hostconfig file
to ensure that it knows to use VTK.
As in previous cell-based Chaste tutorials, we begin by including the necessary header files.
The remaining header files define classes that will be used in the cell population
simulation test. We have encountered each of these header files in previous cell-based
Chaste tutorials.
Next, we define the test class, which inherits from AbstractCellBasedTestSuite
and defines some test methods.
Test 1 - a mesh-based cell centre monolayer simulation#
In the first test, we run a simple cell-based simulation using a MeshBasedCellPopulation,
in which we use
a honeycomb mesh with ghost nodes, and give each cell a stochastic cell-cycle model.
In a similar way to previous cell-based Chaste tutorials,
we create a mesh-based cell population in which cells are defined by their centres,
and cell proliferation is governed by a stochastic generation-based cell-cycle model
with no differentiation.
The default output method for mesh based simulations is as polytopes
In order to output the .vtu files required for Paraview, we explicitly
instruct the simulation to output the data we need.
The following line tells the cell population to also write data to .vtu files with cells
as points, where we may choose the shape used to visualize each cell in Paraview using
glyphs.
In order to visualise the cells on the boundary we apply a bound to the voronoi
tesselation. Note this defaults to false.
We then pass in the cell population into an OffLatticeSimulation,
and set the output directory and end time.
We create a force law and pass it to the OffLatticeSimulation.
To run the simulation, we call Solve().
The next two lines are for test purposes only and are not part of this tutorial.
We are checking that we reached the end time of the simulation
with the correct number of cells. If different simulation input parameters are being explored
the lines should be removed.
To visualize the results, we must first open Paraview. We open the folder containing our test output using the ‘file’ menu at
the top. The output will be located in $CHASTE_TEST_OUTPUT/Test2DMeshBasedMonolayerSimulationForVisualizing/results_from_time_0.
There will be a .vtu file generated for every timestep, which must all be opened at once to view the simulation. To do this,
simply select voronoi_results_..vtu. We should now see voronoi_results* in the pipeline browser. We click Apply in the properties tab
of the object inspector, and we should now see a visualization in the right hand window.
At this stage, it will be necessary to refine how we wish to view this particular visualisation. The viewing styles can be edited using
the display tab of the object inspector. In particular, under Style, the representation drop down menu allows us to view
the cells as a surface with edges, or as simply a wireframe. It is advisable at this point to familiarize ourselves with the different
viewing options, colour and size settings.
To view the simulation, simply use the animation buttons located on the top toolbar. We can also save a screenshot, or an animation, using
the appropriate options from the file menu. Next to the threshold button are two other useful options, ‘slice’ and ‘clip’, but these will
only be applicable for 3D visualisations.
Test 2 - a periodic mesh-based cell centre monolayer simulation#
In the second test, similar to the first test, we run a simple cell-based simulation using a MeshBasedCellPopulation,
in which we use
a honeycomb mesh with ghost nodes, and give each cell a stochastic cell-cycle model. However here we impose periodic boundaries.
The only difference in this test is the generation of the mesh and use of ghost nodes.
We setup the simulation in the same way as above but
here we use a cylindrical mesh as we wish to enforce periodicity
in the x direction.
The next two lines are for test purposes only and are not part of this tutorial.
We are checking that we reached the end time of the simulation
with the correct number of cells. If different simulation input parameters are being explored
the lines should be removed.
To visualize the results, we follow the instructions above for the first simulation, ensuring that we open the
test output from the new folder, Test2DPeriodicMeshBasedMonolayerSimulationForVisualizing. You will see that the left an right sides
of the monolayer are the same.
At this stage, the viewer is showing all cells in the simulation, including the ghost nodes. In order to view only real cells, we must
apply a threshold. This is achieved using the threshold button on the third toolbar (the icon is a cube with a green ‘T’ inside). Once you
click the threshold button, you will see a new threshold appear below your results in the pipeline browser. Go to the properties tab and
reset the lower threshold to be less than 0, and the upper threshold to be between 0 and 1, ensuring that the ‘Non-ghosts’ option is
selected in the ‘Scalars’ drop down menu. Once we have edited this, we click apply (we may need to click it twice), and the visualisation on the
right window will have changed to eliminate ghost nodes.
Note that you cant currently output the mesh when using ghost nodes.
We next run a similar simulation to the first two examples, but now use a NodeBasedCellPopulation,
in which cells are represented as ‘overlapping spheres’.
We set up the simulation in much the same way as above, except now using a NodesOnlyMesh and
NodeBasedCellPopulation. Further details on how to set up a node-based simulation can be found in
Running Node Based Simulations.
The next two lines are for test purposes only and are not part of this tutorial.
We are checking that we reached the end time of the simulation
with the correct number of cells.
To visualize the results, we follow the instructions above for the first simulation, ensuring that we open the
test output from the new folder, Test2DNodeBasedMonolayerSimulationForVisualizing.
After opening Paraview, load the file results.pvd, then click “Apply” in the object inspector panel.
As this simulation uses a NodeBasedCellPopulation, you must use glyphs to visualize cells: click the button
marked “Glyph” in the toolbar of common filters; specify cells to be displayed as spheres; then click “Apply”.
Note that, for larger simulations, you may need to unclick “Mask Points” (or similar) so as not to limit the number of glyphs
displayed by Paraview.
Here, we run a simple vertex-based simulation, in which we create a monolayer
of cells using a mutable vertex mesh. Each cell is assigned a fixed cell-cycle model.
In this test, we create a vertex-based cell population in which cells are defined
by their vertices, and cell proliferation is governed by a fixed generation-based
cell-cycle model (with differentiation after a default number of generations).
We then pass in the cell population into an OffLatticeSimulation,
and set the output directory and end time.
We create a force law and pass it to the OffLatticeSimulation.
We also make a pointer to a target area modifier and add it to the simulator.
The target area modifier assigns target areas to cells throughout the simulation, modelling cell growth.
To run the simulation, we call Solve().
The next two lines are for test purposes only and are not part of this tutorial.
We are checking that we reached the end time of the simulation
with the correct number of cells.
To visualize the results, we follow the instructions above for the first simulation, ensuring that we open the
test output from the new folder, Test2DVertexMonolayerSimulationForVisualizing.