This tutorial was generated from the file projects/Microvessel/test/tutorials/TestBloodFlowLiteratePaper.hpp at revision r27242. Note that the code is given in full at the bottom of the page.

## Modelling Blood Flow Tutorial

This tutorial demonstrates functionality for modelling blood flow, structural adaptation and vessel regression in a vessel network.

This tutorial covers:

- Managing parameter values
- Running a minimal Poiseuille flow simulation and looking at results
- Adding haematocrit
- Adding structural adaptation in response to flow
- Adding vessel regression in low flow regions

## The Test

Start by introducing the necessary header files, explained in previous tutorials.

A container for flow information (boundary conditions, pressure values) for nodes.

A collection of useful literature parameter values and a way to dump values to file after use.

The flow and haematocrit solvers, along with neccessary calculators.

The vessel regression solver and a generic solver to collect all the flow solvers.

Keep this last.

## Test 1 - Simulating 1d Flow in a Bifurcating Network

In the first test we will simulate blood flow in a simple bifurcating vessel network. Subsequent tests will add detail in the form of more complex networks, structural adaptation and vessel regression.

We will work in microns

First make the network using a generator. Start with a simple unit.

Next, pattern it to make a larger network

Specify which nodes will be the inlets and outlets of the network for the flow problem. This information, as well
as all other info related to the flow problem, is contained in a `NodeFlowProperties`

instance. Also, set the inlet and
outlet pressures in Pa or mmHg. We can mix and match these thanks to the dimensional analysis functionality. Because
the network is simple, we can figure out which node is which just from their index. For more complicated networks
we need to use spatial locators and `NearestNode`

type methods.

It would be useful if we had a record of which parameter values we have used in the simulation and where they are sourced in the
literature. Instead of manually entering parameter values like above we can use a `ParameterCollection`

singleton which allows for
some extra metadata storage. We will take some parameter values from a paper by Owen et al. (2011).

Now set the segment radii and viscosity values.

We use a calculator to work out the impedance of each vessel based on assumptions of Poiseuille flow and cylindrical vessels. This updates the value of the impedance in the vessel.

Check that the impedance is as expected in one of the vessels

Now we can solve for the flow rates in each vessel based on the inlet and outlet pressures and impedances. The solver updates the value of pressures and flow rates in each vessel and node in the network.

Check the pressure, it is expected to drop linearly so should be the average of the input and output half way along the network.

Next we write out the network, including updated flow data, to file.

Now we can visualize the results in Paraview. See here to get started. To view the network import the file
`TestBloodFlowLiteratePaper\bifurcating_network.vtp`

into Paraview. For a nicer rendering you can do `Filters->Alphabetical->Tube`

.
Finally, dump our parameter collection to an xml file and, importantly, clear it for the next test.

## Test 2 - Simulating Haematocrit Transport in 3D

In this test we will simulate haematocrit transport in a 3d vessel network.

This time we solve a flow problem and then use the solution to calculate the haematocrit distribution, assuming it has no effect on the flow. Set up the network as before

We will use a locator to mark the bottom left and top right nodes as respective inlets and outlets

Now set the segment radii and viscosity values.

Next some simple extra functionality is demonstrated by mapping the network onto a hemisphere

Get the impedance

Solve the flow problem

Solve the haematocrit problem

Next we write out the network, including updated flow data, to file.

Now we can visualize the results in Paraview. See here to get started. To view the network import the file
`TestBloodFlowLiteratePaper\bifurcating_network.vtp`

into Paraview. For a nicer rendering you can do `Filters->Alphabetical->Tube`

.

## Test 3 - Simulating Flow With Structural Adaptation

In this test the vessel network will adapt over time as a result of flow conditions.

We will work in microns

Set up a hexagonal vessel network

We will use a locator to mark the bottom left and top right nodes as respective inlets and outlets as before.

Set the radius and viscosity and write the initial network to file.

Set up the timer and time scale. The structural adaptation alrogithm works by calcualting growth or shrinkage stimuli from several flow derived sources. We can specify how the network adapts as a function of flow by adding a collection of calculators for wall shear stress, haematocrit etc.

Set up the structural adaptation solver, which manages iterations over a flow solve and executes each calculator in the order it has been added.

Do the solve and write the network to file.

## Test 4 - Simulating Flow With Regression

In this test the vessel network will adapt over time as a result of flow conditions and also vessels will be removed to regression in low wall shear stress regions.

Set up the problem as before.

Set up a regression solver

Set up a `VascalarTumourSolver`

to manage all solves.

Run the solver

## Code

The full code is given below