From 2063c78b8defa5fc5dc5548d82d9bb8b6425f582 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Fri, 14 Jan 2011 13:16:23 +0100 Subject: [PATCH] Enable turbulent walls for coupled patches --- .../regionCouple/regionCouplePolyPatch.C | 7 ++++++- .../regionCouple/regionCouplePolyPatch.H | 14 ++++++++++++-- .../polyPatches/derived/wall/wallPolyPatch.H | 5 +++++ .../polyMesh/polyPatches/polyPatch/polyPatch.H | 6 ++++++ .../fvMesh/fvPatches/fvPatch/fvPatch.H | 11 +++++++---- src/finiteVolume/fvMesh/wallDist/nearWallDist.C | 17 +++++++++++++++-- src/finiteVolume/fvMesh/wallDist/wallDist.C | 15 +++++++++++++-- src/finiteVolume/fvMesh/wallDist/wallDistData.C | 13 ++++++++++++- .../epsilonWallFunctionFvPatchScalarField.C | 4 +++- .../kqRWallFunctionFvPatchField.C | 6 +++++- 10 files changed, 84 insertions(+), 14 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C index 94f649c66..f4b4b84cd 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C @@ -172,13 +172,15 @@ Foam::regionCouplePolyPatch::regionCouplePolyPatch const polyBoundaryMesh& bm, const word& shadowRegionName, const word& shadowPatchName, - const bool attached + const bool attached, + const bool attachedWalls ) : coupledPolyPatch(name, size, start, index, bm), shadowRegionName_(shadowRegionName), shadowPatchName_(shadowPatchName), attached_(attached), + attachedWalls_(attachedWalls), shadowIndex_(-1), patchToPatchPtr_(NULL), reconFaceCellCentresPtr_(NULL) @@ -198,6 +200,7 @@ Foam::regionCouplePolyPatch::regionCouplePolyPatch shadowRegionName_(dict.lookup("shadowRegion")), shadowPatchName_(dict.lookup("shadowPatch")), attached_(dict.lookup("attached")), + attachedWalls_(dict.lookup("attachedWalls")), shadowIndex_(-1), patchToPatchPtr_(NULL), reconFaceCellCentresPtr_(NULL) @@ -215,6 +218,7 @@ Foam::regionCouplePolyPatch::regionCouplePolyPatch shadowRegionName_(pp.shadowRegionName_), shadowPatchName_(pp.shadowPatchName_), attached_(pp.attached_), + attachedWalls_(pp.attachedWalls_), shadowIndex_(-1), patchToPatchPtr_(NULL), reconFaceCellCentresPtr_(NULL) @@ -235,6 +239,7 @@ Foam::regionCouplePolyPatch::regionCouplePolyPatch shadowRegionName_(pp.shadowRegionName_), shadowPatchName_(pp.shadowPatchName_), attached_(pp.attached_), + attachedWalls_(pp.attachedWalls_), shadowIndex_(-1), patchToPatchPtr_(NULL), reconFaceCellCentresPtr_(NULL) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H index 562acd41f..d6caa2341 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H @@ -69,6 +69,9 @@ class regionCouplePolyPatch //- Are the regions attached mutable Switch attached_; + //- Are the region attached walls + mutable Switch attachedWalls_; + //- Shadow patch index. Delayed evaluation for construction mutable label shadowIndex_; @@ -85,7 +88,7 @@ class regionCouplePolyPatch //- Calculate interpolation void calcInterpolation() const; - + protected: // Protected Member functions @@ -139,7 +142,8 @@ public: const polyBoundaryMesh& bm, const word& shadowRegionName, const word& shadowPatchName, - const bool attached + const bool attached, + const bool attachedWall ); //- Construct from dictionary @@ -233,6 +237,12 @@ public: return attached_; } + //AJ: read from dictionary if coupled patch is also a wall + bool isWall() const + { + return attachedWalls_; + } + //- Attach regions void attach() const; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.H index 68f469a8d..b7af899c2 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.H @@ -114,6 +114,11 @@ public: ); } + // Virtual function for wall handling of derived class + virtual bool isWall() const + { + return true; + } // Destructor diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index 98b43c005..6230f0365 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -368,6 +368,12 @@ public: return false; } + // Virtual function for wall handling of all derived calsses + virtual bool isWall() const + { + return false; + } + //- Return true if the given type is a constraint type static bool constraintType(const word& pt); diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index 15cfa54b9..72dcfcc4d 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -170,6 +170,12 @@ public: return polyPatch_.coupled(); } + //- Return true if this patch is wall + bool isWall() const + { + return polyPatch_.isWall(); + } + //- Return true if the given type is a constraint type static bool constraintType(const word& pt); @@ -200,10 +206,7 @@ public: } template - const typename Field::subField patchSlice - ( - const Field& l - ) const + const typename Field::subField patchSlice(const Field& l) const { return typename Field::subField ( diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist.C b/src/finiteVolume/fvMesh/wallDist/nearWallDist.C index 518bf72c5..b5540354a 100644 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/nearWallDist.C @@ -36,8 +36,19 @@ void Foam::nearWallDist::doAll() { cellDistFuncs wallUtils(mesh_); + // AJ: make sure to pick up all patches that are specified as a wall + const polyBoundaryMesh& bMesh = wallUtils.mesh().boundaryMesh(); + labelHashSet wallPatchIDs(bMesh.size()); + forAll(bMesh, patchI) + { + if (bMesh[patchI].isWall()) + { + wallPatchIDs.insert(patchI); + } + } + // Get patch ids of walls - labelHashSet wallPatchIDs(wallUtils.getPatchIDs()); + // labelHashSet wallPatchIDs(wallUtils.getPatchIDs()); // Size neighbours array for maximum possible @@ -54,7 +65,9 @@ void Foam::nearWallDist::doAll() const fvPatch& patch = mesh_.boundary()[patchI]; - if (isA(patch)) + // AJ: Allow other patch types to be seen as a wall type + // if (isA(patch)) + if (patch.isWall()) { const polyPatch& pPatch = patch.patch(); diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist.C index 7faf9d464..4279f03da 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist.C @@ -67,13 +67,24 @@ Foam::wallDist::~wallDist() // future (if only small topology change) void Foam::wallDist::correct() { + // AJ: make sure to pick up all patches that are specified as a wall + const polyBoundaryMesh& bMesh = cellDistFuncs::mesh().boundaryMesh(); + labelHashSet wallPatchIDs(bMesh.size()); + forAll(bMesh, patchI) + { + if (bMesh[patchI].isWall()) + { + wallPatchIDs.insert(patchI); + } + } + // Get patchids of walls - labelHashSet wallPatchIDs(getPatchIDs()); + // labelHashSet wallPatchIDs(getPatchIDs()); // Calculate distance starting from wallPatch faces. patchWave wave(cellDistFuncs::mesh(), wallPatchIDs, correctWalls_); - // Transfer cell values from wave into *this + // Transfer cell values from wave into *this transfer(wave.distance()); // Transfer values on patches into boundaryField of *this diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistData.C b/src/finiteVolume/fvMesh/wallDist/wallDistData.C index 98aa64a08..e0a2f90a2 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDistData.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDistData.C @@ -73,14 +73,25 @@ Foam::wallDistData::~wallDistData() template void Foam::wallDistData::correct() { + Info<< "wallDistData.correct() called" << endl; const polyMesh& mesh = cellDistFuncs::mesh(); // // Fill data on wall patches with initial values // + const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); + labelHashSet wallPatchIDs(bMesh.size()); + forAll(bMesh, patchI) + { + if (bMesh[patchI].isWall()) + { + wallPatchIDs.insert(patchI); + } + } + // Get patchids of walls - labelHashSet wallPatchIDs(getPatchIDs()); + // labelHashSet wallPatchIDs(getPatchIDs()); // Collect pointers to data on patches UPtrList > patchData(mesh.boundaryMesh().size()); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 925fa660f..554286442 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -44,7 +44,9 @@ namespace RASModels void epsilonWallFunctionFvPatchScalarField::checkType() { - if (!isA(patch())) + // AJ: Allow other patch types to be seen as wall type + // if (!isA(patch())) + if (!this->patch().isWall()) { FatalErrorIn("epsilonWallFunctionFvPatchScalarField::checkType()") << "Invalid wall function specification" << nl diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.C index fd4c562a7..41b1e1749 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.C @@ -28,6 +28,8 @@ License #include "fvPatchFieldMapper.H" #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "regionCoupleFvPatch.H" +#include "movingWallVelocityFvPatchVectorField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,7 +45,9 @@ namespace RASModels template void kqRWallFunctionFvPatchField::checkType() { - if (!isA(this->patch())) + // AJ: Allow other patch types to be seemovingWalln as wall type + // if (!isA(this->patch())) + if (!this->patch().isWall()) { FatalErrorIn("kqRWallFunctionFvPatchField::checkType()") << "Invalid wall function specification" << nl