diff --git a/applications/solvers/incompressible/adjointOptimisationFoam/Make/files b/applications/solvers/incompressible/adjointOptimisationFoam/Make/files
new file mode 100644
index 0000000000..3734dc051c
--- /dev/null
+++ b/applications/solvers/incompressible/adjointOptimisationFoam/Make/files
@@ -0,0 +1,3 @@
+adjointOptimisationFoam.C
+
+EXE = $(FOAM_APPBIN)/adjointOptimisationFoam
diff --git a/applications/solvers/incompressible/adjointOptimisationFoam/Make/options b/applications/solvers/incompressible/adjointOptimisationFoam/Make/options
new file mode 100644
index 0000000000..f45d173cbf
--- /dev/null
+++ b/applications/solvers/incompressible/adjointOptimisationFoam/Make/options
@@ -0,0 +1,21 @@
+EXE_INC = \
+ -I$(LIB_SRC)/finiteVolume/lnInclude \
+ -I$(LIB_SRC)/fvOptions/lnInclude \
+ -I$(LIB_SRC)/meshTools/lnInclude \
+ -I$(LIB_SRC)/sampling/lnInclude \
+ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
+ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
+ -I$(LIB_SRC)/transportModels \
+ -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
+ -I$(LIB_SRC)/optimisation/adjointOptimisation/adjoint/lnInclude
+
+
+EXE_LIBS = \
+ -lfiniteVolume \
+ -lfvOptions \
+ -lmeshTools \
+ -lsampling \
+ -lturbulenceModels \
+ -lincompressibleTurbulenceModels \
+ -lincompressibleTransportModels \
+ -ladjointOptimisation
diff --git a/applications/solvers/incompressible/adjointOptimisationFoam/adjointOptimisationFoam.C b/applications/solvers/incompressible/adjointOptimisationFoam/adjointOptimisationFoam.C
new file mode 100644
index 0000000000..683bc95133
--- /dev/null
+++ b/applications/solvers/incompressible/adjointOptimisationFoam/adjointOptimisationFoam.C
@@ -0,0 +1,87 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ | Copyright (C) 2007-2019 PCOpt/NTUA
+ | Copyright (C) 2013-2019 FOSS GP
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Application
+ adjointOptimisation
+
+Description
+ An automated adjoint-based optimisation loop. Supports multiple types
+ of optimisation (shape, topology etc)
+
+\*---------------------------------------------------------------------------*/
+
+#include "fvCFD.H"
+#include "optimisationManager.H"
+#include "primalSolver.H"
+#include "adjointSolverManager.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+ #include "setRootCase.H"
+ #include "createTime.H"
+ #include "createMesh.H"
+ #include "createFields.H"
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+ Info<< "\nStarting time loop\n" << endl;
+
+ for (om++; !om.end(); om++)
+ {
+ Info<< "* * * * * * * * * * * * * * * * * * *" << endl;
+ Info<< "Time = " << runTime.timeName() << endl;
+ Info<< "* * * * * * * * * * * * * * * * * * *" << endl;
+
+ if (om.update())
+ {
+ // Update design variables and solve all primal equations
+ om.updateDesignVariables();
+ }
+ else
+ {
+ // Solve all primal equations
+ om.solvePrimalEquations();
+ }
+
+ // Update primal-based quantities of the adjoint solvers
+ om.updatePrimalBasedQuantities();
+
+ // Solve all adjoint equations
+ om.solveAdjointEquations();
+
+ // Compute all sensitivities
+ om.computeSensitivities();
+ }
+ Info<< "End\n" << endl;
+
+ return(0);
+}
+
+
+// ************************************************************************* //
diff --git a/applications/solvers/incompressible/adjointOptimisationFoam/createFields.H b/applications/solvers/incompressible/adjointOptimisationFoam/createFields.H
new file mode 100644
index 0000000000..637b683faf
--- /dev/null
+++ b/applications/solvers/incompressible/adjointOptimisationFoam/createFields.H
@@ -0,0 +1,6 @@
+ // Construct optimisation manager
+ autoPtr optManagerPtr
+ (
+ optimisationManager::New(mesh)
+ );
+ optimisationManager& om = optManagerPtr();
diff --git a/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/files b/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/files
new file mode 100644
index 0000000000..0d733c0656
--- /dev/null
+++ b/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/files
@@ -0,0 +1,3 @@
+computeSensitivities.C
+
+EXE = $(FOAM_APPBIN)/computeSensitivities
diff --git a/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/options b/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/options
new file mode 100644
index 0000000000..48d2719706
--- /dev/null
+++ b/applications/utilities/postProcessing/optimisation/computeSensitivities/Make/options
@@ -0,0 +1,23 @@
+EXE_INC = \
+ -I$(LIB_SRC)/finiteVolume/lnInclude \
+ -I$(LIB_SRC)/fvOptions/lnInclude \
+ -I$(LIB_SRC)/meshTools/lnInclude \
+ -I$(LIB_SRC)/sampling/lnInclude \
+ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
+ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
+ -I$(LIB_SRC)/transportModels \
+ -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
+ -I$(LIB_SRC)/optimisation/adjointOptimisation/adjoint/lnInclude
+
+
+EXE_LIBS = \
+ -lfiniteVolume \
+ -lfvOptions \
+ -lmeshTools \
+ -lsampling \
+ -lturbulenceModels \
+ -lincompressibleTransportModels \
+ -lincompressibleTurbulenceModels \
+ -lfileFormats \
+ -lsurfMesh \
+ -ladjointOptimisation
diff --git a/applications/utilities/postProcessing/optimisation/computeSensitivities/computeSensitivities.C b/applications/utilities/postProcessing/optimisation/computeSensitivities/computeSensitivities.C
new file mode 100644
index 0000000000..cc915c5eed
--- /dev/null
+++ b/applications/utilities/postProcessing/optimisation/computeSensitivities/computeSensitivities.C
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ | Copyright (C) 2007-2019 PCOpt/NTUA
+ | Copyright (C) 2013-2019 FOSS GP
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Application
+ computeSensitivities
+
+Description
+ Computes the sensitivities wrt what is defined in the optimisationDict
+
+\*---------------------------------------------------------------------------*/
+
+#include "fvCFD.H"
+#include "optimisationManager.H"
+#include "primalSolver.H"
+#include "adjointSolver.H"
+#include "incompressibleVars.H"
+#include "incompressibleAdjointVars.H"
+#include "adjointBoundaryCondition.H"
+#include "adjointSolverManager.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+ #include "setRootCase.H"
+ #include "createTime.H"
+ #include "createMesh.H"
+ #include "createFields.H"
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ forAll(adjointSolverManagers, amI)
+ {
+ PtrList& adjointSolvers =
+ adjointSolverManagers[amI].adjointSolvers();
+ forAll(adjointSolvers, asI)
+ {
+ adjointSolvers[asI].getObjectiveManager().updateAndWrite();
+ adjointSolvers[asI].computeObjectiveSensitivities();
+ }
+ }
+
+ Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
+ << " ClockTime = " << runTime.elapsedClockTime() << " s"
+ << nl << endl;
+
+ Info<< "End" << endl;
+
+ return(0);
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/optimisation/computeSensitivities/createFields.H b/applications/utilities/postProcessing/optimisation/computeSensitivities/createFields.H
new file mode 100644
index 0000000000..6c87fffe1c
--- /dev/null
+++ b/applications/utilities/postProcessing/optimisation/computeSensitivities/createFields.H
@@ -0,0 +1,9 @@
+// Construct optimisation manager
+autoPtr optManagerPtr
+(
+ optimisationManager::New(mesh)
+);
+optimisationManager& om = optManagerPtr();
+
+PtrList& adjointSolverManagers =
+ om.adjointSolverManagers();
diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions
index d05354592b..c7f9b658f1 100644
--- a/bin/tools/CleanFunctions
+++ b/bin/tools/CleanFunctions
@@ -73,6 +73,13 @@ cleanSnappyFiles()
}
+cleanOptimisation()
+{
+ rm -rf optimisation
+ rm -rf constant/controlPoints
+}
+
+
cleanPostProcessing()
{
rm -rf Ensight EnSight ensightWrite insitu VTK > /dev/null 2>&1
@@ -87,6 +94,7 @@ cleanCase()
cleanTimeDirectories
cleanPostProcessing
cleanDynamicCode
+ cleanOptimisation
rm -rf processor* > /dev/null 2>&1
rm -rf TDAC > /dev/null 2>&1
diff --git a/src/Allwmake b/src/Allwmake
index c693a09ba7..f3c927a490 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -107,6 +107,7 @@ wmake $targetType rigidBodyDynamics
wmake $targetType rigidBodyMeshMotion
wmake $targetType semiPermeableBaffle
wmake $targetType atmosphericModels
+wmake $targetType optimisation/adjointOptimisation/adjoint
phaseSystemModels/Allwmake $targetType $*
diff --git a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C
new file mode 100644
index 0000000000..775f83ed7d
--- /dev/null
+++ b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C
@@ -0,0 +1,263 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ | Copyright (C) 2007-2019 PCOpt/NTUA
+ | Copyright (C) 2013-2019 FOSS GP
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "ATCModel.H"
+#include "localMin.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+defineTypeNameAndDebug(ATCModel, 0);
+defineRunTimeSelectionTable(ATCModel, dictionary);
+
+// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
+
+void ATCModel::computeLimiter()
+{
+ computeLimiter(ATClimiter_, zeroATCcells_->getZeroATCcells(), nSmooth_);
+}
+
+
+void ATCModel::smoothATC()
+{
+ ATC_ *= ATClimiter_;
+ DebugInfo<<
+ "max ATC mag " << gMax(ATC_) << endl;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+ATCModel::ATCModel
+(
+ const fvMesh& mesh,
+ const incompressibleVars& primalVars,
+ const incompressibleAdjointVars& adjointVars,
+ const dictionary& dict
+)
+:
+ regIOobject
+ (
+ IOobject
+ (
+ "ATCModel" + adjointVars.solverName(),
+ mesh.time().timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ )
+ ),
+ mesh_(mesh),
+ primalVars_(primalVars),
+ adjointVars_(adjointVars),
+ dict_(dict),
+ extraConvection_(dict_.lookupOrDefault("extraConvection", Zero)),
+ extraDiffusion_(dict_.lookupOrDefault("extraDiffusion", Zero)),
+ nSmooth_(dict_.lookupOrDefault