User-Guide-5 1 0
User-Guide-5 1 0
User-Guide-5 1 0
Element Framework
Version 5.1.0
User Guide
November 24, 2021
Introduction xi
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 . . . . . . . . . . . . . . . . . . . . . . . 14
2 Mathematical Formulation 20
2.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Methods overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.1 The finite element method (FEM) . . . . . . . . . . . . . . . . . . 21
2.2.2 High-order finite element methods . . . . . . . . . . . . . . . . . . 21
2.2.3 The Galerkin formulation . . . . . . . . . . . . . . . . . . . . . . . 23
iii
iv Contents
3.2 Expansions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3.1 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3.2 Time Integration Scheme . . . . . . . . . . . . . . . . . . . . . . . 31
3.3.3 Solver Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.4 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.3.5 Global System Solution Algorithm . . . . . . . . . . . . . . . . . . 33
3.3.6 Boundary Regions and Conditions . . . . . . . . . . . . . . . . . . 38
3.3.7 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.3.8 Quasi-3D approach . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.1 Phase sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.2 Aerodynamic forces . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.4.3 Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.4.4 Cell history points . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.4.5 Checkpoint cell model . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.4.6 Checkpoint fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.4.7 Electrogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.4.8 Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.4.9 FieldConvert checkpoints . . . . . . . . . . . . . . . . . . . . . . . 52
3.4.10 History points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.4.11 Kinetic energy and enstrophy . . . . . . . . . . . . . . . . . . . . . 54
3.4.12 Mean values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.4.13 Modal energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.4.14 Moving body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.4.15 Moving average of fields . . . . . . . . . . . . . . . . . . . . . . . . 56
3.4.16 One-dimensional energy . . . . . . . . . . . . . . . . . . . . . . . . 57
3.4.17 Reynolds stresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.4.18 Time-averaged fields . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.4.19 ThresholdMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.4.20 ThresholdMin value . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.5 Forcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.1 Absorption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.2 Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.3 MovingReferenceFrame . . . . . . . . . . . . . . . . . . . . . . . . 61
3.5.4 Programmatic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.5.5 Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.6 Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.6.1 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.6.2 Cwipi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.7 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.7.1 Variables and coordinate systems . . . . . . . . . . . . . . . . . . . 66
3.7.2 Performance considerations . . . . . . . . . . . . . . . . . . . . . . 70
Contents v
4 NekMesh 73
4.1 Exporting a mesh from Gmsh . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.2 Defining physical surfaces and volumes . . . . . . . . . . . . . . . . . . . . 74
4.3 Converting the MSH to Nektar++ format . . . . . . . . . . . . . . . . . . 75
4.4 NekMesh in NekPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.5 NekMesh modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.5.1 Input modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.5.2 Output modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.5.3 Extract surfaces from a mesh . . . . . . . . . . . . . . . . . . . . . 82
4.5.4 Negative Jacobian detection . . . . . . . . . . . . . . . . . . . . . . 83
4.5.5 Spherigon patches . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.5.6 Periodic boundary condition alignment . . . . . . . . . . . . . . . . 84
4.5.7 Boundary layer splitting . . . . . . . . . . . . . . . . . . . . . . . . 86
4.5.8 High-order cylinder generation . . . . . . . . . . . . . . . . . . . . 87
4.5.9 Linearisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.5.10 Extracting interface between tetrahedra and prismatic elements . . 88
4.5.11 Boundary identification . . . . . . . . . . . . . . . . . . . . . . . . 89
4.5.12 Scalar function curvature . . . . . . . . . . . . . . . . . . . . . . . 89
4.5.13 Link Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.5.14 2D mesh extrusion . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.5.15 Variational Optimisation . . . . . . . . . . . . . . . . . . . . . . . 90
4.5.16 r-adaptation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.5.17 Mesh projection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.6 Mesh generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.6.1 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.6.2 Mesh generation manual . . . . . . . . . . . . . . . . . . . . . . . . 94
5 FieldConvert 99
5.1 Basic usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.1.1 Input formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
5.2 Convert .fld / .chk files into Paraview, VisIt or Tecplot format . . . . . . 100
5.3 Convert field files between XML and HDF5 format . . . . . . . . . . . . . 101
5.4 Range option -r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.5 FieldConvert in NekPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5.6 FieldConvert modules -m . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
5.6.1 Smooth the data: C0Projection module . . . . . . . . . . . . . . . 105
5.6.2 Calculate Q-Criterion: QCriterion module . . . . . . . . . . . . . . 106
5.6.3 Calculate λ2 : L2Criterion module . . . . . . . . . . . . . . . . . . 106
5.6.4 Add composite ID: addcompositeid module . . . . . . . . . . . . . 106
5.6.5 Add new field: fieldfromstring module . . . . . . . . . . . . . . . . 106
5.6.6 Sum two .fld files: addFld module . . . . . . . . . . . . . . . . . . 107
5.6.7 Combine two .fld files containing time averages: combineAvg module107
5.6.8 Concatenate two files: concatenate module . . . . . . . . . . . . . 107
vi Contents
IV Reference 271
15 Optimisation 272
15.1 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
15.1.1 Default implementation . . . . . . . . . . . . . . . . . . . . . . . . 273
15.1.2 Auto-tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
15.1.3 Manual selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
15.1.4 Collection size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Bibliography 280
Introduction
Nektar++ [6] 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.
xi
xii Introduction
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 10.0 (buster) deb http://www.nektar.info/debian-buster buster contrib
Debian 9.0 (stretch) deb http://www.nektar.info/debian-stretch stretch contrib
Debian 8.0 (jessie) deb http://www.nektar.info/debian-jessie jessie contrib
Ubuntu 14.04 (trusty) deb http://www.nektar.info/ubuntu-trusty trusty contrib
Ubuntu 18.04 (bionic beaver) deb http://www.nektar.info/ubuntu-bionic bionic 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 25 http://www.nektar.info/fedora/25/$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 by running
git remote set-url origin [email protected]:nektar/nektar.git
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. Typically, the development packages,
with a -dev or -devel suffix, are required to compile codes against these libraries. 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, supporting C++11
CMake ≥ 3.5.1 3 3 3 Ncurses GUI optional
BLAS 3 3 3 3 Or MKL, ACML, OpenBLAS
LAPACK 3 3 3 3
Boost >= 1.56 3 3 3 3 Compile with iostreams
TinyXML 3 3 3 3 For reading XML input files
Scotch 3 3 3 3 Required for multi-level static con-
densation, highly recommended
METIS 3 3 3 Alternative mesh partitioning
FFTW > 3.0 3 3 3 For high-performance FFTs
ARPACK > 2.0 3 3 3 For arnoldi algorithms
MPI 3 3 For parallel execution (OpenMPI,
MPICH, Intel MPI, etc)
GSMPI 3 For parallel execution
HDF5 3 3 3 For large-scale parallel I/O (requires
CMake >3.1)
OpenCascade CE 3 3 3 For mesh generation and optimisa-
tion
PETSc 3 3 3 Alternative linear solvers
PT-Scotch 3 3 3 Required when MPI enabled
Tetgen 3 3 3 For 3D mesh generation
Triangle 3 3 3 For 2D mesh generation
VTK > 5.8 3 3 Not required to convert field output
files to VTK, only mesh files
2. Change into the source-code directory, create a build subdirectory and enter it
ccmake ../
Note
Selecting THIRDPARTY_BUILD_ options will request CMake to auto-
matically download thirdparty libraries and compile them within the
Nektar++ directory. 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.
1.3 Installing from Source 7
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 ≥ 3.5.1 3 cmake 3 Ncurses GUI optional
BLAS 3 Part of Xcode
LAPACK 3 Part of Xcode
Boost >= 1.56 3 boost 3 3 Compile with iostreams
TinyXML 3 tinyxml 3 3
Scotch 3 scotch 3 3 Required for multi-level static
condensation, highly recom-
mended
METIS metis 3 3 Alternative mesh partitioning
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 For large-scale parallel I/O (re-
quires CMake >3.1)
OpenCascade CE 3 3 For mesh generation and opti-
misation
PETSc petsc 3 3 Alternative linear solvers
PT-Scotch 3 3 Required when MPI enabled
Tetgen 3 3 For 3D mesh generation
Triangle 3 3 For 2D mesh generation
VTK > 5.8 vtk 3 Not required to convert field
output files to VTK, only mesh
files
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 there are some complexities with building addi-
tional features on this platform at present. As such, only builds with a minimal amount
of additional build packages are currently supported. These can either be installed by
the user, or automatically as part of the build process. Support has recently been added
for building with MPI on Windows. This enables parallel computations to be carried
out with Nektar++ on Windows where only sequential computations were previously
supported.
1.3 Installing from Source 11
Installation
Package Req. User Auto. Note
MS Visual Studio 3 3 2015, 2017 and 2019 known working
CMake ≥ 3.5.1 3 3 3.16+ recommended, see info below
BLAS 3 3 3
LAPACK 3 3 3
Boost ≥ 1.61 3 3 3 Recommend installing from binaries
Microsoft MPI ≥ 10.1.2 3 Required for parallel execution. In-
stall both runtime and SDK
Note
These instructions assume you are using a 64-bit version of Windows 10.
Note
There have been issues with automatically building Boost from source as a
third party dependency during the Nektar++ build when using MS Visual
Studio 2015, 2017 and 2019. This should now be possible but it is, nonetheless,
recommended you install a suitable version of Boost from binaries as detailed
in the instructions below.
1. Install Microsoft Visual Studio 2019 (preferred), 2017 or 2015 (both known to work).
This can be obtained from Microsoft free of charge by using their Community
developer tools from https://visualstudio.microsoft.com/vs/community/.
• For Visual Studio 2015, install boost 1.61 using the package boost_1_61_0-
msvc-14.0-64.exe from http://sourceforge.net/projects/boost/files/
boost-binaries/1.61.0/
• For Visual Studio 2017, install boost 1.68 using the package boost_1_68_0-
msvc-14.1-64.exe from http://sourceforge.net/projects/boost/files/
boost-binaries/1.68.0/
• For Visual Studio 2019, install boost 1.72 using the package boost_1_72_0-
msvc-14.2-64.exe from http://sourceforge.net/projects/boost/files/
boost-binaries/1.72.0/
5. If you’ve downloaded the source code archive (as described in Section 1.3.1), unpack
nektar++-5.1.0.zip .
Note
Some Windows versions do not recognise the path of a folder which has
++ in the name. If you are not using Windows 10 and think that your
Windows version cannot handle paths containing special characters, you
should rename nektar++-5.1.0 to nektar-5.1.0 .
8. Change directory into the build directory and run CMake to generate the build
files. You need to set the generator to the correct Visual Studio version using the
-G switch on the command line, e.g. for VS2019:
cd C:\path\to\nektar\builds
cmake -G "Visual Studio 16 2019" ..
You can see the list of available generators using cmake –help. For VS2017 use
“Visual Studio 15 2017 Win64” and for VS2015 use “Visual Studio 14 2015 Win64”.
If you want to build a parallel version of Nektar++ with MPI support, you need to
add the -DNEKTAR_USE_MPI=ON switch to the cmake command, e.g.:
Note
If you installed Boost binaries, as described above, you should ensure at
this stage that the version of Boost that you installed has been correctly
detected by CMake. You should see a number of lines of output from
CMake saying – – Found boost <library name> library: followed by
paths to one or more files which should be located in the directory where
you installed your Boost binaries. If you do not see this output, CMake
has failed to detect the installed Boost libraries and the build process will
instead try to build Boost from source as part of building Nektar++.
9. Assuming the configuration completes successfully and you see the message Build
files have been written to: ..., you should now be ready to issue the build command:
10. After the build and installation process has completed, the executables will be
available in build\dist\bin .
14 Chapter 1 Installation
11. To use these executables, you need to modify your system PATH to include the bin
directory and library directories where DLLs are stored. To do this, click the Start
menu and type ‘env’, you should be presented with an “Edit the system environment
variables” option. Alternatively, navigate to Settings > System > About > System
info (under Related Settings on the right hand panel), select Advanced System
Settings, and in the Advanced tab click the Environment Variables button. In
the System Variables box, select Path and click Edit. Add the full paths to the
following directories to the end of the list of paths shown in the “Edit environment
variable” window:
• nektar++-5.1.0\build\dist\lib\nektar++-5.1.0
• nektar++-5.1.0\build\dist\bin
• nektar++-5.1.0\ThirdParty
• C:\local\boost_<boost_version>\<boost_lib_dir> where boost_<boost_version>
is the directory where the boost binaries were installed to and <boost_lib_dir>
is the name of the library directory within this location, e.g. lib64-msvc-14.2
or similar depending on the version of Boost binaries you installed.
12. To run the test suite, open a new command line window, change to the build
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.
• NEKTAR_BUILD_DOC
Compiles the Doxygen documentation for the code. This will be put in
1.3 Installing from Source 15
$BUILDDIR/doxygen/html
• NEKTAR_BUILD_LIBRARY (Required)
Compiles the Nektar++ framework libraries. This is required for all other options.
• NEKTAR_BUILD_PYTHON
Installs the Python wrapper to Nektar++. Requires running the following command
after installing Nektar++ in order to install the Python package for the current
user:
make nekpy-install-user
Alternatively, the Python package can be installed for all users by running the
following command with appropriate priviledges:
make nekpy-install-system
• 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, including the mesh
conversion and generation tool NekMesh and the FieldConvert post-processing
utility.
• NEKTAR_SOLVER_X
Enable compilation of the ’X’ solver.
• NEKTAR_UTILITY_X
Enable compilation of the ’X’ utility.
16 Chapter 1 Installation
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_ARPACK
Build Nektar++ with support for ARPACK. This provides routines used for linear
stability analyses. Alternative Arnoldi algorithms are also implemented directly in
Nektar++.
• 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_CWIPI
Use the CWIPI library for enabling inter-process communication between two
solvers. Solvers may also interface with third-party solvers using this 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_MESHGEN
Build the NekMesh utility with support for generating meshes from CAD geometries.
This enables use of the OpenCascade Community Edition library, as well as Triangle
and Tetgen.
• NEKTAR_USE_METIS
Build Nektar++ with support for the METIS graph partitioning library. This
provides both an alternative mesh partitioning algorithm to SCOTCH for parallel
simulations.
1.3 Installing from Source 17
• NEKTAR_USE_MPI (Recommended)
Build Nektar++ with MPI parallelisation. This allows solvers to be run in serial or
parallel.
• NEKTAR_USE_PETSC
Build Nektar++ with support for the PETSc package for solving linear systems.
• NEKTAR_USE_SCOTCH (Recommended)
Build Nektar++ with support for the SCOTCH graph partitioning library. This
provides both a mesh partitioning algorithm for parallel simulations and enabled
support for multi-level static condensation, so is highly recommended and enabled
by default. However for systems that do not support SCOTCH build requirements
(e.g. Windows), this can be disabled.
• 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_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.
• ARPACK
Library of iterative Arnoldi algorithms.
• BLAS_LAPACK
Library of linear algebra routines.
• 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.
18 Chapter 1 Installation
• CCMIO
I/O library for the Star-CCM+ format.
• CWIPI
Library for inter-process exchange of data between different solvers.
• FFTW
Fast-Fourier transform library.
• GSMPI
(MPI-only) Parallel communication library.
• HDF5
Hierarchical Data Format v5 library for structured data storage.
• METIS
A graph partitioning library used for mesh partitioning when Nektar++ is run in
parallel.
• OCE
OpenCascade Community Edition 3D modelling library.
• PETSC
A package for the parallel solution of linear algebra systems.
• SCOTCH
A graph partitioning library used for mesh partitioning when Nektar++ is run in
parallel, and reordering routines that are used in multi-level static condensation.
• TETGEN
3D tetrahedral meshing library.
• TINYXML
Library for reading and writing XML files.
• TRIANGLE
2D triangular meshing library.
• NEKTAR_DISABLE_BACKUPS
By default, Nektar++ solvers and the FieldConvert utility will not overwrite any
generated field files or output files they find an existing file with the same name.
1.3 Installing from Source 19
Instead, the existing file will be either moved to a backup file or you will be
prompted to overwrite them. If you do not want this behaviour, then enabling this
option will cause all pre-existing output to be overwritten silently.
• NEKTAR_TEST_ALL
Enables an extra set of more substantial and long-running tests.
• NEKTAR_TEST_USE_HOSTFILE
By default, MPI tests are run directly with the mpiexec command together with
the number of cores. If your MPI installation requires a hostfile, enabling this
option adds the command line argument -hostfile hostfile to the command
line arguments when tests are run with ctest or the Tester executable.
We have recently added explicit support to SIMD (Single Instruction Multiple Data) x86
instruction set extensions (i.e. AVX2, AVX512). Selected operators (the matrix free
operators) utilize the SIMD types, if none of them is enabled these operators default
to scalar types. The various extensions available are marked as advanced options (to
visualize them in the cmake gui you need to press the t-button):
• NEKTAR_ENABLE_SIMD_AVX2
Enables 256 bit wide vector types and set the appropriate compiler flags (gcc only).
• NEKTAR_ENABLE_SIMD_AVX512
Enables 512 bit wide vector types and set the appropriate compiler flags (gcc only).
Note that if you are not configuring cmake for the first time, you need to delete the cached
variable CMAKE_CXX_FLAGS in order for the appropriate flags to be set. Alternatively
you can manually set the flag to target the appropriate architecture.
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 [42] 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 [48] 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
20
2.2 Methods overview 21
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 23
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)
24 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.
uδ = Φn ûn .
X
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
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>
25
26 Chapter 3 XML Session File
6 ...
7 </EXPANSIONS>
8 ...
9 </NEKTAR>
Note
When specifying multiple files, repeated first-level 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 27
Note
The attribute PARTITION may also appear in a partitioned mesh. However,
this attribute should not be explicitly specified by the user.
The contents of 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:
When generating mesh input files for Nektar++ using NekMesh , the binary compressed
form will be used by default. To convert a compressed XML file into human-readable
ASCII format use, for example:
Note
The description in the remainder of this section explains how the GEOMETRY
section is laid out in uncompressed ASCII format.
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>
28 Chapter 3 XML Session File
defines two vertices with coordinates (0.0, 0.0, 0.0), (1.0, 2.0, 0.0).
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 29
• 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, using ranges, or a mixture of the
two. Examples include
1 <C ID="0"> T[0-862] </C>
2 <C ID="1"> E[61-67,69,70,72-74] </C>
30 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 and variables. Expansion entries specify the number of modes and the
expansion type, or a full list of data of basis type, number of modes, points type and
number of points. 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" />
The expansions can be defined with a list of <E> elements (e.g., to represent different
polynomial orders for different variables or to address different composites). The user
can define a default expansion field by entering <E> tags without the FIELDS attribute.
The default expansion is used to define any variables not explicitly listed in the <E>
entries. In the following example, the default expansion is used to define the expansions
for the composites C[0], C[1] and C[2]:
1 <E COMPOSITE="C[0-2]" NUMMODES="5" TYPE="MODIFIED" />
2 <E COMPOSITE="C[3]" NUMMODES="4" TYPE="MODIFIED" FIELDS="u,v"/>
3 <E COMPOSITE="C[3]" NUMMODES="3" TYPE="MODIFIED" FIELDS="p"/>
The expansions of each field should be defined only once for each composite.
3.3 Conditions 31
3.3 Conditions
This 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
Numerical parameters may be required by a particular solver (for instance time-integration
or physical parameters), or may be arbitrary and only used for the purpose of simplifying
the problem specification in the session file (e.g. parameters which would otherwise be
repeated in the definition of an initial condition and boundary conditions). All parameters
are enclosed in the PARAMETERS XML element.
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>
A number of pre-defined constants may also be used in parameter expressions, for example
PI. A full list of supported constants is provided in Section 3.7.1.2.
For additional details on the different time integration schemes refer to the developer’s
guide.
32 Chapter 3 XML Session File
Boolean-valued solver properties are specified using True or False . The list of available
solvers in Nektar++ can be found in Part III.
3.3.3.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.
2. Sets up the initial and boundary conditions.
3. Calls the solver defined by SolverType in the SOLVERINFO XML element.
In the following example, the driver Standard is used to manage the execution of the
incompressible Navier-Stokes equations:
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 2 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
8 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
9 <I PROPERTY="Projection" VALUE="Galerkin" />
10 <I PROPERTY="Driver" VALUE="Standard" />
11 </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. 11.3.1 and 11.4.1, the other possibilities are:
3.3.4 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
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
34 Chapter 3 XML Session File
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.
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 specified 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.5.4 below for some additional information on how
to use the PETSc solvers. This option is only available if the NEKTAR_USE_PETSC
option is enabled in the CMake configuration.
Warning
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.
For a detailed discussion of the mathematical formulation of these options, see the
developer guide.
or
1 <PARAMETERS>
2 <P> SuccessiveRHS = 8 </P>
3 </PARAMETERS>
or
Q2 = (x̃ − x)T A(x̃ − x). (3.5)
there is
J X
J J
Q1 = αm αn eTm bn − 2 αm eTm b + bT b. (3.7)
X X
there is
J X
J J
Q2 = αm αn êTm bn − 2 αm êTm b + xT b. (3.10)
X X
The formulations of Q1 version and Q2 version are the same, except the difference of
projection bases. By default, Q2 is used as the object function. If you want to use Q1
instead, you can assign a negative value to SuccessiveRHS:
1 <I PROPERTY="SuccessiveRHS" VALUE="-8" />
or
1 <P> SuccessiveRHS = -8 </P>
In the original paper of Fischer (1998) [12], the Gram-Schmidt orthogonal process is
applied to the projection bases, this method is very stable and avoids the calculation of
M −1 . However, when the memory space is full, this approach makes it hard to decide
which basis should be overwritten. In our implementation, we just store the normalized
right-hand sides or old solutions, i.e. eTm bm = 1 or êTm bm = 1, and overwrite the oldest
ones. The linear problem (3.8) or (3.11) is solved using a direct method.
To make sure M is positive definite, when a new basis eJ+1 arrives, we test the following
condition to decide whether or not to accept it,
! !
−1 M̃ y −M̃ −1 y
r = (−y M̃
T
, 1) T = 1 − y T M̃ −1 y ≥ ε > 0. (3.12)
y 1 1
Assuming eJ is the oldest basis, there are M̃mn = Mmn , ym = eTm bJ+1 , (m, n = 1, 2, ..., J −
1).
38 Chapter 3 XML Session File
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
-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.
4 </BOUNDARYREGIONS>
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,
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" />
40 Chapter 3 XML Session File
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" />
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.
1 <REGION REF="1">
2 <D VAR="u" FILE="Test_ChanFlow2D_bcsfromfiles_u_1.bc" />
3 <D VAR="v" VALUE="0" />
4 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
5 </REGION>
Boundary conditions can also be loaded simultaneously from a file and from an expression
(currently only implemented in 3D). For example, in the scenario where a spatial boundary
condition is read from a file, but needs to be modulated by a time-dependent expression:
1 <REGION REF="1">
2 <D VAR="u" 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.7 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.6.18. 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>
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
3.3 Conditions 43
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>
• The same number of fields must be defined for both the VAR attribute and in the
comma-separated list 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>
44 Chapter 3 XML Session File
Section 3.7 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 spectral/hp element method.
1 <PARAMETERS>
2 ...
3 <P> HomModesZ = 4 </P>
4 <P> LZ = 1.0 </P>
5 </PARAMETERS>
5 <PARAMETERS>
6 ...
7 <P> HomModesY = 10 </P>
8 <P> LY = 6.5 </P>
9 <P> HomModesZ = 6 </P>
10 <P> LZ = 2.0 </P>
11 </PARAMETERS>
By default the operations associated with the harmonic expansions are performed with
the Matrix-Vector-Multiplication (MVM) defined inside the code. The Fast Fourier
Transform (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 ...
3 <I PROPERTY="HOMOGENEOUS" VALUE="2D" />
4 <I PROPERTY="USEFFT" VALUE="FFTW" />
5 </SOLVERINFO>
The number of homogeneous modes has to be even. The Quasi-3D approach 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
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.
46 Chapter 3 XML Session File
Some filters may perform a large number of operations, potentially taking up a sig-
nificant percentage of the total simulation time. For this purpose, the parameter
IO_FiltersInfoSteps is used to set the number of steps between successive total filter
CPU time stats are printed. By default it is set to 10 times IO_InfoSteps . If the solver
is run with the verbose -v flag, further information is printed, detailing the CPU time
of each individual filter and percentage of time integration.
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 feature is currently only supported for filters derived from the FieldConvert
filter: AverageFields, MovingAverage, ReynoldsStresses.
Since this feature monitors nT every SampleFrequency , for best results it is recommended
to set SampleFrequency = 1.
The maximum error in sampling phase is nT ,tol = 2T ∆t
· SampleFrequency , which is
displayed at the beginning of the simulation if the solver is run with the verbose -v
option.
3.4 Filters 47
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.fce 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 Navier-Stokes solver with
the Smoothed Profile Method.
48 Chapter 3 XML Session File
The lack of physical boundaries in the Smoothed Profile Method requires an alternative
formulation to calculate the aerodynamic forces. Since the method imposes the boundary
geometry by adding an impulse to the flow proportional to the difference between the
flow velocity and the expected velocity of the immersed bodies, the forces in this filter
are computed by integrating this difference where Φ 6= 0 [25]:
Fn 1
Z
= Φn+1 (u∗ − un p ) dΩ
ρ ∆t Ω
will generate a file called Forces.fce with the values of the forces in the (X, Y, Z)
directions, that must be scaled with the density of the fluid to get the real values. It is
important to remark that the computed values are the sum of all the boundaries defined
by Φ.
3.4.3 Benchmark
Note
This filter is only supported for the Cardiac Electrophysiology Solver.
Filter 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>
3.4 Filters 49
• OutputFile specifies the base filename of activation and repolarisation maps output
from the filter. This name is appended with the index of the event and the suffix
‘.fld‘.
Note
This filter is only supported for the Cardiac Electrophysiology Solver.
Filter 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>
Note
This filter is only supported for the Cardiac Electrophysiology Solver.
Filter CheckpointCellModel checkpoints the cell model. Can be used along with the
Checkpoint filter to record complete simulation state and regular intervals.
50 Chapter 3 XML Session File
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‘.
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>
3.4 Filters 51
3.4.7 Electrogram
Note
This filter is only supported for the Cardiac Electrophysiology Solver.
• 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.
• Points specifies a list of coordinates at which electrograms are desired. They must
not lie within the domain.
3.4.8 Error
This filter produces a file containing the time-evolution of the L2 and Linf errors. By
default this file is called session.err where session is the session name.
Module options are specified as a colon-separated list, following the same syntax as the
FieldConvert command-line utility (see Section 5).
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.
The history points filter can be used to evaluate the value of the fields in specific points
of the domain as the solution evolves in time. By default this produces a file called
session.his . For each timestep, and then each history point, a line is output containing
the current solution time, followed by the value of each of the field variables. Commented
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>
or
1 <FILTER TYPE="HistoryPoints">
2 <PARAM NAME="OutputFile">TimeValues</PARAM>
3 <PARAM NAME="OutputFrequency">10</PARAM>
4 <PARAM NAME="line">3,1,0.5,0,3,0.5,0</PARAM>
5 </FILTER>
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
Ek = 2
kuk dx, E= kωk2 dx
2µ(Ω) Ω 2µ(Ω) Ω
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.
1 <FILTER TYPE="Energy">
2 <PARAM NAME="OutputFrequency"> 1 </PARAM>
3 </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 Ω
k=0
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 Quasi-3D incompressible Navier-Stokes
solver, in conjunction with the MovingBody forcing.
This filter MovingBody is encapsulated in the forcing module to evaluate the aerodynamic
forces along the moving body surface. It is described in detail in section 11.3.4.1
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.
3.4 Filters 57
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.
where Lp is the p-th Legendre polynomial. This can be used to show the presence of, for
example, oscillations in the underlying field due to numerical instability. The resulting
output is written into a file called session.eny by default. The following parameters
are supported:
Note
This filter is only supported for the incompressible Navier-Stokes solver.
58 Chapter 3 XML Session File
This filter is an extended version of the time-average fields filter (see Section 3.4.18). 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:
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>
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.4 Filters 59
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.19 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.
Performs the same function as the ThresholdMax filter (see Section ??) but records the
time at which the threshold variable drops below a prescribed value.
60 Chapter 3 XML Session File
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>
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
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 <BOUNDARYREGIONS> 1,4 <BOUNDARYREGIONS/>
6 </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 Forcing 61
3.5.3 MovingReferenceFrame
This force type allows the user to solve the incompressible flow around a moving rigid
body. In this method, the flow velocity and pressure are defined in an inertial reference
frame, but the coordinates and basis vectors are in the reference frame fixed on the rigid
body (body frame).
This force type specifies the name of a moving frame function expressed in the CONDITIONS
section.
1 <FORCE TYPE="MovingReferenceFrame">
2 <FRAMEVELOCITY> [FUNCTION NAME] <FRAMEVELOCITY/>
3 </FORCE>
The moving frame function defines the velocity of the body frame observed in the inertial
reference frame
uf rame = u0 + Ω × (x − x0 )
.
1 <FUNCTION NAME="MovingReferenceFrame">
2 <E VAR="u" VALUE="1" />
3 <E VAR="v" VALUE="0" />
4 <E VAR="w" VALUE="0" />
5 <E VAR="Omega_x" VALUE="0" />
6 <E VAR="Omega_y" VALUE="0" />
7 <E VAR="Omega_z" VALUE="1" />
8 <E VAR="x0" VALUE="0" />
9 <E VAR="y0" VALUE="0" />
10 <E VAR="z0" VALUE="0" />
11 </FUNCTION>
3.5.4 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>
62 Chapter 3 XML Session File
3.5.5 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>
3.6 Coupling
Nektar++ Solvers can be run in parallel with third party applications and other Nektar++
solvers, where run-time data exchange is enabled by the coupling interface. The interface
is configured in the COUPLING tag as
1 <COUPLING TYPE="[type]" NAME="[name]">
2 <I PROPERTY="SendSteps" VALUE="1" />
3 <I PROPERTY="SendVariables" VALUE="u0S,v0S" />
4 <I PROPERTY="ReceiveSteps" VALUE="1" />
5 <I PROPERTY="ReceiveVariables" VALUE="u0R,v0R" />
6 ...
7 </COUPLING>
The coupling type may be any of the types described later in this section, while the name
can be chosen arbitrarily. Inside each coupling block, the send and receive frequencies are
defined by the SendSteps and ReceiveSteps parameters, respectively. Which variables
are to be sent or received is specified by the SendVariables and ReceiveVariables . By
default, the send and receive frequencies is set to zero, which disables the corresponding
exchange in this coupling. An empty SendVariables or ReceiveVariables list has the
same effect.
3.6.1 File
This coupling type allows the user to exchange fields at run time by reading from and
writing to files. Besides the basic parameters which define the exchanged variables
and the exchange frequency, the file coupling type requires the SendFileName and
ReceiveFunction parameters to be set. The Coupling name is not used for this type
and can be ignored.
1 <COUPLING NAME="coupling1" TYPE="File">
2 <I PROPERTY="SendSteps" VALUE="1" />
3 <I PROPERTY="SendVariables" VALUE="u0S,v0S" />
4 <I PROPERTY="SendFileName" VALUE="Dummy0out_%14.8E.pts" />
5 <I PROPERTY="ReceiveSteps" VALUE="1" />
6 <I PROPERTY="ReceiveVariables" VALUE="u0R,v0R" />
7 <I PROPERTY="ReceiveFunction" VALUE="CouplingIn" />
8 </COUPLING>
SendFileName specifies a file name template to write the field data to. Currently, only
.pts files are supported and the file is only created once fully written, avoiding race
conditions between sender and receiver. Receiving is implemented by evaluating a session
function specified in the ReceiveFunction parameter. The coupling waits for the file
given in the receive function to appear.
3.6.2 Cwipi
Note
The Cwipi coupling is only available when Nektar++ is compiled with OpenMPI
and CWIPI
The Cwipi coupling uses CWIPI1 to facilitate real time data exchange over MPI. See [23]
for details. All data transfers are non-blocking to minimize the computational overhead.
The interface must be enabled with the command line option –cwipi and a unique
application name, e.g:
1
http://sites.onera.fr/cwipi/
64 Chapter 3 XML Session File
CWIPI uses the names of the current application and the coupling to identify two peers
in cosimulation setups. The name of the remote application must be provided by the
RemoteName parameter. Unlike the File-type coupling, a linear interpolation in time is
applied to the received fields if non-unity values are set for ReceiveSteps .
Additional options which define the coupling include SendMethod , the method used
to retrieve the physical values at the locations requested by the remote application.
Available options are NearestNeighbour , Shepard and the default Evaluate . The last
option directly evaluates the expansions using a backward transform, giving superior
accuracy at acceptable computational cost.
When using non-conforming domains, the current application might request values outside
of the computational domain of the remote application. How to handle these not-located
points is specified by the NotLocMethod parameter. When set to keep , the point value
is not altered. With Extrapolate , the nearest neighbor value of the current application
is used. Note that this can be very inefficient when using many MPI ranks.
3.7 Expressions 65
3.7 Expressions
• parameter values;
The tags above declare 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 expression. Currently one cannot
directly link a boundary condition declaration with an 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>
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
• 3D problem space with coordinates (x,y,z) has the same coordinates in the global
space coordinates.
3.7 Expressions 67
Currently, there is no way to describe rotations and translations of problem space relative
to the global coordinate system.
• mathematical constants
• 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
computes polar coordinate r = x2 + y 2 from (x, y)
p
rad(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.7.1.3 Examples
Some straightforward examples include
70 Chapter 3 XML Session File
• evaluation to a number.
Parsing of expressions with their partial evaluation take place at the time of setting
the run up (reading an XML file). Each 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.
Some operations are more computationally expensive than others. In an order of increasing
complexity:
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.
72
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
73
74 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,
we can use the FieldConvert command using:
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 Python interface allows the user to instantiate input, output, and process mod-
ules by calling the static Create method of the InputModule, ProcessModule, and
OutputModule, register configuration options, and process them. Consider the following
example:
1 import sys
2 from NekPy.NekMesh import Mesh, ProcessModule, OutputModule
3
4 mesh = Mesh()
5 mesh.expDim = 3
6 mesh.spaceDim = 3
7 mesh.nummode = 5
8 mesh.verbose = True
9
10 # Load the CAD file
11 ProcessModule.Create("loadcad", mesh, \
12 filename="input.stp", verbose=True).Process()
13 # Load the octree
14 ProcessModule.Create("loadoctree", mesh, mindel=0.04,\
15 maxdel=0.2, eps=0.02).Process()
16 # Create a surface mesh
17 ProcessModule.Create("surfacemesh", mesh).Process()
18 # Output a 2D manifold mesh
19 mesh.expDim = 2
20 # Create a high-order surface
21 ProcessModule.Create("hosurface", mesh).Process()
22 # Dump out elemental Jacobians
23 ProcessModule.Create("jac", mesh, list=True).Process()
24 # Dump out the surface mesh.
25 OutputModule.Create("xml", mesh, test=True,\
26 outfile="output.xml").Process()
4.4 NekMesh in NekPy 77
After importing the Mesh, ProcessModule, and OutputModule classes, first we create a
Mesh object by calling the constructor. This object will be shared by the modules. Then
we manipulate the Mesh object by creating different ProcessModules, at the end we write
out the result into a xml file using an OutputModule. The configuration options for a given
module are passed to the static Create method of the InputModule, ProcessModule,
and OutputModule. This creates the corresponding module and the modules can be
processed immediately after instantiation. Note that the first parameter of the Create
method has to be the key for a given module, the second is the previously created
Mesh object. The remaining keyword arguments can specify additional parameters for a
module.
The Python interface allows the user to create new modules by inheriting from one of
the possible base classes (InputModule, ProcessModule, OutputModule).
The following is a simple example when we inherit from the InputModule and override
the Process method:
1 import sys
2 from NekPy.LibUtilities import ShapeType
3 import NekPy.NekMesh as NekMesh
4 import numpy as np
5
6 # StructuredGrid creates a 2D structured grid of triangles.
7 class StructuredGrid(NekMesh.InputModule):
8 def __init__(self, mesh):
9 super(StructuredGrid, self).__init__(mesh)
10 self.mesh.spaceDim = 2
11 self.mesh.expDim = 2
12 # Define some configuration options for this module.
13 self.AddConfigOption("nx", "2", "Number of points in x direction")
14 self.AddConfigOption("ny", "2", "Number of points in y direction")
15 self.AddConfigOption("lx", "0", "Lower-left x-coordinate")
16 self.AddConfigOption("rx", "0", "Upper-right x-coordinate")
17 self.AddConfigOption("ly", "0", "Lower-left y-coordinate")
18 self.AddConfigOption("ry", "0", "Upper-right y-coordinate")
19 self.AddConfigOption("compid", "0", "Composite ID")
20
21 def Process(self):
22 # Get the input variables from our configuration options.
23 coord_1x = self.GetFloatConfig("lx")
24 coord_1y = self.GetFloatConfig("ly")
25 coord_2x = self.GetFloatConfig("rx")
26 coord_2y = self.GetFloatConfig("ry")
27 nx = self.GetIntConfig("nx")
28 ny = self.GetIntConfig("ny")
29 compID = self.GetIntConfig("compid")
30 x_points = np.linspace(coord_1x, coord_2x, nx)
31 y_points = np.linspace(coord_1y, coord_2y, ny)
32
33 nodes = []
34 id_cnt = 0
35
78 Chapter 4 NekMesh
36 for y in range(ny):
37 tmp = []
38 for x in range(nx):
39 tmp.append(NekMesh.Node(id_cnt, x_points[x], y_points[y],
0.0))
40 id_cnt += 1
41 nodes.append(tmp)
42 self._create_triangles(nodes, nx, ny, compID)
43 # Call the Module functions to create all of the edges, faces and
44 # composites.
45 self.ProcessVertices()
46 self.ProcessEdges()
47 self.ProcessFaces()
48 self.ProcessElements()
49 self.ProcessComposites()
50
51 def _create_triangles(self, nodes, nx, ny, compID):
52 ...
53
54 # Register our TestInput module with the factory.
55 NekMesh.Module.Register(
56 NekMesh.ModuleType.Input, "StructuredGrid", StructuredGrid)
57
58 if __name__ == ’__main__’:
59 # Create a ’pipeline’ of the input and output modules.
60 mesh = NekMesh.Mesh()
61
62 # First, call our input module’s create function from the NekMesh
factory.
63 NekMesh.InputModule.Create(
64 "StructuredGrid", mesh,
65 nx = sys.argv[1], ny = sys.argv[2], lx = sys.argv[3],
66 ly = sys.argv[4], rx = sys.argv[5], ry = sys.argv[6],
67 compid = sys.argv[7], shape = sys.argv[8]).Process()
68
69 # Then ensure there’s no negative Jacobians.
70 NekMesh.ProcessModule.Create("jac", mesh, list=True).Process()
71
72 # Finally, output the resulting file
73 NekMesh.OutputModule.Create(
74 "xml", mesh, test=True, outfile=sys.argv[9]).Process()
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: .
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:
4.5 NekMesh modules 81
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 Gmsh, 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 and vtk 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 .
For the uncompressed xml the user can execute:
If the user wishes to obtain the vtk output in the legacy format, the output module
option legacy should be specified 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.
Converting from XML to HDF5 is a simple task that only requires the one NekMesh
command:
This will create two files HDF5Mesh.xml and HDF5Mesh.nekg which are both needed in
the same directory to run the simulation. An additional flag in the session file is required,
ensuring it is placed before the expansion list being:
1 <GEOMETRY DIM="3" SPACE="3" HDF5FILE="HDF5Mesh.nekg" />
HDF5 also has the additional advantage of ensuring the mesh and session file are split -
which allows for easy ammending of the session file - whilst allowing for use of FieldCovnert
modules that require only 1 XML input file - rather than having to concatenate the
session and mesh XML files. Solvers and any FieldConvert modules can be run by
referencing only the session file after the GEOMETRY tag is included.
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.
84 Chapter 4 NekMesh
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:
Figure 4.3 (a) Leading edge without spherigons, (b) Leading edge with spherigons
To facilitate this alignment, 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
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.
When using periodic boundary conditions that are rotationally aligned the following
rotational options should be applied:
NekMesh -m peralign:surf1=11:surf2=12:dir=x:rot=PI/6 \
Mesh.xml Mesh_aligned.xml
where rot specifies the rotation angle in radians from surf1 to surf2 about the axis
specified by dir (i.e. the “x” axis in this example).
NekMesh -m peralign:surf1=11:surf2=12:dir=x:rot=PI/6:tolfact=100 \
Mesh.xml Mesh_aligned.xml
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:
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.
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.
• 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.5.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.
There are no configuration options for this module, as it is highly specific to a certain
class of meshes.
4.5 NekMesh modules 89
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.
90 Chapter 4 NekMesh
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. [13].
There are a large number of options which can be viewed using the help function but the
basic usage is:
4.5.16 r-adaptation
This module can deform an existing mesh by using the variational optimiser presented
above. A file must be provided that contains a list of points and a scaling value for each
of them. This scaling factor is then used to target an element size based on the initial
size of the element. Scaling values are interpolated throughout the domain based on the
interpolation method of the main library. The file should look like
0 0 0 2.0
0 1 0 2.0
1 0 0 0.5
1 1 0 0.5
where the first three columns are x, y, z and the last column is the scaling factor.
where subiter is an additional parameter to the variational optimiser that defines the
frequency at which individual elements update their target scaling based on their latest
location in the domain. subiter should be a scalar and is the number of steps between
updates. It is often recommended to run r-adaptation on a linear mesh for stability and
4.6 Mesh generation 91
performance reasons. Note also that the mesh must have CAD information in order for
nodes to slide on curves and surfaces.
The module needs to be informed of the CAD file to project the mesh to and the order
at which to curve the surface:
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.6.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
92 Chapter 4 NekMesh
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:
a small portion of the domain. The level to which the domain subdivides is based on
the curvature of the geometric boundary. Higher curvature regions will subdivide to
a finer level allowing for increased control on the mesh specification and smoothness.
The geometric curvature is then related to a mesh sizing parameter and propagated
throughout the domain ensuring a smooth mesh. For those unfamiliar with octrees, it is
best to think of it as a non-conforming hexahedral mesh
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.5.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" />
4.6 Mesh generation 95
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 the name of a CAD file (in
either STEP or GEO format). Secondly, what type of mesh to make, the options are
EULER and BndLayer for 3D meshes and 2D and 2DBndLayer for 2D meshes. In the
case of EULER the mesh will be made with only tetrahedra. For BndLayer 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="2DBndLayer" />
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="BndLayerSurfaces" VALUE="5,6" />
17 <P PARAM="BndLayerThickness" VALUE="0.03" />
18 <P PARAM="BndLayerLayers" VALUE="4" />
19 <P PARAM="BndLayerProgression" 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" />
96 Chapter 4 NekMesh
27 </PARAMETERS>
28
29 </MESHING>
30 </NEKTAR>
A list of the CAD surfaces which will have a prism generated on is described by
BndLayerSurfaces and the thickness of the boundary to aim for is BndLayerThickness .
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 [email protected] .
Without the feedback this functionality cannot improve.
For a full description of the GEO format the user should refer to Gmsh’s documentation.
The following commands are currently supported:
• Point
4.6 Mesh generation 97
• Line
• Ellipse (arc): as defined in Gmsh’s OpenCASCADE kernel, the first point defines
the start of the arc, the second point the centre and the fourth point the end. The
third point is not used. The start point along with the centre point form the major
axis and the minor axis is then computed so that the end point falls onto the arc.
The major axis must always be greater or equal to the minor axis.
• Circle (arc): the circle is a special case of the ellipse where the third point is
skipped. The distances between the start and end points and the centre point must
be equal or an error will be thrown.
• Line Loop
• Plane Surface
• Surface Loop
• Volume
At the present time, NekMesh does not support the full scripting capabilities of the GEO
format, but the evaluation of simple variables is supported. The used GEO files should
be a straightforward succession of entity creations (see list above). This should however
allow for the creation of quite a wide range of 2D and 3D geometries by transformation
of arbitrary curves into generic splines and arcs.
• Tetrahedron
• Prism
• Pyramid
98 Chapter 4 NekMesh
Figure 4.6 Linear mesh generated in Star-CCM (visualised with ParaView) showing the one-layer
prismatic cells layer
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 formats which can
be read by common visualisation and post-processing software, primarily Paraview/VisIt
(in unstructured VTK .vtu format) or Tecplot/VisIt (in ASCII .dat or binary .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.
FieldConvert expects at least one input specification (such as a session file and its
corresponding field file) and one output specification. These are specified on the command
line as
These can be combined with a processing module by adding the -m command line option.
There can be more than one module specified, and they can appear anywhere in the
command line arguments, although the order of execution is inferred from their order in
the command line. For example, the command
1
Modules that do not have parallel support will be specified in the appropriate section.
99
100 Chapter 5 FieldConvert
causes in1.xml and in2.fld to be read, followed by the module1 processing module,
the module2 processing module, and finally output to the out.dat Tecplot file.
Note that even though the .fld extension is typically associated with Nektar++ files,
FieldConvert can automatically identify Semtex and Nek5000 input field files.
5.2 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:
When converting to .dat or .plt format, it is possible to enable output with double
precision, which is more accurate but requires larger disk space. For example, double
precision output in plt. format can be produced with the command:
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.
102 Chapter 5 FieldConvert
The Python interface allows the user to instantiate input, output, and process mod-
ules by calling the static Create method of the InputModule, ProcessModule, and
OutputModule, register configuration options, and run them. For example, consider the
command:
The key points are that the FieldConvert command line options, in this case output-points ,
are passed to the constructor of Field. The configuration options for a given module
are passed to the static Create method of the InputModule, ProcessModule, and
OutputModule. This creates the corresponding module and the modules can be run
immediately after instantiation. Note that the first parameter of the Create method
has to be the key for a given module, the second is the field variable and for input and
output modules the remaining arguments may identify the input and output files for a
given module. Optionally we can explicitly specify the file type of an input module using
the "infile" keyword and the "outfile" keyword for output modules.
1 import sys
2 from NekPy.FieldUtils import *
3
4 field = Field(sys.argv, output_points=10)
5
6 InputModule.Create("xml", field, infile={"xml": "session.xml"}).Run()
7 InputModule.Create("fld", field, infile={"fld": "field.fld"}).Run()
8 ProcessModule.Create("wss", field, bnd="0").Run()
9 OutputModule.Create("fld" , field, outfile="field_wss.fld").Run()
It can also emulate the functionality of FieldConvert when using the nparts option in
the following way. Here session_xml is a directory containing the mesh partitioned into
2.
1 import sys
2 from NekPy.FieldUtils import *
3
4 field = Field(sys.argv, nparts=2, forceoutput=True, error=True)
5
6 inputxml = InputModule.Create("xml", field, "session_xml")
5.6 FieldConvert modules -m 103
The number of partitions is looped over, with NewPartition called at the start of each.
When using OutputModule, the info module must be used in order to obtain the correct
result.
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
7. combineAvg : Combine two Nektar++ binary output (.chk or .fld) field file contain-
ing averages of fields (and possibly also Reynolds stresses) into single file;
8. concatenate : Concatenate a Nektar++ binary output (.chk or .fld) field file into
single file (deprecated);
16. innerproduct : take the inner product between one or a series of fields with another
field (or series of fields).
23. qualitymetric : Evaluate a quality metric of the underlying mesh to show mesh
quality;
26. pointdatatofld : Given discrete data at quadrature points project them onto an
expansion basis and output fld file;
31. shear : Computes time-averaged shear stress metrics: TAWSS, OSI, transWSS,
TAAFI, TACFI, WSSG;
33. surfdistance : Computes height of a prismatic boundary layer mesh and projects
onto the surface (for e.g. y + calculation).
34. vorticity : Computes the vorticity field.
35. wss : Computes wall shear stress field.
36. phifile : Computes the Φ function representing a body defined in an .stl file.
Useful for the Smoothed Profile Method solver.
37. wallNormalData : Interpolate values for a set of points in the wall-normal direction
(for e.g. extract boundary layer profiles).
FieldConvert -l
where the file test-C0Proj.fld can be processed in a similar way as described in section
5.2 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
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 = ûorig where K0 =
(1 + k /K0 )
2 2 k
L
106 Chapter 5 FieldConvert
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.2 to visualise the result either in Tecplot, Paraview or VisIt.
where the file test-L2Crit.fld can be processed in a similar way as described in section
5.2 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.5.3).
FieldConvert -m fieldfromstring:fieldstr="x+y+u":fieldname="result" \
file1.xml file2.fld file3.fld
5.6 FieldConvert modules -m 107
To sum two .fld files one can use the addFld module of FieldConvert
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.2 to visualise
the result either in Tecplot, Paraview or VisIt.
5.6.7 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.2 to visualise the
result either in Tecplot, Paraview or VisIt.
To concatenate file1.fld and file2.fld into file-conc.fld one can run the following
command
where the file file-conc.fld can be processed in a similar way as described in section
5.2 to visualise the result either in Tecplot, Paraview or VisIt. The concatenate module
previously used for this purpose is not required anymore, and will be removed in a future
release.
108 Chapter 5 FieldConvert
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
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
5.6 FieldConvert modules -m 109
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.2 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:
The output file file-plane.fld can be processed in a similar way as described in section
5.2 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 .
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:
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
5.6 FieldConvert modules -m 111
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.
If the fromfld is a 3DH1D field and uses HalfMode expansion, you can use realmodetoimag=n1 , n2 , ..., nm
to transform the n1 , n2 , ..., nm th variables from real modes to imaginary modes. Variable
index starts from 0.
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 ( file1.csv ) to the mesh and
expansions defined in file1.xml and output the field to file1.fld . The file file.pts
must be of the form:
1 <?xml version="1.0" encoding="utf-8" ?>
2 <NEKTAR>
112 Chapter 5 FieldConvert
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. An equivalent csv file is:
# x, a, b, c
1.0000,-1.0000,1.0000,-0.7778
2.0000,-0.9798,0.9798,-0.7980
3.0000,-0.9596,0.9596,-0.8182
4.0000,-0.9394,0.9394,-0.8384
FieldConvert -m interppointdatatofld:frompts=1D-file1.pts:interpcoord=1 \
3D-file1.xml 3D-file1.fld
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:topts=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:
5.6 FieldConvert modules -m 113
Similar to the interppointdatatofld module, the .pts file can be interchanged with a
.csv file (the output can also be written to .csv ):
# x, y
0.0,0.0
0.5,0.0
1.0,0.0
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 file2.dat
can be specified where npts is the number of equispaced points between (x0 , y0 ) to
(x1 , y1 ). This also works 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 file2.dat
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 file2.dat
114 Chapter 5 FieldConvert
There is also 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.
If the fromfld is a 3DH1D field and uses HalfMode expansion, you can use realmodetoimag=n1 , n2 , ..., nm
to transform the n1 , n2 , ..., nm th variables from real modes to imaginary modes. Variable
index starts from 0.
Note
This module runs in parallel for the line, plane and box extraction of points.
You can interpolate one set of points to another using the following command:
This command will interpolate the data in file1.pts to a new set of points defined in
file2.pts and output it to file2.dat .
Similarly to the interppoints module, the target point distribution can also be specified
using the line , plane or box options. The optional arguments clamptolowervalue ,
clamptouppervalue , defaultvalue and cp are also supported with the same meaning
as in interppoints.
One useful application for this module is with 3DH1D expansions, for which currently
the interppoints module does not work. In this case, we can use for example
With this usage, the equispacedoutput module will be automatically called to interpolate
the field to a set of equispaced points in each element. The result is then interpolated to
a plane by the interpptstopts module.
5.6 FieldConvert modules -m 115
Note
This module does not work in parallel.
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.2 to visualise the result either in Tecplot, Paraview or VisIt.
• By default a metric outlined in [13] 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.
This module does not create an output file which is reinforced by the out.stdout option.
The integral and mean for each field variable are then printed to the stdout.
The output file file-mean.fld can be processed in a similar way as described in section
5.2 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. Alternatively, the file.pts can be
interchanged with a csv file.
The default argument is to use the equispaced (but potentially collapsed) coordinates
which can be obtained from the command.
In this case the pointdatatofld module should 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 advisable to use the set of points given by
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.
5.6.28 Removes one or more fields from .fld files: removefield module
This module allows to remove one or more fields from a .fld file:
where the file test-removed.fld can be processed in a similar way as described in section
5.2 to visualise the result either in Tecplot, Paraview or VisIt. The lighter resulting file
speeds up the postprocessing of large files when not all fields are required.
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-scal.fld can be processed in a similar way as described in section
5.2 to visualise the result either in Tecplot, Paraview or VisIt.
5.6 FieldConvert modules -m 119
FieldConvert -m shear:N=value:fromfld=test_id_b0.fld \
test.xml test-multishear.fld
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|.
The surface distance module computes the height of a boundary layer formed by quadri-
laterals (in 2D) or prisms and hexahedrons (in 3D) and projects this value onto the
surface of the boundary, in a similar fashion to the extract module. In conjunction
with a mesh of the surface, which can be obtained with NekMesh , and a value of the
average wall shear stress, one potential application of this module is to determine the
distribution of y + grid spacings for turbulence calculations.
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 .
To perform the vorticity calculation and obtain an output data containing the vorticity
solution, the user can run
where the file test-vort.fld can be processed in a similar way as described in section
5.2.
To obtain the wall shear stres vector and magnitude, the user can run:
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
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.
5.6 FieldConvert modules -m 121
5.6.36 Calculating the shape function Φ for an SPM case: phifile module
Note
This module is in experimental phase and only runs in serial. When reading
3D geometries from .stl files, errors may occur if triangles are placed exactly
at 90◦ .
This FieldConvert module converts a binary .stl CAD file into .fld or .vtu / .dat
files that can be used as inputs for the Smoothed Profile Method solver. Running the
command:
will generate an output file geom.fld with all the information required to define a shape
function Φ representing the geometry specified in geom.stl . The option scale sets the
value of ξ as it is described in the Synopsis chapter of the Incompressible N-S solver. If
the output file gets the extension .vtu or .dat , the module will produce a graphical
representation of the shape function; however, the recommended way to proceed is to
generate an .fld file and then, use FieldConvert to obtain the .vtu or .dat files if
needed for visualisation purposes:
This module can also be used to produce a .fld and .vtu / .dat file of shapes defined
directly in the session file through an analytical expression. In this case, the commands
simplify to:
The algorithm computes an octree for the triangles that define the 3D object in the
.stl file, and then loops over all the nodes of the computational mesh looking for the
shortest distance to the 3D object. Since this module is currently in experimental phase,
it only runs in serial and therefore its performance in computing the shape function from
the .stl file is limited, especially in 3D cases. In addition to this, it is recommended
to make sure that the angles between triangles are not strictly equal to 90◦ , since the
algorithm will probably fail to find the real Φ function.
FieldConvert -m wss:bnd=0:xorig="0.5,0,0":projDir="0,1,0":maxDist=0.1:\
distH=0.1:nptsH=0.01:d=0.2 test.xml test.fld test.pts
The option bnd specifies the target boundary region, to which the input point specified
by xorig will be projected as the first point in the interpolation points array. The
projection direction is specified by projDir , which does not have to be a unit vector
but will be automatically normalized. The input point and projetion direction must be
set carefully to make sure a projected point can be found on the target boundary. In
cases with curved boundaries on which multiple projected points might exist, the user
can use maxDist to limit the maximum projection distance between the input point to
the projected point.
After the projected point is found, this module will compute the wall-normal direction
at the point, and an array of points will be set in this direction. The number of points
is specified by nptsH , and the parameter d controls the distribution of the points as
follows
h √ i
tanh (1 − ξ)atanh( 1 − δ)
h(ξ) = H 1 − √
1−δ
Finally, this module will interpolate the values at the points from test.fld, and save the
result in test.pts.
Figure 5.1 (a) Project the input point onto the boundary, (b) Array of points to be interpolated.
5.7 FieldConvert in parallel 123
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_vtu/P0000000.vtu ,
test_vtu/P0000001.vtu, test_vtu/P0000002.vtu. For this format an additional file called
test.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 or creating an output file for visualization.
will partition the mesh into 10 partitions 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.
5.8 Processing large files in serial 125
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
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.
Note the form file1_xml:xml option tells the code it is a parallel partition which should
be treated as an xml type file. the argument of nparts should correpsond to the number
of partitions used in generating the file1_xml directory. This will create a parallel vtu
file as it processes each partition.
Note that internally the routine uses the range option so that it only has to load the part
of file1.xml that overlaps with each partition of file2.xml . 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 . In previous versions of
FieldConvert it was necessary to generate an updated Info.xml file but in the current
version it should automatically be updating this file.
For the example of creating a vtu file above you can use 4 processor concurrently wiht
the command line:
Obviously the executable will have to have been compiled with the MPI option for this
to work.
Part III
Solver Applications
127
Chapter 6
Acoustic Solver
6.1 Synopsis
The aim of the AcousticSolver is to predict acoustic wave propagation. Through the
application of a splitting technique, the flow-induced acoustic field is totally decoupled
from the underlying hydrodynamic field.
(pa , ρa , ρua ) around this state. In conservative form, the LEE are given as:
∂U ∂F 1 ∂F 2 ∂F 3
+ + + + CU = W (6.1)
∂t ∂x1 ∂x2 ∂x3
128
6.1 Synopsis 129
with
a
p
ρa
U = ρua1 , (6.2)
a
ρu2
ρua3
ρua1 c2 + u1 pa ρua2 c2 + u2 pa ρua3 c2 + u3 pa
ρua + u ρa ρua + u ρa ρua + u ρa
1 1 2 2 3 3
F 1 = ρua1 u1 + pa , F2 = ρua1 u2 , F3 = ρua1 u3 , (6.3)
ρua2 u1 ρua2 u2 + pa ρua2 u3
ρua3 u1 ρua3 u2 ρua3 u3 + pa
∂p ∂p ∂p
(γ − 1) ∂u 0 1
(1 − γ) ∂x 1
(1 − γ) ∂x 1
(1 − γ) ∂x
k
∂xk ρ 1 ρ 2 ρ 3
0 0 0 0 0
C= 0 ∂u1 ∂u1 ∂u1 ∂u1
(6.4)
uk ∂x k ∂x1 ∂x2 ∂x3
.
0 ∂u2
uk ∂x k
∂u2
∂x1
∂u2
∂x2
∂u2
∂x3
0 ∂u3
uk ∂x k
∂u3
∂x1
∂u3
∂x2
∂u3
∂x3
By default, the source term vector W is zero and has to be specified by an appropriate
forcing.
∂pa pa
+ c2 ∇ · ρua + u = ω̇c (6.5a)
∂t c2
∂ua
a
p
+ ∇ (u · ua ) + ∇ = ω̇ m , (6.5b)
∂t ρ
where (u, c2 , ρ) represents the base flow and (ua , pa ) the acoustic perturbations. Similar
to the LEE, the acoustic source terms ω̇c and ω̇ m are by default zero and must be
specified e.g. by an appropriate forcing. This way, e.g. the APE-1, APE-4 [11] or revised
APE equations [14] can be obtained. Expressed as hyperbolic conservation law, the
APE-1/4 operator reads:
∂U ∂F 1 ∂F 2 ∂F 3
+ + + =W (6.6)
∂t ∂x1 ∂x2 ∂x3
130 Chapter 6 Acoustic Solver
with
a
p
ua
U = 1a , (6.7)
u2
ua3
ρc2 ua1 + pa u1 ρc2 ua2 + pa u2 ρc2 ua3 + pa u3
u u + p /ρ
a a 0 0
F1 = j j , F2 = , F = . (6.8)
3
0 uj uj + p /ρ
a a 0
0 0 uj uj + p /ρ
a a
6.2 Usage
AcousticSolver session.xml
Parameters
Under this section it is possible to set the parameters of the simulation.
1 <PARAMETERS>
2 <P> TimeStep = 1e-05 /P>
3 <P> NumSteps = 1000 /P>
4 <P> FinTime = 0.01 /P>
5 <P> IO_CheckSteps = 100 /P>
6 <P> IO_InfoSteps = 10 /P>
7 <P> IO_CFLSteps = 10 /P>
8 </PARAMETERS>
• 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;
• IO_CFLSteps sets the number of steps between successive Courant number stats
are printed to screen;
6.3 Session file configuration 131
6.3.3 Variables
For the APE operator, the acoustic pressure and velocity perturbations are solved, e.g.:
1 <VARIABLES>
2 <V ID="0"> p </V>
3 <V ID="1"> u </V>
4 <V ID="2"> v </V>
5 <V ID="3"> w </V>
6 </VARIABLES>
132 Chapter 6 Acoustic Solver
The LEE use a conservative formulation and introduce the additional density perturbation:
1 <VARIABLES>
2 <V ID="0"> p </V>
3 <V ID="1"> rho </V>
4 <V ID="2"> rhou </V>
5 <V ID="3"> rhov </V>
6 <V ID="4"> rhow </V>
7 </VARIABLES>
6.3.4 Functions
• BaseFlow Baseflow (ρ, c2 , u) defined by the variables rho0, c0sq, u0, v0, w0
for APE and (ρ, c2 , u, γ) defined by rho0, c0sq, u0, v0, w0, gamma for LEE.
• InitialConditions
The white noise BC imposes a stochastic, uniform pressure at the boundary. The
implementation uses a Mersenne-Twister pseudo random number generator to
generate white Gaussian noise. The standard deviation σ of the pressure is specified
by the VALUE attribute.
6.4 Examples
To maintain numerical stability we must use a small time-step. Finally, we set the density,
heat ratio and ambient pressure.
1 <PARAMETERS>
2 <P> TimeStep = 1e-05 </P>
3 <P> NumSteps = 1000 </P>
4 <P> FinTime = TimeStep*NumSteps </P>
5 <P> IO_CheckSteps = 10 </P>
6 <P> IO_InfoSteps = 10 </P>
7 </PARAMETERS>
134 Chapter 6 Acoustic Solver
The initial condition and the base flow field are specified by the Baseflow and InitialConditions
functions, respectively:
1 <FUNCTION NAME="Baseflow">
2 <E VAR="u0" VALUE="300 * tanh(2*y/0.1)"/>
3 <E VAR="v0" VALUE="0"/>
4 <E VAR="c0sq" VALUE="1.4 * Pinfinity / Rho0"/>
5 <E VAR="rho0" VALUE="Rho0"/>
6 </FUNCTION>
7 <FUNCTION NAME="InitialConditions">
8 <E VAR="p" VALUE="0"/>
9 <E VAR="u" VALUE="0"/>
10 <E VAR="v" VALUE="0"/>
11 </FUNCTION>
The system is excited via an acoustic source term ω̇c , which is modeled by a field forcing
as:
1 <FORCING>
2 <FORCE TYPE="Field">
3 <FIELDFORCE> Source <FIELDFORCE/>
4 </FORCE>
5 </FORCING>
6.4.1.3 Results
Fig. 6.1 shows the acoustic source term, the velocity and the acoustic pressure and
velocity perturbations at a single time step.
6.4 Examples 135
Figure 6.1 Acoustic source term, base flow velocity, acoustic pressure and acoustic velocity
perturbations.
Chapter 7
Advection-Diffusion-Reaction Solver
7.1 Synopsis
∂u
α + λu + ν∇u + ∇ · (D∇u) = f (7.1)
∂t
in either discontinuous or continuous projections of the solution field. For a full list of
the equations which are supported, and the capabilities of each equation, see the table
below.
2
∇ u=f Poisson All Continuous/Discontinuous
2
∇ u + V∇u = f SteadyAdvectionDiffusion 2D only Continuous/Discontinuous
136
7.2 Usage 137
7.2 Usage
ADRSolver session.xml
UnsteadyAdvection X
UnsteadyDiffusion X X
UnsteadyReactionDiffusion X
UnsteadyAdvectionDiffusion X
UnsteadyInviscidBurger X
• Eqtype: This sets the type of equation to solve, according to the table above.
• DiffusionAdvancement: This specifies how to treat the diffusion term. This will
be restricted by the choice of time integration scheme:
• DiffusionType:
• UpwindType:
– Upwind .
7.3.3 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).
7.3.4 Functions
The following functions can be specified inside the CONDITIONS section of the session file:
7.4 Examples
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 <TIMEINTEGRATIONSCHEME>
2 <METHOD> RungeKutta </METHOD>
3 <ORDER> 4 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvection" />
8 <I PROPERTY="Projection" VALUE="DisContinuous" />
9 <I PROPERTY="AdvectionType" VALUE="FRDG" />
10 <I PROPERTY="UpwindType" VALUE="Upwind" />
11 </SOLVERINFO>
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>
140 Chapter 7 Advection-Diffusion-Reaction Solver
Two boundary regions are defined, one at each end of the domain, and periodicity is
enforced
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>
To visualise the output, we can convert it into either TecPlot or VTK formats
∇2 u + λu = f (7.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
142 Chapter 7 Advection-Diffusion-Reaction Solver
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
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>
This execution should print out a summary of input file, the L2 and Linf errors and the
time spent on the calculation.
7.4.2.4 Post-processing
Simulation results are written in the file Helmholtz2D_modal.fld. We can choose to
visualise the output in Gmsh
7.4 Examples 143
which generates the file Helmholtz2D_modal.vtu which can be visualised and is shown
in Fig. 7.1
7.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.
144 Chapter 7 Advection-Diffusion-Reaction Solver
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.
7.4 Examples 145
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
146 Chapter 7 Advection-Diffusion-Reaction Solver
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>
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>
7.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. 7.3.
interactions and pattern formation. The ADRSolver supports the solution of a single-
variable system
∂u
= ∇2 ux + R(u)
∂t
where the diffusion coefficient and reaction term R(u) are defined using the session file.
Further to this, the reaction term R(u) is imposed by the definition of a body forcing
function. For example, the reaction term R(u) = 0.1u may be defined using the function:
148 Chapter 7 Advection-Diffusion-Reaction Solver
Note in particular the use of the EVARS (equation variables) attribute, which permits
the definition of this function in terms of the scalar variable u. This function should be
used together with an appropriate FORCING block (as described in section 3.5):
1 <FORCING>
2 <FORCE TYPE="Body">
3 <BODYFORCE> BodyForce </BODYFORCE>
4 </FORCE>
5 </FORCING>
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
149
150 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 151
• 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 [10].
• 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 [10].
8.3.4 Filters
The following filters are supported exclusively for the cardiac EP solver. Further filters
from section 3.4 are also available for this solver.
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>
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.
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>
154 Chapter 8 Cardiac Electrophysiology Solver
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 ,
+ 2
ρw
ρuw
ρvw
p ρw
u(E + p) v(E + p) w(E + p)
E
(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
155
156 Chapter 9 Compressible Flow Solver
∂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 can be achieved by
using local discontinuous Galerkin (LDG) approach, interior penalty method or 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 [7] and [29].
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.
158 Chapter 9 Compressible Flow Solver
1 <PARAMETERS>
2 <P> TimeStep = 0.0000001 </P>
3 <P> FinTime = 1.0 </P>
4 <P> NumSteps = FinTime/TimeStep </P>
5 <P> IO_CheckSteps = 5000 </P>
6 <P> IO_InfoSteps = 1 </P>
7 <P> Gamma = 1.4 </P>
8 <P> pInf = 101325 </P>
9 <P> rhoInf = 1.225 </P>
10 <P> GasConstant = 287.058 </P>
11 <P> TInf = pInf/(287.058*rhoInf) </P>
12 <P> Twall = pInf/(287.058*rhoInf)+15.0 </P>
13 <P> uInf = 147.4 </P>
14 <P> vInf = 0.0 </P>
15 <P> wInf = 0.0 </P>
16 <P> mu = 1e-5 </P>
17 <P> Pr = 0.72 </P>
18 <P> thermalConductivity = 0.02 </P>
19 </PARAMETERS>
• 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.
• uInf 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.
9.3 Session file configuration 159
Solver info
Under this section it is possible to set the solver information.
1 <SOLVERINFO>
2 <I PROPERTY="EQTYPE" VALUE="NavierStokesImplicitCFE" />
3 <I PROPERTY="Projection" VALUE="DisContinuous" />
4 <I PROPERTY="TimeIntegrationMethod" VALUE="DIRKOrder2" />
5 <I PROPERTY="AdvectioType" VALUE="WeakDG" />
6 <I PROPERTY="DiffusionType" VALUE="InteriorPenalty" />
7 <I PROPERTY="UpwindType" VALUE="Roe" />
8 <I PROPERTY="ProblemType" VALUE="General" />
9 <I PROPERTY="ViscosityType" VALUE="Constant" />
10 <I PROPERTY="EquationOfState" VALUE="IdealGas" />
11 </SOLVERINFO>
– DisContinuous .
Note that the Continuous projection is not supported in the Compressible
Flow Solver.
Note that only WeakDG is fully supported, the other operators work only with
quadrilateral elements (2D or 2.5D).
9.3 Session file configuration 161
– LDGNS (LDG with primitive variables. The penalty term is inversely propor-
tional to the element size, proportional to the local viscosity for the momentum
equations and to the thermal conductivity for the energy equation, and pro-
portional to an optional parameter LDGNSc11 which is by default set to one;
proportionality to polynomial order can be manually imposed by setting the
parameter LDGNSc11 equal to p2 ).
– LFRDGNS (Flux-Reconstruction recovering nodal DG scheme).
– LFRSDNS (Flux-Reconstruction recovering a spectral difference (SD) scheme).
– LFRHUNS (Flux-Reconstruction recovering Huynh (G2) scheme).
– LFRcminNS (Flux-Reconstruction with c = cmin ).
– LFRcinfNS (Flux-Reconstruction with c = ∞).
– InteriorPenalty (Symmetric interior penalty method).
Note that only LDGNS and InteriorPenalty are fully supported, the other opera-
tors work only with quadrilateral elements (2D or 2.5D).
• 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="2"> E </V>
5 </VARIABLES>
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 .
Note that the no-slip, isothermal, wall boundary condition requires Twall to be specified.
In the following are some examples for a 2D problem:
In some cases we need to excite perturbations inside the boundary layer. This can be
achieved by setting part of the wall as a disturbance strip. In the no-slip/adiabatic
wall boundary conditions, if the VALUE is not exact "0" but any expression, which
can be time-dependent, the value of the expression will be added to the ghost state
of what it should be in the input boundary conditions, and then generate a non-zero
flux through the Riemann solver. The following is an example to set a disturbance
strip of amplitude A, frequency f , and in the range of [x0 , x0 + len] on a flat plate.
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"
6 VALUE="A*sin(2*PI*f*t)*sin(2*PI*(x-x0)/len)
7 *(x>=x0)*(x<=(x0+len))" />
8 <D VAR="E" USERDEFINEDTYPE="WallAdiabatic" VALUE="0" />
9 </REGION>
10 </BOUNDARYCONDITIONS>
9.4 Examples
by an added Laplacian term on right hand side of equation 9.1 [36]. The diffusivity of the
system is controlled by a variable viscosity coefficient ε. For consistency ε is proportional
to the element size and inversely proportional to the polynomial order. Finally, from
physical considerations ε needs to be proportional to the maximum characteristic speed
of the problem. The final form of the artificial viscosity is
h
ε = ε0 λmax S, (9.8)
p
where S is a sensor.
hq − q̃, q − q̃i
se = log10 , (9.9)
hq, qi
where h·, ·i represents a L2 inner product, q and q̃ are the full and truncated expansions
of a state variable (in our case density)
N (P ) N (P −1)
q(x) = q̃(x) = (9.10)
X X
q̂i φi , q̂i φi ,
i=1 i=1
0 if se < s0 − κ
π(se −s0 )
Sε = 1
2 1 + sin 2κ if |se − s0 | ≤ κ , (9.11)
1 if se > s0 + κ
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>
The diffusivity and the sensor can be controlled by the following parameters:
1 <PARAMETERS>
2 <P> Skappa = -1.3 </P>
3 <P> Kappa = 0.2 </P>
4 <P> mu0 = 1.0 </P>
5 </PARAMETERS>
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
coupling between different elements are determined by common numerical fluxes and
there is no further coupling between the elements. Furthermore, the initial p-adaptive
algorithm uses the same sensor as the shock capturing algorithm to identify the smooth-
ness of the local solution so it rather straightforward to implement both algorithms at
the same time.
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
if ssm < se < sds
e
pe = (9.12)
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.13)
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 that we 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.
168 Chapter 9 Compressible Flow Solver
In this example, we solve a compressible flow past a circular cylinder using an implicit
discontinuous Galerkin compressible flow solver as shown in figure 9.2. For the implicit
time-integration schemes, TimeStep or CFL can be adopted to control the time step.
For the case of using CFL , the CFL number can grow from CFL to CFLEnd by a ratio
of CFLGrowth to adjust the time step at different stages of the simulation.
The CFL number, growing CFL number and the maximum value of the CFL number are
controlled by the following parameters as also described in section 9.3
1 <PARAMETERS>
2 <P> CFL = 0.1 </P>
3 <P> CFLGrowth = 1.1 </P>
4 <P> CFLEnd = 2.0 </P>
5 </PARAMETERS>
In this case, the numerical simulation starts from a CFL number of 0.1 and grows by
a ratio of 1.1 up to a maximum value of CFL number of 2.0. Note that the CFLEnd
parameter may assume higher values, depending on the strategy adopted. In addition,
there is no need to define the TimeStep parameter, since the time step size is calculated
based on the CFL number in each time step.
Since we are solving an implicit time-integration scheme, we must specify to the solver in-
formation the EQType which corresponds to an implicit solver. It should be noted that cur-
rently the CFS solver only supports NavierStokesImplicitCFE and EulerImplicitCFE .
1 <PARAMETERS>
2 <I PROPERTY="EQTYPE" VALUE="NavierStokesImplicitCFE" />
3 <I PROPERTY="TimeIntegrationMethod" VALUE="DIRKOrder2" />
4 </PARAMETERS>
There are some other parameters controlling the performance of the implicit solver.
NonlinIterTolRelativeL2 determines the convergence tolerance of the nonlinear system
solver relative to the initial nonlinear system residual. NekNonlinSysMaxIterations is the
maximum iteration number of the nonlinear system solver. LinSysRelativeTolInNonlin
determines the convergence tolerance of linear system solver in each nonlinear iteration.
NekLinSysMaxIterations is the maximum iteration number of the linear system solver
in each nonlinear iteration. LinSysMaxStorage determines the maximum number of
variable vector allowed to store in the linear system solver. Specifically for GMRES
solver, the GMRES solver will be restarted if NekLinSysMaxIterations is larger than
LinSysMaxStorage and thus LinSysMaxStorage determines the storage consumption of
the GMRES solver. Regarding the parameters to control the preconditioners in GMRES,
PreconMatFreezNumb specifies the number of time steps to freeze the preconditioning
matrices, in other words, the preconditioning matrices will be updated based on the
number of time steps provided by the user. PreconItsStep determines the number of
9.4 Examples 169
Here, we choose to solve the compressible Navier-Stokes equations and use the 2nd order
Singly Diagonally Implicit Runge–Kutta (SDIRK) method.
Figure 9.2 Laminar flow past a circular cylinder at Re = 200 and M = 0.2.
Chapter 10
Dummy Solver
10.1 Synopsis
The Dummy solver does not solve any equation systems but only serves to exchange
fields with other solvers and applications. It is intended for demonstrating and testing
the coupling implementations only.
170
Chapter 11
Incompressible Navier-Stokes Solver
11.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 (11.1a)
∂t
∇·u=0 (11.1b)
where V is the velocity, p is the specific pressure (including density) and ν the kinematic
viscosity.
171
172 Chapter 11 Incompressible Navier-Stokes Solver
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 (11.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 (11.2)
Ω ∂t Ω Ω Ω
where N (u) = u · ∇u. We recall that the term Ω ∇q · ∇p is the weak approximation
R
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 (11.2) by parts we can obtain the
weak pressure equation
!
∂u n+1
Z Z
∇q · ∇p n+1
= q∇· + N(u)n+1
Ω Ω ∂t
!
∂u n+1
Z
− q + N(u)n+1 + ν∇ × ∇ × un+1 · n (11.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 − û
' (11.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 = û =
2 , if J = 2 2u − 2 u , if J = 2.
3 n 1 n−1
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.
11.1 Synopsis 173
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 (11.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 (11.6)
∆t
with consistent Neumann boundary conditions prescribed as
∂p n+1 h ∂u n+1 i
=− + ν(∇ × ∇ × u)∗,n+1 + N∗,n+1 · n (11.7)
∂n ∂t
2. The second step is discretise equation (11.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 − û
' (11.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 − û
' . (11.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
174 Chapter 11 Incompressible Navier-Stokes Solver
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 = ∇q · (
− N?,n+1 )
Ω ∆t ∂Ω0 Ω ∆t
γ0
Z Z
∗,n+1
− q ν(∇ × ∇ × u) · n + qwn+1 · n (11.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 [9]. In
this paper they suggest to impose a pressure Dirichlet outflow condition of the form
1
pn+1 = νn · ∇u∗,n+1 · n − | u∗,n+1 |2 So (n · u∗,n+1 ) + fbn+1 · n (11.12)
2
11.1 Synopsis 175
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 (11.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 [8] 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 + û (11.14)
∂n ∆t ν ∆t
176 Chapter 11 Incompressible Navier-Stokes Solver
∂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 (11.15)
− f
ν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 11.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 11.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 [47] and [39]. 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.
11.1 Synopsis 177
Note
Some examples of the substepping scheme can be found in the regression
tests directory under $NEKHOME/Solver/IncNavierStokesSolver/Tests/ di-
rectory: 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 7
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 polynomial order 6. 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 additional 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="GaussLobattoLegendre,GaussRadauMAlpha1Beta0" NUMPOINTS="9,8"
FIELDS="u,v" />
3 <E COMPOSITE="C[0]" BASISTYPE="Modified_A,Modified_B" NUMMODES="7,7"
POINTSTYPE="GaussLobattoLegendre,GaussRadauMAlpha1Beta0" NUMPOINTS="9,8"
FIELDS="p" />
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 that for a quadrilateral expansion it would have been
“Modified_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
178 Chapter 11 Incompressible Navier-Stokes Solver
direction since this uses a Gauss-Radau formula with α = 1, β = 0 weights (see [20] for
details on why).
Immersed Boundary Methods may be very useful in these situations, where the definition
of the boundaries requires a very complex mesh to reach convergence. The main idea
behind them is the use of a forcing term in the incompressible Navier-Stokes equations
in such a way that the mesh does not necessariliy follow the boundaries. The solution in
the regions falling outside the boundaries is simply that of the boundaries, forcing the
flow to behave as if there were a real object even if the mesh does not represent it. The
method presented here is an adaptation of the Smoothed Profile Method [33] extended
to a high-order semi-implicit splitting scheme [25, 45]. This method ensures that the
no-slip, no-penetration and incompressibility constraints are mathematically enforced.
Starting from the incompressible Navier-Stokes equations, the term fs is added to the
right hand side:
∂u
+ u · ∇u = −∇p + ν∇2 u + f + fs (11.16a)
∂t
∇·u=0 (11.16b)
The definition of this term depends on the method but, for the Smoothed Profile Method
(SPM), it is related to a shape function Φ(x, t) valued 0 in the fluid domain and 1 outside.
It is usually defined as:
1 d(x, t)
Φ(x, t) = − tanh −1 , (11.17)
2 ξ
being ξ a scaling factor [45] and d(x, t) a function representing the distance to the
boundary (positive inside the body, negative inside the fluid). If the case to be simulated
includes more than one immersed boundaries, the final shape function is calculated by
adding the individual ones as long as they do not overlap:
Φ= Φi (11.18)
X
i
11.1 Synopsis 179
Φ=1
fluid
body
Figure 11.2 Definition of the shape function Φ close to the boundary of an immersed body.
PJ−1 J−1
γ0 un+1 − q=0 αq un−q
=− βq (u·∇u)n−q −∇(p∗ +pp )n+1 +ν∇2 un+1 +f n+1 +fs n+1
X
∆t q=0
(11.19)
PJ−1 J−1
ũ − q=0αq un−q
=− βq (u · ∇u)n−q + f n+1 , (11.20a)
X
∆t q=0
û − ũ
= −∇p∗ n+1 , (11.20b)
∆t
γ0 u∗ − û
= ν∇2 un+1 , (11.20c)
∆t
γ0 un+1 − γ0 u∗
= −∇pn+1 + fs n+1 (11.20d)
∆t p
where αq , βq and γ0 are coefficients of the stiffly-stable time integration method and up
is the velocity of the points that lay outside the boundaries. Thus, the new term is just
an acceleration proportional to the difference between the expected and the intermediate
velocity, forcing the flow to follow the shapes defined by Φ and up . Some transformations
in these expressions lead to the final SPM equations:
180 Chapter 11 Incompressible Navier-Stokes Solver
2. Pressure:
ũ
2 ∗
∇ p =∇· , (11.23a)
∆t
J−1
∂p ∗
=− βq [−u · ∇u + ν(∇ × ∇ × u) − f ]n−q · n (11.23b)
X
∂n q=0
3. Viscous effects:
γ0 û
∇2 − u∗ = (11.24)
ν∆t ν∆t
4. SPM pressure:
5. SPM force:
γ0 un+1 − γ0 u∗ γ0 Φn+1 (up n+1 − u∗ )
= − ∇pp (11.26)
∆t ∆t
Since the term ∇pp in the last equation may induce a velocity slightly different to up
inside the bodies, it may be changed to (1 − Φ)∇pp , cancelling this effect but adding
some compressibitly to the flow [25]:
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 3 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="SolverType" VALUE="SmoothedProfileMethod" />
8 ...
9 <I PROPERTY="ForceBoundary" VALUE="True" />
10 </SOLVERINFO>
As a brief guideline, to define a cylinder of radius 1 and center at the point (0,0) according
to expression (11.17), the "Phi" field in the ShapeFunction function should be:
where the scaling coefficient has been set to 0.04. The variable names are compulsory,
being Phi the shape of the bodies, and Up , Vp and Wp functions representing the
velocity field inside them. The attribute USERDEFINEDTYPE is compulsory only if the
functions depend on time, when it must be set to "TimeDependent" .
where the value of scale corresponds to the coefficient ξ in equation (11.17). More
details can be found in section 5.6.36. In any case, it is important to remark that this
functionality is still under development.
In the ShapeFunction block of the session file, the line <E VAR="Phi" ... /> indicates
that the immersed bodies are defined by the function introduced in VALUE , while a line
like the following:
1 <F VAR="Phi" FILE="geometry.fld" />
182 Chapter 11 Incompressible Navier-Stokes Solver
must be used when the Φ field is defined in an .stl file previously converted to .fld
format. In this case, the solver only supports non-moving geometries and the attribute
USERDEFINEDTYPE="TimeDependent" , if specified, will not be used.
The second approach consists of directly solving the matrix problem arising from the
discretization of the Stokes problem. The direct solution of the Stokes system introduces
the problem of appropriate spaces for the velocity and the pressure systems to satisfy
the inf-sup condition and it requires the solution of the full velocity-pressure system.
However, if a discontinuous pressure space is used then all but the constant mode of the
pressure system can be decoupled from the velocity. When implementing this approach
with a spectral/hp element discretization, the remaining velocity system may then also
be statically condensed to decouple the so called interior elemental degrees of freedom,
reducing the Stokes problem to a smaller system expressed on the elemental boundaries.
The direct solution of the Stokes problem provides a very natural setting for the solution
of the pressure system which is not easily dealt with in a splitting scheme. Further, the
solution of the full coupled velocity system allows the introduction of a spatially varying
viscosity, which arise for non-Newtonian flows, with only minor modifications.
Note
The coupled solver is only supported for two-dimensional or quasi-3D problems,
and only using a direct solver (e.g. DirectStaticCond ) which prevents its use
in parallel.
We consider the weak form of the Stokes problem for the velocity field u = [u, v]T and
the pressure field p:
(q, ∇ · u) = 0 (11.28b)
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:
11.1 Synopsis 183
DbT − BC −1 Di 0
A − BC −1 B T ub fb − BC −1 fi
Db − DiT C −1 B T −DiT C −1 Di 0 p = −DiT C −1 fi (11.29)
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, 40].
In Nektar++ it is then possible to use the following tools to perform stability analysis:
∂u0
+ U · ∇u0 + u0 · ∇U = −∇p + ν∇2 u0 + f (11.30a)
∂t
∇ · u0 = 0 (11.30b)
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 the real part is positive
then there exist exponentially growing solutions. Conversely, if all the eigenvalues have
negative real part then the flow is linearly stable. If the real part of the eigenvalue is
zero, it is a bifurcation point.
11.1 Synopsis 185
!
−∂t − (U · ∇) + (∇U) · + Re
1
∇2 −∇
Hq = 0 where H = (11.34)
∇· 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 (11.36a)
∂t Re
∇ · u∗ = 0 (11.36b)
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 than 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 11.1.4.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.
Figure 11.3 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̄.
11.2 Usage 187
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
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.
11.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"/>
188 Chapter 11 Incompressible Navier-Stokes Solver
• 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.
• SubStepIntScheme : choose the substep DG time integration scheme so that a
different order schems can be used as compared to the overal time integraiton
scheme.
1 <I PROPERTY="SubStepIntScheme" VALUE="RungeKutta2\_ImprovedEuler"/>
This option is useful if you wish to use an overall scheme that is first order accurate
for example with TimeIntegrationScheme as BDFImplicit Order 1 but using a
second order RungeKutta, Variant SSP, Order 2 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 .
The Exponential kernel is based on the work of Maday et al. [28], its extension to
2D can be found in [21]. A diffusion coefficient can be specified which defines the
base magnitude of the viscosity; this parameter is scaled by h/p. SVV viscosity is
activated for expansion modes greater than the product of the cut-off ratio and the
expansion order. The Power kernel is a smooth function with no cut-off frequency;
it focusses on a narrower band of higher expansion modes as the polynomial order
increases. The cut-off ratio parameter for the Power kernel corresponds to the
power ratio, see Moura et al. [30]. The DG-Kernel is an attempt to match the
dissipation of CG-SVV to DG schemes of lower expansion orders. This kernel does
not require any parameters although the diffusion coefficient can still be modified.
• DEALIASING : activates the 3/2 padding rule on the advection term of a Quasi-3D
simulation.
1 <I PROPERTY="DEALIASING" VALUE="True"/>
11.3.2 Parameters
The following parameters can be specified in the PARAMETERS section of the session file:
• IO_InfoSteps : sets the number of steps between successive info stats are printed
to screen.
• 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).
• SVVDiffCoeff : sets the SVV diffusion coefficient (default value = 0.1 (Exponential
and Power kernel), 1 (DG-Kernel)).
• IO_CFLWriteFld : sets a treshold value for the CFL number. If CFL exceeds this
value, the flow field is written to file (only once). This is useful for debugging
purposes, allowing to visually inspect a flow field that is becoming unstable.
N
J0 (i3/2 αn r/R) iωn t
w(r, t) = A0 (1 − (r/R)2 ) + A˜n [1 − ]e
X
n=1
J0 (i3/2 α)
192 Chapter 11 Incompressible Navier-Stokes Solver
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>
Similarly in the WOMPARAMS section the key parameters of the boundary condition are
also provided as:
11.3.4 Forcing
11.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 [34]. 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 TIMEINTEGRATIONSCHEME and 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. For example:
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 2 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
8 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
9 <I PROPERTY="EvolutionOperator" VALUE="SkewSymmetric" />
10 <I PROPERTY="Projection" VALUE="Galerkin" />
11 <I PROPERTY="GlobalSysSoln" VALUE="DirectStaticCond" />
12 <I PROPERTY="HOMOGENEOUS" VALUE="1D" />
194 Chapter 11 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>
2 <PARAM NAME="OutputFile">DragLift</PARAM>
3 <PARAM NAME="OutputFrequency">10</PARAM>
4 <PARAM NAME="Boundary"> B[0] </PARAM>
5 </FORCE>
During the execution a file named DragLift.fce 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 11.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.
11.3.5 Filters
The following filters are supported exclusively for the incompressible Navier-Stokes solver.
Further filters from section 3.4 are also available for this solver.
u(t) = A(t)u(0).
196 Chapter 11 Incompressible Navier-Stokes Solver
The adjoint evolution operator is denoted as A∗ . This section details the additional
configuration options, in addition to the standard configuration options described earlier,
relating to performing this task.
Note
For visualization of Homogeneous results with FieldConvert you can
use --output-points-hom-z to set output number of modes to a desired
value. To process results obtained with HalfMode you can convert to
SingleMode using FieldConvert module halfmodetofourier .
11.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 with: ModifiedArnoldi
and Arpack . Default value: 16.
• evtol : sets the tolerance of the iterative eigenvalue algorithm. Can be used with:
ModifiedArnoldi and Arpack . Default value: 1 × 10−6 .
• nvec : sets the number of converged eigenvalues sought. Can be used with:
ModifiedArnoldi and Arpack . Default value: 2.
• nits : sets the maximum number of Arnoldi iterations to attempt. Can be used
with: ModifiedArnoldi and Arpack . Default value: 500.
• realShift : provide a real shift to the direct solver eigenvalue problem by the
specified value to improve convergence. Can be used with: Arpack only.
• LZ : sets the length in the spanswise direction Lz . Can be used with Homogeneous
set to 1D . Default value: 1.
• HomModesZ : sets the number of planes in the homogeneous directions. Can be used
with Homogeneous set to 1D and ModeType set to MultipleModes .
• N_start : sets the start number of temporal slices for Floquet stability analysis.
Default value: 0.
• N_skip : sets the number skip of temporal slices for Floquet stability analysis.
Default value: 1.
198 Chapter 11 Incompressible Navier-Stokes Solver
• N_slices : sets the number of temporal slices for Floquet stability analysis. Files se-
quence N_start, N_start + N_skip, ..., N_start + N_skip * (N_slices-1) will
be loaded.
• period : sets the time span (if BaseFlow_interporder >= 2) or period (if BaseFlow_interporder
< 2) of the base flow. Default value: 1.
11.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. 11.1.5). Two cases are detailed here: the execution
of the classical SFD method and the adaptive SFD method, where the control coefficient
χ 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.
11.5 Session file configuration: Steady-state solver 199
11.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 .
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" />
200 Chapter 11 Incompressible Navier-Stokes Solver
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. 11.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:
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.
11.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.
11.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)
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.
11.6.4 Functions
The function COORDS (and VEL for time dependent mappings) indicated in the MAPPING
section need to be defined, for example as:
202 Chapter 11 Incompressible Navier-Stokes Solver
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 .
• Use the sensor defined in equation 9.9 to estimate an error measure (the variable
used in the sensor can be specified). The error is defined here as the square of the
sensor.
• Use the error to determine if the order in each element should be increased by one,
decreased by one, or left unaltered.
• Project the solution in each element to the new polynomial order and use it as
an initial condition to restart the equation, repeating all steps a given number of
times.
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.
11.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.
• AdaptiveUpperTolerance : defines a constant tolerance. The polynomial order in
an element is increased whenever the error is higher than this value. This can be
replaced by a spatially-varying function, as described below. Default value: 10−6 .
• AdaptiveLowerinModes : defines a constant tolerance. The polynomial order in an
element is decreased whenever the error is lower than this value. This can also be
replaced by a spatially-varying function. Default value: 10−8 .
204 Chapter 11 Incompressible Navier-Stokes Solver
11.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" />
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>
11.9 Imposing a constant flowrate 205
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.
In some simulations, it may be desirable to drive the flow by fixing a value of the
volumetric flux through a boundary surface. A common use case for this is a channel flow,
where the inflow and outflow are treated using periodic boundary conditions, requiring a
use of either a body force or a flowrate condition to drive the flow. Often, the use of a
body force is sufficient, but in some cases (e.g. transitional or turbulent simulations), it
may be difficult to determine the correct body force to use in order to attain a specific
Reynolds number. The incompressible solver supports the use of an alternative forcing
whereby the volumetric flux,
1
Z
Q(u) = u · ds,
µ(R) R
through a user-defined surface R of area µ(R) is kept constant. This is supported for
standard two- and three-dimensional simulations, where R is a boundary region, as well
as three-dimensional homogeneous simulations. In the latter case, the forcing can be
206 Chapter 11 Incompressible Navier-Stokes Solver
The flowrate correction works by taking each timestep’s velocity field un , and computing
a scalar α so that the corrected flow
ũn = un + αus
has the desired flowrate. Here, us is a linear Stokes solution that is calculated once at
the start of the simulation, so that the condition is not expensive to implement.
To enable flowrate corrections, three things must be defined in the session file:
• The Flowrate parameter in the parameters section, which defines the desired value
of the volumetric flux Q(u) through the reference region. To set a flux per unit
surface of Q = 1 we would therefore define:
1 <PARAMETERS>
2 <P> Flowrate = 1.0 </P>
3 </PARAMETERS>
Importantly, note that in homogeneous simulations where the forcing is in the z-direction
only the Flowrate parameter should be specified, and the reference area R is taken to
be the homogeneous plane.
Optionally, the IO_FlowSteps parameter can be defined. If set to a non-zero integer, this
produces a file session.prs which records the value of α used in the flowrate correction,
every IO_FlowSteps steps.
11.10 Examples
We next specify the time integration scheme and 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 time-integration scheme must
be used and we choose one of second order.
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 2 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
8 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
9 <I PROPERTY="AdvectionForm" VALUE="Convective" />
10 <I PROPERTY="Projection" VALUE="Galerkin" />
11 </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
208 Chapter 11 Incompressible Navier-Stokes Solver
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>
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.
parameters used here are similar to the previous one. What only we need to modify in
the input file is just the boundary condition type upon the outlet region shown as below
1 <BOUNDARYCONDITIONS>
2 <REGION REF="0">
3 <D VAR="u" VALUE="1-exp(KovLam*x)*cos(2*PI*y)" />
4 <D VAR="v" VALUE="(KovLam/2/PI)*exp(KovLam*x)*sin(2*PI*y)" />
5 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
6 </REGION>
7 <REGION REF="1">
8 <N VAR="u" USERDEFINEDTYPE="HOutflow"
9 VALUE="-Kinvis*KovLam*exp(KovLam*x)*cos(2*PI*y)
10 - 0.5*(1-exp(2*KovLam*x))-0.5*(((1-exp(KovLam*x)*cos(2*PI*y))
11 *(1-exp(KovLam*x)*cos(2*PI*y))+(KovLam/(2*PI)*exp(KovLam*x)
12 *sin(2*PI*y))*(KovLam/(2*PI)*exp(KovLam*x)*sin(2*PI*y))))
13 *(0.5*(1.0-tanh((1-exp(KovLam*x)*cos(2*PI*y))*20)))" />
14 <N VAR="v" USERDEFINEDTYPE="HOutflow"
15 VALUE="Kinvis*KovLam*KovLam/(2*PI)*exp(KovLam*x)*sin(2*PI*y)" />
16 <D VAR="p" USERDEFINEDTYPE="HOutflow"
17 VALUE="-Kinvis*KovLam*exp(KovLam*x)*cos(2*PI*y)
18 - 0.5*(1-exp(2*KovLam*x)) -0.5*(((1-exp(KovLam*x)*cos(2*PI*y))
19 *(1-exp(KovLam*x)*cos(2*PI*y))+(KovLam/(2*PI)*exp(KovLam*x)
20 *sin(2*PI*y))*(KovLam/(2*PI)*exp(KovLam*x)*sin(2*PI*y))))
21 *(0.5*(1.0-tanh((1-exp(KovLam*x)*cos(2*PI*y))*20)))" />
22 </REGION>
23 <REGION REF="2">
24 <N VAR="u" VALUE="0" />
25 <D VAR="v" VALUE="0" />
26 <N VAR="p" VALUE="0" />
27 </REGION>
28 </BOUNDARYCONDITIONS>
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 11.5.
Figure 11.5 Velocity profiles for the Kovasznay Flow in truncated domain (2D).
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.
212 Chapter 11 Incompressible Navier-Stokes Solver
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.
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" />
11.10 Examples 213
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>
The error in the solution should be displayed and be close to machine precision
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.
214 Chapter 11 Incompressible Navier-Stokes Solver
Figure 11.6 Pressure and velocity profiles for the laminar channel flow (2D).
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" />
11.10 Examples 215
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" />
38 <D VAR="w" VALUE="0" />
39 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
40 </REGION>
41 <REGION REF="5">
42 <D VAR="u" VALUE="0" />
43 <D VAR="v" VALUE="0" />
44 <D VAR="w" VALUE="y*(1-y)" />
45 <N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
46 </REGION>
47 </BOUNDARYCONDITIONS>
Figure 11.7 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
11.10 Examples 217
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 11.7.
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 .
218 Chapter 11 Incompressible Navier-Stokes Solver
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]" />
3 <P VAR="v" VALUE="[2]" />
4 <P VAR="w" VALUE="[2]" />
5 <P VAR="p" VALUE="[2]" />
6 </REGION>
7 <REGION REF="2">
8 <P VAR="u" VALUE="[1]" />
9 <P VAR="v" VALUE="[1]" />
10 <P VAR="w" VALUE="[1]" />
11 <P VAR="p" VALUE="[1]" />
12 </REGION>
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,
11.10 Examples 219
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="True" />
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.
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 11.11.
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
222 Chapter 11 Incompressible Navier-Stokes Solver
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.
Figure 11.13 Surface mesh indicating curved surface elements at a branch location.
Input parameters
11.10.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>
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 1 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
11.10.9.4 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>
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" />
224 Chapter 11 Incompressible Navier-Stokes Solver
11.10.9.6 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>
11.10.9.7 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.
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.
11.10.10.3 Parameters
All the simulation parameters are specified in the section as follows.
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
11.10 Examples 227
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 11.16. The
wake response of the cable appears as standing wave pattern in the earlier stage and
then it transitions into travelling wave response, as shown in this figure.
Figure 11.16 Spanwise vorticity contours in standing wave and travelling wave patterns predicted
in finite strip modeling.
In this example, it will be illustrated how to perform a direct stability analysis using
Nektar++. Let us consider a canonical stability problem, the flow in a channel which
is confined in the wall-normal direction between two infinite plates (Poiseuille flow) at
Reynolds number 7500. This problem is a particular case of the stability solver for the
IncNavierStokesSolver.
11.10.11.1 Background
∂u0
+ U · ∇u0 + u0 · ∇U = −∇p + ν∇2 u0 + f (11.39a)
∂t
228 Chapter 11 Incompressible Navier-Stokes Solver
∇ · u0 = 0 (11.39b)
We are interested to compute the leading eigenvalue of the system using the Arnoldi
method.
11.10.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.
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
11.10 Examples 229
11.10.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
11.10.11.7 Parameters
All the stability parameters are specified in this section.
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>
230 Chapter 11 Incompressible Navier-Stokes Solver
11.10.11.9 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">
6 <F VAR="u,v,p" FILE="ChanStability.rst" />
7 </FUNCTION>
8
11.10 Examples 231
Each function Unmask0 selects elements whose center satisfies C0>0 and C1>0 and C2>0,
and so on. More than one unmasked function can be defined, and the finally selected
region is the union of all unmasked regions.
If the unmask function is defined, both the unmasked eigenvector and masked eigenvector
(with _masked) will be output.
11.10.11.11 Usage
IncNavierStokesSolver ChanStability.xml
11.10.11.12 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 11.17
Figure 11.18
11.10.12.1 Background
∂u∗ 1 2
− + (U · ∇)u∗ + (∇U)T · u∗ = −∇p∗ + ∇ u (11.40a)
∂t Re
∇ · u∗ = 0 (11.40b)
We are interested in computing the leading eigenvalue of the system using the Arnoldi
method.
11.10 Examples 233
11.10.12.6 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>
4
11.10.12.7 Usage
IncNavierStokesSolver ChanStability_adj.xml
11.10.12.8 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.
11.10 Examples 235
Figure 11.19
Figure 11.20
11.10.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
236 Chapter 11 Incompressible Navier-Stokes Solver
Figure 11.21
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
11.10 Examples 237
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
11.10.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
11.10.13.6 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
11.10.13.8 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="bfs_tg-AR.bse" />
3 </FUNCTION>
4
11.10 Examples 239
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
11.10.13.9 Usage
IncNavierStokesSolver bfs_tg-AR.xml
11.10.13.10 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 11.22
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
reaching its maximum value at x = 24 and then decays, almost disappearing after 100
temporal units.
240 Chapter 11 Incompressible Navier-Stokes Solver
Figure 11.23
Figure 11.24
11.10 Examples 241
In this example it will be described how to run a BiGlobal stability analysis for a time-
periodic base flow using Nektar++. Let us consider a flow past a circular cylinder at
Re = 220 has a 2D time-periodic wake that is unstable to a 3D synchronous "mode A"
instability.
Figure 11.25
11.10.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
242 Chapter 11 Incompressible Navier-Stokes Solver
incorporated through the Fourier mode: u0 = û0 (x, y, t)eiβz , where β = 2π/L)and L is
the length in the homogeneous direction.
11.10.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
11.10.14.4 Parameters
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> IMEX </METHOD>
3 <ORDER> 2 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
5
6 <SOLVERINFO>
7 <I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
8 <I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
9 <I PROPERTY="EvolutionOperator" VALUE="Direct" />
10 <I PROPERTY="Projection" VALUE="Galerkin" />
11 <I PROPERTY="ModeType" VALUE="HalfMode" />
12 <I PROPERTY="Driver" VALUE= "ModifiedArnoldi" />
13 <I PROPERTY="HOMOGENEOUS" VALUE="1D" />
14 </SOLVERINFO>
15
11.10.14.5 Functions
1 <FUNCTION NAME="BaseFlow">
2 <F VAR="u,v,p" FILE="cyinder_floq" />
3 </FUNCTION>
4
11.10.14.6 Usage
IncNavierStokesSolver session.xml
11.10 Examples 243
11.10.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.
Figure 11.26
Chapter 12
Linear elasticity solver
12.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 ,
244
12.2 Usage 245
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 (12.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 ∂Ω. (12.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.
12.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.
246 Chapter 12 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.
12.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.
12.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.
12.4 Examples 247
Figure 12.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 12.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
248 Chapter 12 Linear elasticity solver
Figure 12.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>
13.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 (13.1)
∂t ∂x
0
" # " # " #
U U A
U= , H = ∂P , S= 1 f
A ρ ∂A U ρ A −s
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 Eq. 13.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, viscoelastic tube
this is given by
√ √ √
Γ ∂A πEh 2 πϕh
P = P0 + β +√ β= Γ= (13.2)
p
A− A0 , ,
A ∂t (1 − ν 2 )A0 3A0
249
250 Chapter 13 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, ν is the Poisson’s ratio, and ϕ is the wall viscosity.
An empirical law has also been implemented that incorporates strain-stiffening through
the parameter α [1]:
√
β A0 A Γ ∂A
P = P0 − ln 1 − α ln +√ . (13.3)
2α A0 A ∂t
13.2 Usage
PulseWaveSolver session.xml
Figure 13.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.
13.3 Session file configuration 251
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>
6 <V ID="4">-2.000e+01 0.000e+00 0.000e+00</V>
7 <V ID="5"> 0.000e+00 0.000e+00 0.000e+00</V>
8
9 <V ID="6"> 2.000e+01 2.000e+01 0.000e+00</V>
10 <V ID="7"> 4.000e+01 4.000e+01 0.000e+00</V>
11 <V ID="8"> 6.000e+01 6.000e+01 0.000e+00</V>
12 <V ID="9"> 8.000e+01 8.000e+01 0.000e+00</V>
13 <V ID="10"> 1.000e+02 1.000e+02 0.000e+00</V>
14
15 <V ID="11"> 2.000e+01 -2.000e+01 0.000e+00</V>
16 <V ID="12"> 4.000e+01 -4.000e+01 0.000e+00</V>
17 <V ID="13"> 6.000e+01 -6.000e+01 0.000e+00</V>
18 <V ID="14"> 8.000e+01 -8.000e+01 0.000e+00</V>
19 <V ID="15"> 1.000e+02 -1.000e+02 0.000e+00</V>
20 </VERTEX>
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
252 Chapter 13 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.
– UpwindPulse
• OutputExtraFields :
13.3.4 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;
• pout outflow pressure to the venous system for the terminal boundary conditions.
Default value = 0;
The composites that we want to apply out boundary conditions then need to be defined
in the BOUNDARYREGIONS , 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
254 Chapter 13 Pulse Wave Solver
inlets and outlets of the domain. Examples of the different boundary conditions will be
provided in the following.
13.3.5.0.1 Inlet boundary condition: The inlet condition may be specified alge-
braically in four different ways: as an area variation ( A-inflow ); a velocity profile
( U-inflow ); a volume flux ( Q-inflow ); or by prescribing the forward characteristic
( TimeDependent ). When prescribing a volume flux, it must be specified in the input file
via the area, as illustrated below. Note that u = 1.0.
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>
13.3.5.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
13.3.6 Functions
The following functions can be specified inside the CONDITIONS section of the session file:
• Viscoelasticity : specifies Γ for each domain. Defaults to zero for every artery if
not included.
• StrainStiffening : specifies α for each domain for Eq. (13.3). Defaults to 0.5 for
every artery if not included.
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 (Eq. (13.2)).
13.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
256 Chapter 13 Pulse Wave Solver
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.
1 <GEOMETRY DIM="1" SPACE="1">
2 <VERTEX>
3 <V ID="0"> 0.000e+00 0.000e+00 0.000e+00</V> <!-- 1 -->
4 <V ID="1"> 4.000e+00 0.000e+00 0.000e+00</V>
5
6 <V ID="2"> 4.000e+00 0.000e+00 0.000e+00</V> <!-- 2 -->
7 <V ID="3"> 6.000e+00 0.000e+00 0.000e+00</V>
8
9 <V ID="4"> 4.000e+00 0.000e+00 0.000e+00</V> <!-- 3 -->
10 <V ID="5"> 7.400e+00 0.000e+00 0.000e+00</V>
11 .
12 .
13 .
14 <V ID="108"> 109.100e+00 -45.000e+00 0.000e+00</V> <!-- 55 -->
15 <V ID="109"> 143.500e+00 -45.000e+00 0.000e+00</V>
16 </VERTEX>
17 <ELEMENT>
18 <S ID="0"> 0 1 </S>
19 <S ID="1"> 1 2 </S>
20 <S ID="2"> 1 4 </S>
21 <S ID="3"> 2 3 </S>
22 <S ID="4"> 4 5 </S>
23 <S ID="5"> 5 6 </S>
24 <S ID="6"> 5 8 </S>
25 <S ID="7"> 6 7 </S>
26 <S ID="8"> 8 9 </S>
27 .
28 .
29 .
30 <S ID="106"> 103 108 </S>
31 <S ID="107"> 108 109 </S>
32 <S ID="108"> 85 98 </S>
33 <ELEMENT>
34 <COMPOSITE>
35 <C ID="0"> S[0] </C> <!-- 1 -->
36 <C ID="1"> V[0] </C>
37 <C ID="2"> V[1] </C>
38
39 <C ID="3"> S[1,3] </C> <!-- 2 -->
40 <C ID="4"> V[2] </C>
41 <C ID="5"> V[3] </C>
42
43 <C ID="6"> S[2,4] </C> <!-- 3 -->
13.4 Examples 257
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 <TIMEINTEGRATIONSCHEME>
24 <METHOD> RungeKutta </METHOD>
25 <VARIANT> SSP </VARIANT>
26 <ORDER> 2 </ORDER>
27 </TIMEINTEGRATIONSCHEME>
28
29 <SOLVERINFO>
30 <I PROPERTY="EQTYPE" VALUE="PulseWavePropagation" />
31 <I PROPERTY="Projection" VALUE="DisContinuous" />
32 <I PROPERTY="TimeIntegrationMethod" VALUE="RungeKutta2_ImprovedEuler" />
33 <I PROPERTY="UpwindTypePulse" VALUE="UpwindPulse"/>
34 </SOLVERINFO>
35
36 <VARIABLES>
37 <V ID="0"> A </V>
38 <V ID="1"> u </V>
39 </VARIABLES>
258 Chapter 13 Pulse Wave Solver
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 [41] 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">
13 <D VAR="A" USERDEFINEDTYPE="TimeDependent" VALUE="A8" />
14 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="0.0" />
15 </REGION>
16 <REGION REF="3">
17 <D VAR="A" USERDEFINEDTYPE="TimeDependent" VALUE="A10" />
18 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="0.0" />
19 </REGION>
20 ....
21 <REGION REF="28">
22 <D VAR="A" USERDEFINEDTYPE="TimeDependent" VALUE="A55" />
23 <D VAR="u" USERDEFINEDTYPE="TimeDependent" VALUE="0.0" />
24 </REGION>
13.4 Examples 259
25 </BOUNDARYCONDITIONS>
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.
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.
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.
13.4.2.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 13.4 Three composites (C[0], C[1] and C[2]) for the stunted artery.
13.4.2.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>
262 Chapter 13 Pulse Wave Solver
13.4.2.0.3 Time Integration Scheme: For the Time Integration Scheme we use a
basic Forward Euler method.
1 <TIMEINTEGRATIONSCHEME>
2 <METHOD> ForwardEuler </METHOD>
3 <ORDER> 1 </ORDER>
4 </TIMEINTEGRATIONSCHEME>
13.4.2.0.5 Parameters: Parameters used for the simulation are taken from [41]
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>
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 13.6 material property variation along the artery. The stiff region in the middle represents
the stent.
13.4.2.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.
13.4.2.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. 13.7).
Figure 13.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
13.5 Further Information 265
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 been developed with contributions by various students and
researchers at the Department of Aeronautics, Imperial College London. Further in-
formation on the solver and its underlying mathematical framework can be found in
[38, 37].
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.7 References
[1] Reavette R, Sherwin SJ, Tang MX, Weinberg PW. Comparison of arterial wave inten-
sity analysis by pressure-velocity and diameter-velocity methods in a virtual population
of adult aubjects. Journal of Engineering in Medicine. 2020.
266 Chapter 13 Pulse Wave Solver
14.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
267
268 Chapter 14 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 ) = Hu2 + gH 2 /2 , G(U ) = Hvu ,
Huv Hv + gH /2
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.
14.2 Usage
ShallowWaterSolver session.xml
• UpwindType
• Projection
14.3.3 Parameters
• Gravity
14.3.4 Functions
14.4 Examples
1 <SOLVERINFO>
2 <I PROPERTY="EqType" VALUE="NonlinearSWE" />
3 <I PROPERTY="Projection" VALUE="DisContinuous" />
4 <I PROPERTY="UpwindType" VALUE="HLLC" />
5 </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:
270 Chapter 14 Shallow Water Solver
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>
./ShallowWaterSolver Rossby_Nonlinear_DG.xml
14.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
271
Chapter 15
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.
15.1 Collections
All configuration relating to Collections is given in the COLLECTIONS XML element within
the NEKTAR XML element.
272
15.1 Collections 273
15.1.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.
--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.
274
Chapter 16 Command-line Options 275
--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. Requires the NEKTAR_USE_METIS
option to be set.
--use-scotch
Forces the use of Scotch for mesh partitioning. If Nektar++ is compiled with
METIS support, the default is to use METIS.
--use-hdf5-node-comm
Partition the Hdf5 -format mesh in parallel to avoid one single thread runs out
of memory in serial partitioning.
Chapter 17
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
276
17.1 Compilation and Testing 277
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
278 Chapter 17 Frequently Asked Questions
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/
17.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:
17.2 Usage 279
• Gmsh (.msh)
• Polygon (.ply)
• Nektar (.rea)
• Semtex (.sem)
Bibliography
280
Bibliography 281
[10] 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.
[11] Roland Ewert and Wolfgang Schröder. Acoustic perturbation equations based on flow
decomposition via source filtering. Journal of Computational Physics, 188(2):365–398,
7 2003.
[12] Paul F. Fischer. Projection techniques for iterative solution of ax = b with succes-
sive right-hand sides. Computer Methods in Applied Mechanics and Engineering,
163(1):193 – 204, 1998.
[13] 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.
[14] Georg Geiser, Holger Nawroth, Arash Hosseinzadeh, Feichi Zhang, Henning Bock-
horn, Peter Habisreuther, Johannes Janicka, Christian O. Paschereit, and Wolfgang
Schröder. Thermoacoustics of a turbulent premixed flame. In 20th AIAA/CEAS
Aeroacoustics Conference. American Institute of Aeronautics and Astronautics.
[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.
[21] Robert M Kirby and Spencer J Sherwin. Stabilisation of spectral/hp element methods
through spectral vanishing viscosity: Application to fluid mechanics modelling.
Computer methods in applied mechanics and engineering, 195(23):3128–3144, 2006.
[22] Jonas Koko. Vectorized matlab codes for linear two-dimensional elasticity. Scientific
Programming, 15(3):157–172, 2007.
[23] Kilian Lackhove. Hybrid Noise Simulation for Enclosed Configurations. Doctoral
thesis, Technische Universität Darmstadt, 2018.
282 Bibliography
[24] 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.
[25] Xian Luo, Martin R. Maxey, and George Em Karniadakis. Smoothed profile method
for particulate flows: Error analysis and simulations. Journal of Computational
Physics, 228(5):1750–1769, 2009.
[28] Yvon Maday, Sidi M Ould Kaber, and Eitan Tadmor. Legendre pseudospectral
viscosity method for nonlinear conservation laws. SIAM Journal on Numerical
Analysis, 30(2):321–342, 1993.
[33] Yasuya Nakayama and Ryoichi Yamamoto. Simulation method to resolve hydrody-
namic interactions in colloidal dispersions. Phys. Rev. E, 71:036707, Mar 2005.
[34] 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.
[35] 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.
[36] P.-O. Persson and J. Peraire. Sub-cell shock capturing for Discontinuous Galerkin
methods. In 44th AIAA Aerospace Sciences Meeting and Exhibit, page 112, 2006.
Bibliography 283
[38] CJ Roth. Pulse wave propagation in the human vascular system, 2012.
[40] SJ Sherwin and M Ainsworth. Unsteady navier-stokes solvers using hybrid spec-
tral/hp element methods. APPLIED NUMERICAL MATHEMATICS, 33:357–363,
2000.
[44] 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.
[46] N Westerhof. Anatomic studies of the human systemic arterial tree. J. Biomech.,
2:121–143, 1969.
[47] 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.
[48] Olgierd Cecil Zienkiewicz and Robert Leroy Taylor. Basic formulation and linear
problems. McGraw-Hill, 1989.