This tutorial was generated from the file projects/Microvessel/test/tutorials/TestBuildVesselNetworkLiteratePaper.hpp at revision r27242.
Note that the code is given in full at the bottom of the page.
Start by introducing the necessary header files. The first contain functionality for setting up unit tests.
Boost shared pointers are used extensively in this component. This header contains some useful
pointer MACROs.
The OutputFileHandler manages where output files are written to.
These headers contain the building-blocks of the vessel networks; nodes, segments, vessels and the network itself.
Tools for reading and writing networks.
Dimensional analysis.
Tools for automatically generating vessel networks
Used to initialize MPI/PETSc in unit tests.
Tutorials are developed as a series of unit tests using the CxxTest framework. Make a single test class, which inherits from
AbstractCellBasedWithTimingsTestSuite. AbstractCellBasedWithTimingsTestSuite adds some useful functionality to the default
CxxTest::TestSuite class, including setting up timers and initializing random number generators.
Test 1 - Building a vessel network manually, writing it to file and visualizing it#
In the first test build a vessel network from its constituent components; nodes, segments and vessels. Do some
simple tests to make sure the network has been formed as expected. Then write the network to file and visualize it in Paraview. The
network will be built manually, which is tedious and not done much in practice. Later examples will used automatic generators.
First, a note on units. In many simulations with vessel networks care is needed in managing units, as multiple computational grids and
physical phenomena are of interest. It is helpful to be explicit regarding assumed length, time and mass scales and to specify input parameters
with accompanying units. In this component, the DimensionalChastePoint is a fundamental geometric feature which contains a location in N
dimensional space, stored as a vector of dimensionless doubles, and an accompanying reference length. Thus, each DimensionalChastePoint is a
location with units. To demonstrate, we will create a point, which has a reference length of 1 micron and then re-scale its location according
to a different reference length, a cell width. Note that the syntax reference_length(1.0 * unit::microns) rather than
reference_length = 1.0 * unit::microns is used when instantiating quantities.
We can use the unit test framework to check our coordinate values are assigned as expected.
If we want our coordinates in terms of a fictitious cell width unit we just have to rescale the reference length.
It is tedious to keep supplying a reference length, mass, time when setting up simulations. To avoid this a BaseUnits singleton is
used to set these values. Any geometrical features, readers, writers, solvers etc. created after a base unit has been set will take
the current value as their ReferenceXScale. As will be demonstrated, these values can be over-ridden on a class-by-class basis
if needed.
All geometric features, VesselNodes, Parts, RegularGrids use the DimensionalChastePoint as their base representation of spatial
location, meaning that it is straight-forward to change or even mix length scales in a simulation.
Now we proceed to making some nodes, which are point features from which vessels can be constructed. They are initialized in the same way as
a DimensionalChastePoint, but use a convenience Create factory method to get a shared pointer. We will create a 2D Y shaped network.
Again, we will avoid the tedium of manual network creation in later examples.
Next make vessel segments and vessels. Vessel segments are straight-line features which contain a VesselNode at each end. Vessels
can be constructed from multiple vessel segments by adding them in order, but in this case each vessel just has a single segment.
Now add the vessels to a vessel network.
Use the test framework to make sure that the network has been created correctly by checking the number of vessels and nodes
Next write the network to file. Use the OutputFileHandler functionality to manage the output location
and the pointer MACRO MAKE_PTR_ARGS to easily make a smart pointer. Networks are written using VTK’s PolyData format by default,
which will have a .vtp extension.
Now we can visualize then network in Paraview. See the tutorial here, to get started. To view the network import the file
TestBuildVesselNetworkLiteratePaper\bifurcating_network.vtp into Paraview. For a nicer rendering you can do Filters->Alphabetical->Tube.
Test 2 - Building a vessel network using a generator and reading from file#
It is usually tedious to build a vessel network from scratch. In this test we use a generator to automatically construct a network.
We then write it to file, read it back in and check that it is restored as expected.
Create a hexagonal network in 3D space using a generator. Specify the target network width and height and the desired vessel
length. The use of dimensional analysis is demonstrated by now using a fictitious ‘cell width’ reference length unit instead of microns.
Note that the generator is given the reference length scale. This is not imperative, but helps to ensure that all point coordinates
are stored with the same reference length scale. This is helpful when combining with computational grids and cell populations later on.
Get the number of nodes and vessels for testing later, and write the network to file as before. We want to over-ride the
reference length scale so that the output is written in micron. We could also change the ‘ReferenceLengthScale’ in ‘BaseUnits’
if we wanted.
Use a reader to read the network back in from the VTK file. Our network was written in units of micron, so
we need to tell the reader this so that locations are suitably stored.
Finally we check that the network has been correctly read back in using our unit test framework
It is suggested that the tutorial on flow modelling is covered next.