Skip to content

RASModelVariables::SpalartAllmaras cannot be combined with an fvMotionSolver diffusivity which depends on wall distances

Summary

When an fvMotionSolver using a distance-dependent diffusivity is used, wallDist names the distance field as "yPatch". However, RASModelVariables::SpalartAllmaras expects to find a field named "yWall" in the database. Since getObjectPtr returns a nullptr if the field is not found in the database, this bug is silenced but manifests later on when the pointer is dereferenced in adjointSpalartAllmaras.

Possible fixes

Replace

dPtr_ = mesh_.getObjectPtr<volScalarField>("yWall");

with

dPtr_ = &(const_cast<volScalarField&>(wallDist::New(mesh_).y()));

so that wallDist.y() is retrieved, no matter what the actual name of the variable is.