Added scalar adjoint advection terms in AdjointSolver

Merged Chi Hin Chan requested to merge fix/AdjointSolver into master

Issue/feature addressed

The scalar (i.e energy equation) adjoint advection terms were omitted in solvers/IncNavierStokesSolver/AdvectionTerms/AdjointAdvection.cpp, leading to wrong solutions of the adjoint (with scalar advection).

Proposed solution

The scalar adjoint advection terms (-U_j ds/dx_j, where s denotes the scalar) are added in solvers/IncNavierStokesSolver/AdvectionTerms/AdjointAdvection.cpp:181-191.


The implementation is almost similar to solvers/IncNavierStokesSolver/AdvectionTerms/LinearisedAdvection.cpp except an if-statement is added in solvers/IncNavierStokesSolver/AdvectionTerms/AdjointAdvection.cpp:147 as a condition to compute the momentum (i < ndim) or scalar (i > ndim) adjoint advection.


The computation of adjoint and direct eigenvalues of a periodically heated thermal convection problem were added in solvers/IncNavierStokesSolver/Tests. The eigenvalues were validated with Hossain et. al. (2013) - Instabilities of natural convection in a periodically heated layer.

Specifically, 4 tests were added and they are:

  1. ThermStab_dir.tst - Direct eigensolver (Modified Arnoldi)
  2. ThermStab_dir_Ar.tst - Direct eigensolver (Arpack)
  3. ThermStab_adj.tst - Adjoint eigensolver (Modified Arnoldi)
  4. ThermStab_adj_Ar.tst - Adjoint eigensolver (Arpack)

These unit tests were tested on fenchurchstreet and my laptop which worked.

Suggested reviewers

Spencer Sherwin



  • Functions and classes, or changes to them, are documented.
  • User guide/documentation is updated.
  • Changelog is updated.
  • Suitable tests added for new functionality.
  • Contributed code is correctly formatted. (See the contributing guidelines).
  • [ ] License added to any new files.
  • No extraneous files have been added (e.g. compiler output or test data files).
Edited by Chi Hin Chan

Merge request reports