User-Guide-4 4 1
User-Guide-4 4 1
User-Guide-4 4 1
Element Framework
Version 4.4.1
User Guide
October 13, 2017
Introduction x
I Getting Started 1
1 Installation 2
1.1 Installing Debian/Ubuntu Packages . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Installing Redhat/Fedora Packages . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Installing from Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Obtaining the source code . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.3 OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.4 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3.5 CMake Option Reference . . . . . . . . . . . . . . . . . . . . . . . 12
1.4 Compiling Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.1 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.2 Compiling the User Guide . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.3 Compiling the code documentation . . . . . . . . . . . . . . . . . . 17
1.5 Compiling Tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2 Mathematical Formulation 18
2.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Methods overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.1 The finite element method (FEM) . . . . . . . . . . . . . . . . . . 19
2.2.2 High-order finite element methods . . . . . . . . . . . . . . . . . . 19
2.2.3 The Galerkin formulation . . . . . . . . . . . . . . . . . . . . . . . 21
iii
iv Contents
3.1.3 Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.4 Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.5 Curved Edges and Faces . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.6 Composites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.7 Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2 Expansions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.1 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.2 Solver Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3.4 Global System Solution Information . . . . . . . . . . . . . . . . . 30
3.3.5 Boundary Regions and Conditions . . . . . . . . . . . . . . . . . . 34
3.3.6 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.3.7 Quasi-3D approach . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.4 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4.1 FieldConvert checkpoints . . . . . . . . . . . . . . . . . . . . . . . 41
3.4.2 Time-averaged fields . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.3 Moving average of fields . . . . . . . . . . . . . . . . . . . . . . . . 43
3.4.4 Reynolds stresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.4.5 Checkpoint fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.6 History points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.7 ThresholdMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.8 ThresholdMin value . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.9 One-dimensional energy . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.10 Modal energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.4.11 Aerodynamic forces . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.4.12 Kinetic energy and enstrophy . . . . . . . . . . . . . . . . . . . . . 48
3.5 Forcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.1 Absorption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.2 Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3 Programmatic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.4 Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6 Analytic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6.1 Variables and coordinate systems . . . . . . . . . . . . . . . . . . . 51
3.6.2 Performance considerations . . . . . . . . . . . . . . . . . . . . . . 56
4 NekMesh 59
4.1 Exporting a mesh from Gmsh . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2 Defining physical surfaces and volumes . . . . . . . . . . . . . . . . . . . . 60
4.3 Converting the MSH to Nektar++ format . . . . . . . . . . . . . . . . . . 61
4.4 NekMesh modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.4.1 Input modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Contents v
5 FieldConvert 78
5.1 Convert .fld / .chk files into Paraview, VisIt or Tecplot format . . . . . . 78
5.2 Convert field files between XML and HDF5 format . . . . . . . . . . . . . 79
5.3 Range option -r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.4 FieldConvert modules -m . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.4.1 Smooth the data: C0Projection module . . . . . . . . . . . . . . . 81
5.4.2 Calculate Q-Criterion: QCriterion module . . . . . . . . . . . . . . 82
5.4.3 Add composite ID: addcompositeid module . . . . . . . . . . . . . 82
5.4.4 Sum two .fld files: addFld module . . . . . . . . . . . . . . . . . . 82
5.4.5 Combine two .fld files containing time averages: combineAvg module 83
5.4.6 Concatenate two files: concatenate module . . . . . . . . . . . . . 83
5.4.7 Equi-spaced output of data: equispacedoutput module . . . . . . . 83
5.4.8 Extract a boundary region: extract module . . . . . . . . . . . . . 83
5.4.9 Compute the gradient of a field: gradient module . . . . . . . . . . 84
5.4.10 Extract a plane from 3DH1D expansion: homplane module . . . . 84
5.4.11 Stretch a 3DH1D expansion: homstretch module . . . . . . . . . . 85
5.4.12 Inner Product of a single or series of fields with respect to a single
or series of fields: innerproduct module . . . . . . . . . . . . . . . . 85
5.4.13 Interpolate one field to another: interpfield module . . . . . . . . . 86
5.4.14 Interpolate scattered point data to a field: interppointdatatofld
module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
5.4.15 Interpolate a field to a series of points: interppoints module . . . . 87
5.4.16 Isocontour extraction: iscontour module . . . . . . . . . . . . . . . 89
5.4.17 Show high frequency energy of the Jacobian: jacobianenergy module 89
5.4.18 Calculate mesh quality: qualitymetric module . . . . . . . . . . . . 90
5.4.19 Extract mean mode of 3DH1D expansion: meanmode module . . . 90
5.4.20 Project point data to a field: pointdatatofld module . . . . . . . . 90
vi Contents
IIISolver Applications 98
6 Advection-Diffusion-Reaction Solver 99
6.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.3 Session file configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.3.1 Solver Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.3.2 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.3.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.4.1 1D Advection equation . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.4.2 2D Helmholtz Problem . . . . . . . . . . . . . . . . . . . . . . . . . 103
6.4.3 Advection dominated mass transport in a pipe . . . . . . . . . . . 106
IV Reference 223
14 Optimisation 224
14.1 Operator evaluation strategies . . . . . . . . . . . . . . . . . . . . . . . . . 224
14.1.1 Selecting an operator strategy . . . . . . . . . . . . . . . . . . . . . 225
14.1.2 XML syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
14.1.3 Selecting different operator strategies . . . . . . . . . . . . . . . . . 226
14.2 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
14.2.1 Default implementation . . . . . . . . . . . . . . . . . . . . . . . . 227
14.2.2 Auto-tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.2.3 Manual selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.2.4 Collection size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Bibliography 235
Introduction
Nektar++ [8] is a tensor product based finite element package designed to allow one
to construct efficient classical low polynomial order h-type solvers (where h is the size
of the finite element) as well as higher p-order piecewise polynomial order solvers. The
framework currently has the following capabilities:
• Segment, plane and volume domains are permissible, as well as domains representing
curves and surfaces (dimensionally-embedded domains).
• Hybrid shaped elements, i.e triangles and quadrilaterals or tetrahedra, prisms and
hexahedra.
The framework comes with a number of solvers and also allows one to construct a variety
of new solvers.
x
Introduction xi
For further information and to download the software, visit the Nektar++ website at
http://www.nektar.info.
Part I
Getting Started
1
Chapter 1
Installation
Binary packages are available for current Debian/Ubuntu based Linux distributions.
These can be installed through the use of standard system package management utilities,
such as Apt, if administrative access is available.
1. Add the appropriate line for the Debian-based distribution to the end of the file
/etc/apt/sources.list
Distribution Repository
Debian 8.0 (jessie) deb http://www.nektar.info/debian-jessie jessie contrib
Debian 7.0 (wheezy) deb http://www.nektar.info/debian-wheezy wheezy contrib
Ubuntu 14.04 (trusty) deb http://www.nektar.info/ubuntu-trusty trusty contrib
apt-get update
2
1.2 Installing Redhat/Fedora Packages 3
Tip
Nektar++ is split into multiple packages for the different components of
the software. A list of available Nektar++ packages can be found using:
apt-cache search nektar++
[Nektar]
name=nektar
baseurl=<baseurl>
substituting <baseurl> for the appropriate line from the table below.
Distribution <baseurl>
Fedora 20 http://ww.nektar.info/fedora/20/$basearch
Note
The $basearch variable is automatically replaced by Yum with the architecture
of your system.
This section explains how to build Nektar++ from the source-code package.
Nektar++ uses a number of third-party libraries. Some of these are required, others are
optional. It is generally more straightforward to use versions of these libraries supplied
pre-packaged for your operating system, but if you run into difficulties with compilation
errors or failing regression tests, the Nektar++ build system can automatically build
tried-and-tested versions of these libraries for you. This requires enabling the relevant
options in the CMake configuration.
• Download the latest source-code archive from the Nektar++ downloads page.
4 Chapter 1 Installation
– Using anonymous access. This does not require credentials but any changes
to the code cannot be pushed to the public repository. Use this initially if you
would like to try using Nektar++ or make local changes to the code.
– Using authenticated access. This will allow you to directly contribute back
into the code.
Tip
You can easily switch to using the authenticated access from anony-
mous access at a later date.
1.3.2 Linux
1.3.2.1 Prerequisites
Nektar++ uses a number of external programs and libraries for some or all of its
functionality. Some of these are required and must be installed prior to compiling
Nektar++, most of which are available as pre-built system packages on most Linux
distributions or can be installed manually by a user. Others are optional and required
only for specific features, or can be downloaded and compiled for use with Nektar++
automatically (but not installed system-wide).
1.3 Installing from Source 5
Installation
Package Req. Sys. User Auto. Note
C++ compiler 3 3 gcc, icc, etc
CMake > 2.8.7 3 3 3 Ncurses GUI optional
BLAS 3 3 3 Or MKL, ACML, OpenBLAS
LAPACK 3 3 3
Boost >= 1.52 3 3 3 3 Compile with iostreams
ModMETIS 3 3
FFTW > 3.0 3 3 3 For high-performance FFTs
ARPACK > 2.0 3 3 For arnoldi algorithms
OpenMPI 3 For parallel execution
GSMPI 3 For parallel execution
HDF5 3 3 3 For large-scale parallel I/O (requires CMake >3.1)
PETSc 3 3 Alternative linear solvers
Scotch 3 3 3 Alternative mesh partitioning
VTK > 5.8 3 3 Visualisation utilities
Warning
Boost version 1.51 has a bug which prevents Nektar++ working correctly. Please
use a newer version.
2. Change into the source-code directory, create a build subdirectory and enter it
ccmake ../
Note
Selecting THIRDPARTY_BUILD_ options will request CMake to automatically
download thirdparty libraries and compile them within the Nektar++ direc-
tory. If you have administrative access to your machine, it is recommended
to install the libraries system-wide through your package-management
system.
4. Press c to configure the build. If errors arise relating to missing libraries, review
the THIRDPARTY_BUILD_ selections in the configuration step above or install the
missing libraries manually or from system packages.
5. When configuration completes without errors, press c again until the option g to
generate build files appears. Press g to generate the build files and exit CMake.
make install
Tip
If you have multiple processors/cores on your system, compilation can be
significantly increased by adding the -jX option to make, where X is the
number of simultaneous jobs to spawn. For example, use
make -j4 install
on a quad-core system.
ctest
1.3.3 OS X
1.3.3.1 Prerequisites
Nektar++ uses a number of external programs and libraries for some or all of its
functionality. Some of these are required and must be installed prior to compiling
Nektar++, most of which are available on MacPorts (www.macports.org) or can be
installed manually by a user. Others are optional and required only for specific features,
or can be downloaded and compiled for use with Nektar++ automatically (but not
installed system-wide).
Note
To compile Nektar++ on OS X, Apple’s Xcode Developer Tools must be
installed. They can be installed either from the App Store (only on Mac
OS 10.7 and above) or downloaded directly from http://connect.apple.com/
(you are required to have an Apple Developer Connection account). Xcode
includes Apple implementations of BLAS and LAPACK (called the Accelerate
Framework).
8 Chapter 1 Installation
Installation
Package Req. MacPorts User Auto. Note
Xcode 3 Provides developer tools
CMake > 2.8.7 3 cmake 3 Ncurses GUI optional
BLAS 3 Part of Xcode
LAPACK 3 Part of Xcode
Boost >= 1.52 3 boost 3 3 Compile with iostreams
TinyXML 3 tinyxml 3 3
ModMETIS 3 3
FFTW > 3.0 fftw-3 3 3 For high-performance FFTs
ARPACK > 2.0 arpack 3 For arnoldi algorithms
OpenMPI openmpi For parallel execution
GSMPI 3 For parallel execution
HDF5 3 3 3 For large-scale parallel I/O (requires CMake >3.1)
PETSc petsc 3 3 Alternative linear solvers
Scotch scotch 3 3 Alternative mesh partitioning
VTK > 5.8 vtk 3 Visualisation utilities
Tip
CMake, and some other software, is available from MacPorts (http://macports.
org) and can be installed using, for example,
Package names are given in the table above. Similar packages also exist in
other package managers such as Homebrew.
2. Change into the source-code directory, create a build subdirectory and enter it
ccmake ../
Use the arrow keys to navigate the options and ENTER to select/edit an option.
Note
Selecting THIRDPARTY_BUILD_ options will request CMake to automatically
download thirdparty libraries and compile them within the Nektar++ direc-
tory. If you have administrative access to your machine, it is recommended
to install the libraries system-wide through MacPorts.
4. Press c to configure the build. If errors arise relating to missing libraries (variables
set to NOTFOUND ), review the THIRDPARTY_BUILD_ selections in the previous step
or install the missing libraries manually or through MacPorts.
5. When configuration completes without errors, press c again until the option g to
generate build files appears. Press g to generate the build files and exit CMake.
make install
Tip
If you have multiple processors/cores on your system, compilation
can be significantly increased by adding the -jX option to make,
where X is the number of simultaneous jobs to spawn. For example,
make -j4 install
ctest
1.3.4 Windows
Windows compilation is supported, but the build process is somewhat convoluted at
present. As such, only serial execution is supported with a minimal amount of additional
build packages. These can either be installed by the user, or automatically in the build
process.
Installation
Package Req. User Auto. Note
MS Visual Studio 3 3 2012, 2013 and 2015 known working
CMake ≥ 3.0 3 3
BLAS 3 3 3
LAPACK 3 3 3
Boost ≥ 1.55 3 3 3 Compile with iostreams
ModMETIS 3 3 3
1. Install Microsoft Visual Studio 2015 (preferred), 2013 or 2012 (known to work). This
can be obtained from Microsoft free of charge by using their Community developer
tools from https://www.visualstudio.com/en-us/products/visual-studio-community-vs.
aspx.
5. (Optional) If you do not wish to build boost during the compilation process (which
can take some time), then boost binaries can be found at http://sourceforge.
net/projects/boost/files/boost-binaries/1.61.0/. By default these install
into C:\local\boost_1_61_0 . If you use these libraries, you will need to:
Note
Some Windows versions do not recognise the path of a folder which has
++ in the name. If you think that your Windows version can not handle
path containing special characters, you should rename nektar++-4.4.1
to nektar-4.4.1 .
8. Open a Visual Studio terminal. From the start menu, this can be found in All
Programs > Visual Studio 2015 > Visual Studio Tools > Developer Command
Prompt for VS2015.
9. Change directory into the builds directory and run the CMake graphical utility:
cd C:\path\to\nektar\builds
cmake-gui ..
10. Select the build system you want to generate build scripts for. Note that Visual
Studio 2015 is listed as Visual Studio 14 in the drop-down list. If you have a 64-bit
installation of Windows, you should select the Win64 variant, otherwise 32-bit
executables will be generated. Select the option to use the native compilers.
12 Chapter 1 Installation
13. After the installation process is completed, the executables will be available in
builds\dist\bin .
14. To use these executables, you need to modify your system PATH to include the
library directories where DLLs are stored. To do this, navigate to Control Panel
> System and Security > System, select Advanced System Settings, and in the
Advanced tab click the Environment Variables. In the System Variables box, select
Path and click Edit. To the end of this list, add the full paths to directories:
• builds\dist\lib\nektar++-4.4.1
• builds\dist\bin
• Optionally, if you installed Boost from the binary packages, C:\local\boost_1_61_0 \lib
15. To run the test suite, open a new command line window, change to the builds
directory, and then issue the command
ctest -C Release
1.3.5.1 Components
The first set of options specify the components of the Nektar++ toolkit to compile. Some
options are dependent on others being enabled, so the available options may change.
Components of the Nektar++ package can be selected using the following options:
• NEKTAR_BUILD_DEMOS (Recommended)
Compiles the demonstration programs. These are primarily used by the regression
testing suite to verify the Nektar++ library, but also provide an example of the
basic usage of the framework.
1.3 Installing from Source 13
• NEKTAR_BUILD_DOC
Compiles the Doxygen documentation for the code. This will be put in
$BUILDDIR/doxygen/html
• NEKTAR_BUILD_LIBRARY (Required)
Compiles the Nektar++ framework libraries. This is required for all other options.
• NEKTAR_BUILD_SOLVERS (Recommended)
Compiles the solvers distributed with the Nektar++ framework.
If enabling NEKTAR_BUILD_SOLVERS , individual solvers can be enabled or disabled.
See Part III for the list of available solvers. You can disable solvers which are not
required to reduce compilation time. See the NEKTAR_SOLVER_X option.
• NEKTAR_BUILD_TESTS (Recommended)
Compiles the testing program used to verify the Nektar++ framework.
• NEKTAR_BUILD_TIMINGS
Compiles programs used for timing Nektar++ operations.
• NEKTAR_BUILD_UNIT_TESTS
Compiles tests for checking the core library functions.
• NEKTAR_BUILD_UTILITIES
Compiles utilities for pre- and post-processing simulation data.
• NEKTAR_SOLVER_X
Enabled compilation of the ’X’ solver.
A number of ThirdParty libraries are required by Nektar++. There are also optional
libraries which provide additional functionality. These can be selected using the following
options:
• NEKTAR_USE_ACML
Use the optimised BLAS library for AMD processors.
• NEKTAR_USE_ACCELERATE_FRAMEWORK
Use the Mac Osx accelerate framework for BLAS and LAPACK methods. This
option should only be required under in a Mac OSX environment.
• NEKTAR_USE_ARPACK
Build Nektar++ with support for ARPACK. This provides routines used for linear
stability analyses. Alternative Arnoldi algorithms are also implemented directly in
Nektar++.
14 Chapter 1 Installation
• NEKTAR_USE_BLAS_LAPACK (Required)
Enables the use of Basic Linear Algebra Subroutines libraries for linear algebra
operations.
• NEKTAR_USE_SYSTEM_BLAS_LAPACK (Recommended)
On Linux systems, use the default BLAS and LAPACK library on the system.
This may not be the implementation offering the highest performance for your
architecture, but it is the most likely to work without problem.
• NEKTAR_USE_CCM
Use the ccmio library provided with the Star-CCM package for reading ccm files.
This option is required as part of NekMesh if you wish to convert a Star-CCM mesh
into the Nektar format. It is possible to read a Tecplot plt file from Star-CCM
but this output currently needs to be converted to ascii format using the Tecplot
package.
• NEKTAR_USE_FFTW
Build Nektar++ with support for FFTW for performing Fast Fourier Transforms
(FFTs). This is used only when using domains with homogeneous coordinate
directions.
• NEKTAR_USE_HDF5
Build Nektar++ with support for HDF5. This enables input/output in the HDF5
parallel file format, which can be very efficient for large numbers of processes. HDF5
output can be enabled by using a command-line option or in the SOLVERINFO
section of the XML file. This option requires that Nektar++ be built with MPI
support with NEKTAR_USE_MPI enabled and that HDF5 is compiled with MPI
support.
• NEKTAR_USE_MKL
Use the Intel MKL library. This is typically available on cluster environments and
should offer performance tuned for the specific cluster environment.
• NEKTAR_USE_MPI (Recommended)
Build Nektar++ with MPI parallelisation. This allows solvers to be run in serial
or parallel.
• NEKTAR_USE_OPENBLAS
Use OpenBLAS for the BLAS library. OpenBLAS is based on the Goto BLAS
implementation and generally offers better performance than a non-optimised
system BLAS. However, the library must be installed on the system.
• NEKTAR_USE_PETSC
Build Nektar++ with support for the PETSc package for solving linear systems.
1.3 Installing from Source 15
• NEKTAR_USE_SCOTCH
Build Nektar++ with support for the SCOTCH graph partitioning library. This
provides an alternative mesh partitioning algorithm to METIS. However, METIS
is still required as it is used by the multi-level static condensation algorithm.
• NEKTAR_USE_SMV
Build Nektar++ with support for optimised sparse matrix-vector operations.
• NEKTAR_USE_VTK
Build Nektar++ with support for VTK libraries. This is only needed for specialist
utilities and is not needed for general use.
Note
The VTK libraries are not needed for converting the output of simulations
to VTK format for visualization as this is handled internally.
• BOOST
The Boost libraries are frequently provided by the operating system, so automatic
compilation is not enabled by default. If you do not have Boost on your system,
you can enable this to have Boost configured automatically.
• GSMPI
(MPI-only) Parallel communication library.
• LOKI
An implementation of a singleton.
• METIS
A graph partitioning library used for substructuring of matrices and mesh parti-
tioning when Nektar++ is run in parallel.
• PETSC
A package for the parallel solution of linear algebra systems.
• SCOTCH
An alternative graph partitioning library used for mesh partitioning when Nektar++
is run in parallel.
• TINYXML
Library for reading and writing XML files.
16 Chapter 1 Installation
1.4.1 Dependencies
To build the LaTeX documents (user guide or tutorials), the following dependencies are
required:
• texlive-base
• texlive-latex-extra
• texlive-science
• texlive-fonts-recommended
• imagemagick
• doxygen
• graphviz
2. Run
make user-guide-pdf
make user-guide-html
make doc
If you are using a clone of the Nektar++ git repository, you can also download the source
for the Nektar++ tutorials which is available as a git submodule.
2. From your build directory (e.g. $NEKPP/build ), re-run cmake to update the build
system to include the tutorials
cmake ../
make flow-stability-channel
Chapter 2
Mathematical Formulation
2.1 Background
The spectral/hp element method combines the geometric flexibility of classical h-type
finite element techniques with the desirable resolution properties of spectral methods. In
this approach a polynomial expansion of order P is applied to every elemental domain of a
coarse finite element type mesh. These techniques have been applied in many fundamental
studies of fluid mechanics [34] and more recently have gained greater popularity in the
modelling of wave-based phenomena such as computational electromagnetics [17] and
shallow water problems [5] - particularly when applied within a Discontinuous Galerkin
formulation.
There are at least two major challenges which arise in developing an efficient implemen-
tation of a spectral/hp element discretisation:
• designing and implementing the numerical methods and data structures in a matter
so that both high- and low-order discretisations can be efficiently applied.
In order to design algorithms which are efficient for both low- and high-order spectral/hp
discretisations, it is important clearly define what we mean with low- and high-order.
The spectral/hp element method can be considered as bridging the gap between the
high-order end of the traditional finite element method and low-order end of conventional
spectral methods. However, the concept of high- and low-order discretisations can mean
very different things to these different communities. For example, the seminal works by
Zienkiewicz & Taylor [40] and Hughes list examples of elemental expansions only up to
third or possibly fourth-order, implying that these orders are considered to be high-order
for the traditional h-type finite element community. In contrast the text books of the
spectral/hp element community typically show examples of problems ranging from a
18
2.2 Methods overview 19
One could wonder whether these different definitions of low- and high-order are just
inherent to the tradition and lore of each of the communities or whether there are more
practical reasons for this distinct interpretation. Proponents of lower-order methods might
highlight that some problems of practical interest are so geometrically complex that one
cannot computationally afford to use high-order techniques on the massive meshes required
to capture the geometry. Alternatively, proponents of high-order methods highlight that
if the problem of interest can be captured on a computational domain at reasonable
cost then using high-order approximations for sufficiently smooth solutions will provide a
higher accuracy for a given computational cost. If one however probes even further it also
becomes evident that the different communities choose to implement their algorithms
in different manners. For example the standard h-type finite element community will
typically uses techniques such as sparse matrix storage formats (where only the non-zero
entries of a global matrix are stored) to represent a global operator. In contrast the
spectral/hp element community acknowledges that for higher polynomial expansions
more closely coupled computational work takes place at the individual elemental level
and this leads to the use of elemental operators rather than global matrix operators. In
addition the global spectral method community often make use of the tensor-product
approximations where products of one-dimensional rules for integration and differentiation
can be applied.
Here a review of some terminology in order to situate the spectral/hp element method
within the field of the finite element methods.
solution. For the high-order FEM, the solution is locally expanded into a set of P + 1
linearly independent polynomials which span the polynomial space of order P . Confusion
may arise about the use of the term order. While the order, or degree, of the expansion
basis corresponds to the maximal polynomial degree of the basis functions, the order of
the method essentially refers to the accuracy of the approximation. More specifically, it
depends on the convergence rate of the approximation with respect to mesh-refinement.
It has been shown by Babuska and Suri [3], that for a sufficiently smooth exact solution
u ∈ H k (Ω), the error of the FEM approximation uδ can be bounded by:
This implies that when decreasing the mesh-size h, the error of the approximation
algebraically scales with the P th power of h. This can be formulated as:
If this holds, one generally classifies the method as a P th -order FEM. However, for
non-smooth problems, i.e. k < P + 1, the order of the approximation will in general be
lower than P , the order of the expansion.
A finite element method is said to be of h-type when the degree P of the piecewise
polynomial basis functions is fixed and when any change of discretisation to enhance
accuracy is done by means of a mesh refinement, that is, a reduction in h. Dependent
on the problem, local refinement rather than global refinement may be desired. The
h-version of the classical FEM employing linear basis functions can be classified as a
first-order method when resolving smooth solutions.
In contrast with the h-version FEM, finite element methods are said to be of p-type when
the partitioning of domain is kept fixed and any change of discretisation is introduced
through a modification in polynomial degree P . Again here, the polynomial degree
may vary per element, particularly when the complexity of the problem requires local
enrichment. However, sometimes the term p-type FEM is merely used to indicated that
a polynomial degree of P > 1 is used.
In the hp-version of the FEM, both the ideas of mesh refinement and degree enhancement
are combined.
2.2 Methods overview 21
L(u) = f,
subject to appropriate boundary conditions. In the Galerkin method, the weak form of
this equation can be derived by pre-multiplying this equation with a test function v and
integrating the result over the entire domain Ω to arrive at: Find u ∈ U such that
Z Z
vL(u)dx = vf dx, ∀v ∈ V,
Ω Ω
where U and V respectively are a suitably chosen trial and test space (in the traditional
Galerkin method, one typically takes U = V). In case the inner product of v and L(u)
22 Chapter 2 Mathematical Formulation
can be rewritten into a bi-linear form a(v, u), this problem is often formulated more
concisely as: Find u ∈ U such that
a(v, u) = (v, f ), ∀v ∈ V,
where (v, f ) denotes the inner product of v and f . The next step in the classical Galerkin
finite element method is the discretisation: rather than looking for the solution u in the
infinite dimensional function space U, one is going to look for an approximate solution
uδ in the reduced finite dimensional function space U δ ⊂ U. Therefore we represent the
approximate solution as a linear combination of basis functions Φn that span the space
U δ , i.e.
X
uδ = Φn ûn .
n∈N
Adopting a similar discretisation for the test functions v, the discrete problem to be
solved is given as: Find ûn (n ∈ N ) such that
X
a(Φm , Φn )ûn = (Φm , f ), ∀m ∈ N .
n∈N
Aû = f̂ ,
where û is the vector of coefficients ûn , A is the system matrix with elements
Z
A[m][n] = a(Φm , Φn ) = Φm L(Φn )dx,
Ω
The Nektar++ native file format is compliant with XML version 1.0. The root element
is NEKTAR which contains a number of other elements which describe configuration for
different aspects of the simulation. The required elements are shown below:
1 <NEKTAR>
2 <GEOMETRY>
3 ...
4 </GEOMETRY>
5 <EXPANSIONS>
6 ...
7 </EXPANSIONS>
8 <CONDITIONS>
9 ...
10 </CONDITIONS>
11 ...
12 </NEKTAR>
The different sub-elements can be split across multiple files, however each file must have a
top-level NEKTAR tag. For example, one might store the geometry information separate
from the remaining configuration in two separate files as illustrated below:
geometry.xml
1 <NEKTAR>
2 <GEOMETRY>
3 ...
4 </GEOMETRY>
5 </NEKTAR>
conditions.xml
1 <NEKTAR>
2 <CONDITIONS>
3 ...
4 </CONDITIONS>
5 <EXPANSIONS>
23
24 Chapter 3 XML Session File
6 ...
7 </EXPANSIONS>
8 ...
9 </NEKTAR>
Note
When specifying multiple files, repeated XML sub-elements are not merged.
The sub-elements from files appearing later in the list will, in general, override
those elements from earlier files.
For example, the NekMesh utility will produce a default EXPANSIONS element
and blank CONDITIONS element. Specifying a custom-written XML file con-
taining these sections after the file produced by NekMesh will override these
defaults.
The exception to this rule is when an empty XML sub-element would override a
non-empty XML sub-element. In this case the empty XML sub-element will be
ignored. If the custom-written XML file containing CONDITIONS were specified
before the file produced by NEKMESH , the empty CONDITIONS tag in the latter
file would be ignored.
3.1 Geometry
This section defines the mesh. It specifies a list of vertices, edges (in two or three
dimensions) and faces (in three dimensions) and how they connect to create the elemental
decomposition of the domain. It also defines a list of composites which are used in the
Expansions and Conditions sections of the file to describe the polynomial expansions and
impose boundary conditions.
• SPACE specifies the dimension of the space in which the elements exist.
3.1 Geometry 25
Note
The attribute PARTITION may also appear in a partitioned mesh. However,
this attribute should not be explicitly specified by the user.
Each of the VERTEX , EDGE , FACE , ELEMENT and CURVED sections may optionally be
compressed and stored in base64-encoded gzipped binary form, using either little-endian or
big-endian ordering, as specified by the COMPRESSED attribute to these sections. Currently
supported values are:
Note
The description below explains how the GEOMETRY section is laid out in un-
compressed ascii format. From Jan 2016 the distribution uses the compressed
format for each of the above sections. To convert a compressed xml file into
ascii format use
NekMesh file.msh newfile.xml:xml:uncompress
3.1.1 Vertices
Vertices have three coordinates. Each has a unique vertex ID. In uncompressed form,
they are defined within VERTEX subsection as follows:
1 <V ID="0"> 0.0 0.0 0.0 </V> ...
The VERTEX subsection has optional attributes which can be used to apply a transforma-
tion to the mesh:
XSCALE , YSCALE , ZSCALE , XMOVE , YMOVE , ZMOVE
They specify scaling factors (centred at the origin) and translations to the vertex coordi-
nates. For example, the following snippet
1 <VERTEX XSCALE="5">
2 <V ID="0"> 0.0 0.0 0.0 </V>
3 <V ID="1"> 1.0 2.0 0.0 </V>
4 </VERTEX>
defines two vertices with coordinates (0.0, 0.0, 0.0), (1.0, 2.0, 0.0).
26 Chapter 3 XML Session File
All of these attributes can be arbitrary analytic expressions depending on pre- defined
constants and parameters defined in the XML file and mathematical operations/functions
of the latter. If omitted, default scaling factors 1.0, and translations of 0.0, are assumed.
3.1.2 Edges
Tip
The EDGES section is only necessary when DIM=2 or DIM=3 in the parent
GEOMETRY element and may be omitted for one-dimensional meshes.
Edges are defined by two vertices. Each edge has a unique edge ID. In uncompressed
form, they are defined in the file with a line of the form
1 <E ID="0"> 0 1 </E>
3.1.3 Faces
Tip
The FACES section is only necessary when DIM=3 in the parent GEOMETRY
element and may otherwise be omitted.
Faces are defined by three or more edges. Each face has a unique face ID. They are
defined in the file with a line of the form
1 <T ID="0"> 0 1 2 </T>
2 <Q ID="1"> 3 4 5 6 </Q>
The choice of tag specified (T or Q), and thus the number of edges specified depends on
the geometry of the face (triangle or quadrilateral).
3.1.4 Element
Elements define the top-level geometric entities in the mesh. Their definition depends
upon the dimension of the expansion. For two-dimensional expansions, an element is
defined by a sequence of three or four edges. For three-dimensional expansions, the
element is defined by a list of faces. Elements are defined in the file with a line of the
form
1 <T ID="0"> 0 1 2 </T>
2 <H ID="1"> 3 4 5 6 7 8 </H>
Again, the choice of tag specified depends upon the geometry of the element. The element
tags are:
3.1 Geometry 27
• S Segment
• T Triangle
• Q Quadrilateral
• A Tetrahedron
• P Pyramid
• R Prism
• H Hexahedron
Tip
The CURVED section is only necessary if curved edges or faces are present in
the mesh and may otherwise be omitted.
For mesh elements with curved edges and/or curved faces, a separate entry is used
to describe the control points for the curve. Each curve has a unique curve ID and
is associated with a predefined edge or face. The total number of points in the curve
(including end points) and their distribution is also included as attributes. The control
points are listed in order, each specified by three coordinates. Curved edges are defined
in the file with a line of the form
1 <E ID="3" EDGEID="7" TYPE="PolyEvenlySpaced" NUMPOINTS="3">
2 0.0 0.0 0.0 0.5 0.5 0.0 1.0 0.0 0.0
3 </E>
Note
In the compressed form, this section contains different sub-elements to efficiently
encode the high-order curvature data. This is not described further in this
document.
3.1.6 Composites
Composites define collections of elements, faces or edges. Each has a unique composite ID
associated with it. All components of a composite entry must be of the same type. The
syntax allows components to be listed individually or using ranges. Examples include
1 <C ID="0"> T[0-862] </C>
2 <C ID="1"> E[68,69,70,71] </C>
28 Chapter 3 XML Session File
3.1.7 Domain
This tag specifies composites which describe the entire problem domain. It has the form
of
1 <DOMAIN> C[0] </DOMAIN>
3.2 Expansions
This section defines the polynomial expansions used on each of the defined geometric
composites. Expansion entries specify the number of modes, the basis type. The
short-hand version has the following form
1 <E COMPOSITE="C[0]" NUMMODES="5" FIELDS="u" TYPE="MODIFIED" />
or, if we have more then one variable we can apply the same basis to all using
1 <E COMPOSITE="C[0]" NUMMODES="5" FIELDS="u,v,p" TYPE="MODIFIED" />
3.3 Conditions
The final section of the file defines parameters and boundary conditions which define the
nature of the problem to be solved. These are enclosed in the CONDITIONS tag.
3.3.1 Parameters
Parameters may be required by a particular solver (for instance time-integration parame-
ters or solver-specific parameters), or arbitrary and only used within the context of the
session file (e.g. parameters in the definition of an initial condition). All parameters are
enclosed in the PARAMETERS XML element.
3.3 Conditions 29
1 <PARAMETERS>
2 ...
3 </PARAMETERS>
A parameter may be of integer or real type and may reference other parameters defined
previous to it. It is expressed in the file as
1 <P> [PARAMETER NAME] = [PARAMETER VALUE] </P>
For example,
1 <P> NumSteps = 1000 </P>
2 <P> TimeStep = 0.01 </P>
3 <P> FinTime = NumSteps*TimeStep </P>
3.3.2.1 Drivers
Drivers are defined under the CONDITIONS section as properties of the SOLVERINFO XML
element. The role of a driver is to manage the solver execution from an upper level.
The default driver is called Standard and executes the following steps:
1. Prints out on screen a summary of all the conditions defined in the input file.
In the following example, the driver Standard is used to manage the execution of the
incompressible Navier-Stokes equations:
30 Chapter 3 XML Session File
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
3 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
4 <I PROPERTY="Projection" VALUE="Galerkin" />
5 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2" />
6 <I PROPERTY="Driver" VALUE="Standard" />
7 </SOLVERINFO>
If no driver is specified in the session file, the driver Standard is called by default. Other
drivers can be used and are typically focused on specific applications. As described in
Sec. 10.3.1 and 10.4.1, the other possibilities are:
• SteadyState - uses the Selective Frequency Damping method (see Sec. 10.1.4)
to obtain a steady-state solution of the Navier-Stokes equations (compressible or
incompressible).
3.3.3 Variables
These define the number (and name) of solution variables. Each variable is prescribed
a unique ID. For example a two-dimensional flow simulation may define the velocity
variables using
1 <VARIABLES>
2 <V ID="0"> u </V>
3 <V ID="1"> v </V>
4 </VARIABLES>
This section of the XML file therefore allows the user to specify the global system solution
parameters, which dictates the type of solver to be used for any implicit systems that are
constructed. This section is particularly useful when using a multi-variable solver such as
the incompressible Navier-Stokes solver, as it allows us to select different preconditioning
3.3 Conditions 31
and residual convergence options for each variable. As an example, consider the block
defined by:
1 <GLOBALSYSSOLNINFO>
2 <V VAR="u,v,w">
3 <I PROPERTY="GlobalSysSoln" VALUE="IterativeStaticCond" />
4 <I PROPERTY="Preconditioner" VALUE="LowEnergyBlock"/>
5 <I PROPERTY="IterativeSolverTolerance" VALUE="1e-8"/>
6 </V>
7 <V VAR="p">
8 <I PROPERTY="GlobalSysSoln" VALUE="IterativeStaticCond" />
9 <I PROPERTY="Preconditioner" VALUE="FullLinearSpaceWithLowEnergyBlock"/>
10 <I PROPERTY="IterativeSolverTolerance" VALUE="1e-6"/>
11 </V>
12 </GLOBALSYSSOLNINFO>
The above section specifies that the variables u,v,w should use the IterativeStaticCond
global solver alongside the LowEnergyBlock preconditioner and an iterative tolerance of
10−8 on the residuals. However the pressure variable p is generally stiffer: we therefore
opt for a more expensive FullLinearSpaceWithLowEnergyBlock preconditioner and a
larger residual of 10−6 . We now outline the choices that one can use for each of these
parameters and give a brief description of what they mean.
Note
Defaults for all fields can be defined by setting the equivalent property in
the SOLVERINFO section. Parameters defined in this section will override any
options specificed there.
• Direct solvers construct the full global matrix and directly invert it using an
appropriate matrix technique, such as Cholesky factorisation, depending on the
properties of the matrix. Direct solvers only run in serial.
• Xxt solvers use the XX T library to perform a parallel direct solve. This option is
only available if the NEKTAR_USE_MPI option is enabled in the CMake configuration.
• PETSc solvers use the PETSc library, giving access to a wide range of solvers and
preconditioners. See section 3.3.4.4 below for some additional information on how
32 Chapter 3 XML Session File
to use the PETSc solvers. This option is only available if the NEKTAR_USE_PETSC
option is enabled in the CMake configuration.
Both the Xxt and PETSc solvers are considered advanced and are under development –
either the direct or iterative solvers are recommended in most scenarios.
• The Full approach constructs the global system based on all of the degrees of
freedom contained within an element. For most of the Nektar++ solvers, this
technique is not recommended.
The GlobalSysSoln option is formed by combining the method of solution with the
approach: for example IterativeStaticCond or PETScMultiLevelStaticCond.
Preconditioners can be used in the iterative and PETSc solvers to reduce the number
of iterations needed to converge to the solution. There are a number of preconditioner
choices, the default being a simple Jacobi (or diagonal) preconditioner, which is enabled
by default. There are a number of choices that can be enabled through this parameter,
which are all generally discretisation and dimension-dependent:
3.3 Conditions 33
For a detailed discussion of the mathematical formulation of these options, see the
developer guide.
Configuration of PETSc options using its command-line interface dictates what matrix
storage, solver type and preconditioner should be used. This should be specified in a
.petscrc file inside your working directory, as command line options are not currently
passed through to PETSc to avoid conflict with Nektar++ options. As an example, to
select a GMRES solver using an algebraic multigrid preconditioner, and view the residual
convergence, one can use the configuration:
-ksp_monitor
-ksp_view
-ksp_type gmres
-pc_type gamg
-ksp_type preonly
-pc_type lu
-pc_factor_mat_solver_package mumps
34 Chapter 3 XML Session File
-mat_mumps_icntl_7 2
A final choice that can be specified is whether to use a shell approach. By default,
Nektar++ will construct a PETSc sparse matrix (or whatever matrix is specified on the
command line). This may, however, prove suboptimal for higher order discretisations.
In this case, you may choose to use the Nektar++ matrix-vector operators, which by
default use an assembly approach that can prove faster, by setting the PETScMatMult
SOLVERINFO option to Shell:
1 <I PROPERTY="PETScMatMult" VALUE="Shell" />
The downside to this approach is that you are now constrained to using one of the
Nektar++ preconditioners. However, this does give access to a wider range of Krylov
methods than are available inside Nektar++ for more advanced users.
For example,
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[2] </B>
3 <B ID="1"> C[3] </B>
4 </BOUNDARYREGIONS>
The second XML element defines, for each variable, the condition to impose on each
boundary region, and has the form,
1 <BOUNDARYCONDITIONS>
2 <REGION REF="[regionID]">
3 <[type1] VAR="[variable1]" VALUE="[expression1]" />
4 ...
5 <[typeN] VAR="[variableN]" VALUE="[expressionN]" />
6 </REGION>
7 ...
8 </BOUNDARYCONDITIONS>
There should be precisely one REGION entry for each B entry defined in the BOUNDARYREGION
section above. For example, to impose a Dirichlet condition on both variables for a
domain with a single region,
3.3 Conditions 35
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="u" VALUE="sin(PI*x)*cos(PI*y)" />
4 <D VAR="v" VALUE="sin(PI*x)*cos(PI*y)" />
5 </REGION>
6 </BOUNDARYCONDITIONS>
Boundary condition specifications may refer to any parameters defined in the session file.
The REF attribute corresponds to a defined boundary region. The tag used for each
variable specifies the type of boundary condition to enforce.
Example:
1 <!-- homogeneous condition -->
2 <D VAR="u" VALUE="0" />
3 <!-- inhomogeneous condition -->
4 <D VAR="u" VALUE="x^2+y^2+z^2" />
5 <!-- time-dependent condition -->
6 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="x+t" />
Example:
1 <!-- homogeneous condition -->
2 <N VAR="u" VALUE="0" />
3 <!-- inhomogeneous condition -->
4 <N VAR="u" VALUE="x^2+y^2+z^2" />
5 <!-- time-dependent condition -->
6 <N VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="x+t" />
7 <!-- high-order pressure boundary condition (for IncNavierStokesSolver) -->
8 <N VAR="u" USERDEFINEDTYPE="H" VALUE="0" />
36 Chapter 3 XML Session File
Example:
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B>
3 <B ID="1"> C[2] </B>
4 </BOUNDARYREGIONS>
5
6 <BOUNDARYCONDITIONS>
7 <REGION REF="0">
8 <P VAR="u" VALUE="[1]" />
9 </REGION>
10 <REGION REF="1">
11 <P VAR="u" VALUE="[0]" />
12 </REGION>
13 </BOUNDARYCONDITIONS>
Caveats:
• A periodic condition must be set for ”’both”’ boundary regions; simply specifying
a condition for region 0 or 1 in the above example is not enough.
• The order of the elements inside the composites defining periodic boundaries is
important. For example, if ‘C[0]‘ above is defined as edge IDs ‘0,5,4,3‘ and ‘C[1]‘ as
‘7,12,2,1‘ then edge 0 is periodic with edge 7, 5 with 12, and so on.
• For the above reason, the composites must also therefore be of the same size.
• In three dimensions, care must be taken to correctly align triangular faces which
are intended to be periodic. The top (degenerate) vertex should be aligned so that,
if the faces were connected, it would lie at the same point on both triangles.
Boundary conditions can also be loaded simultaneously from a file and from an analytic
expression. For example in the scenario where a spatial boundary condition is read from
a file, but needs to be modulated by a time-dependent analytic expression:
1 <REGION REF="1">
2 <D VAR="u" VALUE="USERDEFINEDTYPE="TimeDependent" VALUE="sin(PI*(x-t))"
3 FILE="bcsfromfiles_u_1.bc" />
4 </REGION>
In the case where both VALUE and FILE are specified, the values are multiplied together
to give the final value for the boundary condition.
3.3.6 Functions
Finally, multi-variable functions such as initial conditions and analytic solutions may
be specified for use in, or comparison with, simulations. These may be specified using
expressions ( <E> ) or imported from a file ( <F> ) using the Nektar++ FLD file format
1 <FUNCTION NAME="ExactSolution">
2 <E VAR="u" VALUE="sin(PI*x-advx*t))*cos(PI*(y-advy*t))" />
3 </FUNCTION>
4 <FUNCTION NAME="InitialConditions">
5 <F VAR="u" FILE="session.rst" />
6 </FUNCTION>
A restart file is a solution file (in other words an .fld renamed as .rst) where the field data
is specified. The expansion order used to generate the .rst file must be the same as that
for the simulation. .pts files contain scattered point data which needs to be interpolated
to the field. For further information on the file format and the different interpolation
schemes, see section 5.4.14. All filenames must be specified relative to the location of the
.xml file.
With the additional argument TIMEDEPENDENT="1" , different files can be loaded for
each timestep. The filenames are defined using boost::format syntax where the step
time is used as variable. For example, the function Baseflow would load the files
U0V0_1.00000000E-05.fld , U0V0_2.00000000E-05.fld and so on.
1 <FUNCTION NAME="Baseflow">
2 <F VAR="U0,V0" TIMEDEPENDENT="1"FILE="U0V0_%14.8E.fld"/>
3 </FUNCTION>
38 Chapter 3 XML Session File
For .pts files, the time consuming computation of interpolation weights is only performed
for the first timestep. The weights are stored and reused in all subsequent steps, which
is why all consecutive .pts files must use the same ordering, number and location of data
points.
Other examples of this input feature can be the insertion of a forcing term,
1 <FUNCTION NAME="BodyForce">
2 <E VAR="u" VALUE="0" />
3 <E VAR="v" VALUE="0" />
4 </FUNCTION>
5 <FUNCTION NAME="Forcing">
6 <E VAR="u" VALUE="-(Lambda + 2*PI*PI)*sin(PI*x)*sin(PI*y)" />
7 </FUNCTION>
• You must specify the same number of fields for both the variable, and after the
colon. For example, the following is not valid.
1 <FUNCTION NAME="AdvectionVelocity">
2 <F VAR="Vx,Vy,Vz" FILE="file.fld:u" />
3 </FUNCTION>
• This syntax is not valid with the wildcard operator * , so one cannot write for
example:
1 <FUNCTION NAME="AdvectionVelocity">
2 <F VAR="*" FILE="file.fld:u,v,w" />
3 </FUNCTION>
3.3 Conditions 39
1 <FUNCTION NAME="Baseflow">
2 <F VAR="U0,V0" TIMEDEPENDENT="1" FILE="U0V0_%14.8R.fld" />
3 </FUNCTION>
Section 3.6 provides the list of acceptable mathematical functions and other related
technical details.
then we need to specify the parameters which define the 1D harmonic expanson along the
z-axis, namely the homogeneous length (LZ) and the number of modes in the homogeneous
direction (HomModesZ). HomModesZ corresponds also to the number of quadrature
points in the homogenous direction, hence on the number of 2D planes discretized with a
specral/hp element method.
1 <PARAMETERS>
2 <P> TimeStep = 0.001 </P>
3 <P> NumSteps = 1000 </P>
4 <P> IO_CheckSteps = 100 </P>
5 <P> IO_InfoSteps = 10 </P>
6 <P> Kinvis = 0.025 </P>
7 <P> HomModesZ = 4 </P>
8 <P> LZ = 1.0 </P>
9 </PARAMETERS>
40 Chapter 3 XML Session File
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvectionDiffusion" />
3 <I PROPERTY="Projection" VALUE="Continuous"/>
4 <I PROPERTY="HOMOGENEOUS" VALUE="2D"/>
5 <I PROPERTY="DiffusionAdvancement" VALUE="Implicit"/>
6 <I PROPERTY="AdvectionAdvancement" VALUE="Explicit"/>
7 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2"/>
8 </SOLVERINFO>
9 <PARAMETERS>
10 <P> TimeStep = 0.001 </P>
11 <P> NumSteps = 200 </P>
12 <P> IO_CheckSteps = 200 </P>
13 <P> IO_InfoSteps = 10 </P>
14 <P> wavefreq = PI </P>
15 <P> epsilon = 1.0 </P>
16 <P> Lambda = 1.0 </P>
17 <P> HomModesY = 10 </P>
18 <P> LY = 6.5 </P>
19 <P> HomModesZ = 6 </P>
20 <P> LZ = 2.0 </P>
21 </PARAMETERS>
By default the opeartions associated with the harmonic expansions are performed with the
Matix-Vector-Multiplication (MVM) defined inside the code. The Fast Fourier Transofrm
(FFT) can be used to speed up the operations (if the FFTW library has been compiled
in ThirdParty, see the compilation instructions). To use the FFT routines we need just
to insert a flag in the solver information as below:
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvectionDiffusion" />
3 <I PROPERTY="Projection" VALUE="Continuous"/>
4 <I PROPERTY="HOMOGENEOUS" VALUE="2D"/>
5 <I PROPERTY="DiffusionAdvancement" VALUE="Implicit"/>
6 <I PROPERTY="AdvectionAdvancement" VALUE="Explicit"/>
7 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2"/>
8 <I PROPERTY="USEFFT" VALUE="FFTW"/>
9 </SOLVERINFO>
The number of homogenenous modes has to be even. The Quasi-3D apporach can be
created starting from a 2D mesh and adding one homogenous expansion or starting form
a 1D mesh and adding two homogeneous expansions. Not other options available. In
case of a 1D homogeneous extension, the homogeneous direction will be the z-axis. In
case of a 2D homogeneous extension, the homogeneous directions will be the y-axis and
the z-axis.
3.4 Filters 41
3.4 Filters
Filters are a method for calculating a variety of useful quantities from the field variables
as the solution evolves in time, such as time-averaged fields and extracting the field
variables at certain points inside the domain. Each filter is defined in a FILTER tag
inside a FILTERS block which lies in the main NEKTAR tag. In this section we give an
overview of the modules currently available and how to set up these filters in the session
file.
A filter has a name – in this case, FilterName – together with parameters which are set
to user-defined values. Each filter expects different parameter inputs, although where
functionality is similar, the same parameter names are shared between filter types for
consistency. Numerical filter parameters may be expressions and so may include session
parameters defined in the PARAMETERS section.
In the following we document the filters implemented. Note that some filters are solver-
specific and will therefore only work for a given subset of the available solvers.
Note
This filter is still at an experimental stage. Not all modules and options from
FieldConvert are supported.
As an example, consider:
1 <FILTER TYPE="FieldConvert">
2 <PARAM NAME="OutputFile">MyFile.vtu</PARAM>
3 <PARAM NAME="OutputFrequency">100</PARAM>
4 <PARAM NAME="Modules"> vorticity isocontour:fieldid=0:fieldvalue=0.1 </PARAM>
5 </FILTER>
This will create a sequence of files named MyFile_*_fc.vtu containing isocontours. The
result will be output every 100 time steps. Output directly to .vtu or .dat is currently
only supported for isocontours. In other cases, the output should be a .fld file.
This filter computes time-averaged fields for each variable defined in the session file.
Time averages are computed by either taking a snapshot of the field every timestep,
or alternatively at a user-defined number of timesteps N . An output is produced at
the end of the simulation into session_avg.fld , or alternatively every M timesteps as
defined by the user, into a sequence of files session_*_avg.fld , where * is replaced by
a counter. This latter option can be useful to observe statistical convergence rates of the
averaged variables.
This filter is derived from FieldConvert filter, and therefore support all parameters
available in that case. The following additional parameter is supported:
As an example, consider:
1 <FILTER TYPE="AverageFields">
2 <PARAM NAME="OutputFile">MyAverageField</PARAM>
3 <PARAM NAME="RestartFile">MyRestartAvg.fld</PARAM>
4 <PARAM NAME="OutputFrequency">100</PARAM>
5 <PARAM NAME="SampleFrequency"> 10 </PARAM>
6 </FILTER>
This will create a file named MyAverageField.fld averaging the instantaneous fields
every 10 time steps. The averaged field is however only output every 100 time steps.
3.4 Filters 43
The same parameters of the time-average filter are supported, with the output file in
the form session_*_movAvg.fld . In addition, either α or the time-constant τ must be
defined. They are related by:
ts
α=
τ + ts
where ts is the time interval between consecutive samples.
As an example, consider:
1 <FILTER TYPE="MovingAverage">
2 <PARAM NAME="OutputFile">MyMovingAverage</PARAM>
3 <PARAM NAME="OutputFrequency">100</PARAM>
4 <PARAM NAME="SampleFrequency"> 10 </PARAM>
5 <PARAM NAME="tau"> 0.1 </PARAM>
6 </FILTER>
This will create a file named MyMovingAverage_movAvg.fld with a moving average sam-
pled every 10 time steps. The averaged field is however only output every 100 time
steps.
Note
This filter is only supported for the incompressible Navier-Stokes solver.
This filter is an extended version of the time-average filter. It outputs not only the
time-average of the fields, but also the Reynolds stresses. The same parameters supported
in the time-average case can be used, for example:
1 <FILTER TYPE="ReynoldsStresses">
2 <PARAM NAME="OutputFile">MyAverageField</PARAM>
3 <PARAM NAME="RestartFile">MyAverageRst.fld</PARAM>
4 <PARAM NAME="OutputFrequency">100</PARAM>
5 <PARAM NAME="SampleFrequency"> 10 </PARAM>
6 </FILTER>
By default, this filter uses a simple average. Optionally, an exponential moving average
can be used, in which case the output contains the moving averages and the Reynolds
stresses calculated based on them. For example:
44 Chapter 3 XML Session File
1 <FILTER TYPE="ReynoldsStresses">
2 <PARAM NAME="OutputFile">MyAverageField</PARAM>
3 <PARAM NAME="MovingAverage">true</PARAM>
4 <PARAM NAME="OutputFrequency">100</PARAM>
5 <PARAM NAME="SampleFrequency"> 10 </PARAM>
6 <PARAM NAME="alpha"> 0.01 </PARAM>
7 </FILTER>
Note
This functionality is equivalent to setting the IO_CheckSteps parameter in the
session file.
For example, to output the fields every 100 timesteps we can specify:
1 <FILTER TYPE="Checkpoint">
2 <PARAM NAME="OutputFile">IntermediateFields</PARAM>
3 <PARAM NAME="OutputFrequency">100</PARAM>
4 </FILTER>
lines are created at the top of the file containing the location of the history points and
the order of the variables.
For example, to output the value of the solution fields at three points (1, 0.5, 0), (2, 0.5, 0)
and (3, 0.5, 0) into a file TimeValues.his every 10 timesteps, we use the syntax:
1 <FILTER TYPE="HistoryPoints">
2 <PARAM NAME="OutputFile">TimeValues</PARAM>
3 <PARAM NAME="OutputFrequency">10</PARAM>
4 <PARAM NAME="Points">
5 1 0.5 0
6 2 0.5 0
7 3 0.5 0
8 </PARAM>
9 </FILTER>
3.4.7 ThresholdMax
The threshold value filter writes a field output containing a variable m, defined by the
time at which the selected variable first exceeds a specified threshold value. The default
name of the output file is the name of the session with the suffix _max.fld . Thresholding
is applied based on the first variable listed in the session by default.
1 <FILTER TYPE="Energy1D">
2 <PARAM NAME="OutputFile">EnergyFile</PARAM>
3 <PARAM NAME="OutputFrequency">10</PARAM>
4 </FILTER>
Note
This filter is only supported for the incompressible Navier-Stokes solver.
This filter calculates the time-evolution of the kinetic energy. In the case of a two- or
three-dimensional simulation this is defined as
1
Z
Ek (t) = kuk2 dx
2 Ω
Note that in this case, each component of ûk is a complex number and therefore
N = HomModesZ /2 lines are output for each timestep. This is a particularly useful tool
in examining turbulent and transitional flows which use the homogeneous extension. In
either case, the resulting output is written into a file called session.mdl by default.
Note
This filter is only supported for the incompressible Navier-Stokes solver.
This filter evaluates the aerodynamic forces along a specific surface. The forces are
projected along the Cartesian axes and the pressure and viscous contributions are
computed in each direction.
During the execution a file named DragLift.frc will be created and the value of the
aerodynamic forces on boundaries 1 and 2, defined in the GEOMETRY section, will be
output every 10 time steps.
Note
This filter is only supported for the incompressible and compressible Navier-
Stokes solvers in three dimensions.
The purpose of this filter is to calculate the kinetic energy and enstrophy
1 1
Z Z
2
Ek = kuk dx, E= kωk2 dx
2µ(Ω) Ω 2µ(Ω) Ω
3.5 Forcing 49
where µ(Ω) is the volume of the domain Ω. This produces a file containing the time-
evolution of the kinetic energy and enstrophy fields. By default this file is called
session.eny where session is the session name.
3.5 Forcing
An optional section of the file allows forcing functions to be defined. These are enclosed
in the FORCING tag. The forcing type is enclosed within the FORCE tag and expressed in
the file as:
1 <FORCE TYPE="[NAME]">
2 ...
3 </FORCE>
• "Absorption"
• "Body"
• "Programmatic"
• "Noise"
3.5.1 Absorption
This force type allows the user to apply an absorption layer (essentially a porous region)
anywhere in the domain. The user may also specify a velocity profile to be imposed
at the start of this layer, and in the event of a time-dependent simulation, this profile
can be modulated with a time-dependent function. These velocity functions and the
function defining the region in which to apply the absorption layer are expressed in the
CONDITIONS section, however the name of these functions are defined here by the COEFF
50 Chapter 3 XML Session File
tag for the layer, the REFFLOW tag for the velocity profile, and the REFFLOWTIME for the
time-dependent function.
1 <FORCE TYPE="Absorption">
2 <COEFF> [FUNCTION NAME] <COEFF/>
3 <REFFLOW> [FUNCTION NAME] <REFFLOW/>
4 <REFFLOWTIME> [FUNCTION NAME] <REFFLOWTIME/>
5 </FORCE>
3.5.2 Body
This force type specifies the name of a body forcing function expressed in the CONDITIONS
section.
1 <FORCE TYPE="Body">
2 <BODYFORCE> [FUNCTION NAME] <BODYFORCE/>
3 </FORCE>
3.5.3 Programmatic
This force type allows a forcing function to be applied directly within the code, thus it
has no associated function.
1 <FORCE TYPE="Programmatic">
2 </FORCE>
3.5.4 Noise
This force type allows the user to specify the magnitude of a white noise force. Optional
arguments can also be used to define the frequency in time steps to recompute the noise
(default is never) and the number of time steps to apply the noise (default is the entire
simulation).
1 <FORCE TYPE="Noise">
2 <WHITENOISE> [VALUE] <WHITENOISE/>
3 <!-- Optional arguments -->
4 <UPDATEFREQ> [VALUE] <UPDATEFREQ/>
5 <NSTEPS> [VALUE] <NSTEPS/>
6 </FORCE>
The tags above declare analytic expressions as well as link them to one of the field
variables declared in <EXPANSIONS> section. For example, the declaration
1 <D VAR="u" VALUE="sin(PI*x)*cos(PI*y)" />
Enforcing the same velocity profile at multiple boundary regions and/or field variables
results in repeated re-declarations of a corresponding analytic expression. Currently
one cannot directly link a boundary condition declaration with an analytic expression
uniquely specified somewhere else, e.g. in the <FUNCTION> subsection. However this
duplication does not affect an overall computational performance.
Internally, the library uses 3D global coordinate space regardless of problem dimension.
Internal global coordinate system has natural basis (1,0,0),(0,1,0),(0,0,1) with coordinates
”’x”’,”’y”’ and ”’z”’. In other words, variables ”’x”’,”’y”’ and ”’z”’ are considered to be
first, second and third coordinates of a point (”’x”’,”’y”’,”’z”’).
Declarations of problem spatial variables do not exist in the current XML file format.
Even though field variables are declarable as in the following code snippet,
1 <VARIABLES>
2 <V ID="0"> u </V>
3 <V ID="1"> v </V>
4 </VARIABLES>
there are no analogous tags for space variables. However an attribute SPACE of
<GEOMETRY> section tag declares the dimension of problem space. For example,
1 <GEOMETRY DIM="1" SPACE="2"> ...
2 </GEOMETRY>
52 Chapter 3 XML Session File
specifies 1D flow within 2D problem space. The number of spatial variables presented in
expression declaration should match space dimension declared via <GEOMETRY> section
tag.
The library assumes the problem space also has natural basis and spatial coordinates
have names ”’x”’,”’y”’ and”’z”’.
Problem space is naturally embedded into the global coordinate space: each point of
Currently, there is no way to describe rotations and translations of problem space relative
to the global coordinate system.
The list of variables allowed in analytic expressions depends on the problem dimension:
• For 1D problem analytic expressions must make use of variable ”’x”’ only;
• For 2D problem analytic expressions should make use of variables ”’x”’ and ”’y”’.
• 3D problems may use variables ”’x”’, ”’y”’ and ”’z”’ in their analytic expressions.
Here one declares 1D problem, so Nektar++ library assumes spacial variable is ”’x”’.
At the same time, an expression sin(y) is perfectly valid on its own, but since it does
not depend on ”’x”’, it will be evaluated to constant sin(−9999) regardless of degree of
freedom under consideration.
Variable ”’t”’ represents time dependence within analytic expressions. The boundary con-
dition declarations need to add an additional property USERDEFINEDTYPE="TimeDependent"
in order to flag time dependency to the library.
• mathematical constants
54 Chapter 3 XML Session File
• boolean comparison operations <, <=, >, >=, == evaluate their sub-expressions
to real values 0.0 or 1.0.
Identifier Meaning
abs(x) absolute value |x|
asin(x) inverse sine arcsin x
acos(x) inverse cosine arccos x
ang(x,y) computes polar coordinate θ = arctan(y/x) from (x, y)
atan(x) inverse tangent arctan x
atan2(y,x) inverse tangent function (used in polar transformations)
ceil(x) round up to nearest integer dxe
cos(x) cosine cos x
cosh(x) hyperbolic cosine cosh x
exp(x) exponential ex
fabs(x) absolute value (equivalent to abs)
floor(x) rounding down bxc
log(x) logarithm base e, ln x = log x
log10(x) logarithm base 10, log10 x p
rad(x,y) computes polar coordinate r = x2 + y 2 from (x, y)
sin(x) sine sin x
sinh(x) hyperbolic sine sinh x
√
sqrt(x) square root x
tan(x) tangent tan x
tanh(x) hyperbolic tangent tanh x
3.6.1.3 Examples
Some straightforward examples include
• evaluation to a number.
Parsing of analytic expressions with their partial evaluation take place at the time of
setting the run up (reading an XML file). Each analytic expression, after being pre-
processed, is stored internally and quickly retrieved when it turns to evaluation at given
spatial-time point(s). This allows to perform evaluation of expressions at a large number
of spacial points with minimal setup costs.
• constants, numbers and their combinations with arithmetic, analytic and comparison
operators are pre-evaluated,
Grouping predefined constants and numbers together helps. Its useful to put brackets to
be sure your constants do not run out and become factors of some variables or parameters.
Expression evaluator does not do any clever simplifications of input expressions, which is
clear from example above (there is no point in double negation). The following subsection
addresses the simplification strategy.
3.6 Analytic Expressions 57
Some operations are more computationally expensive than others. In an order of increasing
complexity:
• ˆ, sqrt, exp, log, log10, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan .
For example,
If any simplifying identity applies to input expression, it may worth applying it, provided
it minimises the complexity of evaluation. Computer algebra systems may help.
58
Chapter 4
NekMesh
• allow foreign mesh file formats to be converted into Nektar++’s XML format;
• aide in the generation of high-order meshes through a series of supplied processing
modules.
Note
NekMesh replaces a previous utility called MeshConvert. This change is to
reflect the fact that the program no longer only converts and manipulates
meshes but can now also generate them from a CAD definition. This mesh
generator is in an early stage of development and as such is disabled by default.
For the time being those not using the mesh generator can use NekMesh as they
would have used MeshConvert, none of the functionality or methodology has
changed.
There is also some limited support for other output formats. We begin by running
through a basic example to show how a mesh can be converted from the widely-used
mesh-generator Gmsh to the XML file format.
Note
The default since January 2016 is to output the .xml files in a compressed form
where the VERTEX, EDGES, FACES, ELEMENTS and CURVED information
is compressed into binary format which is then converted into base64. This is
identified for each section by the attribute COMPRESSED="B64Z-LittleEndian” .
To output in ascii format add the module option “:xml:uncompress” to the
.xml file, i.e.
NekMesh file.msh newfile.xml:xml:uncompress
59
60 Chapter 4 NekMesh
Whilst a full tutorial on Gmsh is far beyond the scope of this document, note the use
of the Recombine argument. This allows us to generate a structured hexahedral mesh;
remove the first Recombine to generate a prismatic mesh and both occurances to generate
a tetrahedral mesh. Increasing the Layers numbers refines the mesh in the radial and
azimuthal direction respectively.
Figure 4.1 Geometry definition in Gmsh (left) and resulting high-order mesh visualised in
ParaView (right).
In order for us to use the mesh, we need to define the physical surfaces which correspond
to the inflow, outflow and walls so that we can set appropriate boundary conditions.
The numbering resulting from the extrusions in this case is not straightforward. In the
graphical interface, select Geometry > Physical Groups > Add > Surface , and then
hover over each of the surfaces which are shown by the dashed gray lines. The numbering
will be revealed in the toolbar underneath the geometry as a ruled surface. In this case:
We also need to define the physical volumes, which can be done in a similar fashion. For
this example, there is only one volume having ID 1. Adding these groups to the end of
the .geo file is very straightforward:
1 Physical Volume(0) = {1};
2 Physical Surface(1)= {7,8,28,29};
3 Physical Surface(2) = {16};
4 Physical Surface(3) = {24};
Either choose the option File->Save Mesh or, assuming this is saved in a file named
test.geo , run the command
gmsh -3 test.geo
which will produce the resulting MSH file test.msh . One can generate a high-order
mesh by specifying the order on the command line, for example
will generate a sixth-order mesh. Note that you will need to use a current version of
Gmsh in order to do this, most likely from subversion.
Assuming that you have compiled Nektar++ according to the compilation instructions,
run the command
Note
This file contains only the geometry definition (and a default EXPANSIONS
definition). In order to use this mesh, a CONDITIONS section must be supplied
detailing the solver and parameters to use.
To validate the mesh visually, we can use a utility such as Paraview or VisIt. To do this,
run the command
XmlToVtk test.xml
62 Chapter 4 NekMesh
It is possible that, when the high-order information was inserted into the mesh by Gmsh,
invalid elements are generated which self intersect. In this case, the Jacobian of the
mapping defining the curvature will have negative regions, which will generate warnings
such as:
This tells you the element ID that is invalid, and the ID of the first vertex of the element.
Whilst a resulting simulation may run, the results may not be valid because of this
problem, or excessively large amounts of time may be needed to solve the resulting linear
system.
The figure below depicts how these might be coupled together to form a pipeline: On the
Process modules can also have parameters passed to them, that can take arguments, or
not.
Available classes:
Input: dat:
Reads Tecplot polyhedron ascii format converted from Star CCM (.dat).
...
and then to see the options for a particular module, use the -p command line argument:
Note
Module names change when you use the -p option. Input modules should be
preceded by in: , processing modules by proc: and output modules by out: .
Input and output modules use file extension names to determine the correct module to
use. Not every module is capable of reading high-order information, where it exists. The
table below indicates support currently implemented.
64 Chapter 4 NekMesh
Note that you can override the module used on the command line. For example, Semtex
session files rarely have extensions. So for a session called pipe-3d we can convert this
using the syntax
Typically, mesh generators allow physical surfaces and volumes to contain many element
types; for example a cube could be constructed from a mixture of hexes and prisms. In
Nektar++, a composite can only contain a single element type. Whilst the converter will
attempt to preserve the numbering of composites from the original mesh type, sometimes
a renumbering will occur when a domain contains many element types. For example, for
a domain with the tag 150 containing quadrilaterals and triangles, the Gmsh reader
will print a notification along the lines of:
The resulting file therefore has two composites of IDs 150 and 151 respectively, con-
taining the triangular and quadrilateral elements of the original mesh.
Note that for both Gmsh and VTK, it is highly likely that you will need to experiment
with the source code in order to successfully generate meshes since robustness is not
guaranteed.
The default for xml is into binary data which has been converted into base64. If you
wish to see an ascii output you need to specify the output module option uncompress
by executing:
Finally, both the Gmsh and Nektar++ output modules support an order parameter,
which allows you to generate a mesh of a uniform polynomial order. This is used in the
same manner as the above, so that the command
will generate an order 7 Gmsh mesh. In the rest of these subsections, we discuss the
various processing modules available within NekMesh.
As an example, we can extract composite surfaces 2 and 3-5 from a mesh using the
extract module:
If you also wish to have the boundaries of the extracted surface detected add the
detectbnd option
To get a detailed list of elements which have negative Jacobians, one may use the list
option:
and to extract the elements for the purposes of visualisation within the domain, use the
extract boolean parameter:
To turn off curvature associated with negative jacobians one can try to use the linearise
module:
This option will remove all high order curvature on all element types with singular
jacobians.
Spherigons work through the use of surface normals, where in this sense ‘surface’ refers
to the underlying geometry. If we have either the exact or approximate surface normal
at each given vertex, spherigon patches approximate the edges connecting two vertices
by arcs of a circle. In NekMesh we can either approximate the surface normals from the
linear elements which connect to each vertex (this is done by default), or supply a file
which gives the surface normals.
To apply spherigon patches on two connected surfaces 11 and 12 use the following
command:
NekMesh -m spherigon:surf=11,12 \
MeshWithStraighEdges.xml MeshWithSpherigons.xml
If the two surfaces "11" and "12" are not connected, or connect at a sharp edge which is
C 0 continuous but not C 1 smooth, use two separate instances of the spherigon module.
This is to avoid the approximated surface normals being incorrect at the edge.
If you have a high-resolution mesh of the surfaces 11 and 12 in ply format it can be
used to improve the normal definition of the spherigons. Run:
NekMesh -m spherigon:surf=11,12:usenormalfile=Surf_11-12_Mesh.ply \
MeshWithStraighEdges.xml MeshWithSpherigons.xml
This can be useful, for example, when meshing the Leading edge of an airfoil. Starting
from a linear mesh (left figure) the spherigon patches curve the surface elements producing
leading edge closer to the underlying geometry:
To counteract this issue, NekMesh has a periodic alignment module which attempts
to identify pairs of mutually periodic edges. Given two surfaces surf1 and surf2 ,
which for example correspond to the physical surface IDs specified in Gmsh, and an axis
which defines the periodicity direction, the following command attempts to reorder the
composites:
NekMesh -m peralign:surf1=11:surf2=12:dir=y \
-m peralign:surf1=13:surf2=14:dir=z Mesh.xml Mesh_aligned.xml
68 Chapter 4 NekMesh
Figure 4.3 (a) Leading edge without spherigons, (b) Leading edge with spherigons
Here the surfaces with IDs 11 and 12 will be aligned normal to the y-axis and the surfaces
13 and 14 will be aligned normal to the z-axis.
Note that this command cannot perform magic – it assumes that any given edge or face
lying on the surface is periodic with another face on the opposing surface, that there are
the same number of elements on both surfaces, and the corresponding edge or face is the
same size and shape but translated along the appropriate axis.
In 3D, where prismatic or tetrahedral elements are connected to one or both of the
surfaces, additional logic is needed to guarantee connectivity in the XML file. In this
case we append the orient parameter:
Note
One of the present shortcomings of orient is that it throws away all high-order
information and works only on the linear element. This can be gotten around
if you are just doing e.g. spherigon patches by running this peralign module
before the spherigon module.
Given n layers, and a ratio r which defines the relative heights of elements in different
layers, the method works by defining a geometric progression of points
2(1 − r)
xk = xk−1 + ark , a=
1 − rn+1
in the standard segment [−1, 1]. These are then projected into the coarse elements to
construct a sequence of increasingly refined elements, as depicted in figure 4.4.
∆n χe (ξ)
ξ3
ξ1 ξ2
Figure 4.4 Splitting Ωst and applying the mapping χe to obtain a high-order layer of prisms
from the macro-element.
To split a prism boundary layer on surface 11 into 3 layers with a growth rate of 2 and 7
integration points per element use the following command:
Note
You can also use an expression in terms of coordinates (x, y, z) for r to make
the ratio spatially varying; e.g. r=sin(x) . In this case the function should be
sufficiently smooth to prevent the elements self-intersecting.
Figure 4.5 (a) LE with Spherigons but only one prism layer for resolving the boundary layer,
(b) LE with Spherigons with 3 growing layers of prisms for better resolving the boundary layer.
• surf : Surface on which to apply curvature. This should be the outer surface of
the cylinder.
Note
The module could also be used to apply curvature along the interior of a hollow
cylinder. However, there are no checks to ensure the resulting elements are not
self-intersecting.
4.4.9 Linearisation
The ability to remove all the high-order information in a mesh can be useful at times
when mesh generation is tricky or impossible in the presence of curvature
The output will contain only the linear mesh information, all curved information is
removed. Alternatively
attempts to remove curvature from elements only where necessary. This is a simple
algorithm that removes curvature from invalid elements and repeats until all elements
are valid. Either all or invalid must be specified.
• prismonly : consider only prisms when removing curvature. This is useful in the
presence of a prismatic boundary layer.
There are no configuration options for this module, as it is highly specific to a certain
class of meshes.
Note
This module makes no attempt to apply the curvature to the interior of the
domain. Elements must therefore be coarse in order to prevent self-intersection.
If a boundary layer is required, one option is to use this module in combination
with the splitting module described earlier.
This module should be added to the module chain if the user suspects there may be a
mesh issue. The module will print a warning if there is a connectivity error.
length which determines how long the z extrusion will be and layers, the number of
elements in the z direction.
It works by considering the boundary (curved) mesh entities to be fixed and moving the
interior nodes to a lower energy configuration. This new configuration in most scenarios
is a higher quality mesh. The energy is evaluated depending on which functional is
chosen. We find hyperleastic to be the most reliable but it can also model the mesh
and a linearelastic solid as well as functionals based on the Winslow equation and the
distortion method proposed by Roca et al. [14].
There are a large number of options which can be viewed using the help function but the
basic usage is:
4.5 Mesh generation 73
The most critical dependancy of the mesh generation routines is OpenCascade which
powers the CAD engine. NekMesh is capable of finding and using existing installations
of OpenCascade 6.8 or OCE 0.17. If either are not present on the installation machine
NekMesh will install OCE 0.17 from source. This is a very big installation and will take
some time so it is advised that the user ensures OpenCascade is availble on the machine.
As with all tasks within NekMesh the mesh generation capability exists as its own separate
module which is of type Input. Due to the vast amount of code associated with the
generation of high-order meshes and the comparatively small nature of modules in the
NekMesh program a new library has been created for Nektar++ called NekMeshUtils,
which contains all the core routines and classes for the NekMesh mesh format as well as a
series of classes for the generation of meshes. This library also contains the CAD API
for Nektar++ which is used to generate the meshes.
4.5.1 Methodology
This section outlines the approach taken by NekMesh to generate high-order meshes. To
simplify the sometimes very complicated high-order mesh generation processes in other
programs, NekMesh executes all the stages required to produce a high-order mesh in one
single pipeline which once started requires no interaction from the user. In broad terms
these stages are:
generators included in commercial packages this linear mesh generator takes the quite
unconventional and more historic approach in building the mesh in a bottom up fashion
from 0D to 3D. Using this approach means it is possible to guarantee a level of boundary
conformity which direct to 3D approaches cannot at the desired level of coarseness. In
this approach, first mesh nodes are placed on the vertices of the CAD model (0D), then
the curves in the CAD are meshed in 1D using the vertex nodes as boundaries, then the
surfaces are meshed in their 2D parameter plane using the curve meshes as boundaries
and finally the 3D volume is meshed using the surface mesh as the boundary to complete
the linear mesh. In NekMesh, to achieve greater robustness, the 2D mesh generation
library Triangle is used and the TetGen library for the 3D. Both of which are highly
developed Delaunay based mesh generators. As with all additional libraies in Nektar++
these are automatically downloaded and installed if needed.
An alternative to this is to use the linear elastic solver within Nektar++ to deform the
mesh interior entities. Its use is very computationally expensive, as with all PDE solvers,
and is also not particularly robust. It can be used with the set of commands outlined in
the FieldConvert deform and displacement modules and the section on the Linear Elastic
Solver.
The final and possibly most useful approach is to use the Variational Optimsation module
to curve the interior of the domain. This is explained in 4.4.15.
where session.mcf is a mesh configuration file which contains all the options and parameters
needed for mesh generation. Below is an example of a simple example which generates a
2D NACA wing.
1 <NEKTAR>
2 <MESHING>
3
4 <INFORMATION>
5 <I PROPERTY="CADFile" VALUE="6412" />
6 <I PROPERTY="MeshType" VALUE="2D" />
7 </INFORMATION>
8
9 <PARAMETERS>
10 <P PARAM="MinDelta" VALUE="0.01" />
11 <P PARAM="MaxDelta" VALUE="1.0" />
12 <P PARAM="EPS" VALUE="0.1" />
13 <P PARAM="Order" VALUE="4" />
14
15 <!-- 2D Domain !-->
16 <P PARAM="Xmin" VALUE="-1.0" />
17 <P PARAM="Ymin" VALUE="-2.0" />
18 <P PARAM="Xmax" VALUE="3.0" />
19 <P PARAM="Ymax" VALUE="2.0" />
20 <P PARAM="AOA" VALUE="15.0" />
21 </PARAMETERS>
22
23 </MESHING>
24 </NEKTAR>
In all cases the mesh generator needs two pieces of information and four parameters. It
firstly needs to know the CAD file with which to work. In the example above this is
listed as a 4 digit number, this is because the mesh generator is equiped with a NACA
wing generator. In all other cases this parameter would be a STEP file. Secondly, what
type of mesh to make, the options are EULER and BL for 3D meshes and 2D and
2DBL for 2D meshes. In the case of EULER the mesh will be made with only tetrahedra.
4.5 Mesh generation 77
For BL the mesh generator will attempt to insert a single macro prism layer onto the
geometry surface. This option requires additional parameters. This is similar for the 2D
scenarios. The automatic mesh specification system requires three parameters to build
the specification of a smooth, curvature refined mesh. Firstly MinDelta which is the
size of the smallest element to be found in the final mesh. Secondly MaxDelta which
is the maximum size of an element in the mesh and lastly EPS which is a sensitivity
to curvature parameter with a range 1 ≥ ε > 0 which heuristically controls the size of
the elements for a given degree of curvature on the geometric surface. Order is the
polynomial order of the mesh to be generated. When generating a boundary layer mesh
a few additional parameters must be given. An example is shown.
1 <NEKTAR>
2 <MESHING>
3
4 <INFORMATION>
5 <I PROPERTY="CADFile" VALUE="6412" />
6 <I PROPERTY="MeshType" VALUE="2DBL" />
7 </INFORMATION>
8
9 <PARAMETERS>
10 <P PARAM="MinDelta" VALUE="0.01" />
11 <P PARAM="MaxDelta" VALUE="1.0" />
12 <P PARAM="EPS" VALUE="0.1" />
13 <P PARAM="Order" VALUE="4" />
14
15 <!-- Boundary layer !-->
16 <P PARAM="BLSurfs" VALUE="5,6" />
17 <P PARAM="BLThick" VALUE="0.03" />
18 <P PARAM="BLLayers" VALUE="4" />
19 <P PARAM="BLProg" VALUE="2.0" />
20
21 <!-- 2D Domain !-->
22 <P PARAM="Xmin" VALUE="-1.0" />
23 <P PARAM="Ymin" VALUE="-2.0" />
24 <P PARAM="Xmax" VALUE="3.0" />
25 <P PARAM="Ymax" VALUE="2.0" />
26 <P PARAM="AOA" VALUE="15.0" />
27 </PARAMETERS>
28
29 </MESHING>
30 </NEKTAR>
A list of the CAD surfaces which will have a prism generated on is described by BLSurfs
and the thickness of the boundary to aim for is BLThick . The mesh generator has been
created with a range of error messages to aid in debugging. If you encounter an error
and the mesh generator fails, run NekMesh with the verbose -v flag and send the stdout
with the .mcf and .step files to m.turner14@imperial.ac.uk . Without the feedback this
functionality cannot improve.
Chapter 5
FieldConvert
FieldConvert is a utility embedded in Nektar++ with the primary aim of allowing the
user to convert the Nektar++ output binary files (.chk and .fld) into a format which
can be read by two common visualisation softwares: Paraview/VisIt (.vtu format) or
Tecplot/VisIt (.dat or .plt formats). FieldConvert also allows the user to manipulate the
Nektar++ output binary files by using some additional modules which can be called with
the option -m which stands for m odule. Note that another flag, -r (which stand for
r ange) allows the user to specify a sub-range of the domain on which the conversion or
manipulation of the Nektar++ output binary files will be performed.
5.1 Convert .fld / .chk files into Paraview, VisIt or Tecplot format
To convert the Nektar++ output binary files (.chk and .fld) into a format which can be
read by two common visualisation softwares: Paraview (.vtu format), VisIt (.vtu format)
or Tecplot (.dat or .plt format) the user can run the following commands:
78
5.2 Convert field files between XML and HDF5 format 79
Tip
Note that the session file is also supported in its compressed format
test.xml.gz .
When Nektar++ is compiled with HDF5 support, solvers can select the format used for
output of .fld files. FieldConvert can be used to convert between these formats using
an option on the .fld output module. For example, if in.fld is stored in the default
XML format, it can be converted to HDF5 format by issuing the command
The Fieldconvert range option -r allows the user to specify a sub-range of the mesh
(computational domain) by using an additional flag, -r (which stands for r ange and
either convert or manipulate the Nektar++ output binary files. Taking as an example
the conversion of the Nektar++ binary files (.chk or .fld) shown before and wanting to
convert just the 2D sub-range defined by −2 ≤ x ≤ 3, −1 ≤ y ≤ 2 the additional flag
-r can be used as follows:
where -r defines the range option of the FieldConvert utility, the two first numbers
define the range in x direction and the the third and fourth number specify the y range.
A sub-range of a 3D domain can also be specified. For doing so, a third set of numbers
has to be provided to define the z range.
80 Chapter 5 FieldConvert
FieldConvert allows the user to manipulate the Nektar++ output binary files (.chk and
.fld) by using the flag -m (which stands for m odule).. Specifically, FieldConvert has
these additional functionalities
5. combineAvg : Combine two Nektar++ binary output (.chk or .fld) field file contain-
ing averages of fields (and possibly also Reynolds stresses) into single file;
6. concatenate : Concatenate a Nektar++ binary output (.chk or .fld) field file into
single file;
11. innerproduct : take the inner product between one or a series of fields with another
field (or series of fields).
14. interppoints : Interpolates a set of points to another, requires fromfld and fromxml
to be defined, a line or plane of points can be defined;
17. qualitymetric : Evaluate a quality metric of the underlying mesh to show mesh
quality;
19. pointdatatofld : Given discrete data at quadrature points project them onto an
expansion basis and output fld file;
20. printfldnorms : Print L2 and LInf norms to stdout;
23. shear : Computes time-averaged shear stress metrics: TAWSS, OSI, transWSS,
TAAFI, TACFI, WSSG;
24. surfdistance : Computes height of a prismatic boundary layer mesh and projects
onto the surface (for e.g. y + calculation).
25. vorticity : Computes the vorticity field.
26. wss : Computes wall shear stress field.
FieldConvert -l
where the file test-C0Proj.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
The option localtoglobalmap will do a global gather of the coefficients and then scatter
them back to the local elements. This will replace the coefficients shared between two
elements with the coefficients of one of the elements (most likely the one with the highest
id). Although not a formal projection it does not require any matrix inverse and so is
very cheap to perform.
The option usexmlbcs will enforce the boundary conditions specified in the input xml
file.
The option helmsmoothing=L will perform a Helmholtz smoothing projection of the form
2 ! 2
2π 2π
2
∇ + ûnew = ûorig
L L
82 Chapter 5 FieldConvert
which can be interpreted in a Fourier sense as smoothing the original coefficients using a
low pass filter of the form
1 2π
ûnew
k = 2 2 ûorig
k where K0 =
(1 + k /K0 ) L
and so L is the length scale below which the coefficients values are halved or more. Since
this form of the Helmholtz operator is not possitive definite, currently a direct solver is
necessary and so this smoother is mainly of use in two-dimensions.
where the file test-QCrit.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
In this case, we have produced a Tecplot file which contains the mesh and a variable that
contains the composite ID. To assist in boundary identification, the input file mesh.xml
should be a surface XML file that can be obtained through the NekMesh extract module
(see section 4.4.3).
In this case we use it in conjunction with the command scale which multiply the values
of a given .fld file by a constant value . file1.fld is the file multiplied by value ,
file1.xml is the associated session file, file2.fld is the .fld file which is summed to
file1.fld and finally file3.fld is the output which contain the sum of the two .fld
files. file3.fld can be processed in a similar way as described in section 5.1 to visualise
the result either in Tecplot, Paraview or VisIt.
5.4 FieldConvert modules -m 83
5.4.5 Combine two .fld files containing time averages: combineAvg module
To combine two .fld files obtained through the AverageFields or ReynoldsStresses filters,
use the combineAvg module of FieldConvert
file3.fld can be processed in a similar way as described in section 5.1 to visualise the
result either in Tecplot, Paraview or VisIt.
where the file file-conc.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
or
Note
Currently this option is only set up for triangles, quadrilaterals, tetrahedrons
and prisms.
The option bnd specifies which boundary region to extract. Note this is different to
NekMesh where the parameter surf is specified and corresponds to composites rather
boundaries. If bnd is not provided, all boundaries are extracted to different fields. The
fldtoboundary is an optional command argument which copies the expansion of test.fld
into the boundary region before outputting the .fld file. This option is on by default.
If it turned off using fldtoboundary=0 the extraction will only evaluate the boundary
condition from the xml file. The output will be placed in test-boundary-b2.fld. If more
than one boundary region is specified the extension -b0.fld, -b1.fld etc will be outputted.
To process this file you will need an xml file of the same region. This can be generated
using the command:
The surface to be extracted in this command is the composite number and so needs to
correspond to the boundary region of interest. Finally to process the surface file one can
use
This will obviously generate a Tecplot output if a .dat file is specified as last argument.
A .vtu extension will produce a Paraview or VisIt output.
where the file file-grad.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
If the option wavespace is used, the Fourier coefficients corresponding to planeid are
obtained. The command in this case is:
5.4 FieldConvert modules -m 85
The output file file-plane.fld can be processed in a similar way as described in section
5.1 to visualise it either in Tecplot or in Paraview.
The number of modes in the resulting field can be chosen using the command-line
parameter output-points-hom-z . Note that the output for this module should always
be a .fld file and this should not be used in combination with other modules using a
single command.
This command will load the file1.fld and file2.fld assuming they both are spatially
defined by files.xml and determine the inner product of these fields. The input option
fromfld must therefore be specified in this module.
Optional arguments for this module are fields which allow you to specify the fields
that you wish to use for the inner product, i.e.
will only take the inner product between the variables 0,1 and 2 in the two fields files.
The default is to take the inner product between all fields provided.
Additional options include multifldids and allfromflds which allow for a series of
fields to be evaluated in the following manner:
86 Chapter 5 FieldConvert
FieldConvert -m innerproduct:fromfld=file1.fld:multifldids=’’0-3’’\
file2.xml file2.fld out.stdout
will take the inner product between a file names field1_0.fld, field1_1.fld, field1_2.fld
and field1_3.fld with respect to field2.fld.
FieldConvert -m innerproduct:fromfld=file1.fld:multifldids=’’0-3’’:\
allfromflds file2.xml file2.fld out.stdout
Will take the inner product of all the from fields, i.e. field1_0.fld,field1_1.fld,field1_2.fld
and field1_3.fld with respect to each other. This option essentially ignores file2.fld. Only
the unique inner products are evaluated so if four from fields are given only the related
trianuglar number 4 × 5/2 = 10 of inner products are evaluated.
FieldConvert -m interpfield:fromxml=file1.xml:fromfld=file1.fld \
file2.xml file2.fld
This command will interpolate the field defined by file1.xml and file1.fld to the
new mesh defined in file2.xml and output it to file2.fld . The fromxml and
fromfld must be specified in this module. In addition there are two optional ar-
guments clamptolowervalue and clamptouppervalue which clamp the interpolation
between these two values. Their default values are -10,000,000 and 10,000,000.
Tip
This module can run in parallel where the speed is increased not only due to
using more cores but also, since the mesh is split into smaller sub-domains, the
search method currently adopted performs faster.
This command will interpolate the data from file1.pts to the mesh and expansions
defined in file1.xml and output the field to file1.fld . The file file.pts is of the
form:
1 <?xml version="1.0" encoding="utf-8" ?>
2 <NEKTAR>
3 <POINTS DIM="1" FIELDS="a,b,c">
4 1.0000 -1.0000 1.0000 -0.7778
5 2.0000 -0.9798 0.9798 -0.7980
6 3.0000 -0.9596 0.9596 -0.8182
7 4.0000 -0.9394 0.9394 -0.8384
8 </POINTS>
9 </NEKTAR>
where DIM="1" FIELDS="a,b,c specifies that the field is one-dimensional and contains
three variables, a, b, and c. Each line defines a point, while the first column contains
its x-coordinate, the second one contains the a-values, the third the b-values and so on.
In case of n-dimensional data, the n coordinates are specified in the first n columns
accordingly. In order to interpolate 1D data to a nD field, specify the matching coordinate
in the output field using the interpcoord argument:
This will interpolate the 1D scattered point data from 1D-file1.pts to the y-coordinate
of the 3D mesh defined in 3D-file1.xml . The resulting field will have constant values
along the x and z coordinates. For 1D Interpolation, the module implements a quadratic
scheme and automatically falls back to a linear method if only two data points are
given. A modified inverse distance method is used for 2D and 3D interpolation. Linear
and quadratic interpolation require the data points in the .pts -file to be sorted by
their location in ascending order. The Inverse Distance implementation has no such
requirement.
FieldConvert -m interppoints:fromxml=file1.xml:fromfld=file1.fld \
file2.pts file2.dat
This command will interpolate the field defined by file1.xml and file1.fld to the
points defined in file2.pts and output it to file2.dat . The fromxml and fromfld
must be specified in this module. The format of the file file2.pts is of the same form
as for the interppointdatatofld module:
1 <?xml version="1.0" encoding="utf-8" ?>
2 <NEKTAR>
88 Chapter 5 FieldConvert
In addition, instead of specifying the file file2.pts , a module list of the form
FieldConvert -m interppoints:fromxml=file1.xml:fromfld= \
file1.fld:line=npts,x0,y0,x1,y1
can be specified where npts is the number of equispaced points between (x0, y0) to
(x1, y1) which can also be used in 3D by specifying (x0, y0, z0) to (x1, y1, z1).
FieldConvert -m interppoints:fromxml=file1.xml:fromfld=file1.fld:\
plane=npts1,npts2,x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3
where npts1,npts2 is the number of equispaced points in each direction and (x0, y0, z0),
(x1, y1, z1), (x2, y2, z2) and (x3, y3, z3) define the plane of points specified in a clockwise
or anticlockwise direction.
FieldConvert -m interppoints:fromxml=file1.xml:fromfld=file1.fld:\
box=npts1,npts2,npts3,xmin,xmax,ymin,ymax,zmin,zmax
For the plane and box interpolation there is an additional optional argument cp=p0,q
which adds to the interpolated fields the value of cp = (p − p0)/q and cp0 = (p − p0 +
0.5u2 )/q where p0 is a reference pressure and q is the free stream dynamics pressure. If
the input does not contain a field “p” or a velocity field “u,v,w” then cp and cp0 are not
evaluated accordingly
5.4 FieldConvert modules -m 89
Note
This module runs in parallel for the plane and box extraction of points. In
this case a series of .dat files are generated that can be concatinated together.
Other options do not run in parallel.
Alternatively fieldstr =”u+v” can be specified to calculate the field u2 and extract
its isocontour. You can also specify fieldname =”UplusV” to define the name of the
isocontour in the .dat file, i.e.
FieldConvert -m isocontour:fieldstr="u+v":fieldvalue=0.5:\
fieldname="UplusV" test.xml test.fld test-isocontour.dat
Optionally smooth can be specified to smooth the isocontour with default values
smoothnegdiffusion =0.495, smoothnegdiffusion =0.5 and smoothiter =100. This op-
tion typically should be used wiht the globalcondense option which removes multiply
defined verties from the simplex definition which arise as isocontour are generated element
by element. The smooth option preivously automatically called the globalcondense
option but this has been depracated since it is now possible to read isocontour files
directly and so it is useful to have these as separate options.
In addition to the smooth or globalcondense options you can specify removesmallcontour =100
which will remove separate isocontours of less than 100 triangles.
Note
Currently this option is only set up for triangles, quadrilaterals, tetrahedrons
and prisms.
The option topmodes can be used to specify the number of top modes to keep.
The output file jacenergy.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
• By default a metric outlined in [14] is produced, where all straight sided elements
have quality Q = 1 and Q < 1 shows the deformation between the curved element
and the straight-sided element. If Q = 0 then the element is invalid. Note that
Q varies over the volume of the element but is not guaranteed to be continuous
between elements.
• Alternatively, if the scaled option is passed through to the module, then the
scaled Jacobian
minξ∈Ωst J(ξ)
Js =
maxξ∈Ωst J(ξ)
(i.e. the ratio of the minimum to maximum Jacobian of each element) is calculated.
Again Q = 1 denotes an ideal element, but now invalid elements are shown by
Q < 0. Any elements with Q near zero are determined to be low quality.
The output file file-mean.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot or in Paraview or VisIt.
This command will read in the points provided in the file.pts and assume these
are given at the same quadrature distribution as the mesh and expansions defined in
file.xml and output the field to file.fld . If the points do not match an error will be
dumped.
The file file.pts which is assumed to be given by an interpolation from another source
is of the form:
1 <?xml version="1.0" encoding="utf-8" ?>
2 <NEKTAR>
3 <POINTS DIM="3" FIELDS="p">
4 1.70415 -0.4 -0.0182028 -0.106893
5 1.70415 -0.395683 -0.0182028 -0.106794
6 1.70415 -0.3875 -0.0182028 -0.106698
7 1.70415 -0.379317 -0.0182028 -0.103815
8 </POINTS>
9 </NEKTAR>
where DIM="3" FIELDS="p specifies that the field is three-dimensional and contains one
variable, p. Each line defines a point, the first, second, and third columns contains the
x, y, z-coordinate and subsequent columns contain the field values, in this case the p-value
So in the general case of n-dimensional data, the n coordinates are specified in the first
n columns accordingly followed by the field data.
The default argument is to use the equipapced (but potentially collapsed) coordinates
which can be obtained from the command.
In this case the pointdatatofld module shoudl be used without the –noequispaced
option. However this can lead to problems when peforming an elemental forward
projection/transform since the mass matrix in a deformed element can be singular as
the equispaced points do not have a sufficiently accurate quadrature rule that spans the
polynomial space. Therefore it is adviseable to use the set of points given by
which produces a set of points at the gaussian collapsed coordinates. In this case one
must also use the –noequispaced option when projecting to a field.
Finally the option setnantovalue=0 can also be used which sets any nan values in the
interpolation to zero or any specified value in this option.
This module does not create an output file which is reinforced by the out.stdout option.
The L2 and LInf norms for each field variable are then printed to the stdout.
The option bnd specifies which boundary region to extract. Note this is different to
NekMesh where the parameter surf is specified and corresponds to composites rather
boundaries. If bnd is not provided, all boundaries are extracted to different fields. To
process this file you will need an xml file of the same region.
The argument scale=value rescales of a factor value test.fld by the factor value.
The output file file-conc.fld can be processed in a similar way as described in section
5.1 to visualise the result either in Tecplot, Paraview or VisIt.
The argument N and fromfld are compulsory arguments that respectively define the
number of fld files corresponding to the number of discrete equispaced time-steps,
and the first fld file which should have the form of test_id_b0.fld where the first
underscore in the name marks the starting time-step file ID.
The input .fld files are the outputs of the wss module. If they do not contain the
surface normals (an optional output of the wss modle), then the shear module will not
compute the last metric, |WSSG|.
To compute the height of the prismatic layer connected to boundary region 3, the user
can issue the command:
Note that no .fld file is required, since the mesh is the only input required in order
to calculate the element height. This produces a file output_b3.fld , which can be
visualised with the appropriate surface mesh from NekMesh .
where the file test-vort.fld can be processed in a similar way as described in section
5.1.
The option bnd specifies which boundary region to extract. Note this is different to
NekMesh where the parameter surf is specified and corresponds to composites rather
boundaries. If bnd is not provided, all boundaries are extracted to different fields. The
94 Chapter 5 FieldConvert
addnormals is an optional command argument which, when turned on, outputs the
normal vector of the extracted boundary region as well as the shear stress vector and
magnitude. This option is off by default. To process the output file(s) you will need an
xml file of the same region.
FieldConvert has support for two modules that can be used in conjunction with the linear
elastic solver, as shown in chapter 11. To do this, FieldConvert has an XML output
module, in addition to the Tecplot and VTK formats.
The deform module, which takes no options, takes a displacement field and applies it to
the geometry, producing a deformed mesh:
The displacement module is designed to create a boundary condition field file. Its
intended use is for mesh generation purposes. It can be used to calculate the displacement
between the linear mesh and a high-order surface, and then produce a fld file, prescribing
the displacement at the boundary, that can be used in the linear elasticity solver.
Presently the process is somewhat convoluted and must be used in conjunction with
NekMesh to create the surface file. However the bash input below describes the pro-
cedure. Assume the high-order mesh is in a file called mesh.xml , the linear mesh
is mesh-linear.xml that can be generated by removing the CURVED section from
mesh.xml , and that we are interested in the surface with ID 123.
To run FieldConvert in parallel the user needs to compile Nektar++ with MPI support
and can employ the following command
or
replacing <nprocs> with the number of processors. For the .dat and .plt outputs
the current version will proudce a single output file. However it is also sometimes useful
to produce multiple output files, one for each partition, and this can be done by using
the writemultiplefiles option, i.e.
For the .vtu format multiple files will by default be produced of the form test_P0.vtu ,
test_P1.vtu , test_P2.vtu . For this format an additional file called .pvtu is written
out which allows for parallel reading of the individual .vtu files.
FieldConvert functions that produce a .fld file output will also be created when running
in parallel. In this case when producing a .fld file a directory called test.fld (or the
specified output name) is created with the standard parallel field files placed within the
directory.
When processing large files, it is not always convenient to run in parallel but process
each parallel partition in serial, for example when interpolating a solution field from one
mesh to another.
This call will only therefore consider the interpolation process across one partition
(namely, partition 2). To create the full interpolated field requires a loop over each of the
partitions, which, in a bash shell can be run as
The resulting output will lie in a directory called file2.fld , with each of the different
parallel partitions in files with names P0000000.fld , P0000001.fld , . . . , P0000009.fld .
This is nearly a complete parallel field file. However, the Info.xml file, which contains
the information about which elements lie in each partition, is missing. This can be
generated by using the command
Note the final :info extension on the last argument is necessary to tell FieldConvert
that you wish to generate an info file, but with the extension .xml . This syntax allows
the routine not to get confused with the input/output XML files.
will partition the mesh into 10 paritions and write each partition into a directory called
file_xml . If you enter this directory you will find partitioned XML files P0000000.xml ,
P0000001.xml , . . . , P0000009.xml which can then be processed individually as outlined
above.
There is also a –part-only-overlapping option, which can be run in the same fashion.
In this mode, the mesh is partitioned into 10 partitions in a similar manner, but the
elements at the partition edges will now overlap, so that the intersection of each partition
5.6 Processing large files in serial 97
with its neighbours is non-empty. This is sometime helpful when, for example, producing a
global isocontour which has been smoothed. Applying the smoothed isocontour extraction
routine with the –part-only option will produce a series of isocontour where there will be
a gap between partitions, as the smoother tends to shrink the isocontour within a partition.
using the –part-only-overlapping option will still yield a shrinking isocontour, but the
overlapping partitions help to overlap the partiiton boundaries.
Part III
Solver Applications
98
Chapter 6
Advection-Diffusion-Reaction Solver
6.1 Synopsis
2
∇ u=f Poisson All Continuous/Discontinuous
2
∇ u + λu = f SteadyDiffusionReaction 2D only Continuous/Discontinuous
6.2 Usage
99
100 Chapter 6 Advection-Diffusion-Reaction Solver
ADRSolver session.xml
• Eqtype: This sets the type of equation to solve, according to the table above.
UnsteadyAdvection X
UnsteadyDiffusion X X
UnsteadyAdvectionDiffusion X
UnsteadyInviscidBurger X
• DiffusionAdvancement: This specifies how to treat the diffusion term. This will
be restricted by the choice of time integration scheme:
• DiffusionType:
– LDG .
• UpwindType:
– Upwind .
6.3.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• d00 , d11 , d22 : sets the diagonal entries of the diffusion tensor D.
Can be used in: UnsteadyDiffusion
Default value: All set to 1 (i.e. identity matrix).
6.3.3 Functions
The following functions can be specified inside the CONDITIONS section of the session file:
6.4 Examples
∂u ∂f
+ = 0, (6.2)
∂t ∂x
where f = au is the advection flux.
Since we are solving the unsteady advection problem, we must specify this in the solver
information. We also choose to use a discontinuous flux-reconstruction projection and
use a Runge-Kutta order 4 time-integration scheme.
1 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvection" />
2 <I PROPERTY="Projection" VALUE="DisContinuous" />
3 <I PROPERTY="AdvectionType" VALUE="FRDG" />
4 <I PROPERTY="UpwindType" VALUE="Upwind" />
5 <I PROPERTY="TimeIntegrationMethod" VALUE="ClassicalRungeKutta4"/>
We choose to advect our solution for 20 time units with a time-step of 0.01 and so provide
the following parameters
1 <P> FinTime = 20 </P>
2 <P> TimeStep = 0.01 </P>
3 <P> NumSteps = FinTime/TimeStep </P>
Two boundary regions are defined, one at each end of the domain, and periodicity is
enforced
6.4 Examples 103
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B>
3 <B ID="1"> C[2] </B>
4 </BOUNDARYREGIONS>
5
6 <BOUNDARYCONDITIONS>
7 <REGION REF="0">
8 <P VAR="u" VALUE="[1]" />
9 </REGION>
10 <REGION REF="1">
11 <P VAR="u" VALUE="[0]" />
12 </REGION>
13 </BOUNDARYCONDITIONS>
ADRSolver Advection1D.xml
To visualise the output, we can convert it into either TecPlot or VTK formats
∇2 u + λu = f (6.3)
The geometry for this problem is a two-dimensional octagonal plane containing both
triangles and quadrilaterals. Note that a mesh composite may only contain one type of
element. Therefore, we define two composites for the domain, while the rest are used for
enforcing boundary conditions.
1 <COMPOSITE>
2 <C ID="0"> Q[22-47] </C>
3 <C ID="1"> T[0-21] </C>
4 <C ID="2"> E[0-1] </C>
5 .
6 .
7 <C ID="10"> E[84,75,69,62,51,40,30,20,6] </C>
8 </COMPOSITE>
9
10 <DOMAIN> C[0-1] </DOMAIN>
For both the triangular and quadrilateral elements, we use the modified Legendre basis
with 7 modes (maximum polynomial order is 6).
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="7" FIELDS="u" TYPE="MODIFIED" />
3 <E COMPOSITE="C[1]" NUMMODES="7" FIELDS="u" TYPE="MODIFIED" />
4 </EXPANSIONS>
Only one parameter is needed for this problem. In this example λ = 1 and the Continuous
Galerkin Method is used as projection scheme to solve the Helmholtz equation, so we
need to specify the following parameters and solver information.
1 <PARAMETERS>
2 <P> Lambda = 1 </P>
3 </PARAMETERS>
4
5 <SOLVERINFO>
6 <I PROPERTY="EQTYPE" VALUE="Helmholtz" />
7 <I PROPERTY="Projection" VALUE="Continuous" />
8 </SOLVERINFO>
All three basic boundary condition types have been used in this example: Dirichlet,
Neumann and Robin boundary. The boundary regions are defined, each of which
corresponds to one of the edge composites defined earlier. Each boundary region is then
assigned an appropriate boundary condition.
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[2] </B>
3 .
4 .
5 <B ID="8"> C[10] </B>
6 </BOUNDARYREGIONS>
7
6.4 Examples 105
8 <BOUNDARYCONDITIONS>
9 <REGION REF="0">
10 <D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
11 </REGION>
12 <REGION REF="1">
13 <R VAR="u" VALUE="sin(PI*x)*sin(PI*y)-PI*sin(PI*x)*cos(PI*y)"
14 PRIMCOEFF="1" />
15 </REGION>
16 <REGION REF="2">
17 <N VAR="u" VALUE="(5/sqrt(61))*PI*cos(PI*x)*sin(PI*y)-
18 (6/sqrt(61))*PI*sin(PI*x)*cos(PI*y)" />
19 </REGION>
20 .
21 .
22 </BOUNDARYCONDITIONS>
We know that for f = −(λ+2π 2 )sin(πx)cos(πy), the exact solution of the two-dimensional
Helmholtz equation is u = sin(πx)cos(πy). These functions are defined specified to
initialise the problem and verify the correct solution is obtained by evaluating the L2
and Linf errors.
1 <FUNCTION NAME="Forcing">
2 <E VAR="u" VALUE="-(Lambda + 2*PI*PI)*sin(PI*x)*sin(PI*y)" />
3 </FUNCTION>
4
5 <FUNCTION NAME="ExactSolution">
6 <E VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
7 </FUNCTION>
ADRSolver Test_Helmholtz2D_modal.xml
This execution should print out a summary of input file, the L2 and Linf errors and the
time spent on the calculation.
6.4.2.4 Post-processing
which generates the file Helmholtz2D_modal.vtu which can be visualised and is shown
in Fig. 6.1
106 Chapter 6 Advection-Diffusion-Reaction Solver
6.4.3.1 Background
The governing equation for modelling mass transport is the unsteady advection diffusion
equation:
∂u
+ v∇u + ∇2 u = 0
∂t
For small diffusion coefficient, , the transport is dominated by advection and this leads
to a very fine boundary layer adjacent to the surface which must be captured in order to
get a realistic representation of the wall mass transfer processes. This creates problems
not only from a meshing perspective, but also numerically where classical oscillations are
observed in the solution due to under-resolution of the boundary layer.
24/3 (P eR/z)1/3
Sh(z) = ,
g 1/3 Γ(4/3)
where z is the streamwise coordinate, R the pipe radius, Γ(4/3) an incomplete Gamma
function and P e the Peclet number given by:
2U R
Pe =
In the following we will numerically solver mass transport in a pipe and compare the
calculated mass transfer at the wall with the Graetz-Nusselt solution. The Peclet number
of the transport regime under consideration is 750000, which is physiologically relevant.
Since the mass transport boundary layer will be confined to a very small layer adjacent
to the wall we do not need to mesh the interior region, hence the mesh consists of a layer
of ten prismatic elements over a thickness of 0.036R. The elements progressively grow
over the thickness of domain.
2 <E COMPOSITE="C[0]"
3 NUMMODES="3,5,3"
4 BASISTYPE="Modified_A,Modified_A,Modified_B"
5 NUMPOINTS="4,6,3"
6 POINTSTYPE="GaussLobattoLegendre,GaussLobattoLegendre,GaussRadauMAlpha1Beta0"
7 FIELDS="u" />
8 </EXPANSIONS>
The above represents a quadratic polynomial order in the azimuthal and streamwise
direction and 4th order polynomial normal to the wall for a prismatic element.
We integrate for a total of 30 time units with a time-step of 0.0005, necessary to keep
the simulation numerically stable.
1 <P> TimeStep = 0.0005 </P>
2 <P> FinalTime = 30 </P>
3 <P> NumSteps = FinalTime/TimeStep </P>
The analytical solution represents a developing mass transfer boundary layer in a pipe. In
order to reproduce this numerically we assume that the inlet concentration is a uniform
value and the outer wall concentration is zero; this will lead to the development of the
mass transport boundary layer along the length of the pipe. Since we do not model
explicitly the mass transfer in the interior region of the pipe we assume that the inner
wall surface concentration is the same as the inlet concentration; this assumption is valid
based on the large Peclet number meaning the concentration boundary layer is confined
to the region in the immediate vicinity of the wall. The boundary conditions are specified
as follows in the input file:
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[3] </B> <!-- inlet -->
3 <B ID="1"> C[4] </B> <!-- outlet -->
4 <B ID="2"> C[2] </B> <!-- outer surface -->
5 <B ID="3"> C[5] </B> <!-- inner surface -->
6 </BOUNDARYREGIONS>
7
8 <BOUNDARYCONDITIONS>
6.4 Examples 109
9 <REGION REF="0">
10 <D VAR="u" VALUE="1" />
11 </REGION>
12 <REGION REF="1">
13 <N VAR="u" VALUE="0" />
14 </REGION>
15 <REGION REF="2">
16 <D VAR="u" VALUE="0" />
17 </REGION>
18 <REGION REF="3">
19 <D VAR="u" VALUE="1" />
20 </REGION>
21 </BOUNDARYCONDITIONS>
The velocity field within the domain is fully devqeloped pipe flow (Poiseuille flow), hence
we can define this through an analytical function as follows:
1 <FUNCTION NAME="AdvectionVelocity">
2 <E VAR="Vx" VALUE="0" />
3 <E VAR="Vy" VALUE="0" />
4 <E VAR="Vz" VALUE="2.0*(1-(x*x+y*y)/0.25)" />
5 </FUNCTION>
We assume that the initial domain concentration is uniform everywhere and the same as
the inlet. This is defined by,
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="u" VALUE="1" />
3 </FUNCTION>
6.4.3.3 Results
To compare with the analytical expression we numerically calculate the concentration
gradient at the surface of the pipe. This is then plotted against the analytical solution
by extracting the solution along a line in the streamwise direction, as shown in Fig. 6.3.
110 Chapter 6 Advection-Diffusion-Reaction Solver
7.1 Synopsis
where (ui , p, ρ, c2 = γp/ρ) represents the base flow and (u0i , p0 ) the perturbations. c2 qc is
the acoustic source term.
7.2 Usage
APESolver session.xml
111
112 Chapter 7 Acoustic Perturbation Equations Solver
• UpwindType Specifies the numerical interface flux scheme. Currently, only APEUpwind
supported.
7.3.2 Parameters
7.3.3 Functions
7.4 Examples
To maintain numerical stability we must use a small time-step. The total simulation
time is 150 time units. Finally, we set the density, heat ratio and ambient pressure.
1 <P> TimeStep = 0.00001 </P>
2 <P> NumSteps = 150 </P>
3 <P> FinTime = TimeStep*NumSteps </P>
4 <P> Rho0 = 1.204 </P> <!-- Incompressible density -->
5 <P> Gamma = 1.4 </P> <!-- Ratio of specific heats -->
6 <P> Pinfinity = 100000 </P> <!-- Ambient pressure -->
7.4 Examples 113
Figure 7.1 Geometry used for the example case of modelling propagation of acoustic waves
where ui = 0, p = p∞ = 106 , ρ = ρ0 = 1.204
Let us note that to solve efficiently this problem a discontinuous Garlerkin approach was
used. The system is excited via the initial conditions putting a Gaussian pulse for pulse
fluctuations. Finally, it is necessary to specify the base flow and the eventual source
terms using the following functions:
1 <FUNCTION NAME="Baseflow">
2 <E VAR="u0" VALUE="0" />
3 <E VAR="v0" VALUE="0" />
4 <E VAR="p0" VALUE="Pinfinity" />
5 <E VAR="rho0" VALUE="Rho0" />
6 </FUNCTION>
7
8 <FUNCTION NAME="Source">
9 <E VAR="S" VALUE="0" />
10 </FUNCTION>
11
12 <!-- Gaussian pulse located at the origin -->
13 <FUNCTION NAME="InitialConditions">
14 <E VAR="p" VALUE="100*exp(-32*(((x)*(x))+((y)*(y))))" />
15 <E VAR="u" VALUE="0" />
16 <E VAR="v" VALUE="0" />
17 </FUNCTION>
APESolver Test_pulse.xml
7.4.1.3 Results
Fig. 7.2 shows the pressure profile at different time steps, showing the acoustic propaga-
tion.
Figure 7.2
It is possible to show the profile of the pressure perturbations with respect to the spatial
coordinate. The pressure fluctuations, that are concentrated in a specific locations at the
beginning (as specified by the initial conditions), propagate with time and for sufficiently
large time the decay is exponential as predicted by literature [12].
Figure 7.3
Chapter 8
Cardiac Electrophysiology Solver
8.1 Synopsis
∂ 2 Vi ∂ 2 Vi ∂(Vi − Ve )
gix + g iy = χ Cm + Gm (Vi − Ve )
∂x2 ∂y 2 ∂t
∂ 2 Ve ∂ 2 Ve ∂(Vi − Ve )
gex + gey = −χ Cm + Gm (Vi − Ve ) .
∂x2 ∂y 2 ∂t
However, when solving numerically, one often rewrites these equations in terms of the
transmembrane potential and extracellular potential,
∂Vm ∂ 2 Ve ∂ 2 Ve
χ Cm + Jion = gex + gey
∂t ∂x2 ∂y 2
2
∂ Ve 2
∂ Ve 2
∂ Vm ∂ 2 Vm
(gix + gex ) 2 + (giy + gey ) 2 = −gix − g iy
∂x ∂y ∂x2 ∂y 2
∂Vm
χ Cm + Jion = ∇ · (σ∇Vm )
∂t
115
116 Chapter 8 Cardiac Electrophysiology Solver
A number of ionic cell models are currently supported by the solver including:
• Aliev-Panfilov
• Fitzhugh-Nagumo
It is important to ensure that the units of the voltage and currents from the cell model
are consistent with the units expected by the tissue level solver (monodomain/bidomain).
We will show as an example the Courtemanche, Ramirez, Nattel, 1998 human atrial
model.
8.2 Usage
CardiacEPSolver session.xml
• Eqtype Specifies the PDE system to solve. The following values are supported:
• CellModel Specifies the cell model to use. Available cell models are
8.3 Session file configuration 117
• Projection Specifies the Galerkin projection type to use. Only Continuous has
been extensively tested.
8.3.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file.
Example values are taken from [13].
• Substeps sets the number of substeps taken in time integrating the cell model for
each PDE timestep.
Example: 4
8.3.3 Functions
The following functions can be specified inside the CONDITIONS section of the session file.
If both are specified, the effect is multiplicative. Example values are taken from [13].
8.3.4 Filters
• CellHistoryPoints writes all cell model states over time at fixed points. Can be
used along with the HistoryPoints filter to record all variables at specific points
during a simulation.
1 <FILTER TYPE="CellHistoryPoints">
2 <PARAM NAME="OutputFile">crn.his</PARAM>
3 <PARAM NAME="OutputFrequency">1</PARAM>
4 <PARAM NAME="Points">
5 0.00 0.0 0.0
6 </PARAM>
7 </FILTER>
• CheckpointCellModel checkpoints the cell model. Can be used along with the
Checkpoint filter to record complete simulation state and regular intervals.
1 <FILTER TYPE="CheckpointCellModel">
2 <PARAM NAME="OutputFile"> session </PARAM>
3 <PARAM NAME="OutputFrequency"> 1 </PARAM>
4 </FILTER>
– OutputFile (optional) specifies the base filename to use. If not specified, the
session name is used. Checkpoint files are suffixed with the process ID and
the extension ‘.chk‘.
8.3 Session file configuration 119
– OutputFile (optional) specifies the base filename to use. If not specified, the
session name is used. The extension ‘.ecg‘ is appended if not already specified.
– OutputFrequency specifies the number of resolution of the electrogram data.
– Points specifies a list of coordinates at which electrograms are desired. They
must not lie within the domain.
• Benchmark Records spatially distributed event times for activation and repolarisa-
tion (recovert) during a simulation, for undertaking benchmark test problems.
1 <FILTER TYPE="Benchmark">
2 <PARAM NAME="ThresholdValue"> -40.0 </PARAM>
3 <PARAM NAME="InitialValue"> 0.0 </PARAM>
4 <PARAM NAME="OutputFile"> benchmark </PARAM>
5 <PARAM NAME="StartTime"> 0.0 </PARAM>
6 </FILTER>
8.3.5 Stimuli
Electrophysiological propagaion is initiated through the stimulus current Iion . The
STIMULI section describes one or more regions of stimulus and the time-dependent
protocol with which they are applied.
1 <STIMULI>
2 ...
3 </STIMULI>
120 Chapter 8 Cardiac Electrophysiology Solver
8.3.5.2 Protocols
A protocol specifies the time-dependent function indicating the strength of the stimulus
and one such PROTOCOL section should be included within each STIMULUS . This can be
expressed as one of:
• ProtocolSingle a single stimulus is applied at a given start time and for a given
duration
1 <PROTOCOL TYPE="ProtocolSingle">
2 <START> 0.0 </START>
3 <DURATION> 2.0 </DURATION>
4 </PROTOCOL>
• ProtocolS1 a train of pulses of fixed duration applied at a given start time and
with a given cycle length.
8.3 Session file configuration 121
1 <PROTOCOL TYPE="ProtocolS1">
2 <START> 0.0 </START>
3 <DURATION> 2.0 </DURATION>
4 <S1CYCLELENGTH> 300.0 </S1CYCLELENGTH>
5 <NUM_S1> 5 </NUM_S1>
6 </PROTOCOL>
9.1 Synopsis
where q is the vector of the conserved variables, fi = fi (q), gi = gi (q) and hi = hi (q)
are the vectors of the inviscid fluxes
ρ
ρu
ρv
ρw
ρu p + ρu2 ρuv ρuw
q= ρv , fi = ρuv , gi = p + ρv 2 , hi = ρvw ,
ρw
ρuw
ρvw
p + ρw 2
E u(E + p) v(E + p) w(E + p)
(9.2)
where ρ is the density, u, v and w are the velocity components in x, y and z directions, p
is the pressure and E is the total energy. In this work we considered a perfect gas law
for which the pressure is related to the total energy by the following expression
p 1
E= + ρ(u2 + v 2 + w2 ), (9.3)
γ−1 2
122
9.1 Synopsis 123
∂q ∂f ∂g ∂h
+ + + = 0, (9.4)
∂t ∂x ∂y ∂z
where q is the vector of the conserved variables, f = f (q, ∇(q)), g = g(q, ∇(q)) and
h = h(q, ∇(q)) are the vectors of the fluxes which can also be written as:
f = fi − fv , g = gi − gv , h = hi − hv , (9.5)
where fi , gi and hi are the inviscid fluxes of Eq. (9.2) and fv , gv and hv are the viscous
fluxes which take the following form:
0
0
τxx τxy
fv = τyx , gv = τyy ,
τzx
τzy
uτxx + vτyx + wτzx + kTx uτxy + vτyy + wτzy + kTy
(9.6)
0
τxz
hv = τyz ,
τzz
uτxz + vτyz + wτzz + kTz
where τxx , τxy , τxz , τyx , τyx , τyy , τyz , τzx , τzy and τzz are the components of the stress
tensor1
u +v +w u +v +w
τxx = 2µ ux − x 3y z , τyy = 2µ vy − x 3y z ,
ux +vy +wz
τzz = 2µ wz − 3 , τxy = τyx = µ(vx + uy ), (9.7)
τyz = τzy = µ(wy + vz ), τzx = τxz = µ(uz + wx ).
where µ is the dynamic viscosity calculated using the Sutherland’s law and k is the
thermal conductivity.
approach. In both the approaches the physical domain Ω is divided into a mesh of N non-
overlapping elements Ωe and the solution is allowed to be discontinuous at the boundary
between two adjacent elements. Since the Euler as well as the Navier-Stokes equations are
defined locally (on each element of the computational domain), it is necessary to define a
term to couple the elements of the spatial discretisation in order to allow information to
propagate across the domain. This term, called numerical interface flux, naturally arises
from the discontinuous Galerkin formulation as well as from the Flux Reconstruction
approach.
For the advection term it is common to solve a Riemann problem at each interface of the
computational domain through exact or approximated Riemann solvers. In Nektar++
there are different Riemann solvers, one exact and nine approximated. The exact Riemann
solver applies an iterative procedure to satisfy conservation of mass, momentum and
energy and the equation of state. The left and right states are connected either with
the unknown variables through the Rankine-Hugoniot relations, in the case of shock,
or the isentropic characteristic equations, in the case of rarefaction waves. Across the
contact surface, conditions of continuity of pressure and velocity are employed. Using
these equations the system can be reduced to a non-linear algebraic equation in one
unknown (the velocity in the intermediate state) that is solved iteratively using a Newton
method. Since the exact Riemann solver gives a solution with an order of accuracy that
is related to the residual in the Newton method, the accuracy of the method may come
at high computational cost. The approximated Riemann solvers are simplifications of
the exact solver.
Concerning the diffusion term, the coupling between the elements is achieved by using a
local discontinuous Galerkin (LDG) approach as well as five different FR diffusion terms.
The boundary conditions are also implemented by exploiting the numerical interface
fluxes just mentioned. For a more detailed description of the above the interested reader
can refer to [9] and [24].
9.2 Usage
CompressibleFlowSolver session.xml
In the following we describe the session file configuration. Specifically we consider the
sections under the tag <CONDITIONS> in the session (.xml) file.
Parameters
Under this section it is possible to set the parameters of the simulation.
1 <PARAMETERS>
2 <P> TimeStep = 0.0000001 </P>
9.3 Session file configuration 125
• FinTime is the final physical time at which we want our simulation to stop;
• NumSteps is the equivalent of FinTime but instead of specifying the physical final
time we specify the number of time-steps;
• IO_InfoSteps sets the number of steps between successive info stats are printed
to screen;
• Twall temperature at the wall when isothermal boundary conditions are employed
(i.e. Tw ). Default value = 300.15K;
• uint farfield X-component of the velocity (i.e. u∞ ). Default value = 0.1 m/s;
• vInf farfield Y -component of the velocity (i.e. v∞ ). Default value = 0.0 m/s;
• wInf farfield Z-component of the velocity (i.e. w∞ ). Default value = 0.0 m/s;
Solver info
Under this section it is possible to set the solver information.
1 <SOLVERINFO>
2 <I PROPERTY="EQType" VALUE="NavierStokesCFE" />
3 <I PROPERTY="Projection" VALUE="DisContinuous" />
4 <I PROPERTY="AdvectionType" VALUE="WeakDG" />
5 <I PROPERTY="DiffusionType" VALUE="LDGNS" />
6 <I PROPERTY="TimeIntegrationMethod" VALUE="ClassicalRungeKutta4"/>
7 <I PROPERTY="UpwindType" VALUE="ExactToro" />
8 <I PROPERTY="ProblemType" VALUE="General" />
9 <I PROPERTY="ViscosityType" VALUE="Constant" />
10 </SOLVERINFO>
– DisContinuous .
Note that the Continuous projection is not supported in the Compressible
Flow Solver.
– LDGNS (LDG);
9.3 Session file configuration 127
– ForwardEuler ;
– RungeKutta2_ImprovedEuler ;
– ClassicalRungeKutta4 .
• UpwindType is the numerical interface flux (i.e. Riemann solver) we want to use
for the advection operator:
– AUSM0 ;
– AUSM1 ;
– AUSM2 ;
– AUSM3 ;
– Average ;
– ExactToro ;
– HLL ;
– HLLC ;
– LaxFriedrichs ;
– Roe .
Boundary conditions
In this section we can specify the boundary conditions for our problem. First we need to
define the variables under the section VARIABLES . For a 1D problem we have:
1 <VARIABLES>
2 <V ID="0"> rho </V>
3 <V ID="1"> rhou </V>
4 <V ID="4"> E </V>
5 </VARIABLES>
128 Chapter 9 Compressible Flow Solver
After having defined the variables depending on the dimensions of the problem we want
to solve it is necessary to specify the boundary regions on which we want to define the
boundary conditions:
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[100] </B>
3 </BOUNDARYREGIONS>
Finally we can specify the boundary conditions on the regions specified under BOUNDARYREGIONS .
In the following some examples for a 2D problem:
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="rho" USERDEFINEDTYPE="WallAdiabatic" VALUE="0" />
4 <D VAR="rhou" USERDEFINEDTYPE="WallAdiabatic" VALUE="0" />
5 <D VAR="rhov" USERDEFINEDTYPE="WallAdiabatic" VALUE="0" />
6 <D VAR="E" USERDEFINEDTYPE="WallAdiabatic" VALUE="0" />
7 </REGION>
8 </BOUNDARYCONDITIONS>
9.4 Examples
To enable the non-smooth viscosity model, the following line has to be added to the
SOLVERINFO section:
1 <SOLVERINFO>
2 <I PROPERTY="ShockCaptureType" VALUE="NonSmooth" />
3 <SOLVERINFO>
where mu0 is the maximum values for the viscosity coefficient, Kappa is half of the width
of the transition interval and Skappa is the value of the centre of the interval.
9.4 Examples 131
Mach ADViscCoeff
1.3 0.28
1.2 0.26
0.5 1.1 0.5 0.24
1 0.22
0.9 0.2
0.8 0.18
0.7 0.16
0.6 0.14
0.5
y
y
0.12
0.4 0.1
0.3 0.08
0 0 0.06
0.04
0.02
-0.5 -0.5
0 0.5 1 0 0.5 1
x x
Figure 9.1 (a) Steady state solution for M = 0.8 flow at α = 1.25◦ past a NACA 0012 profile,
(b) Artificial viscosity () distribution
∂ 1 h
= ∇ · (∇) + λmax Sκ − on Ω
∂t τ p
(9.10)
∂
=0 on Γ
∂n
where Sκ is a normalised sensor value and serves as a forcing term for the artificial
viscosity. A smooth artificial viscosity distribution is obtained.
To enable the smooth viscosity model, the following line has to be added to the
SOLVERINFO section:
1 <SOLVERINFO>
2 <I PROPERTY="ShockCaptureType" VALUE="Smooth" />
3 <SOLVERINFO>
Furthermore, the extra viscosity variable eps has to be added to the variable list:
1 <VARIABLES>
2 <V ID="0"> rho </V>
3 <V ID="1"> rhou </V>
4 <V ID="2"> rhov </V>
5 <V ID="4"> E </V>
6 <V ID="5"> eps </V>
7 </VARIABLES>
132 Chapter 9 Compressible Flow Solver
A similar addition has to be made for the boundary conditions and initial conditions.
The tests that have been run started with a uniform homogeneous boundary condition
and initial condition. The following parameters can be set in the xml session file:
1 <PARAMETERS>
2 <P> Skappa = -1.3 </P>
3 <P> Kappa = 0.2 </P>
4 <P> mu0 = 1.0 </P>
5 <P> FH = 3 </P>
6 <P> FL = 0.01*FH </P>
7 <P> C1 = 0.03 </P>
8 <P> C2 = 5/3*C1 </P>
9 </PARAMETERS>
where for now FH and FL are used to tune which range of the sensor is used as a forcing
term and C1 and C2 are fixed constants which can be played around with to make the
model more diffusive or not. However these constants are generally fixed.
The polynomial order in each element can be adjusted based on the sensor value that
is obtained. Initially, a converged solution is obtained after which the sensor in each
element is calculated. Based on the determined sensor value and the pre-defined sensor
thresholds, it is decided to increase, decrease or maintain the degree of the polynomial
approximation in each element and a new converged solution is obtained.
pe − 1 if se > sds
p +1
e if ssm < se < sds
pe = (9.11)
pe
if sf l < se < ssm
pe − 1 if se < sf l
For now, the threshold values se , sds , ssm and sf l are determined empirically by looking
at the sensor distribution in the domain. Once these values are set, two .txt files are
outputted, one that has the composites called VariablePComposites.txt and one with the
expansions called VariablePExpansions.txt. These values have to copied into a new .xml
file to create the adapted mesh.
are calculated at an insufficient number of quadrature points. We can identify two types
of nonlinearities:
• Global dealiasing: It targets both the PDE and the geometrical-aliasing sources. It
requires a richer quadrature order to consistently integrate the nonlinear fluxes,
the geometric factors, the mass matrix and the boundary term.
Since Nektar++ tackles separately the PDE and geometric aliasing during the projection
and solution of the equations, to consistently integrate all the nonlinearities in the
compressible NavierStokes equations, the quadrature points should be selected based on
the maximum order of the nonlinearities:
max(2Pexp , Pgeom ) 3
Qmin = Pexp + + (9.12)
2 2
where Qmin is the minimum required number of quadrature points to exactly integrate
the highest-degree of nonlinearity, Pexp being the order of the polynomial expansion
and Pgeom being the geometric order of the mesh. Bear in mind thatwe are using a
discontinuous discretisation, meaning that aliasing effect are not fully controlled, since
the boundary terms introduce non-polynomial functions into the problem.
To enable the global de-aliasing technique, modify the number of quadrature points by:
1 <E COMPOSITE="[101]"
2 BASISTYPE="Modified_A,Modified_A"
3 NUMMODES="7,7"
4 POINTSTYPE="GaussLobattoLegendre,GaussLobattoLegendre"
5 NUMPOINTS="14,14"
6 FIELDS="rho,rhou,rhov,E"
7 />
where NUMMODES corresponds to P +1, where P is the order of the polynomial used to
approximate the solution. NUMPOINTS specifies the number of quadrature points.
Chapter 10
Incompressible Navier-Stokes Solver
10.1 Synopsis
A useful tool implemented in Nektar++ is the incompressible Navier Stokes solver that
allows one to solve the governing equation for viscous Newtonians fluids governed by:
∂u
+ u · ∇u = −∇p + ν∇2 u + f (10.1a)
∂t
∇·u=0 (10.1b)
where V is the velocity, p is the specific pressure (including density) and ν the kinematic
viscosity.
134
10.1 Synopsis 135
Briefly, high order splitting scheme was originally proposed in three steps involving
explicit advection of the non-linear terms, followed by the solution of the pressure Poisson
system and finally solving a Helmholtz problem to enforce the viscous terms and velocity
boundary conditions. In the following however we briefly formulate this scheme as a two
steps using a formulation outline by Guermond and Shen.
1. In the first step we formulate a weak pressure Poisson problem by taking the inner
product over the solution domain Ω of equation (10.1a) with respect to the gradient
of the test basis, ∇q, i.e.
∂u
Z Z Z Z
∇q · + ∇q · N(u) = − ∇q · ∇p + ∇q · ν∇2 u (10.2)
Ω ∂t Ω Ω Ω
R
where N (u) = u · ∇u. We recall that the term Ω ∇q · ∇p is the weak approximation
to the Laplacian operator for pressure. To decouple this term from the velocity
system a few steps are necessary. Using the identity
∇2 u = −∇ × ∇ × u + ∇(∇ · u)
we can enforce the divergence to be zero by setting the last term to zero. If we now
integrate the 1st, 2nd and last term in equation (10.2) by parts we can obtain the
weak pressure equation
!
∂u n+1
Z Z
n+1
∇q · ∇p = q∇· + N(u)n+1
Ω Ω ∂t
!
∂u n+1
Z
− q + N(u)n+1 − ν∇ × ∇ × un+1 · n (10.3)
∂Ω ∂t
where ∂Ω is the boundary of the domain and we have used the factor that ∇ · (∇ ×
∇ × u) = 0. To get the final form of the weak pressure Poisson equation we can
use a backward approximation of the time derivative to obtain
∂u n+1 γ0 ũn+1 − û
' (10.4)
∂t ∆t
where ũn+1 is an intermediate velocity upon which to decouple the system we
impose that ∇ · ũn+1 = 0 and
( (
1, if J = 1 un , if J = 1
γ0 = 3 û = n 1 n−1
2 , if J = 2 2u − 2 u , if J = 2.,
Finally we introduce a consistent extrapolation for the non-linear terms and the
curl of vorticity terms of the form:
(
∗,n+1 Nn , if J = 1
N =
2Nn − Nn−1 , if J = 2.
136 Chapter 10 Incompressible Navier-Stokes Solver
A similar extrapolation can be used on the curl-curl term to end up with the final
weak pressure approximation
û
Z Z
∇q · ∇pn+1 = q∇· − + N(u)∗,n+1
Ω Ω ∆t
!
∂u n+1
Z
− q + N(u)∗.n+1 − ν(∇ × ∇ × u)∗,n+1 · n (10.5)
∂Ω ∂t
We note this can be recast into an equivalent strong form of the pressure Poisson
equation of the form
û
∇2 pn+1 = ∇ · − N∗,n+1 (10.6)
∆t
with consistent Neumann boundary conditions prescribed as
∂p n+1 h ∂u n+1 i
=− − ν(∇ × ∇ × u)∗,n+1 + N∗,n+1 · n (10.7)
∂n ∂t
2. The second step is discretise equation (10.1a) at time level n + 1, use the pressure
at n + 1 from the first step and solve for the velocity un+1 .
In this step now approximate the time derivative using
∂u n+1 γ0 un+1 − û
' (10.8)
∂t ∆t
This scheme is activated in the SolverInfo section with the SolverType specification:
1 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
∂u n+1 γ0 ũn+1 − û
' . (10.10)
∂t ∆t
However this time we only integrate by parts the last term and do not integrate the
non-linear term by parts. However we still need to enforce the condition that ∇ · ũn+1 = 0
10.1 Synopsis 137
and so we also integrate just this part of the time derivate by parts to arrive at a weak
pressure system of the form:
γ0 û
Z Z Z
∇q · ∇pn+1 + q ũn+1 · n = − N?,n+1 )
∇q · (
Ω ∆t ∂Ω0 Ω ∆t
γ0
Z Z
∗,n+1
− q ν(∇ × ∇ × u) · n + qwn+1 · n (10.11)
∆t ∂Ωd
S
∂Ωd ∂Ω0
where ∂Ωd is the Dirichlet boundary conditions for the velocity and ∂Ω0 is the outflow
boundary.
This scheme is activated in the SolverInfo section with the SolverType specification:
1 <I PROPERTY="SolverType" VALUE="VCSWeakPressure"/>
However when energetic vortices pass through an outflow region one can experience
instabilities as identified by the work of Dong, Karnidakis and Chryssostomidis [11]. In
this paper they suggest to impose a pressure Dirichlet outflow condition of the form
1
pn+1 = ν∇u∗,n+1 · n − | u∗,n+1 |2 So (n · u∗,n+1 ) + fbn+1 · n (10.12)
2
138 Chapter 10 Incompressible Navier-Stokes Solver
1 h n+1 1 i
∇un+1 · n = p n + | u∗,n+1 |2 So (n · u∗,n+1 ) − ν(∇ · u∗,n+1 )n − fbn+1 (10.13)
ν 2
Note that in the moving body work of Bao et al. [4] some care must be made to identify
when the flow over the boundary is incoming or outgoing and so a modification of the
term
1
| u∗,n+1 |2 So (n · u∗,n+1 )
2
is replaced with
1
(θ + α2 ) | u∗,n+1 |2 +(1 − θ + α1 )(u∗,n+1 · n)u∗,n+1 So (n · u∗,n+1 )
2
where the default values are given by θ = 1, α1 = 0, α2 = 0 and these values can be set
through the parameters OutflowBC_theta , OutflowBC_alpha1 and OutflowBC_alpha2 .
Dong has also suggested convective like outflow conditions in [10] which can be enforced
through a Robin type specification of the form
∂un+1 γ0 D0 n+1 1h D0
+ u = f n+1 + E(n, u∗,n+1 ) + pn+1 n − ν(∇ · u∗,n+1 )n + û (10.14)
∂n ∆t ν ∆t
10.1 Synopsis 139
∂pn+1 1 n+1
+ p = − −ν(∇ × ∇ × u)∗,n+1 + N∗,n+1 · n
∂n νD0
1 h n+1
+ E(n, u∗,n+1 + pn+1 n − ν(∇ · u∗,n+1 )n
− f (10.15)
νD0
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <R VAR="u" USERDEFINEDTYPE="HOutflow" VALUE="0" PRIMCOEFF="D0/TimeStep"/>
4 <R VAR="v" USERDEFINEDTYPE="HOutflow" VALUE="0" PRIMCOEFF="D0/TimeStep"/>
5 <R VAR="p" USERDEFINEDTYPE="HOutflow" VALUE="0" PRIMCOEFF="1.0/(D0*Kinvis)"/>
6 </REGION>
7 </BOUNDARYCONDITIONS>
Figure 10.1 Schematic representation of the substepping approach. (a) Making an explicit time
step the hyperbolic solution, travelling with a speed a, can be understood as being related to the
solution at point xd (the departure point). (b) Making smaller explicit time steps we can evaluate
the solution φ(xd ) at the departure point and then use this value to make a semi-Lagrangian
discretisation of the implicit components usually associated with diffusion.
A schematic of the approach can be understood from figure 10.1.1.5 where we observe
that smaller time steps can be used for the explicit advection steps whilst a larger overall
time step is adopted for the more expensive implicit solve for the diffusion operator. More
details of the implementation can be found in [39] and [31]. In the following sections
we outline the parameters that can be used to set up this scheme. Since the explicit
part is advanced using a DG scheme it is necessary to use a Mixed_CG_Discontinuous
expansion with this option.
140 Chapter 10 Incompressible Navier-Stokes Solver
Note
Example of the substepping scheme can be found in the regression
tests directory under $NEKHOME/Solver/IncNavierStokesSolver/Tests/ di-
rectory. For exmaple the test cases KovaFlow_SubStep_2order.xml,
Hex_Kovasnay_SubStep.xml and Tet_Kovasnay_SubStep.xml
In the above example the “u,v” fields are specified to have a polynomial order of 8 using
a modified expansion. Implicitly this form of the expansion definition uses a quadrature
order of 9. The above definition then also uses a modified expansion for pressure but of
order 7. Since currently for this solver to run we need to use a consistent quadrature
order for both the velocity and pressure fields we specify the MODIFIEDQUADPLUS1 to tell
the solver to use an addition quadrature point and therefore also use 9 quadrature points
in each 1D direction for the pressure.
In other cases it is sometimes useful to run with an even higher quadrature order, for
example to handle highly deformed elements where the Jacobian is represented by a
polynomial expansion. This can be done by using a more detailed definition of the
expansion of the form:
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" BASISTYPE="Modified_A,Modified_B" NUMMODES="8,8" POINTSTYPE="GaussLobattoLegen
3 <E COMPOSITE="C[0]" BASISTYPE="Modified_A,Modified_B" NUMMODES="7,7" POINTSTYPE="GaussLobattoLegen
4 </EXPANSIONS>
In this example we have specified an 8th order expansion for “u,v” and a 7th order
expansion for “p”. The BasisType is given as “Modified_A, Modified_B” which is
for a triangular expansion (note a quadrilateral expansion would have been “Modi-
fied_A,Modified_A”) and so the number of quadrature points in this case is 9 in the first
direction which uses Gauss Lobatto Legendre points but only 8 in the second direction
since this uses a Gauss Radau formula with α = 1, β = 0 weights (see ?? for details on
why).
10.1 Synopsis 141
We consider the weak form of the Stokes problem for the velocity field boldsymbolu =
[u, v]T and the pressure field p:
where the components of A,B and C are ∇φb , ν∇ub , ∇φb , ν∇ui and ∇φi , ν∇ui and the
components Db and Di are q, ∇ub and q, ∇ui . The indices b and i refer to the degrees of
freedom on the elemental boundary and interior respectively. In constructing the system
we have lumped the contributions form each component of the velocity field into matrices
A,B and C. However, we note that for a Newtonian fluid the contribution from each field
is decoupled. Since the interior degrees of freedom of the velocity field do not overlap,
the matrix C is block diagonal and to take advantage of this structure we can statically
condense out the C matrix to obtain the system:
A − BC −1 B T DbT − BC −1 Di 0 ub fb − BC −1 fi
Db − DiT C −1 B T −DiT C −1 Di 0 p = −DiT C −1 fi (10.17)
BT Di C ui fi
To extend the above Stokes solver to an unsteady Navier-Stokes solver we first introduce
the unsteady term, ∂u/∂t, into the Stokes problem. This has the principal effect
of modifying the weak Laplacian operator ∇φ, ν∇u] into a weak Helmholtz operator
∇φ, ν∇u) − λ(φ, u where λ depends on the time integration scheme. The second
modification requires the explicit discretisation of the non-linear terms in a similar
manner to the splitting scheme and this term is then introduced as the forcing term f .
For more details see [1, 32].
142 Chapter 10 Incompressible Navier-Stokes Solver
In Nektar++ it is then possible to use the following tools to perform stability analysis:
The equations that describe the evolution of an infinitesimal disturbance in the flow
can be derived decomposing the solution into a basic state (U, p) and a perturbed state
U + εu0 with ε 1 that both satisfy the Navier-Stokes equations. Substituting into
the Navier Stokes equations and considering that the quadratic terms u0 · ∇u0 can be
10.1 Synopsis 143
∂u0
+ U · ∇u0 + u0 · ∇U = −∇p + ν∇2 u0 + f (10.18a)
∂t
∇ · u0 (10.18b)
The linearised Navier-Stokes equations are identical in form to the non-linear equation,
except for the non-linear advection term. Therefore the numerical techniques used for
solving Navier-Stokes equations can still be applied as long as the non-linear term is
substituted with the linearised one. It is possible to define the linear operator that
evolved the perturbation forward in time:
Let us assume that the base flow U is steady, then the perturbations are autonomous
and we can assume that:
The dominant eigenvalue determines the behaviour of the flow. If it the real part is
positive there exists exponentially growing solutions, conversely if every single eigenvalues
has negative real part then the flow is linearly stable. If the real part of the eigenvalue is
zero, it is present a bifurcation point.
!
1
−∂t − (U · ∇) + (∇U) · + Re ∇2 −∇
Hq = 0 where H = (10.22)
∇· 0
Integrating by parts and employing the divergence theorem, it is possible to express the
adjoint equations:
∂u∗ 1 2
− + (U · ∇)u∗ + (∇U)T · u∗ = −∇p∗ + ∇ u (10.24a)
∂t Re
∇ · u∗ = 0 (10.24b)
The adjoint fields are in fact related to the concept of receptivity. The value of the
adjoint velocity at a point in the flow indicates the response that arises from an unsteady
momentum source at that point. The adjoint pressure and the adjoint stream function
play instead the same role for mass and vorticity sources respectively. Therefore, the
adjoint modes can be seen as a powerful tool to understand where to act in order to
ease/inhibit the transition.
where σ = ku0 (τ )k. This is no other that the singular value decomposition of A(τ ). The
phenomenology of the transient growth can be explained considering the non-normality of
the linearised Navier-Stokes evolution operator. This can be simply understood using the
simple geometric example showed in figure 10.1.3.3. Let us assume a unit-length vector
f represented in a non-orthogonal basis .This vector is defined as the difference of the
nearly collinear vectors Φ1 and Φ2 . With the time progression, the component of these
two vectors decrease respectively by 20% and 50%. The vector f increases substantially
in length before decaying to zero. Thus, the superposition of decaying non-orthogonal
eigenmode can produce in short term a growth in the norm of the perturbations.
10.1 Synopsis 145
Figure 10.2 Geometric interpretation of the transient growth. Adapted from Schmid, 2007
where q represents the problem unknown(s), the dot represents the time derivative, N S
represents the Navier-Stokes equations, χ ∈ R+ is the control coefficient, q̄ is a filtered
version of q, and ∆ ∈ R∗+ is the filter width of a first-order low-pass time filter. The
steady-state solution is reached when q = q̄.
The convergence of the method towards a steady-state solution depends on the choice of
the parameters χ and ∆. They have to be carefully chosen: if they are too small, the
instabilities within the flow can not be damped; but if they are too large, the method
may converge extremely slowly. If the dominant eigenvalue of the flow studied is known
(and given as input), the algorithm implemented can automatically select parameters
that ensure a fast convergence of the SFD method. Most of the time, the dominant
eigenvalue is not know, that is why an adaptive algorithm that adapts χ and ∆ all along
the solver execution is also implemented.
Note that this method can not be applied for flows with a pure exponential growth of
146 Chapter 10 Incompressible Navier-Stokes Solver
the instabilities (e.g. jet flow within a pipe). In other words, if the frequency of the
dominant eigenvalue is zero, then the SFD method is not a suitable tool to obtain a
steady-state solution.
10.2 Usage
IncNavierStokesSolver session.xml
In the following the possible options are shown for the incompressible Navier-Stokes.
The Expansion section for an incompressible flow simulation can be set as for other
solvers regardless of the projection type. Here an example for a 3D simulation (for 2D
simulations the specified fields would be just u,v,p ).
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="6" FIELDS="u,v,w,p" TYPE="MODIFIED" />
3 </EXPANSIONS>
In case of a simulation using the Direct Solver we need to set FIELDS=u,v as the pressure
expansion order will be automatically set to fulfil the inf-sup condition. Possible choices
for the expansion TYPE are:
Basis TYPE
Modal MODIFIED
Nodal GLL_LAGRANGE
Nodal SEM GLL_LAGRANGE_SEM
• EqType : sets the kind of equations we want to solve on the domain as:
1 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes"/>
• SolverType : sets the scheme we want to use to solve the set of equations as
1 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
Possible values are SubStepping or Standard with “Standard” being the default
value if nothing is specifiied.
This option is useful if you wish to use an overall scheme that is first order accurate
for example with TimeIntegrationMethod as BDFImplicitOrder1 but using a second
order RungeKutta2_ImprovedEuler for greater stability in the substep.
• GlobalSysSoln : sets the approach we use to solve the the linear systems of the
type Ax = b appearing in the solution steps, such as the Poisson equation for the
pressure in the splitting-scheme. It can be set as
1 <I PROPERTY="GlobalSysSoln" VALUE="IterativeStaticCond"/>
In a Quasi-3D simulation, this will affect both the Fourier and the spectral/hp expan-
sions. To activate them independently, use SpectralVanishingViscositySpectralHP
and SpectralVanishingViscosityHomo1D .
• DEALIASING : activates the 3/2 padding rule on the advection term of a Quasi-3D
simulation.
1 <I PROPERTY="DEALIASING" VALUE="ON"/>
10.3.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• SubStepCFL : sets the CFL safety limit for the sub-stepping algorithm (default
value = 0.5)
• SVVCutoffRatio : sets the ratio of Fourier frequency not affected by the SVV
technique (default value = 0.75, i.e. the first 75% of frequency are not damped)
N
J0 (i3/2 αn r/R) iωn t
A˜n [1 −
X
w(r, t) = A0 (1 − (r/R)2 ) + ]e
n=1
J0 (i3/2 α)
and A˜n (n = 1 : N )are the Fourier coefficients scaled in the following way:
1
A˜n = 2An /[1 − ]
J0 (i3/2 α)
A file containing the Fourier coefficients, Ã, must be in the directory where the solver
is called from. The name of the file is defined by the string given in the attribute
USERDEFINEDTYPE after the “:” and contains the real and imaginary coefficients. This
file has the format
1 <NEKTAR>
2 <WOMERSLEYBC>
3 <WOMPARAMS>
4 <W PROPERTY="Radius" VALUE="0.5" />
5 <W PROPERTY="Period" VALUE="1.0" />
6 <W PROPERTY="axisnormal" VALUE="0.0,0.0,1.0" />
7 <W PROPERTY="axispoint" VALUE="0.0,0.0,0.0" />
8 </WOMPARAMS>
9
10 <FOURIERCOEFFS>
11 <F ID="0"> 0.600393641193, 0.0 </F>
12 <F ID="1"> -0.277707172935, 0.0767582715413 </F>
13 <F ID="2"> -0.0229953131146, 0.0760936232478 </F>
14 <F ID="3"> 0.00858135174058, 0.017089888642 </F>
15 <F ID="4"> 0.0140332527651, 0.0171575122496 </F>
16 <F ID="5"> 0.0156970122129, -0.00547357750345 </F>
17 <F ID="6"> 0.00473626554238, -0.00498786519876 </F>
18 <F ID="7"> 0.00204434981523, -0.00614566561937 </F>
19 <F ID="8"> -0.000274697215201, 0.000153571881197 </F>
20 <F ID="9"> -0.000148037910774, 2.68919619581e-05 </F>
21 </FOURIERCOEFFS>
22 </WOMERSLEYBC>
23 </NEKTAR>
10.3 Session file configuration 151
Similarly in the WOMPARAMS section the key parameters of the boundary condition are
also provided as:
10.3.4 Forcing
10.3.4.1 MovingBody
Note
This force type is only supported for the Quasi-3D incompressible Navier-Stokes
solver.
This force type allows the user to solve the interaction system of an incompressible fluid
flowing past a flexible moving bodies [27]. By this forcing function, one can eliminate
the difficulty of moving mesh by using body-fitted coordinates, so that an additional
acceleration term(i.e., forcing term) is introduced to the momentum equations by the
non-inertial transform from the deformed and moving coordinate system to non-deformed
and stationary one.
1 <FORCE TYPE="MovingBody">
2 </FORCE>
Available options of the motion type for the moving body include free, constrained and
forced vibrations, which can be specified in the SOLVERINFO section. The free type of
motion allows the body to move in both streamwise and crossflow directions, while the
constrained type limits the motion only in the crossflow direction. For the forced type,
the vibration profiles of the body should be specified as a given function or read from
input file in MovingBody section. here an example,
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
3 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
4 <I PROPERTY="EvolutionOperator" VALUE="SkewSymmetric" />
5 <I PROPERTY="Projection" VALUE="Galerkin" />
6 <I PROPERTY="GlobalSysSoln" VALUE="DirectStaticCond"/>
7 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2" />
152 Chapter 10 Incompressible Navier-Stokes Solver
For the simulation of low mass ratio, there is an option to activate fictitious mass method
for stabilizing explicit coupling between the fluid solver and structural dynamic solver.
Here we need to specify the values of fictitious mass and damping in PARAMETERS , for
example,
1 <SOLVERINFO>
2 <I PROPERTY="FictitiousMassMethod" VALUE="True"/>
3 </SOLVERINFO>
4 <PARAMETERS>
5 <P> FictDamp = 1000 </P>
6 <P> FictMass = 1.5 </P>
7 </PARAMETERS>
1 <FORCE TYPE="MovingBody">
2 <PARAM NAME="OutputFile">DragLift.frc</PARAM>
3 <PARAM NAME="OutputFrequency">10</PARAM>
4 <PARAM NAME="Boundary"> B[0] </PARAM>
5 </FORCE>
During the execution a file named DragLift.frc will be created and the value of the
aerodynamic forces on boundary 0, defined in the GEOMETRY section, will be output every
10 time steps.evaluates the aerodynamic forces along the moving body surface. The forces
for each computational plane are projected along the Cartesian axes and the pressure
and viscous contributions are computed in each direction.
Also, to use this module a MAPPING needs to be specified, as described in section 10.6.
In the case of free and constrained motion presented here, the functions defined by the
mapping act as initial conditions. Also, when using the MovingBody forcing, it is not
necessary to set the TIMEDEPENDENT property of the mapping.
The type of equation which is to be solved is specified through the EqType option in the
session file. This can be set to any of the following:
Equation to solve
∂u0
∂t
+ L(U, u0 ) = −∇p + ν∇2 u0
• EvolutionOperator :
154 Chapter 10 Incompressible Navier-Stokes Solver
10.4.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• kdim : sets the dimension of the Krylov subspace κ. Can be used in: ModifiedArnoldi
and Arpack . Default value: 16.
10.5 Steady-state solver Session file configuration 155
• nits : sets the maximum number of iterations. Can be used in: ModifiedArnoldi
and Arpack . Default value: 500.
• HomModesZ : sets the number of planes in the homogeneous directions. Can be used
in Homogeneous set to 1D and ModeType set to MultipleModes .
• N_slices : sets the number of temporal slices for Floquet stability analysis.
• realShift : provide a real shift to the direct sovler eigenvalue problem by the
specified value.
10.4.3 Functions
When using the direct solver for stability analysis it is necessary to specify a Forcing
function “StabilityCoupledLNS” in the form:
1 <FORCING>
2 <FORCE TYPE="StabilityCoupledLNS">
3 </FORCE>
4 </FORCING>
This is required since we need to tell the solver to use the existing field as a forcing
function to the direct matrix inverse as part of the Arnoldi iteration.
Note
Examples of the set up of the direct solver stability analysis (and other incom-
pressible Navier-Stokes solvers) can be found in the regression test directory
NEKTAR/solvers/IncNavierStokesSolver/Tests . See for example the files
PPF_R15000_ModifiedArnoldi_Shift.tst and PPF_R15000_3D.xml noting
that some parameters are specified in the .tst files.
In this section, we detail how to use the steady-state solver (that implements the selective
frequency damping method, see Sec. 10.1.4). Two cases are detailed here: the execution
of the classical SFD method and the adaptive SFD method, where the control coefficient
156 Chapter 10 Incompressible Navier-Stokes Solver
χ and the filter width ∆ of the SFD method are updated all along the solver execution.
For the second case, the parameters of the SFD method do not need to be defined by the
user (they will be automatically calculated all along the solver execution) but several
session files must be defined in a very specific way.
10.5.1.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• Kinvis : sets the kinematic viscosity ν. It is typically 1/Re if both the characteristic
velocity and characteristic length are chosen to be 1.
• ControlCoeff : sets the control coefficient χ of the SFD method. Default value: 1.
• FilterWidth : sets the filter width ∆ of the SFD method. Default value: 2.
• GrowthRateEV and FrequencyEV : if the growth rate and the frequency of the
dominant eigenvalue are known, they can be given given as input and the code will
automatically select the optimum parameters χ and ∆ (and overwrite the values of
ControlCoeff and GrowthRateEV that may be given in the session file)
• TOL : sets the tolerance of the SFD method. The code will run until ||q − q̄||inf <
T OL. Default value: 10−8 .
Note that for the steady-state solver, the parameter NumSteps is not taken into account.
The solver will run until a steady-state solution is found and not for a pre-defined number
of time steps.
The requirements for the file Session.xml are similar as for the ones for the classical
SFD method. The Geometry section being removed and placed in Session.xml.gz .
10.6 Coordinate transformations Session file configuration 157
This file defines the properties of the nonlinear problem solved (i.e. the flow for which
we want a steady-state). Also, the SOLVERINFO section must contain the line:
1 <I PROPERTY="EvolutionOperator" VALUE="AdaptiveSFD" />
The adaptive SFD method used is coupled with a stability analysis method. Then kdim ,
nvec , evtol and nits should be defined into the PARAMETERS section of Session.xml .
If not, these parameters will take the default values presented in Sec. 10.4.
The goal of running the stability analysis is to evaluate the dominant eigenvalue of a
“partially converged” steady base flow. This approximation is then used by the steady-
state solver to select a control coefficient χ and a filter width ∆ then ensure a fast
convergence towards a steady-state solution.
To define the linear stability problem, another file, that must be called Session_LinNS.xml ,
has to be defined. This file must be an exact copy/paste of Session.xml , only
three things have to be modified:
3. A random function BaseFlow has to be defined (it will be overwritten all along
the solver execution). We recommend it to be a copy of InitialConditions .
Once these three files (the Geometry in Session.xml.gz , the nonlinear problem defini-
tion in Session.xml and the homogeneous linear problem in Session_LinNS.xml ) are
correctly defined, the adaptive SFD method must be executed using:
This section describes how to include a coordinate transformation to the solution of the
incompressible Navier-Stokes equations. In some cases, this approach allows a slightly
deformed geometry to be mapped into a geometry with a homogeneous direction, which
can be treated using a quasi-3D method. It is also useful for problems with a moving
body, where otherwise a moving mesh would have to be employed.
the first two options determine if the pressure and viscous terms resulting from the
coordinate transformation are treated implicitly using an iterative procedure. If the last
option is set to true, the viscous terms in the mapping are not computed. This leads to
a faster solution, but the effect on the results need to be determined for the specific case.
By default, all mapping terms are computed and treated explicitly.
10.6.2 Parameters
When treating the mapping terms implicitly, the following parameters can be set:
1 <P> MappingPressureTolerance = 1e-8 </P> <!-- Default = 1e-12 -->
2 <P> MappingViscousTolerance = 1e-8 </P> <!-- Default = 1e-12 -->
3 <P> MappingPressureRelaxation = 0.9 </P> <!-- Default = 1.0 -->
4 <P> MappingViscousRelaxation = 0.9 </P> <!-- Default = 1.0 -->
They determine the tolerance of the iterative solution of the equations, and a relaxation
parameter which can improve the numerical stability of the method.
10.6.3 Mapping
The particular transformation employed is specified by:
1 <MAPPING TYPE="XYofZ">
2 <COORDS>Mapping</COORDS>
3 <VEL>MappingVel</VEL>
4 <TIMEDEPENDENT>True</TIMEDEPENDENT> <!-- Default is False -->
5 </MAPPING>
The available values for TYPE , and the transformations they represent, are:
Mapping type x̄ ȳ z̄
Translation x + f (t) y + g(t) z + h(t)
XofZ x + f (z, t) y z
XofXZ f (x, z, t) y z
XYofZ x + f (z, t) y + g(z, t) z
XYofXY f (x, y, t) g(x, y, t) z
General f (x, y, z, t) g(x, y, z, t) h(x, y, z, t)
10.6 Coordinate transformations Session file configuration 159
where (x̄, ȳ, z̄) are the Cartesian (physical) coordinates and (x, y, z) are the transformed
coordinates. Note that for quasi-3D problems, the z coordinate cannot be transformed.
10.6.4 Functions
The function COORDS (and VEL for time dependent mappings) indicated in the MAPPING
section need to be defined, for example as:
1 <FUNCTION NAME="Mapping">
2 <E VAR="x" VALUE="x + cos(PI*z)" />
3 <E VAR="y" VALUE="y + cos(2*PI*t)" />
4 </FUNCTION>
5
6 <FUNCTION NAME="MappingVel">
7 <E VAR="vx" VALUE="0.0" />
8 <E VAR="vy" VALUE="-1.0*2*PI*sin(2*PI*t)" />
9 </FUNCTION>
When using the MovingBody boundary condition, the Dirichlet condition is relative to
the boundary, while the regular Dirichlet boundary condition is taken in an absolute
sense.
All Dirichlet boundary conditions are specified in the Cartesian (physical) space, and are
automatically transformed to the computational frame of reference.
Note
Examples of the use of mappings can be found in the test direc-
tory NEKTAR/solvers/IncNavierStokesSolver/Tests . See for exam-
ple the files KovaFlow_3DH1D_P8_16modes_Mapping-implicit.xml and
CylFlow_Mov_mapping.xml .
160 Chapter 10 Incompressible Navier-Stokes Solver
It is important to note that restarting the simulation after the refinement can be an
expensive operation (in a typical case 200 times the cost of a single time step). Therefore,
the number of steps between successive refinements needs to be carefully chosen, since
if this value is too low the procedure becomes inefficient, while if it is too high the
refinement might not capture accurately structures that are convected by the flow.
10.7.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• NumSteps : when using the adaptive order procedure, this parameter determines
the number of time steps between successive refinements.
• NumRuns : this parameter defines the number of times the sequence of solving the
equation and refining is performed. Therefore, the total number of time steps in
the simulation is N umSteps × N umRuns.
• AdaptiveMaxModes : sets the maximum number of modes (in each direction) that
can be used in an element during the adaptive procedure. The solution will not be
refined beyond this point, even if the error is higher than the tolerance. Default
value: 12.
• AdaptiveMinModes : sets the minimal number of modes (in each direction) that can
be used in an element during the adaptive procedure. Default value: 4.
10.8 Advecting extra passive scalar fields 161
10.7.3 Functions
Spatially varying tolerances can be specified by defining the functions AdaptiveLowerinModes
and/or AdaptiveUpperTolerance . In this case, the tolerance in an element is taken as
the average of the function in the quadrature points of the element. If these functions
are defined, the values set for the tolerances in the PARAMETERS section are ignored.
note that this will only affect the polynomial order. The initial condition still needs to
be set correctly, and does not need to come from the same file used for the expansions.
In some cases, it might be useful to advect passive scalar fields with the velocity obtained
from the solution of the Navier-Stokes equation. For example, in study of mass transfer
or heat transfer problems where getting analytical expression for advection velocity is
not possible, the transport (advection-diffusion) equation needs to be solved along with
the Navier-Stokes equation to get the scalar concentration or temperature distribution in
the flow field.
In the input file, the extra field variables that are being advected need to be defined
after the variables representing the velocity components. The pressure needs to be at the
end of the list. For example, for a 2D simulation the expansions and variables would be
defined as
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="5" FIELDS="u,v,c1,c2,p" TYPE="MODIFIED" />
162 Chapter 10 Incompressible Navier-Stokes Solver
3 </EXPANSIONS>
4
5 <VARIABLES>
6 <V ID="0"> u </V>
7 <V ID="1"> v </V>
8 <V ID="2"> c1 </V>
9 <V ID="3"> c2 </V>
10 <V ID="4"> p </V>
11 </VARIABLES>
where u, v are the velocity components, c1 and c2 are extra fields that are being advected
and p is the pressure.
In addition, diffusion coefficients for each extra variable can be specified by adding a
function DiffusionCoefficient
1 <FUNCTION NAME="DiffusionCoefficient">
2 <E VAR="c1" VALUE="0.1" />
3 <E VAR="c2" VALUE="0.01" />
4 </FUNCTION>
Boundary conditions for the extra fields are set up in the same way as the velocity and
pressure
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="u" VALUE="0" />
4 <D VAR="v" VALUE="0" />
5 <D VAR="c1" VALUE="1" />
6 <D VAR="c2" VALUE="0" />
7 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
8 </REGION>
9 </BOUNDARYCONDITIONS>
It should be noted that if the diffusion coefficient is too small, the transport equation
becomes advection dominated. This leads to small grid spacing required to resolve all
physical scales associated with the transport equation (the ratio of resolution required for
transport to Navier Stokes equation scales with Sc3/4 , where Sc is the Schmidt number
= kinematic viscosity/diffusion coefficient). Hence, small diffusion coefficient might lead
to spurious oscillations if the mesh spacing is not small enough.
10.9 Examples
This example demonstrates the use of the velocity correction o solve the 2D Kovasznay
flow at Reynolds number Re = 40. In the following we will numerically solve for the two
dimensional velocity and pressure fields with steady boundary conditions.
10.9 Examples 163
We next specify the solver information for our problem. In particular, we select the
velocity correction scheme formulation, using a continuous Galerkin projection. For this
scheme, an implicit-explicit ime-integration scheme must be used and we choose one of
second order.
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
3 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
4 <I PROPERTY="AdvectionForm" VALUE="Convective" />
5 <I PROPERTY="Projection" VALUE="Galerkin" />
6 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2" />
7 </SOLVERINFO>
The key parameters are listed below. Since the problem is unsteady we prescribe the
time step and the total number of time steps. We also know the required Reynolds
number, but we must prescribe the kinematic viscosity to the solver. We first define a
dummy parameter for the Reynolds number, and then define the kinematic viscosity as
the inverse of this. The value of λ is used when defining the boundary conditions and
exact solution. Note that PI is a pre-defined constant.
1 <PARAMETERS>
2 <P> TimeStep = 0.001 </P>
3 <P> NumSteps = 100 </P>
4 <P> Re = 40 </P>
5 <P> Kinvis = 1/Re </P>
6 <P> LAMBDA = 0.5*Re-sqrt(0.25*Re*Re+4*PI*PI)</P>
7 </PARAMETERS>
11 </REGION>
12 <REGION REF="2">
13 <N VAR="u" VALUE="0" />
14 <D VAR="v" VALUE="0" />
15 <N VAR="p" VALUE="0" />
16 </REGION>
17 </BOUNDARYCONDITIONS>
Initial conditions are obtained from the file KovaFlow_m8.rst, which is a Nektar++ field
file. This is the output of an earlier simulation, renamed with the extension rst to
avoid being overwritten, and is used in this case to reduce the integration time necessary
to obtain the steady flow.
1 <FUNCTION NAME="InitialConditions">
2 <F FILE="KovaFlow_m8.rst" />
3 </FUNCTION>
Note the use of the F tag to indicate the use of a file. In contrast, the exact solution is
prescribed using analytic expressions which requires the use of the E tag.
1 <FUNCTION NAME="ExactSolution">
2 <E VAR="u" VALUE="1-exp(LAMBDA*x)*cos(2*PI*y)" />
3 <E VAR="v" VALUE="(LAMBDA/2/PI)*exp(LAMBDA*x)*sin(2*PI*y)" />
4 <E VAR="p" VALUE="0.5*(1-exp(2*LAMBDA*x))" />
5 </FUNCTION>
IncNavierStokesSolver KovaFlow_m8.xml
After completing the prescribed 100 time-steps, the difference between the computed
solution and the exact solution will be displayed. The actual mantissas may vary slightly,
but the overall magnitude should be as shown.
We note that in this example the “VALUE” property is set based on the analytic solution
but this is not typically known and so often a VALUE of zero will be specified.
Instead of loading an initial condition from a specified file, we initialized the flow fields
in this example by using following expressions
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="u" VALUE="(1-exp(KovLam*x)*cos(2*PI*y))" />
3 <E VAR="v" VALUE="(KovLam/(2*PI))*exp(KovLam*x)*sin(2*PI*y)" />
4 <E VAR="p" VALUE="0.5*(1-exp(2*KovLam*x))" />
5 </FUNCTION>
IncNavierStokesSolver KovaFlow_m8_short_HOBC.xml
The physical solution visualized in velocity profiles is also illustrated in Figure 10.4.
Figure 10.4 Velocity profiles for the Kovasznay Flow in truncated domain (2D).
10.9 Examples 167
In the solver information, we must instead select the Steady-Oseen equation type and
choose to use the coupled linearised Navier-Stokes
1 <I PROPERTY="EQTYPE" VALUE="SteadyOseen" />
2 <I PROPERTY="SolverType" VALUE="CoupledLinearisedNS" />
Note
Since we are using a coupled system, we are not solving for the pressure.
We should therefore remove all references to the variable p in the ses-
sion. In particular, it should be removed from the EXPANSIONS , VARIABLES ,
BOUNDARYCONDITIONS and FUNCTIONS sections of the file.
Instead of loading an initial condition from file, we can simply prescribe a zero field.
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="u" VALUE="0" />
3 <E VAR="v" VALUE="0" />
4 </FUNCTION>
IncNavierStokesSolver Oseen_m8.xml
The resulting flow field should match the solution from the previous example.
168 Chapter 10 Incompressible Navier-Stokes Solver
A first-order time integration scheme is used and we set the time-step and number of time
integration steps in the parameters section. We also prescribe the kinematic viscosity
ν = 1/Re = 1.
Boundary conditions are defined on the walls (region 0) and at the inflow (regions 1) as
Dirichlet for the velocity field and as high-order for the pressure. At the outflow the
velocity is left free using Neumann boundary conditions and the pressure is pinned to
zero.
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="u" VALUE="0" />
4 <D VAR="v" VALUE="0" />
5 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
6 </REGION>
7 <REGION REF="1">
8 <D VAR="u" VALUE="y*(1-y)" />
9 <D VAR="v" VALUE="0" />
10 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
11 </REGION>
12 <REGION REF="2">
13 <N VAR="u" VALUE="0" />
14 <N VAR="v" VALUE="0" />
15 <D VAR="p" VALUE="0" />
16 </REGION>
17 </BOUNDARYCONDITIONS>
Initial conditions are set to zero. The exact solution is a parabolic profile with a pressure
gradient dependent on the Reynolds number. This is defined to allow verification of the
calculation.
1 <FUNCTION NAME="ExactSolution">
2 <E VAR="u" VALUE="y*(1-y)" />
3 <E VAR="v" VALUE="0" />
4 <E VAR="p" VALUE="-2*Kinvis*(x-1)" />
5 </FUNCTION>
10.9 Examples 169
IncNaverStokesSolver ChanFlow_m3_SKS.xml
The error in the solution should be displayed and be close to machine precision
Figure 10.5 Pressure and velocity profiles for the laminar channel flow (2D).
Note
In order to run the example, you must have a version of Nektar++ compiled
with MPI. This is the case for the packaged binary distributions.
170 Chapter 10 Incompressible Navier-Stokes Solver
The solver information and parameters are similar to the previous example. Boundary
conditions must now be defined on the six faces of the domain. Flow is prescribed in the
z-direction through imposing a Poiseulle profile on the inlet and side walls. The outlet is
zero-Neumann and top and bottom faces impose zero-Dirichlet conditions.
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B> <!-- Inlet -->
3 <B ID="1"> C[6] </B> <!-- Outlet -->
4 <B ID="2"> C[2] </B> <!-- Wall -->
5 <B ID="3"> C[3] </B> <!-- Wall left -->
6 <B ID="4"> C[4] </B> <!-- Wall -->
7 <B ID="5"> C[5] </B> <!-- Wall right -->
8 </BOUNDARYREGIONS>
9
10 <BOUNDARYCONDITIONS>
11 <REGION REF="0">
12 <D VAR="u" VALUE="0" />
13 <D VAR="v" VALUE="0" />
14 <D VAR="w" VALUE="y*(1-y)" />
15 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
16 </REGION>
17 <REGION REF="1">
18 <N VAR="u" VALUE="0" />
19 <N VAR="v" VALUE="0" />
20 <N VAR="w" VALUE="0" />
21 <D VAR="p" VALUE="0" />
22 </REGION>
23 <REGION REF="2">
24 <D VAR="u" VALUE="0" />
25 <D VAR="v" VALUE="0" />
26 <D VAR="w" VALUE="0" />
27 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
28 </REGION>
29 <REGION REF="3">
30 <D VAR="u" VALUE="0" />
31 <D VAR="v" VALUE="0" />
32 <D VAR="w" VALUE="y*(1-y)" />
33 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
34 </REGION>
35 <REGION REF="4">
36 <D VAR="u" VALUE="0" />
37 <D VAR="v" VALUE="0" />
10.9 Examples 171
Figure 10.6 Pressure and velocity profiles for the laminar channel flow (full 3D).
The parameter HomModesZ specifies the number of Fourier modes to use in the homoge-
neous direction. The LZ parameter specifies the physical length of the domain in that
direction.
Note
This example uses an in-built Fourier transform routine. Alternatively, one
can use the FFTW library to perform Fourier transforms which typically offers
improved performance. This is enabled using the following solver information
1 <I PROPERTY="USEFFT" VALUE="FFTW"/>
As with the the spectral/hp element mesh consists of four quadrilateral elements with a
second-order polynomial expansion. Since our domain is three-dimensional we have to
now include the third velocity component
1 <E COMPOSITE="C[0]" NUMMODES="3" FIELDS="u,v,w,p" TYPE="MODIFIED" />
Boundary conditions are specified as for the two-dimensional case (except with the
addition of the third velocity component) since the side walls are now implicitly periodic.
The initial conditions and exact solution are prescribed as for the fully three-dimensional
case.
The results can be post-processed and should match those of the fully three-dimensional
case as shown in Figure 10.6.
Note
This example requires the FFTW Fast-Fourier transform library to be selected
when compiling Nektar++.
The spanwise length of the channel is set using the LZ parameter and discretised with
32 Fourier modes by setting the value of HomModesZ .
1 <P> HomModesZ = 32 </P>
2 <P> LZ = 4*PI/3 </P>
A second-order IMEX scheme is used for time-integration scheme is used with a time-step
of 0.0001. The length of the simulation is 1 time-unit (10,000 steps).
In this example, we will use a body force to drive the flow and so, in addition to the
spanwise periodicity, enforce periodicity in the streamwise direction of the spectral/hp
element mesh. This is achieved by imposing the following boundary conditions
1 <REGION REF="1">
2 <P VAR="u" VALUE="[2]" />
174 Chapter 10 Incompressible Navier-Stokes Solver
Here, we use P to denote the boundary type is periodic, and the value in square brackets
denotes the boundary region to which the given boundary is periodic with. In this case
regions 1 and 2 are denoted periodic with each other.
The second defines the BodyForce function which will be used and is located within the
CONDITIONS section,
1 <FUNCTION NAME="BodyForce">
2 <E VAR="u" VALUE="2*Kinvis" />
3 <E VAR="v" VALUE="0" />
4 <E VAR="w" VALUE="0" />
5 </FUNCTION>
To improve numerical stability, we also enable dealising of the advection term. This uses
additional points to perform the quadrature and then truncates the higher-order terms
when projecting back onto the polynomial space, thereby removing spurious oscillations.
It is enabled by setting the solver information tag
1 <I PROPERTY="DEALIASING" VALUE="ON" />
This feature is only available when using the FFTW library is used, so we enable this
using
1 <I PROPERTY="USEFFT" VALUE="FFTW" />
IncNaverStokesSolver TurbChFl_3DH1D.xml
The input file for this example is Pipe_turb.xml . We use 7th-order lagrange polynomials
through the Gauss-Lobatto-Legendre points for the quadrilateral expansions.
1 <E COMPOSITE="C[0]" NUMMODES="8" FIELDS="u,v,w,p" TYPE="GLL_LAGRANGE_SEM" />
We set the Fourier options, as in the previous example, except using 128 modes and a
length of 5 non-dimensional units. A small amplitude noise is also added to the initial
condition, which is a plug profile, to help stimulate transition. Since the streamwise
direction is the Fourier direction, we must necessarily use a body force to drive the flow.
176 Chapter 10 Incompressible Navier-Stokes Solver
To improve the efficiency of the solver further, we would prefer to solve the Helmholtz
problems within the spectral/hp element planes using a direct solver (since no paralleli-
sation is necessary). The default when running in parallel is to use an iterative solver, so
we explicitly specify the type of algorithm to use in the session file solver information:
1 <I PROPERTY="GlobalSysSoln" VALUE="DirectStaticCond" />
When the pipe transitions, the result should look similar to Figure 10.10.
In the following we will numerically solve for the three dimensional velocity and pressure
field for steady boundary conditions. The Reynolds number under consideration is 300,
which is physiologically relevant.
Geometry
The geometry under consideration is a segment of a rabbit descending aorta with two
pairs of intercostal arteries branching off. The inlet has a diameter D = 3.32mm.
In order to capture the physics of the flow in the boundary layer, a thin layer consisting
of prismatic elements is created adjacent to the surface, and curved using spherigons.
The interior consist of tetrahedral elements.
Input parameters
178 Chapter 10 Incompressible Navier-Stokes Solver
Figure 10.12 Surface mesh indicating curved surface elements at a branch location.
10.9.9.1 Expansion:
In this example we will use a fourth order polynomial expansion. There are two composites
defined here since we have both prismatic and tetrahedral elements.
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="5" TYPE="MODIFIED" FIELDS="u,v,w,p" />
3 <E COMPOSITE="C[1]" NUMMODES="5" TYPE="MODIFIED" FIELDS="u,v,w,p" />
4 </EXPANSIONS>
10.9.9.3 Parameters:
Since we are prescribing a Reynolds number of 300, and to simplify the problem definition,
we set the mean inlet velocity to 1, this allows us to define the kinematic viscosity as
ν = URe
D
= 3.32
300 = 1/90.36.
1 <PARAMETERS>
2 <P> TimeStep = 0.0005 </P>
3 <P> NumSteps = 1600 </P>
4 <P> IO_CheckSteps = 200 </P>
5 <P> IO_InfoSteps = 50 </P>
6 <P> Kinvis = 1.0/90.36 </P>
7 </PARAMETERS>
10.9 Examples 179
Dirichlet boundary conditions are imposed for the velocity at the inlet, as well as on the
wall to account for the no-slip condition. Neumann boundary conditions are imposed for
the velocity field at the outlets where fully developed flow is imposed.
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[2] </B> <!-- Inlet -->
3 <B ID="1"> C[3,4,5,6] </B> <!-- intercostal outlets -->
4 <B ID="2"> C[7] </B> <!-- outlet -->
5 <B ID="3"> C[8] </B> <!-- wall -->
6 </BOUNDARYREGIONS>
7
8 <BOUNDARYCONDITIONS>
9 <REGION REF="0">
10 <D VAR="u" VALUE="0.024" />
11 <D VAR="v" VALUE="-0.064" />
12 <D VAR="w" VALUE="-0.998" />
13 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
14 </REGION>
15 <REGION REF="1">
16 <N VAR="u" VALUE="0" />
17 <N VAR="v" VALUE="0" />
18 <N VAR="w" VALUE="0" />
19 <D VAR="p" VALUE="0" />
20 </REGION>
21 <REGION REF="2">
22 <N VAR="u" VALUE="0" />
23 <N VAR="v" VALUE="0" />
24 <N VAR="w" VALUE="0" />
25 <D VAR="p" VALUE="0" />
26 </REGION>
27 <REGION REF="3">
28 <D VAR="u" VALUE="0" />
29 <D VAR="v" VALUE="0" />
30 <D VAR="w" VALUE="0" />
31 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
32 </REGION>
33 </BOUNDARYCONDITIONS>
10.9.9.5 Functions:
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="u" VALUE="0" />
3 <E VAR="v" VALUE="0" />
4 <E VAR="w" VALUE="0" />
5 <E VAR="p" VALUE="0" />
6 </FUNCTION>
180 Chapter 10 Incompressible Navier-Stokes Solver
10.9.9.6 Results
We can visualise the internal velocity field by applying a volume render filter in ParaView.
It is possible to visualise the wall shear stress distribution by running the FldAddWSS
utility.
of 2D strip solution under this assumption is that it is unable to reflect the influence
of spanwise wake turbulence on the structural dynamics. In order to overcome this
shortcoming, we proposed a new module in the framework of Nektar++, in which a
spanwise scale is locally allocated to each one of the strips, so that the spanwise velocity
correlation is reconstructed in the flow field within each strips. In particular, this model
lets the fluid domain to be divided in N strips with thickness ratio of Lz /D and evenly
distributed along the spanwise (z) direction. The gap between the neighboring strips,
represented by Lg , satisfies relation Lc = N (Lz + Lg ). Since the strip in this model has
finite scale in the z-direction, we named it as finite strip to distinguish from traditional 2D
strip plane. Next, the flow dynamics within each individual strips are modeled by viscous
incompressible Navier-Stokes equations, while a tensioned beam model is employed to
govern the dynamics of the flexible structures. In this example, we will show how to
perform a finite-strip model to predict the vortex-induced vibration responses of flexible
cables. Let us consider a vortex-induced vibration of a slender cable with an aspect ratio
of Lz /D=4π, which is immersed in uniform flows at Re=100.
To use the finite strip routines we need just to insert a flag of "HomoStrip" in the solver
information as below, in addition, we need to specify the types of vibration and support
ends for the cables. In this case, the vibration type is specified as VALUE="CONSTRAINED" ,
which means that the cable’s vibration is constrained only in the crossflow direction.
Other options include VALUE="FREE" and "FORCED" , respectively corresponding to the
free vibrations in both streamwise and crossflow directions and forced vibration by
specified functions given in input file. For the support ends of the cable, another option
of VALUE="PINNED-PINNED" is available for the simulations, which satisfies the condition
of zero values of displacements on the support ends.
10.9.10.3 Parameters
All the simulation parameters are specified in the section as follows.
182 Chapter 10 Incompressible Navier-Stokes Solver
1 <PARAMETERS>
2 <P> LZ = PI/8 </P> <!--thickness ratio-->
3 <P> LC = 4*PI </P> <!--aspect ratio-->
4 <P> A = 0.025 </P>
5 <P> omega = 1.0 </P>
6 <P> PROC_Z = 16 </P>
7 <P> Strip_Z = 16 </P> <!--number of the strips-->
8 <P> DistStrip = PI/4 </P> <!--distance of the strips-->
9 <P> StructStiff = 0.02 </P>
10 <P> StructRho = 2.0 </P>
11 <P> CableTension = 8.82 </P>
12 <P> BendingStiff = 0.0 </P>
13 <P> FictDamp = 0.0 </P>
14 <P> FictMass = 3.0 </P>
15 </PARAMETERS>
16
In this example we will run the solver in parallel. We can specify the number of the
strips by providing an additional flag to the solver, –nsz. In this example, we will run 16
strips, therefore it would be specified as –nsz 16. The solver can now be run as follows
The simulation results are illustrated in spanwise vorticity contours in Figure 10.15. The
wake response of the cable appears as standing wave patter in the earlier stage and then
it transitions into traveling wave response, as shown in this figure.
Figure 10.15 Spanwise vorticity contours in standing wave and traveling wave patterns predicted
in finite strip modeling.
10.9 Examples 183
10.9.11.1 Background
We consider the linearised Incompressible Navier-Stokes equations:
∂u0
+ U · ∇u0 + u0 · ∇U = −∇p + ν∇2 u0 + f (10.27a)
∂t
∇ · u0 = 0 (10.27b)
We are interested to compute the leading eigenvalue of the system using the Arnoldi
method.
10.9.11.2 Geometry
The geometry under consideration is a 2D channel.
In the ELEMENT section, the tag T and Q define respectively triangular and quadrilateral
element. Triangular elements are defined by a sequence of three edges and quadrilateral
elements by a sequence of four edges.
184 Chapter 10 Incompressible Navier-Stokes Solver
1 <ELEMENT>
2 <Q ID="0"> 0 1 2 3 </Q>
3 ...
4 <Q ID="47"> 107 108 109 95 </Q>
5 </ELEMENT>
6
Finally, collections of elements are listed in the COMPOSITE section and the DOMAIN section
specifies that the mesh is composed by all the triangular and quadrilateral elements. The
other composites will be used to enforce boundary conditions.
1 <COMPOSITE>
2 <C ID="0"> Q[0-47] </C>
3 <C ID="1"> E[17,31,44,57,70,83,96,109,0,19,32,45,58,71,84,97] </C> //wall
4 <C ID="2"> E[3,6,9,12,15,18] </C>//inflow
5 <C ID="3"> E[98,100,102,104,106,108] </C> //outflow
6 </COMPOSITE>
7 <DOMAIN> C[0] </DOMAIN>
8 </GEOMETRY>
9
10.9.11.4 Expansion
This section defines the polynomial expansions used on each composites. For this example
we will use a 10th order polynomial, i.e. P = 11.
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="11" FIELDS="u,v,p" TYPE="MODIFIED" />
3 </EXPANSIONS>
4
10.9.11.6 Parameters
All the stability parameters are specified in this section.
10.9 Examples 185
1 <PARAMETERS>
2 <P> TimeStep = 0.002 </P>
3 <P> NumSteps = 500 </P>
4 <P> IO_CheckSteps = 1000 </P>
5 <P> IO_InfoSteps = 10 </P>
6 <P> Re = 7500 </P>
7 <P> Kinvis =1./Re </P>
8 <P> kdim =16 </P>
9 <P> nvec =2 </P>
10 <P> evtol =1e-5</P>
11 <P> nits =5000 </P>
12 </PARAMETERS>
13
10.9.11.8 Function
We need to set up the base flow that can be specified as a function BaseFlow. In case
the base flow is not analytical, it can be generated by means of the Nonlinear evolution
operator using the same mesh and polynomial expansion. The initial guess is specified in
the InitialConditions functions and can be both analytical or a file. In this example
it is read from a file.
1 <FUNCTION NAME="BaseFlow">
2 <F VAR="u,v,p" FILE="ChanStability.bse" />
3 </FUNCTION>
4
5 <FUNCTION NAME="InitialConditions">
186 Chapter 10 Incompressible Navier-Stokes Solver
10.9.11.9 Usage
IncNavierStokesSolver ChanStability.xml
10.9.11.10 Results
The stability simulation takes about 250 iterations to converge and the dominant eigen-
values (together with the respective eigenvectors) will be printed. In this case it was
found λ1,2 = 1.000224 × e±0.24984i . Therefore, since the magnitude of the eigenvalue is
larger than 1, the flow is absolutely unstable. It is possible to visualise the eigenvectors
using the post-processing utilities. The figure shows the profile of the two eigenmode
component, which shows the typical Tollmien - Schlichting waves that arise in viscous
boundary layers.
Figure 10.16
10.9.12.1 Background
We consider the equations:
∂u∗ 1 2
− + (U · ∇)u∗ + (∇U)T · u∗ = −∇p∗ + ∇ u (10.28a)
∂t Re
10.9 Examples 187
Figure 10.17
∇ · u∗ = 0 (10.28b)
We are interested in computing the leading eigenvalue of the system using the Arnoldi
method.
10.9.12.5 Functions
We need to set up the base flow that can be specified as a function BaseFlow. In case
the base flow is not analytical, it can be generated by means of the Nonlinear evolution
operator using the same mesh and polynomial expansion.
1 <FUNCTION NAME="BaseFlow">
2 <F VAR="u,v,p" FILE="ChanStability.bse" />
3 </FUNCTION>
4
The initial guess is specified in the InitialConditions functions and can be both
analytical or a file. In this example it is read from a file.
1 <FUNCTION NAME="InitialConditions">
2 <F VAR="u,v,p" FILE="ChanStability.rst" />
3 </FUNCTION>
10.9 Examples 189
10.9.12.6 Usage
IncNavierStokesSolver ChanStability_adj.xml
10.9.12.7 Results
The equations will then be evolved backwards in time (consistently with the negative
sign in front of the time derivative) and the leading eigenvalues will be computed after
about 300 iterations. It is interesting to note that their value is the same one computed
for the direct problem, but the eigenmodes present a different shape.
Figure 10.18
Figure 10.19
190 Chapter 10 Incompressible Navier-Stokes Solver
Figure 10.20
10.9.13.1 Background
Transient growth analysis allows us to study the presence of convective instabilities that
can arise in stable flows. Despite the fact that these instabilities will decay for a long time
(due to the stability of the flow), they can produce significant increases in the energy of
perturbations. The phenomenon of transient growth is associated with the non-normality
of the linearised Navier-Stokes equations and it consists in computing the perturbation
that leads to the highest energy growth for a fixed time horizon.
In the ELEMENT section, the tag T and Q define respectively triangular and quadrilateral
element. Triangular elements are defined by a sequence of three edges and quadrilateral
elements by a sequence of four edges.
1 <ELEMENT>
2 <T ID="0"> 0 1 2 </T>
3 ...
4 <T ID="209"> 333 314 332 </T>
5 <Q ID="210"> 334 335 336 0 </Q>
6 ...
7 <Q ID="429"> 826 827 828 818 </Q>
8 </ELEMENT>
9
Finally, collections of elements are listed in the COMPOSITE section and the DOMAIN section
specifies that the mesh is composed by all the triangular and quadrilateral elements. The
other composites will be used to enforce boundary conditions.
1 <COMPOSITE>
2 <C ID="0"> T[0-209] </C>
3 <C ID="1"> Q[210-429] </C>
4 <C ID="2"> E[2-3,7,10,16,21,2,...,828] </C>
5 <C ID="3"> E[821,823,825,827] </C>
6 <C ID="4"> E[722,724,726,728] </C>
7 </COMPOSITE>
8
9 <DOMAIN> C[0,1] </DOMAIN>
10 </GEOMETRY>
11
10.9.13.3 Expansion
For this example we will use a 6th order polynomial, i.e. P = 7:
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="7" FIELDS="u,v,p" TYPE="MODIFIED" />
3 <E COMPOSITE="C[1]" NUMMODES="7" FIELDS="u,v,p" TYPE="MODIFIED" />
4 </EXPANSIONS>
5
10.9.13.5 Parameters
1 <PARAMETERS>
2 <P> FinalTime = 0.1 </P>
3 <P> TimeStep = 0.005 </P>
4 <P> NumSteps = FinalTime/TimeStep </P>
5 <P> IO_CheckSteps = 1/TimeStep </P>
6 <P> IO_InfoSteps = 1 </P>
7 <P> Re = 500 </P>
8 <P> Kinvis = 1.0/Re </P>
9 <P> kdim = 4 </P>
10 <P> nvec = 1 </P>
11 <P> evtol = 1e-4 </P>
12 </PARAMETERS>
13
10.9.13.7 Functions
We need to set up the base flow that can be specified as a function BaseFlow. In case
the base flow is not analytical, it can be generated by means of the Nonlinear evolution
operator using the same mesh and polynomial expansion.
1 <FUNCTION NAME="BaseFlow">
10.9 Examples 193
The initial guess is specified in the InitialConditions functions and in this case is read
from a file.
1 <FUNCTION NAME="InitialConditions">
2 <F VAR="u,v,p" FILE="bfs_tg-AR.rst" />
3 </FUNCTION>
4
10.9.13.8 Usage
IncNavierStokesSolver bfs_tg-AR.xml
10.9.13.9 Results
The solution will be evolved forward in time using the operator A, then backward in
time through the adjoint operator A∗ . The leading eigenvalue is λ = 3.236204). This
corresponds to the largest possible transient growth at the time horizon τ = 1. The
leading eigenmode is shown below. This is the optimal initial condition which will lead
to the greatest growth when evolved under the linearised Navier-Stokes equations.
Figure 10.21
It is possible to visualise the transient growth plotting the energy evolution over time
if the system is initially perturbed with the leading eigenvector. This analysis was
performed for a time horizon τ = 60. It can be seen that the energy grows in time
194 Chapter 10 Incompressible Navier-Stokes Solver
Figure 10.22
reaching its maximum value at x = 24 and then decays, almost disappearing after 100
temporal units.
Figure 10.23
Figure 10.24
10.9.14.1 Background
The numerical solution of the fully three- dimensional linear eigenvalue problem is often
computationally demanding and may not have significant advantages over performing
a direct numerical simulation. Therefore, some simplifications are required; the most
radical consist in considering that the base flow depends only on one spatial coordinate,
assuming that the other two spatial coordinates are homogenous. While this method
offers a good prediction for the instability of boundary layers, it is not able to predict
the instability of Hagen-Poiseuille flow in a pipe at all Reynolds numbers. Between
a flow that depends upon one and three-spatial directions, it is possible to consider a
steady or time-periodic base flow depending upon two spatial directions and impose three-
dimensional disturbances that are periodic in the the third homogeneous spatial direction.
This approach is known as BiGlobal stability analysis and it represents the extension
of the classic linear stability theory; let us consider a base flow U that is function of
only two spatial coordinates: mathbf U (x, y, t). The perturbation velocity can u0 can be
expressed in a similar form, but with the dependence on the third homogeneous direction
incorporated through the Fourier mode: u0 = û0 (x, y, t)eiβz , where β = 2π/L)and L is
the length in the homogeneous direction.
196 Chapter 10 Incompressible Navier-Stokes Solver
10.9.14.3 Expansion
In this example we will use a 6th order polynomial expansion, i.e. P = 7.
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="7" TYPE="GLL_LAGRANGE_SEM" FIELDS="u,v,w,p" />
3 </EXPANSIONS>
4
10.9.14.4 Parameters
1 <SOLVERINFO>
2 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
3 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes"/>
4 <I PROPERTY="EvolutionOperator" VALUE="Direct"/>
5 <I PROPERTY="Projection" VALUE="Galerkin"/>
6 <I PROPERTY="ModeType" VALUE="HalfMode"/>
7 <I PROPERTY="Driver" VALUE= "ModifiedArnoldi" />
8 <I PROPERTY="HOMOGENEOUS" VALUE="1D"/>
9 <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2" />
10 </SOLVERINFO>
11
10.9.14.5 Functions
1 <FUNCTION NAME="BaseFlow">
2 <F VAR="u,v,p" FILE="cyinder_floq" />
3 </FUNCTION>
4
10.9.14.6 Usage
IncNavierStokesSolver session.xml
10.9.14.7 Results
The stability simulation takes about 20 cycles to converge and the leading eigenvalue is
λ = 1.2670 with a growth rate σ = 4.7694e − 02. The figure below shows the profile of
the magnitude of the eigenmode at z = 2.
10.9 Examples 197
Figure 10.25
Chapter 11
Linear elasticity solver
11.1 Synopsis
The LinearElasticSolver is a solver for solving the linear elasticity equations in two and
three dimensions. Whilst this may be suitable for simple solid mechanics problems, its
main purpose is for use for mesh deformation and high-order mesh generation, whereby
the finite element mesh is treated as a solid body, and the deformation is applied at the
boundary in order to curve the interior of the mesh.
Value Description
LinearElasticSystem Solves the linear elastic equations.
IterativeElasticSystem A multi-step variant of the elasticity solver,
which breaks a given deformation into multiple
steps, and applies the deformation to a mesh.
where S is the stress tensor and f denotes a spatially-varying force. We further assume
that the stress tensor S incorporates elastic and, optionally, thermal stresses that can
be switched on to assist in mesh deformation applications. We assume these can be
decomposed so that S is written as
S = Se + St ,
198
11.2 Usage 199
where the subscripts e and t denote the elastic and thermal terms respectively. We adopt
the usual linear form of the elastic stress tensor as
Se = λTr(E) I + µE,
where λ and µ are the Lamé constants, E represents the strain tensor, and I is the
identity tensor. For small deformations, the strain tensor E is given as
1
E= ∇u + ∇ut (11.2)
2
where u is the two- or three-dimensional vector of displacements. The boundary conditions
required to close the problem consist of prescribed displacements at the boundary ∂Ω,
i.e.
u = û in ∂Ω. (11.3)
We further express the Lamé constants in terms of the Young’s modulus E and Poisson
ratio ν as
νE E
λ= , µ= .
(1 + ν)(1 − 2ν) 2(1 + ν)
The Poisson ratio, valid in the range ν < 21 , is a measure of the compressibility of the
body, and the Young’s modulus E > 0 is a measure of its stiffness.
11.2 Usage
• EqType Specifies the PDE system to solve, based on the choices in the table above.
• Temperature Specifies the form of the thermal stresses to use. The choices are:
• BCType Specifies the type of boundary condition to apply when the IterativeElasticSystem
is being used.
200 Chapter 11 Linear elasticity solver
– Normal : The boundary conditions are split into NumSteps steps, as defined
by a parameter in the session file (default).
– Repeat : As the geometry is updated, re-evaluate the boundary conditions.
This enables, for example, a cirlce to be rotated continuously.
11.3.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• NumSteps : sets the number of steps to use in the case that the iterative elastic
system is enabled. Should be greater than 0.
Default value: 0.
11.4 Examples
rα
ur (r, θ) = [C1 (C2 − α − 1) cos((α − 1)θ) − (α + 1) cos((α + 1)θ)]
2µ
rα
uθ (r, θ) = [(α + 1) sin((α + 1)θ) + C1 (C2 + α − 1) sin((α − 1)θ)]
2µ
cos((α + 1)ω) λ + 2µ
C1 = − , C2 = 2
cos((α − 1)ω) λ+µ
with λ and µ being the Lamé constants and ω = 3π/4. Boundary conditions are set to
be the exact solution and f = 0. The solution has a singularity at the origin, and so in
order to test convergence h-refinement is required.
11.4 Examples 201
Figure 11.1 Solution of the u displacement field for the L-shaped domain.
A simple example of how the linear elastic solver can be set up can be found in the
Tests/L-shaped.xml session file in the linear elastic solver directory. A more refined
domain with the obtained u solution is shown in figure 11.1. The solver can be run using
the command:
LinearElasticSolver L-domain.xml
The obtained solution L-domain.fld can be applied to the mesh to obtain a deformed
XML file using the deform module in FieldConvert :
The setup is very straightforward. The geometry can be found inside the file Examples/bl-mesh.xml
202 Chapter 11 Linear elasticity solver
Figure 11.2 Figures that show the initial domain (left), after 50 steps (middle) and final
deformation of the domain (right).
To identify the boundary that we intend to split up into substeps, we must assign the
WALL tag to our boundary regions:
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="u" VALUE="0" USERDEFINEDTYPE="Wall" />
4 <D VAR="v" VALUE="0.5*sin(PI*x)" USERDEFINEDTYPE="Wall" />
5 </REGION>
6 <REGION REF="1">
7 <D VAR="u" VALUE="0" />
8 <D VAR="v" VALUE="0" />
9 </REGION>
10 </BOUNDARYCONDITIONS>
12.1 Synopsis
1D modelling of the vasculature (arterial network) represents and insightful and efficient
tool for tackling problems encountered in arterial biomechanics as well as other engineering
problems. In particular, 3D modelling of the vasculature is relatively expensive. 1D
modelling provides an alternative in which the modelling assumptions provide a good
balance between physiological accuracy and computational efficiency.To describe the flow
and pressure in this network we consider the conservation of mass and momentum applied
to an impermeable, deformable tube filled with an incompressible fluid, the nonlinear
system of partial differential equations presented in non-conservative form is given by
∂U ∂U
+H =S (12.1)
∂t ∂x
in which A is the Area (related to pressure), x is the axial coordinate along the vessel,
U (x, t) the axial velocity, P (x, t) is the pressure in the tube, ρ is the density and finally
f the frictional force per unit length. The unknowns in equation 12.1 are u, A and p;
hence we must provide an explicit algebraic relationship to close this system. Typically,
closure is provided by an algebraic relationship between A and p. For a thin elastic tube
this is given by
√
√
p πhE
p = p0 + β A− A0 , β= (12.2)
(1 − ν 2 )A0
203
204 Chapter 12 Pulse Wave Solver
where p0 is the external pressure, A0 is the initial cross-sectional area, E is the Young’s
modulus, h is the vessel wall thickness and ν is the Poisson’s ratio. Other more elaborate
pressure - area relationships are currently being implemented into the framework. Appli-
cation of Riemann’s method of characteristics to equations 12.1 and 12.2 indicates that
velocity and area are propagated through the system by forward and backward travelling
waves. These waves are reflected and within the network by appropriate treatment of
interfaces and boundaries. In the following, we will explain the usage of the blood flow
solver on the basis of a single-artery problem and also on an arterial network consisting
of 55 arteries.
12.2 Usage
PulseWaveSolver session.xml
Figure 12.1 Model of bifurcating artery. The bifurcation is made of three domains and 15
vertices. Vertex V[0] is the inlet and vertices V[10] and V[15] the outlets.
To represent this topology in the xml file we specify the following vertices under the
section VERTEX (the extents are: −100 ≥ x ≤ 100 and −100 ≥ y ≤ 100 )
1 <VERTEX>
2 <V ID="0">-1.000e+02 0.000e+00 0.000e+00</V>
3 <V ID="1">-8.000e+01 0.000e+00 0.000e+00</V>
4 <V ID="2">-6.000e+01 0.000e+00 0.000e+00</V>
5 <V ID="3">-4.000e+01 0.000e+00 0.000e+00</V>
12.3 Session file configuration 205
The elements from these vertices are then constructed under the section ELEMENT by
defining
1 <ELEMENT>
2 <!-- Parent artery -->
3 <S ID="0"> 0 1 </S>
4 <S ID="1"> 1 2 </S>
5 <S ID="2"> 2 3 </S>
6 <S ID="3"> 3 4 </S>
7 <S ID="4"> 4 5 </S>
8 <!-- Daughter artery 1 -->
9 <S ID="5"> 5 6 </S>
10 <S ID="6"> 6 7 </S>
11 <S ID="7"> 7 8 </S>
12 <S ID="8"> 8 9 </S>
13 <S ID="9"> 9 10 </S>
14 <!-- Daughter artery 2 -->
15 <S ID="11"> 5 11 </S>
16 <S ID="12"> 11 12 </S>
17 <S ID="13"> 12 13 </S>
18 <S ID="14"> 13 14 </S>
19 <S ID="15"> 14 15 </S>
20 </ELEMENT>
The composites, which represent groups of elements and boundary regions are defined
under the section COMPOSITE by
1 <COMPOSITE>
2 <C ID="0"> S[0-4] </C> <!-- Parent artery -->
3 <C ID="1"> V[0] </C> <!-- Inlet to domain -->
4
5 <C ID="3"> S[5-9] </C> <!-- Daughter artery 1 -->
6 <C ID="4"> V[10] </C> <!-- Outlet of daughter artery 1 -->
7
8 <C ID="6"> S[11-15] </C> <!-- Daughter artery 2 -->
9 <C ID="8"> V[15] </C> <!-- Outlet of daughter artery 2 -->
10 </COMPOSITE>
206 Chapter 12 Pulse Wave Solver
Each of the segments can be then represented under the section DOMAIN by
1 <DOMAIN>
2 <D ID="0"> C[0] </D> <!-- Parent artery -->
3 <D ID="1"> C[3] </D> <!-- Daughter artery 1 -->
4 <D ID="2"> C[6] </D> <!-- Daughter artery 2 -->
5 </DOMAIN>
We will use the different domains later to define variable material properties and cross-
sectional areas.
• TimeIntegrationMethod
• UpwindTypePulse :
– UpwindPulse
12.3.3 Parameters
The following parameters can be specified in the PARAMETERS section of the session file.
• FinTime is the final physical time at which the simulation will stop;
• NumSteps is the equivalent of FinTime but instead of specifying the physical final
time the number of time-steps is defined;
• IO_InfoSteps sets the number of steps between successive info stats are printed
to screen;
The composites that we want to apply out boundary conditions then need to be defined
in the BOUNDARYREIONS , for example if we had three composites (C[1], C[4] and C[8])
that correspond to three vertices of the computational mesh we would define:
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B>
3 <B ID="1"> C[4] </B>
4 <B ID="2"> C[8] </B>
5 </BOUNDARYREGIONS>
Finally we can specify the boundary conditions on the regions specified under BOUNDARYREGIONS .
The Pulse Wave Solver comes with a number of boundary conditions that are unique to
this solver. Boundary conditions must be provided for both the area and velocity at the
inlets and outlets of the domain. Examples of the different boundary conditions will be
provided in the following.
12.3.4.0.1 Inlet boundary condition: Typically at the inlet of the domain a flow
profile ( Q-inflow ) is specified through a USERDEFINEDTYPE boundary conditioning . An
example inlet condition for the parent artery of the previously bifurcation example is
1 <REGION REF="0">
2 <D VAR="A" USERDEFINEDTYPE="Q-inflow" VALUE="(7.112e-4)*(sin(7.854*t)
3 -0.562)*(1/(1+exp(-400*(sin(7.854*t)-0.562))))" />
4 <D VAR="u" USERDEFINEDTYPE="Q-inflow" VALUE="1.0" />
5 </REGION>
12.3.4.0.2 Terminal boundary conditions: At the outlets of the domain there are
four possible boundary conditions: reflection ( Terminal ), terminal resistance R-terminal ,
Two element windkessel (CR) CR-terminal , and three element windkessel (RCR)
RCR-terminal . An example of the outflow boundary condition of the RCR terminal is
given below
1 <REGION REF="1">
2 <D VAR="A" USERDEFINEDTYPE="RCR-terminal" VALUE="RT" />
3 <D VAR="u" USERDEFINEDTYPE="RCR-terminal" VALUE="C" />
4 </REGION>
Where RT is the total peripheral resistance used in the the R-terminal , CR-terminal
and RCR-terminal models
208 Chapter 12 Pulse Wave Solver
12.3.5 Functions
The following functions can be specified inside the CONDITIONS section of the session file:
As an example to specify the material properties for each domain in the previous
bifurcation example we would enter:
1 <FUNCTION NAME="MaterialProperties">
2 <E VAR="beta" DOMAIN="0" VALUE="97" />
3 <E VAR="beta" DOMAIN="1" VALUE="87" />
4 <E VAR="beta" DOMAIN="2" VALUE="233" />
5 </FUNCTION>
The values of beta are used in the pressure-area relationship (equation 12.2).
12.4 Examples
First, we will set up the mesh where each arterial segment is represented by one element
and two vertices respectively. Then, we will subdivide the mesh into different subdomains
by using the <COMPOSITE> section. Here, each arterial segment is described by the
contained elements and its first and last vertex.
The mesh connectivity is specified during the creation of elements by indicating the
starting vertex and ending vertex of each individual artery segment. Shared vertices are
used to describe bifurcations, junctions and mergers between different artery segments in
the network.
The composites are then used to specify the two adjoining segments of an artery, where
the first segment merely allows for description of the connectivity.
12.4 Examples 209
Then the choice of polynomial order, solver information, area of the arteries and other
parameters are specified.
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="5" FIELDS="A,u" TYPE="MODIFIED" />
3 <E COMPOSITE="C[3]" NUMMODES="5" FIELDS="A,u" TYPE="MODIFIED" />
4 ...
5
6 <E COMPOSITE="C[162]" NUMMODES="5" FIELDS="A,u" TYPE="MODIFIED" />
7 </EXPANSIONS>
8
9 <CONDITIONS>
10
11 <PARAMETERS>
12
13 <P> TimeStep = 1e-4 </P>
14 <P> FinTime = 1.0 </P>
15 <P> NumSteps = FinTime/TimeStep </P>
16 <P> IO_CheckSteps = NumSteps/50 </P>
17 ...
18 <P> A53 = 0.126 </P>
19 <P> A54 = 0.110 </P>
20 <P> A55 = 0.060 </P>
21 </PARAMETERS>
22
23 <SOLVERINFO>
12.4 Examples 211
The vertices where the network terminates are specified as boundary regions based on
their subsequent composite ids.
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B> <B ID="1"> C[17] </B> <B ID="2"> C[23] </B>
3 ...
4 <B ID="28"> C[164] </B>
5 </BOUNDARYREGIONS>
In the boundary conditions section the inflow and outflow conditions are set up. Here we
use an inflow boundary condition for the area at the beginning of the ascending aorta
taken from [33] and plotted on the right. Potential choices for inflow boundary conditions
include Q-Inflow and Time-Dependent inflow. The outflow conditions for the terminal
regions of the network could be specified by different models including eTerminal, R, CR,
RCR and Time-Dependant outflow.
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0"> <!-- Inflow -->
3 <D VAR="A" USERDEFINEDTYPE="TimeDependent"
4 VALUE="5.983*(1+0.597*(sin(6.28*t + 0.628) - 0.588)*
5 (1./(1+exp(-2*200*(sin(6.28*t + 0.628) - 0.588)))))" />
6 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="0.0" />
7 </REGION>
8 <REGION REF="1">
9 <D VAR="A" USERDEFINEDTYPE="TimeDependent" VALUE="A6" />
10 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="0.0" />
11 </REGION>
12 <REGION REF="2">
212 Chapter 12 Pulse Wave Solver
Again, for the initial conditions we start our simulation from static equilibrium conditions
A = A0 and for u being initially at rest. The following lines show how we specify A0 and
β for different arterial segments.
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="A" DOMAIN="0" VALUE="5.983" />
3 <E VAR="u" DOMAIN="0" VALUE="0.0" />
4 </FUNCTION>
5 ...
6 <FUNCTION NAME="InitialConditions">
7 <E VAR="A" DOMAIN="54" VALUE="A55" />
8 <E VAR="u" DOMAIN="54" VALUE="0.0" />
9 </FUNCTION>
10
11 <FUNCTION NAME="A_0">
12 <E VAR="A_0" DOMAIN="0" VALUE="A1" />
13 ...
14 <E VAR="A_0" DOMAIN="54" VALUE="A55" />
15 </FUNCTION>
16
17 <FUNCTION NAME="MaterialProperties">
18 <E VAR="beta" DOMAIN="0" VALUE="97" />
19 ...
20 <E VAR="beta" DOMAIN="54" VALUE="9243" />
21 </FUNCTION>
Our simulation is started as described before and the results show the time history for
the conservative variables A and u, as well as for the characteristic variables W1 and W2
at the beginning of the ascending aorta (Artery 1). We can see that physically correct the
shape of the inflow boundary condition appears in the forward traveling characteristic
W1. As we do not have a terminal resistance at the outflow, one would normally expect
W2 to be constant. However this is not the case, as bifurcations cause reflections if the
radii of parent and daughter vessels are not well matching, leading to changes in W2.
The shapes of A and u result from this facts and show the values for the physiological
variables during one cardiac cycle. We may annotate that this values slightly differ from
in vivo measurements due to the missing terminal resistance, which will be added in
future.
12.4 Examples 213
These short examples should give an insight to the functionality of our PulseWaveSolver
and show that results such as luminal area and pressure within the artery can be simulated.
These results can contribute to understanding the physiology of the human vascular
system and they can be used for patient-specific planning of medical interventions.
In the following we will explain the usage of the Pulse Wave solver to model the flow and
pressure variation through a stented artery - a cardiovascular procedure in which a small
mesh tube is inserted into an artery to restore blood flow through a constricted region.
Due to the implantation of the stent this region will have different material properties
compared to the the surrounding unstented tissue; hence will influence the propagation
of waves through this system. The stent scenario to be modelled is a straight arterial
segment with a stent situated between x = a1 and x = a2 as shown below.
12.4.3.0.1 Geometry: In the following we describe the geometry setup for modelling
1D flow in a stent. This is done by defining vertices, elements and composites. The
vertices of the domain are shown below, consisting of 30 elements (Ω) and 31 vertices
(V[n]).
These elements are combined to three different composites (shown below): composite 0
represents all the elements; composite 1 the inflow boundary and composite 2 the outflow
boundary.
Figure 12.4 Three composites (C[0], C[1] and C[2]) for the stunted artery.
12.4.3.0.2 Expansion: For the expansions we use 4th-order polynomials which define
our two variables A and u on the domain.
1 <EXPANSIONS>
2 <E COMPOSITE="C[0]" NUMMODES="5" FIELDS="A,u" TYPE="MODIFIED" />
3 </EXPANSIONS>
12.4.3.0.4 Parameters: Parameters used for the simulation are taken from [33]
1 <PARAMETERS>
2 <P> TimeStep = 2e-6 </P>
3 <P> FinTime = 0.25 </P>
4 <P> NumSteps = FinTime/TimeStep </P>
5 <P> IO_CheckSteps = NumSteps/50 </P>
6 <P> IO_InfoSteps = 100 </P>
7 <P> T = 0.33 </P>
8 <P> h0 = 1.0 </P>
9 <P> rho = 1.0 </P>
10 <P> nue = 0.5 </P>
11 <P> pext = 0.0 </P>
12 <P> a1 = 10.0 </P>
13 <P> a2 = 20.0 </P>
14 <P> kappa = 100.0 </P>
15 <P> Y0 = 1.9099e+5 </P>
16 <P> k = 2 </P>
17 <P> k1 = 200 </P>
18 </PARAMETERS>
1 <BOUNDARYREGIONS>
2 <B ID="0"> C[1] </B>
3 <B ID="1"> C[2] </B>
4 </BOUNDARYREGIONS>
5
6 <BOUNDARYCONDITIONS>
7 <REGION REF="0">
8 <D VAR="A" USERDEFINEDTYPE="TimeDependent" VALUE=
9 "(2000*sin(2*PI*t/T)*1./(1+exp(-2*k1*(T/2-t))-pext)/451352+1)^2" />
10 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="1.0" />
11 </REGION>
12 <REGION REF="1">
13 <D VAR="A" VALUE="1.0" />
14 <D VAR="u" VALUE="1.0" />
15 </REGION>
16 </BOUNDARYCONDITIONS>
The simulation starts from the static equilibrium of the vessel with normalised area and
velocity.
1 <FUNCTION NAME="InitialConditions">
2 <E VAR="A" DOMAIN="0" VALUE="1.0" />
3 <E VAR="u" DOMAIN="0" VALUE="1.0" />
4 </FUNCTION>
5
6 <FUNCTION NAME="A_0">
7 <E VAR="A" DOMAIN="0" VALUE="1.0" />
8 </FUNCTION>
Figure 12.6 material property variation along the artery. The stiff region in the middle represents
the stent.
3 "Y0*(1.0-kappa/(1+exp(-2*k*(a1-x)))+kappa/(1+exp(-2*k*(a2-x))))" />
4 </FUNCTION>
12.4.3.1 Simulation
The simulation is started by running
PulseWaveSolver Test_1.xml
It will take about 60 seconds on a 2.4GHz Intel Core 2 Duo processor and therefore is
computationally realisable at every clinical site.
12.4.3.2 Results
As a result we get a 3-dimensional interpretation of the aortic cross-sectional area varying
in axial direction both for the stented and non-stented vessel. In case of the stent, the
rigid metal mesh will restrict the deformation of the area in that specific part of the
artery compared to the normal vessel (Fig. 12.7).
Also, if we look at the pressure at three points within the artery (P, M, D) we will
recognize that there are major differences between the stented and normal vessel. While
in the normal vessel (left) the pressure wave applied at the inflow is propagated without
any losses, this does not hold for the stented artery (right). Here, the stiffening at the
stent causes reflections and thus there are losses for total pressure at the medial (M) and
distal (D) point.
The PulseWaveSolver has beqen developed with contributions by various students and
researchers at the Department of Aeronautics, Imperial College London. Further in-
218 Chapter 12 Pulse Wave Solver
Figure 12.7
formation on the solver and its underlying mathematical framework can be found in
[30, 29].
3. Cleaning up the input file to make the input format more user-friendly.
4. Modelling of valves and alternative pressure-area laws for models of venous flow.
13.1 Synopsis
Value Description
LinearSWE Linearized SWE solver in primitive variables
(constant still water depth)
NonlinearSWE Nonlinear SWE solver in conservative variables
(constant still water depth)
where F(U ) = [E(U ) , G(U )] is the flux vector and the vector of conserved variables read
U = [H , Hu , Hv]T . Here H(x, t) = ζ(x, t) + d(x) is the total water depth, ζ(x, t) is the
free surface elevation and d(x) is the still water depth. The depth-averaged velocity is
219
220 Chapter 13 Shallow Water Solver
denoted by u(x, t) = [u, v]T , where u and v are the velocities in the x- and y-directions,
respectively. The content of the flux vector is
Hu Hv
E(U ) = Hu + gH 2 /2 ,
2 G(U ) = Hvu ,
Huv Hv 2 + gH 2 /2
in which g is the acceleration due to gravity. The source term S(U ) accounts for, e.g.,
forcing due to bed friction, bed slope, Coriolis force and higher-order dispersive effects
(Boussinesq terms). In the distributed version of the ShallowWaterSolver only the Coriolis
force is included.
13.2 Usage
ShallowWaterSolver session.xml
• UpwindType
• Projection
• TimeIntegrationScheme
13.3.2 Parameters
• Gravity
13.3.3 Functions
13.4 Examples
For what concern the ShallowWaterSolver the <SOLVERINFO> section allows us to specify
the solver, the type of projection (continuous or discontinuous), the explicit time inte-
gration scheme to use and (in the case the discontinuous Galerkin method is used) the
choice of numerical flux. A typical example would be:
1 <SOLVERINFO>
2 <I PROPERTY="EqType" VALUE="NonlinearSWE">
3 <I PROPERTY="Projection" VALUE="DisContinuous">
4 <I PROPERTY="TimeIntegrationMethod" VALUE="ClassicalRungeKutta4">
5 <I PROPERTY="UpwindType" VALUE="HLLC">
6 </SOLVERINFO>
In the <PARAMETERS> section we, in addition to the normal setting of time step etc., also
define the acceleration of gravity by setting the parameter "Gravity":
1 <PARAMETERS>
2 <P> TimeStep = 0.04 </P>
3 <P> NumSteps = 1000 </P>
4 <P> IO_CheckSteps = 100 </P>
5 <P> IO_InfoSteps = 100 </P>
6 <P> Gravity = 1.0 </P>
7 </PARAMETERS>
We specify f which is the Coriolis parameter and d denoting the still water depth as
analytic functions:
1 <FUNCTION NAME="Coriolis">
2 <E VAR="f" VALUE="0+1*y" />
3 </FUNCTION>
4
5 <FUNCTION NAME="WaterDepth">
6 <E VAR="d" VALUE="1" />
7 </FUNCTION>
Initial values and boundary conditions are given in terms of primitive variables (please note
that also the output files are given in terms of primitive variables). For the discontinuous
Galerkin we typically enforce any slip wall boundaries weakly using symmetry technique.
This is given by the USERDEFINEDTYPE="Wall" choice in the <BOUNDARYCONDITIONS>
section:
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="eta" USERDEFINEDTYPE="Wall" VALUE="0" />
4 <D VAR="u" USERDEFINEDTYPE="Wall" VALUE="0" />
5 <D VAR="v" USERDEFINEDTYPE="Wall" VALUE="0" />
6 </REGION>
7 </BOUNDARYCONDITIONS>
222 Chapter 13 Shallow Water Solver
./ShallowWaterSolver Rossby_Nonlinear_DG.xml
13.4.1.3 Post-proceesing
After the final time step the solver will write an output file RossbyModon_Nonlinear_DG.fld .
We can convert it to tecplot format by using the FieldConvert utility. Thus we execute
the following command:
This will generate a file called RossbyModon_Nonlinear_DG.dat that can be loaded directly
into tecplot:
Part IV
Reference
223
Chapter 14
Optimisation
One of the most frequently asked questions when performing almost any scientific
computation is: how do I make my simulation faster? Or, equivalently, why is my
simulation running so slowly?
The spectral element method is no exception to this rule. The purpose of this chapter
is to highlight some of the easiest parameters that can be tuned to attain optimum
performance for a given simulation.
Details are kept as untechnical as possible, but some background information on the
underlying numerical methods is necessary in order to understand the various options
available and the implications that they can have on your simulation.
When discretising a PDE using most variants of the spectral element method, the resulting
problem is usually expressed as a matrix equation. In traditional linear finite element
codes, the matrix is usually represented as a large sparse global matrix, which represents
the action of a particular operator such as the Laplacian matrix across the whole domain.
However, when we consider spectral element methods, in which the polynomial order
representing the expansion can be far higher, this method becomes far less optimal. We
can instead consider the action of an operator locally on each element, and then perform
an assembly operation. This is mathematically equivalent to the global matrix approach
and gives exactly the same answer, but at high polynomial orders it is far more efficient
on modern CPU architectures.
Furthermore, this local approach can be represented in one of two ways: either as a dense
matrix for each element, which is typically more efficient at intermediate polynomial
orders, or in the hp element case as a tensor product of smaller dense matrices via
an approach deemed sum-factorisation, which is used at very high polynomial orders.
Figure ?? gives an overview of these three different operator strategies.
224
14.1 Operator evaluation strategies 225
A goal of Nektar++ is to support not only high order expansions, but all orders from low
(where element size h is the dominant factor) to high (where p dominates); a procedure
we have dubbed “from h to p efficiently”.
2. polynomial order p;
Generally you can use results from three publications [37, 7, 6] which outline results for
two- and three-dimensional elements.
In general, the best approach is to perform some preliminary timings by changing the
appropriate variables in the session file, which is outlined below. As a very rough guide,
for 1 ≤ p ≤ 2 you should use the global approach; for 3 ≤ p ≤ 7 use the local approach;
and for p ≥ 8 use sum-factorisation. However, these guidelines will vary due to the
parameters noted above. In future releases of Nektar++ we hope to tune these variables
automatically to make this decision easier to make.
Note that global takes precendence over block, so if VALUE is set to 1 for both then the
operator will be global.
14.2 Collections
All configuration relating to Collections is given in the COLLECTIONS XML element within
the NEKTAR XML element.
14.2.2 Auto-tuning
The choice of implementation for each operator, for the given mesh and expansion orders,
can be selected automatically through auto-tuning. To enable this, add the following to
the Nektar++ session file:
1 <COLLECTIONS DEFAULT="auto" />
This will collate elements from the given mesh and given expansion orders, run and time
each implementation strategy in turn, and select the fastest performing case. Note that
the selections will be mesh- and order- specific. The selections made via auto-tuning are
output if the –verbose command-line switch is given.
8 </OPERATOR>
9 </COLLECTIONS>
--verbose
Displays extra info.
--version
Displays software version, and source control information if applicable.
--help
Displays help information about the available command-line options for the
executable.
--parameter [key]=[value]
Override a parameter (or define a new one) specified in the XML file.
--solverinfo [key]=[value]
Override a solverinfo (or define a new one) specified in the XML file.
--io-format [format]
Determines the output format for writing Nektar++ field files that are used to
store, for example, checkpoint and solution field files. The default for format is
Xml , which is an XML-based format, which is written as one file per process. If
Nektar++ is compiled with HDF5 support, then an alternative option is Hdf5 ,
which will write one file for all processes and can be more efficient for very
large-scale parallel jobs.
--npx [int]
When using a fully-Fourier expansion, specifies the number of processes to use
in the x-coordinate direction.
--npy [int]
When using a fully-Fourier expansion or 3D expansion with two Fourier direc-
tions, specifies the number of processes to use in the y-coordinate direction.
229
230 Chapter 15 Command-line Options
--npz [int]
When using Fourier expansions, specifies the number of processes to use in the
z-coordinate direction.
--part-info
Prints detailed information about the generated partitioning, such as number
of elements, number of local degrees of freedom and the number of boundary
degrees of freedom.
--part-only [int]
Partition the mesh only into the specified number of partitions, write to file
and exit. This can be used to pre-partition a very large mesh on a single
high-memory node, prior to being executed on a multi-node cluster.
--use-metis
Forces the use of METIS for mesh partitioning. If Nektar++ is compiled with
Scotch support, the default is to use Scotch.
--use-scotch
Forces the use of Scotch for mesh partitioning.
Chapter 16
Frequently Asked Questions
Q. I compile Nektar++ successfully but, when I run ctest, all the tests fail.
What might be wrong?
On Linux or Mac, if you compile the ThirdParty version of Boost, rather than using
version supplied with your operating system (or MacPorts on a Mac), the libraries will
be installed in the ThirdParty/dist/lib subdirectory of your Nektar++ directory.
When Nektar++ executables are run, the Boost libraries will not be found as this path
is not searched by default. To allow the Boost libraries to be found set the following
environmental variable, substituting $NEKTAR_HOME with the absolute path of your
Nektar++ directory:
export LD_LIBRARY_PATH=${NEKTAR_HOME}/ThirdParty/dist/lib
or (csh, etc)
• On Mac
export DYLD_LIBRARY_PATH=${NEKTAR_HOME}/ThirdParty/dist/lib
Parallel execution of all Nektar++ solvers is available using MPI. To compile using MPI,
enable the NEKTAR_USE_MPI option in the CMake configuration. On recent versions of
231
232 Chapter 16 Frequently Asked Questions
MPI, the solvers can still be run in serial when compiled with MPI. More information on
Nektar++ compilation options is available in Section 1.3.5.
• The BLAS and LAPACK libraries and development files are not installed. On
Linux systems, both the LAPACK library package (usually called liblapack3 or
lapack) and the development package (usually called liblapack-dev or lapack-devel)
must be installed. Often the latter is missing.
-DMPICH_IGNORE_CXX_SEEK -DMPICH_SKIP_MPICXX
Q. After installing Nektar++ on my local HPC cluster, when I run the ’ctest’
command, all the parallel tests fail. Why is this?
The parallel tests are those which include the word parallel or par . On many HPC
systems, the MPI binaries used to execute jobs are not available on the login nodes, to
prevent inadvertent parallel runs outside of the queuing system. Consequently, these
16.2 Usage 233
tests will not execute. To fully test the code, you can submit a job to the queuing system
using a minimum of two cores, to run the ctest command.
Windows searches for DLL files in directories specified in the PATH environmental
variable. You should add the location of the ThirdParty files to your path. To fix this
(example for Windows XP):
http://www.nektar.info/thirdparty/
16.2 Usage
In a desktop environment, simply prefix the solver executable with the mpirun helper.
For example, to run the Incompressible Navier-Stokes solver on a 4-core desktop computer,
you would run
In a cluster environment, using PBS for example, the mpiexec command should be used.
Nektar++ supports a number of mesh input formats. These are converted to the
Nektar++ native XML format (see Section 3) using the NekMesh utility (see Section 4.
Supported formats include:
234 Chapter 16 Frequently Asked Questions
• Gmsh (.msh)
• Polygon (.ply)
• Nektar (.rea)
• Semtex (.sem)
Bibliography
[3] Ivo Babuška and Manil Suri. The p and h-p versions of the finite element method,
basic principles and properties. SIAM review, 36(4):578–632, 1994.
[4] Y. Bao, R. Palacios, M. Graham, and S.J. Sherwin. Generalized “thick” strip
modelling for vortex-induced vibration of long flexible cylinders. J. Comp. Phys,
321:1079–1097, 2016.
[5] P-E Bernard, J-F Remacle, Richard Comblen, Vincent Legat, and Koen Hillewaert.
High-order discontinuous galerkin schemes on general 2d manifolds applied to the
shallow water equations. Journal of Computational Physics, 228(17):6514–6535,
2009.
235
236 Bibliography
[12] AP Dowling and Ffowcs-Williams JE. Sound and sources of sound. Ellis Horwood
series in engineering science, 1983.
[13] Niederer ”et al.”. Verification of cardiac tissue electrophysiology simulators using an
n-version benchmark. Philos Transact A Math Phys Eng Sci, 369:4331–51, 2011.
[14] Abel Gargallo-Peiró, Xevi Roca, Jaime Peraire, and Josep Sarrate. Distortion
and quality measures for validating and generating high-order tetrahedral meshes.
Engineering with Computers, 31(3):423–437, 2015.
[16] J.L. Guermond and J. Shen. Velocity-correction projection methods for incompress-
ible flows. SIAM J. Numer. Anal., 41:112–134, 2003.
[17] Jan S Hesthaven and Tim Warburton. Nodal high-order methods on unstructured
grids: I. time-domain solution of maxwell’s equations. Journal of Computational
Physics, 181(1):186–221, 2002.
[20] Jonas Koko. Vectorized matlab codes for linear two-dimensional elasticity. Scientific
Programming, 15(3):157–172, 2007.
[21] C. H. Luo and Y. Rudy. A model of the ventricular cardiac action potential.
depolarization repolarization and their interaction. Circulation research, 68:1501–
1526, 1991.
[27] David J Newman and George Em Karniadakis. A direct numerical simulation study
of flow past a freely vibrating cable. Journal of Fluid Mechanics, 344:95–136, 1997.
[28] Anthony T Patera. A spectral element method for fluid dynamics: laminar flow in a
channel expansion. Journal of computational Physics, 54(3):468–488, 1984.
[30] CJ Roth. Pulse wave propagation in the human vascular system, 2012.
[32] SJ Sherwin and M Ainsworth. Unsteady navier-stokes solvers using hybrid spec-
tral/hp element methods. APPLIED NUMERICAL MATHEMATICS, 33:357–363,
2000.
[36] M Turner, J Peiró, and D Moxey. A Variational Framework for High-Order Mesh
Generation. In 25th International Meshing Roundtable, volume 163, pages 340–352,
2016.
238 Bibliography
[37] Peter EJ Vos, Spencer J Sherwin, and Robert M Kirby. From h to p efficiently:
Implementing finite and spectral/hp element methods to achieve optimal perfor-
mance for low-and high-order discretisations. Journal of Computational Physics,
229(13):5161–5181, 2010.
[38] N Westerhof. Anatomic studies of the human systemic arterial tree. J. Biomech.,
2:121–143, 1969.
[39] D Xiu, SJ Sherwin, S Dong, and GE Karniadakis. Strong and auxiliary forms of the
semi-lagrangian method for incompressible flows. J. Sci. Comp., 25:323–346, 2005.
[40] Olgierd Cecil Zienkiewicz and Robert Leroy Taylor. Basic formulation and linear
problems. McGraw-Hill, 1989.