From 30033568980e28b4490c2d7036921ad222d1c862 Mon Sep 17 00:00:00 2001
From: Vaggelis Papoutsis <vaggelisp@gmail.com>
Date: Fri, 15 Nov 2019 19:43:25 +0200
Subject: [PATCH] BUG: RASModelVariables::SpalartAllmaras cannot be combined
 with an fvMotionSolver diffusivity which depends on wall distances (fixes
 #1501)

---
 .../RAS/SpalartAllmaras/SpalartAllmaras.C                      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C
index cf498f0812d..3f09ad7a56a 100644
--- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C
+++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/turbulenceModelVariables/RAS/SpalartAllmaras/SpalartAllmaras.C
@@ -28,6 +28,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "SpalartAllmaras.H"
+#include "wallDist.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -77,7 +78,7 @@ SpalartAllmaras::SpalartAllmaras
     nutPtr_ = mesh_.getObjectPtr<volScalarField>("nut");
 
     hasDist_ = true;
-    dPtr_ = mesh_.getObjectPtr<volScalarField>("yWall");
+    dPtr_ = &(const_cast<volScalarField&>(wallDist::New(mesh_).y()));
 
     allocateInitValues();
     allocateMeanFields();
-- 
GitLab