From c4804e5a0bd3d3f3b6022127a9de15734b16d2a9 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 8 Jan 2015 16:08:53 +0000 Subject: [PATCH] wallDist: Add support for cached wall-reflection vectors Currently these vectors are generated at the same time as the wall-distance field by the same run-time selected algorithm. This will be changed so that the wall-reflection vectors are only generated and stored if required. --- .../wallDependentModel/wallDependentModel.C | 27 +-- .../test/nearWallDist-wave/Make/files | 3 - applications/test/nearWallDist-wave/README | 7 - .../test/nearWallDist-wave/Test-WallDist2.C | 215 ------------------ .../nearWallDist-wave/Test-WallDistData.C | 135 ----------- .../test/nearWallDist-wave/Test-YPlus.C | 119 ---------- applications/test/wallDist/Make/files | 3 + .../Make/options | 0 .../Test-wallDist.C} | 9 +- src/finiteVolume/Make/files | 2 - .../meshWave/meshWavePatchDistMethod.C | 56 ++++- .../meshWave/meshWavePatchDistMethod.H | 3 + .../meshWave/meshWaveWallDist.C | 53 ----- .../meshWave/meshWaveWallDist.H | 91 -------- .../meshWave/wallDistData}/wallDistData.C | 0 .../meshWave/wallDistData}/wallDistData.H | 0 .../patchDistMethod/patchDistMethod.H | 3 + .../fvMesh/wallDist/wallDist/wallDist.C | 36 ++- .../fvMesh/wallDist/wallDist/wallDist.H | 10 + .../wallDistReflection/reflectionVectors.C | 72 ------ .../wallDistReflection/reflectionVectors.H | 98 -------- .../wallDistReflection/wallDistReflection.C | 57 ----- .../wallDistReflection/wallDistReflection.H | 90 -------- .../RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C | 16 +- .../RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H | 5 +- .../IDDESDelta/IDDESDelta.C | 7 +- .../RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C | 16 +- .../RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H | 5 +- 28 files changed, 132 insertions(+), 1006 deletions(-) delete mode 100644 applications/test/nearWallDist-wave/Make/files delete mode 100644 applications/test/nearWallDist-wave/README delete mode 100644 applications/test/nearWallDist-wave/Test-WallDist2.C delete mode 100644 applications/test/nearWallDist-wave/Test-WallDistData.C delete mode 100644 applications/test/nearWallDist-wave/Test-YPlus.C create mode 100644 applications/test/wallDist/Make/files rename applications/test/{nearWallDist-wave => wallDist}/Make/options (100%) rename applications/test/{nearWallDist-wave/Test-WallDist.C => wallDist/Test-wallDist.C} (92%) delete mode 100644 src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.C delete mode 100644 src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.H rename src/finiteVolume/fvMesh/wallDist/{wallDistReflection => patchDistMethods/meshWave/wallDistData}/wallDistData.C (100%) rename src/finiteVolume/fvMesh/wallDist/{wallDistReflection => patchDistMethods/meshWave/wallDistData}/wallDistData.H (100%) delete mode 100644 src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.C delete mode 100644 src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.H delete mode 100644 src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.C delete mode 100644 src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.H diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/interfacialModels/wallDependentModel/wallDependentModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/interfacialModels/wallDependentModel/wallDependentModel.C index 32c178bd95..93b2bb3f70 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/interfacialModels/wallDependentModel/wallDependentModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/interfacialModels/wallDependentModel/wallDependentModel.C @@ -25,7 +25,6 @@ License #include "wallDependentModel.H" #include "wallDist.H" -#include "wallDistReflection.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -51,31 +50,7 @@ const Foam::volScalarField& Foam::wallDependentModel::yWall() const const Foam::volVectorField& Foam::wallDependentModel::nWall() const { - if (!mesh_.foundObject("nWall")) - { - wallDistReflection w(mesh_); - - volVectorField* nPtr - ( - new volVectorField - ( - IOobject - ( - "nWall", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - true - ), - w.n() - ) - ); - - nPtr->checkIn(); - } - - return mesh_.lookupObject("nWall"); + return wallDist::New(mesh_).n(); } diff --git a/applications/test/nearWallDist-wave/Make/files b/applications/test/nearWallDist-wave/Make/files deleted file mode 100644 index e3298a3c68..0000000000 --- a/applications/test/nearWallDist-wave/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-WallDist.C - -EXE = $(FOAM_USER_APPBIN)/Test-WallDist diff --git a/applications/test/nearWallDist-wave/README b/applications/test/nearWallDist-wave/README deleted file mode 100644 index 5fb7864f1c..0000000000 --- a/applications/test/nearWallDist-wave/README +++ /dev/null @@ -1,7 +0,0 @@ -Test-WallDist.C: - calculate distance to wall and reflection vectors. - -Test-WallDist2.C: - for debugging: same but do explicit iterations and dump every - timestep. - diff --git a/applications/test/nearWallDist-wave/Test-WallDist2.C b/applications/test/nearWallDist-wave/Test-WallDist2.C deleted file mode 100644 index ba14f91b0d..0000000000 --- a/applications/test/nearWallDist-wave/Test-WallDist2.C +++ /dev/null @@ -1,215 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Description - Wave propagation of nearwall distance through grid. Every iteration - information goes through one layer of cells. - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" -#include "wallFvPatch.H" -#include "FaceCellWave.H" -#include "wallPoint.H" - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" - - Info<< "Mesh read in = " - << runTime.cpuTimeIncrement() - << " s\n" << endl << endl; - - Info<< "Creating field wDistNC\n" << endl; - volScalarField wallDistUncorrected - ( - IOobject - ( - "wDistNC", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar - ( - "wallDist", - dimensionSet(0, 1, 0, 0, 0), - 0.0 - ) - ); - - // - // Set initial changed faces: set wallPoint for wall faces to wall centre - // - - // Count walls - label nWalls = 0; - forAll(mesh.boundary(), patchI) - { - const fvPatch& patch = mesh.boundary()[patchI]; - - if (isA(patch)) - { - nWalls += patch.size(); - } - } - - List faceDist(nWalls); - labelList changedFaces(nWalls); - - label nChangedFaces = 0; - forAll(mesh.boundary(), patchI) - { - const fvPatch& patch = mesh.boundary()[patchI]; - - if (isA(patch)) - { - forAll(patch.Cf(), patchFaceI) - { - const polyPatch& polyPatch = mesh.boundaryMesh()[patchI]; - - label meshFaceI = polyPatch.start() + patchFaceI; - - changedFaces[nChangedFaces] = meshFaceI; - - faceDist[nChangedFaces] = - wallPoint(patch.Cf()[patchFaceI], 0.0); - - nChangedFaces++; - } - } - } - - List allFaceInfo(mesh.nFaces()); - List allCellInfo(mesh.nCells()); - - FaceCellWave wallDistCalc - ( - mesh, - changedFaces, - faceDist, - allFaceInfo, - allCellInfo, - 0 // max iterations - ); - - Info<< "\nStarting time loop\n" << endl; - - while (runTime.loop()) - { - Info<< "Time = " << runTime.timeName() << endl; - - - label nCells = wallDistCalc.faceToCell(); - - Info<< " Total changed cells : " << nCells << endl; - - if (nCells == 0) - { - break; - } - - - label nFaces = wallDistCalc.cellToFace(); - - Info<< " Total changed faces : " << nFaces << endl; - - if (nFaces == 0) - { - break; - } - - - // - // Copy face and cell values into field - // - - label nIllegal = 0; - - // Copy cell values - forAll(allCellInfo, cellI) - { - scalar dist = allCellInfo[cellI].distSqr(); - if (allCellInfo[cellI].valid(wallDistCalc.data())) - { - wallDistUncorrected[cellI] = Foam::sqrt(dist); - } - else - { - wallDistUncorrected[cellI] = -1; - nIllegal++; - } - } - - // Copy boundary values - forAll(wallDistUncorrected.boundaryField(), patchI) - { - fvPatchScalarField& patchField = - wallDistUncorrected.boundaryField()[patchI]; - - forAll(patchField, patchFaceI) - { - const label meshFaceI = patchField.patch().start() + patchFaceI; - - scalar dist = allFaceInfo[meshFaceI].distSqr(); - if (allFaceInfo[meshFaceI].valid(wallDistCalc.data())) - { - patchField[patchFaceI] = Foam::sqrt(dist); - } - else - { - patchField[patchFaceI] = dist; - nIllegal++; - } - } - } - - Info<< "nIllegal:" << nIllegal << endl; - - - // - // Write it - // - - wallDistUncorrected.write(); - - Info<< "ExecutionTime = " - << runTime.elapsedCpuTime() - << " s\n" << endl << endl; - } - - Info<< "End\n" << endl; - - return 0; -} - - -// ************************************************************************* // diff --git a/applications/test/nearWallDist-wave/Test-WallDistData.C b/applications/test/nearWallDist-wave/Test-WallDistData.C deleted file mode 100644 index 14f38ca2e0..0000000000 --- a/applications/test/nearWallDist-wave/Test-WallDistData.C +++ /dev/null @@ -1,135 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Description - Calculate distance to wall. - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" -#include "wallDistData.H" -#include "wallPointData.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" - - Info<< "Mesh read in = " - << runTime.cpuTimeIncrement() - << " s\n" << endl << endl; - - - Info<< "Time now = " << runTime.timeName() << endl; - - // wall distance and reflection vectors - - volVectorField n - ( - IOobject - ( - "n", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedVector("n", dimLength, point::max) - ); - - // Fill wall patches with unit normal - forAll(mesh.boundary(), patchI) - { - const fvPatch& patch = mesh.boundary()[patchI]; - - if (isA(patch)) - { - fvPatchVectorField& wallData = n.boundaryField()[patchI]; - - forAll(patch.Cf(), patchFaceI) - { - wallData[patchFaceI] = patch.Cf()[patchFaceI]; - wallData[patchFaceI] /= Foam::mag(wallData[patchFaceI]); - } - } - } - - - // Do distance calculation, transporting values of n. - wallDistData > y(mesh, n, true); - - if (y.nUnset() != 0) - { - WarningIn(args.executable()) - << "There are " << y.nUnset() - << " remaining unset cells and/or boundary values" << endl; - } - - - y.write(); - y.data().write(); - - runTime++; - - Info<< "Time now = " << runTime.timeName() << endl; - - - // Move points - - boundBox meshBb(mesh.points()); - - pointField newPoints(mesh.points()); - - const point half(0.5*(meshBb.min() + meshBb.max())); - - forAll(newPoints, pointI) - { - point& pt = newPoints[pointI]; - - // expand around half - pt.y() += pt.y() - half.y(); - } - - mesh.movePoints(newPoints); - - mesh.write(); - - y.correct(); - - y.write(); - y.data().write(); - - - Info<< "End\n" << endl; - - return 0; - - - -} - - -// ************************************************************************* // diff --git a/applications/test/nearWallDist-wave/Test-YPlus.C b/applications/test/nearWallDist-wave/Test-YPlus.C deleted file mode 100644 index 14aa511963..0000000000 --- a/applications/test/nearWallDist-wave/Test-YPlus.C +++ /dev/null @@ -1,119 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Description - Calculate distance to wall. - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" -#include "wallDistData.H" -#include "wallPointYPlus.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" - - Info<< "Mesh read in = " - << runTime.cpuTimeIncrement() - << " s\n" << endl << endl; - - - Info<< "Time now = " << runTime.timeName() << endl; - - // wall distance and yStar - - volScalarField yStar - ( - IOobject - ( - "yStar", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar("yStar", dimless, 1.0) - ); - - // Fill wall patches of yStar with some value. - forAll(mesh.boundary(), patchI) - { - const fvPatch& patch = mesh.boundary()[patchI]; - - if (isA(patch)) - { - fvPatchScalarField& wallData = yStar.boundaryField()[patchI]; - - forAll(patch, patchFaceI) - { -// Hack. Just some value. - wallData[patchFaceI] = 1/2500.0; - } - } - } - - - // Do distance calculation, transporting values of yStar - wallPointYPlus::yPlusCutOff = 200; - wallDistData y(mesh, yStar, true); - - if (y.nUnset() != 0) - { - WarningIn(args.executable()) - << "There are " << y.nUnset() - << " remaining unset cells and/or boundary values" << endl; - } - - - y.write(); - - y.data().write(); - - volScalarField yPlus - ( - IOobject - ( - "yPlus", - mesh.time().timeName(), - mesh - ), - y/y.data() - ); - - yPlus.write(); - - Info<< "End\n" << endl; - - return 0; - - - -} - - -// ************************************************************************* // diff --git a/applications/test/wallDist/Make/files b/applications/test/wallDist/Make/files new file mode 100644 index 0000000000..d3c9b0e5cb --- /dev/null +++ b/applications/test/wallDist/Make/files @@ -0,0 +1,3 @@ +Test-wallDist.C + +EXE = $(FOAM_USER_APPBIN)/Test-wallDist diff --git a/applications/test/nearWallDist-wave/Make/options b/applications/test/wallDist/Make/options similarity index 100% rename from applications/test/nearWallDist-wave/Make/options rename to applications/test/wallDist/Make/options diff --git a/applications/test/nearWallDist-wave/Test-WallDist.C b/applications/test/wallDist/Test-wallDist.C similarity index 92% rename from applications/test/nearWallDist-wave/Test-WallDist.C rename to applications/test/wallDist/Test-wallDist.C index 3827b6bbd2..39d273d290 100644 --- a/applications/test/nearWallDist-wave/Test-WallDist.C +++ b/applications/test/wallDist/Test-wallDist.C @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Description - Calculate distance to wall. + Calculate and write the distance-to-wall field for a moving mesh. \*---------------------------------------------------------------------------*/ @@ -48,6 +48,10 @@ int main(int argc, char *argv[]) Info<< "Time now = " << runTime.timeName() << endl; + // Wall-reflection vectors + const volVectorField& n = wallDist::New(mesh).n(); + n.write(); + // Wall distance const volScalarField& y = wallDist::New(mesh).y(); y.write(); @@ -74,8 +78,7 @@ int main(int argc, char *argv[]) mesh.movePoints(newPoints); mesh.write(); - - y.correct(); + n.write(); y.write(); Info<< "End\n" << endl; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 4c550aaab2..5105ccc80b 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -44,8 +44,6 @@ $(wallDist)/nearWallDist/nearWallDist.C $(wallDist)/wallDist/wallDist.C $(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C $(wallDist)/patchDistMethods/meshWave/meshWavePatchDistMethod.C -$(wallDist)/wallDistReflection/reflectionVectors.C -$(wallDist)/wallDistReflection/wallDistReflection.C fvMeshMapper = fvMesh/fvMeshMapper diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C index b44817921e..e21af62a31 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C @@ -27,6 +27,8 @@ License #include "fvMesh.H" #include "volFields.H" #include "patchWave.H" +#include "patchDataWave.H" +#include "wallPointData.H" #include "emptyFvPatchFields.H" #include "addToRunTimeSelectionTable.H" @@ -76,10 +78,10 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y) // Calculate distance starting from patch faces patchWave wave(mesh_, patchIDs_, correctWalls_); - // Transfer cell values from wave into *this + // Transfer cell values from wave into y y.transfer(wave.distance()); - // Transfer values on patches into boundaryField of *this + // Transfer values on patches into boundaryField of y forAll(y.boundaryField(), patchI) { if (!isA(y.boundaryField()[patchI])) @@ -97,4 +99,54 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y) } +bool Foam::patchDistMethods::meshWave::correct +( + volScalarField& y, + volVectorField& n +) +{ + // Collect pointers to data on patches + UPtrList patchData(mesh_.boundaryMesh().size()); + + forAll(n.boundaryField(), patchI) + { + patchData.set(patchI, &n.boundaryField()[patchI]); + } + + // Do mesh wave + patchDataWave > wave + ( + mesh_, + patchIDs_, + patchData, + correctWalls_ + ); + + // Transfer cell values from wave into y and n + y.transfer(wave.distance()); + + n.transfer(wave.cellData()); + + // Transfer values on patches into boundaryField of y and n + forAll(y.boundaryField(), patchI) + { + scalarField& waveFld = wave.patchDistance()[patchI]; + + if (!isA(y.boundaryField()[patchI])) + { + y.boundaryField()[patchI].transfer(waveFld); + + vectorField& wavePatchData = wave.patchData()[patchI]; + + n.boundaryField()[patchI].transfer(wavePatchData); + } + } + + // Transfer number of unset values + nUnset_ = wave.nUnset(); + + return nUnset_ > 0; +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H index 674af38042..01fc1e8540 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H @@ -118,6 +118,9 @@ public: //- Correct the given distance-to-patch field virtual bool correct(volScalarField& y); + + //- Correct the given distance-to-patch and normal-to-patch fields + virtual bool correct(volScalarField& y, volVectorField& n); }; diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.C deleted file mode 100644 index a2ca9d656e..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.C +++ /dev/null @@ -1,53 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 "meshWaveWallDist.H" -#include "fvMesh.H" -#include "wallPolyPatch.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::meshWaveWallDist::meshWaveWallDist -( - const fvMesh& mesh, - const bool correctWalls -) -: - patchDist - ( - mesh, - mesh.boundaryMesh().findPatchIDs(), - correctWalls - ) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::meshWaveWallDist::~meshWaveWallDist() -{} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.H deleted file mode 100644 index fa9a9aea52..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWaveWallDist.H +++ /dev/null @@ -1,91 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Class - Foam::meshWaveWallDist - -Description - Specialisation of patchDist for wall distance calculation - -SourceFiles - meshWaveWallDist.C - -\*---------------------------------------------------------------------------*/ - -#ifndef meshWaveWallDist_H -#define meshWaveWallDist_H - -#include "patchDist.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class fvMesh; - -/*---------------------------------------------------------------------------*\ - Class meshWaveWallDist Declaration -\*---------------------------------------------------------------------------*/ - -class meshWaveWallDist -: - public patchDist -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - meshWaveWallDist(const meshWaveWallDist&); - - //- Disallow default bitwise assignment - void operator=(const meshWaveWallDist&); - - -public: - - // Constructors - - //- Construct from mesh and flag whether or not to correct wall. - // Calculate for all cells. correctWalls : correct wall (face&point) - // cells for correct distance, searching neighbours. - meshWaveWallDist - ( - const fvMesh& mesh, - const bool correctWalls = true - ); - - - //- Destructor - virtual ~meshWaveWallDist(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistData.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.C similarity index 100% rename from src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistData.C rename to src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.C diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistData.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.H similarity index 100% rename from src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistData.H rename to src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.H diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H index efacc2f888..774f6d9d59 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H @@ -138,6 +138,9 @@ public: //- Correct the given distance-to-patch field virtual bool correct(volScalarField& y) = 0; + + //- Correct the given distance-to-patch and reflection vector fields + virtual bool correct(volScalarField& y, volVectorField& n) = 0; }; diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index e48915272c..d06a8456ba 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "wallDist.H" -#include "wallPolyPatch.H" +#include "wallFvPatch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -58,8 +58,36 @@ Foam::wallDist::wallDist(const fvMesh& mesh) ), mesh, dimensionedScalar("yWall", dimLength, GREAT) - ) + ), + n_(NULL) { + // Temporarily always construct n + // until the demand-driven interface is complete + n_ = tmp + ( + new volVectorField + ( + IOobject + ( + "nWall", + mesh.time().timeName(), + mesh + ), + mesh, + dimensionedVector("nWall", dimless, vector::zero) + ) + ); + + const fvPatchList& patches = mesh.boundary(); + + forAll(patches, patchi) + { + if (isA(patches[patchi])) + { + n_().boundaryField()[patchi] = patches[patchi].nf(); + } + } + movePoints(); } @@ -76,7 +104,7 @@ bool Foam::wallDist::movePoints() { if (pdm_->movePoints()) { - return pdm_->correct(y_); + return pdm_->correct(y_, n_()); } else { @@ -88,7 +116,7 @@ bool Foam::wallDist::movePoints() void Foam::wallDist::updateMesh(const mapPolyMesh& mpm) { pdm_->updateMesh(mpm); - pdm_->correct(y_); + pdm_->correct(y_, n_()); } diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index 50063bdad8..683a8c095f 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -62,6 +62,9 @@ class wallDist //- Distance-to-wall field volScalarField y_; + //- Distance-to-wall field + tmp n_; + // Private Member Functions @@ -90,11 +93,18 @@ public: // Member Functions + //- Return reference to cached distance-to-wall field const volScalarField& y() const { return y_; } + //- Return reference to cached normal-to-wall field + const volVectorField& n() const + { + return n_(); + } + //- Update the y-field when the mesh moves virtual bool movePoints(); diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.C b/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.C deleted file mode 100644 index a78c54faa4..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.C +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 "reflectionVectors.H" -#include "wallFvPatch.H" -#include "surfaceFields.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -Foam::reflectionVectors::reflectionVectors(const Foam::fvMesh& mesh) -: - n_ - ( - IOobject - ( - "reflectionVectors", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedVector("n", dimless, vector::zero) - ) -{ - correct(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -void Foam::reflectionVectors::correct() -{ - const fvMesh& mesh = n_.mesh(); - const fvPatchList& patches = mesh.boundary(); - - forAll(patches, patchi) - { - // find the nearest face for every cell - if (isA(patches[patchi])) - { - n_.boundaryField()[patchi] = - mesh.Sf().boundaryField()[patchi] - /mesh.magSf().boundaryField()[patchi]; - } - } -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.H b/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.H deleted file mode 100644 index b66c1d52b0..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/reflectionVectors.H +++ /dev/null @@ -1,98 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Class - Foam::reflectionVectors - -Description - Container for reflection vectors (= unit normal of nearest wall) -SourceFiles - reflectionVectors.C - -\*---------------------------------------------------------------------------*/ - -#ifndef reflectionVectors_H -#define reflectionVectors_H - -#include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class reflectionVectors Declaration -\*---------------------------------------------------------------------------*/ - -class reflectionVectors -{ - -protected: - - // Protected data - - volVectorField n_; - - -private: - - // Private Member Functions - - //- Disallow default bitwise copy construct - reflectionVectors(const reflectionVectors&); - - //- Disallow default bitwise assignment - void operator=(const reflectionVectors&); - - -public: - - // Constructors - - //- Construct from mesh - reflectionVectors(const fvMesh& mesh); - - - // Member Functions - - const volVectorField& n() const - { - return n_; - } - - - //- Correct for mesh geom/topo changes - void correct(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.C b/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.C deleted file mode 100644 index 8f9b5d2c14..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.C +++ /dev/null @@ -1,57 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 "wallDistReflection.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -Foam::wallDistReflection::wallDistReflection -( - const Foam::fvMesh& mesh, - const bool correctWalls -) -: - reflectionVectors(mesh), - wallDistData > - ( - mesh, - reflectionVectors::n_, - correctWalls - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -// Correct for mesh geom/topo changes -void Foam::wallDistReflection::correct() -{ - reflectionVectors::correct(); - wallDistData >::correct(); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.H b/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.H deleted file mode 100644 index f9c26e820c..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/wallDistReflection/wallDistReflection.H +++ /dev/null @@ -1,90 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -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 . - -Class - Foam::wallDistReflection - -Description - Wall distance and reflection vector calculation. See wallDist.H - -SourceFiles - wallDistReflection.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallDistReflection_H -#define wallDistReflection_H - -#include "reflectionVectors.H" -#include "wallDistData.H" -#include "wallPointData.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class wallDistReflection Declaration -\*---------------------------------------------------------------------------*/ - -class wallDistReflection -: - public reflectionVectors, - public wallDistData > -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - wallDistReflection(const wallDistReflection&); - - //- Disallow default bitwise assignment - void operator=(const wallDistReflection&); - - -public: - - // Constructors - - //- Construct from mesh and flag whether or not to correct wall. - // Calculate for all cells. correctWalls : correct wall (face&point) - // cells for correct distance, searching neighbours. - wallDistReflection(const fvMesh& mesh, bool correctWalls = true); - - - // Member Functions - - //- Correct for mesh geom/topo changes - void correct(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 990cccc0e1..60a1a53a1c 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -184,7 +184,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM ) ), - yr_(mesh_), + n_(wallDist::New(mesh_).n()), + y_(wallDist::New(mesh_).y()), R_ ( @@ -373,11 +374,6 @@ void LaunderGibsonRSTM::correct() RASModel::correct(); - if (mesh_.changing()) - { - yr_.correct(); - } - volSymmTensorField P(-twoSymm(R_ & fvc::grad(U_))); volScalarField G(GName(), 0.5*mag(tr(P))); @@ -443,10 +439,10 @@ void LaunderGibsonRSTM::correct() // wall reflection terms + symm ( - I*((yr_.n() & reflect) & yr_.n()) - - 1.5*(yr_.n()*(reflect & yr_.n()) - + (yr_.n() & reflect)*yr_.n()) - )*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*yr_*epsilon_) + I*((n_ & reflect) & n_) + - 1.5*(n_*(reflect & n_) + + (n_ & reflect)*n_) + )*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*y_*epsilon_) ); REqn().relax(); diff --git a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H index 8460b97ddf..b3aa0ddb50 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H +++ b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H @@ -60,7 +60,7 @@ SourceFiles #define compressibleLaunderGibsonRSTM_H #include "RASModel.H" -#include "wallDistReflection.H" +#include "wallDist.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -109,7 +109,8 @@ protected: // Fields - wallDistReflection yr_; + const volVectorField& n_; + const volScalarField& y_; volSymmTensorField R_; volScalarField k_; diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C index 3b312d5ae4..e7c459b888 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C @@ -25,7 +25,6 @@ License #include "IDDESDelta.H" #include "addToRunTimeSelectionTable.H" -#include "wallDistReflection.H" #include "wallDist.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -43,10 +42,8 @@ void Foam::IDDESDelta::calcDelta() { const volScalarField& hmax = hmax_(); - // initialise wallNorm - wallDistReflection wallNorm(mesh()); - - const volVectorField& n = wallNorm.n(); + // Wall-reflection vectors + const volVectorField& n = wallDist::New(mesh()).n(); tmp tfaceToFacenMax ( diff --git a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 15d032f654..385b3695d2 100644 --- a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -174,7 +174,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM ) ), - yr_(mesh_), + n_(wallDist::New(mesh_).n()), + y_(wallDist::New(mesh_).y()), R_ ( @@ -380,11 +381,6 @@ void LaunderGibsonRSTM::correct() return; } - if (mesh_.changing()) - { - yr_.correct(); - } - volSymmTensorField P(-twoSymm(R_ & fvc::grad(U_))); volScalarField G(GName(), 0.5*mag(tr(P))); @@ -450,10 +446,10 @@ void LaunderGibsonRSTM::correct() // wall reflection terms + symm ( - I*((yr_.n() & reflect) & yr_.n()) - - 1.5*(yr_.n()*(reflect & yr_.n()) - + (yr_.n() & reflect)*yr_.n()) - )*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*yr_*epsilon_) + I*((n_ & reflect) & n_) + - 1.5*(n_*(reflect & n_) + + (n_ & reflect)*n_) + )*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*y_*epsilon_) ); REqn().relax(); diff --git a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H index 42233d41b0..7ae8b343b9 100644 --- a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H +++ b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H @@ -59,7 +59,7 @@ SourceFiles #define LaunderGibsonRSTM_H #include "RASModel.H" -#include "wallDistReflection.H" +#include "wallDist.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -106,7 +106,8 @@ protected: // Fields - wallDistReflection yr_; + const volVectorField& n_; + const volScalarField& y_; volSymmTensorField R_; volScalarField k_;