Commit bb2c2efd authored by Henry's avatar Henry
Browse files

wallDist: now a MeshObject cached and updated automatically with a run-time selected algorithm

When using models which require the wallDist e.g. kOmegaSST it will
request the method to be used from the wallDist sub-dictionary in
fvSchemes e.g.

wallDist
{
    method meshWave;
}

specifies the mesh-wave method as hard-coded in previous OpenFOAM versions.
parent 2028973e
......@@ -45,29 +45,7 @@ Foam::wallDependentModel::~wallDependentModel()
const Foam::volScalarField& Foam::wallDependentModel::yWall() const
{
if (!mesh_.foundObject<volScalarField>("yWall"))
{
volScalarField* yPtr
(
new volScalarField
(
IOobject
(
"yWall",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
true
),
wallDist(mesh_).y()
)
);
yPtr->checkIn();
}
return mesh_.lookupObject<volScalarField>("yWall");
return wallDist::New(mesh_).y();
}
......@@ -77,28 +55,6 @@ const Foam::volVectorField& Foam::wallDependentModel::nWall() const
{
wallDistReflection w(mesh_);
if (!mesh_.foundObject<volScalarField>("yWall"))
{
volScalarField* yPtr
(
new volScalarField
(
IOobject
(
"yWall",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
true
),
w.y()
)
);
yPtr->checkIn();
}
volVectorField* nPtr
(
new volVectorField
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -26,46 +26,36 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "wallDist.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
#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
wallDist y(mesh, true);
if (y.nUnset() != 0)
{
WarningIn(args.executable())
<< "There are " << y.nUnset()
<< " remaining unset cells and/or boundary values" << endl;
}
const volScalarField& y = wallDist::New(mesh).y();
y.write();
runTime++;
Info<< "Time now = " << runTime.timeName() << endl;
// Move points
boundBox meshBb(mesh.points());
......@@ -83,14 +73,11 @@ int main(int argc, char *argv[])
}
mesh.movePoints(newPoints);
mesh.write();
y.correct();
y.write();
Info<< "End\n" << endl;
return 0;
......
......@@ -34,7 +34,6 @@ Description
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "LESModel.H"
#include "nearWallDist.H"
#include "wallDist.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -53,17 +52,6 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl;
fvMesh::readUpdateState state = mesh.readUpdate();
// Wall distance
if (timeI == 0 || state != fvMesh::UNCHANGED)
{
Info<< "Calculating wall distance\n" << endl;
wallDist y(mesh);
Info<< "Writing wall distance to field "
<< y.name() << nl << endl;
y.write();
}
volScalarField yPlus
(
IOobject
......
......@@ -43,8 +43,6 @@ Description
#include "compressible/RAS/RASModel/RASModel.H"
#include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void calcIncompressibleYPlus
......@@ -204,15 +202,6 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl;
fvMesh::readUpdateState state = mesh.readUpdate();
// Wall distance
if (timeI == 0 || state != fvMesh::UNCHANGED)
{
Info<< "Calculating wall distance\n" << endl;
wallDist y(mesh);
Info<< "Writing wall distance to field " << y.name() << nl << endl;
y.write();
}
volScalarField yPlus
(
IOobject
......
......@@ -38,7 +38,7 @@ volVectorField U
);
Info<< "Calculating wall distance field" << endl;
volScalarField y(wallDist(mesh).y());
const volScalarField& y(wallDist::New(mesh).y());
// Set the mean boundary-layer thickness
dimensionedScalar ybl("ybl", dimLength, 0);
......
......@@ -610,6 +610,7 @@ DebugSwitches
meshCutAndRemove 0;
meshCutter 0;
meshModifier 0;
meshObject 0;
meshRefinement 0;
meshSearch 0;
meshToMesh 0;
......
......@@ -43,7 +43,7 @@ void Foam::PrandtlDelta::calcDelta()
delta_ = min
(
static_cast<const volScalarField&>(geometricDelta_()),
(kappa_/Cdelta_)*wallDist(mesh_).y()
(kappa_/Cdelta_)*wallDist::New(mesh_).y()
);
}
......
......@@ -261,7 +261,7 @@ kOmegaSST<BasicTurbulenceModel>::kOmegaSST
)
),
y_(this->mesh_),
y_(wallDist::New(this->mesh_).y()),
k_
(
......
......@@ -148,12 +148,13 @@ protected:
Switch F3_;
//- Wall distance
// Note: different to wall distance in parent RASModel
wallDist y_;
// Fields
//- Wall distance
// Note: different to wall distance in parent RASModel
// which is for near-wall cells only
const volScalarField& y_;
volScalarField k_;
volScalarField omega_;
......
......@@ -42,8 +42,8 @@ $(wallDist)/wallPointYPlus/wallPointYPlus.C
$(wallDist)/nearWallDist/nearWallDistNoSearch.C
$(wallDist)/nearWallDist/nearWallDist.C
$(wallDist)/wallDist/wallDist.C
$(wallDist)/meshWaveWallDist/patchDist.C
$(wallDist)/meshWaveWallDist/meshWaveWallDist.C
$(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C
$(wallDist)/patchDistMethods/meshWave/meshWavePatchDistMethod.C
$(wallDist)/wallDistReflection/reflectionVectors.C
$(wallDist)/wallDistReflection/wallDistReflection.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -49,8 +49,19 @@ namespace Foam
void Foam::fvMesh::clearGeomNotOldVol()
{
meshObject::clear<fvMesh, GeometricMeshObject>(*this);
meshObject::clear<lduMesh, GeometricMeshObject>(*this);
meshObject::clearUpto
<
fvMesh,
GeometricMeshObject,
MoveableMeshObject
>(*this);
meshObject::clearUpto
<
lduMesh,
GeometricMeshObject,
MoveableMeshObject
>(*this);
slicedVolScalarField::DimensionedInternalField* VPtr =
static_cast<slicedVolScalarField::DimensionedInternalField*>(VPtr_);
......
......@@ -23,22 +23,47 @@ License
\*---------------------------------------------------------------------------*/
#include "patchDist.H"
#include "patchWave.H"
#include "meshWavePatchDistMethod.H"
#include "fvMesh.H"
#include "volFields.H"
#include "patchWave.H"
#include "emptyFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace patchDistMethods
{
defineTypeNameAndDebug(meshWave, 0);
addToRunTimeSelectionTable(patchDistMethod, meshWave, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchDist::patchDist
Foam::patchDistMethods::meshWave::meshWave
(
const dictionary& dict,
const fvMesh& mesh,
const labelHashSet& patchIDs
)
:
patchDistMethod(mesh, patchIDs),
correctWalls_(dict.lookupOrDefault<Switch>("correctWalls", true)),
nUnset_(0)
{}
Foam::patchDistMethods::meshWave::meshWave
(
const fvMesh& mesh,
const labelHashSet& patchIDs,
const bool correctWalls
)
:
mesh_(mesh),
patchIDs_(patchIDs),
patchDistMethod(mesh, patchIDs),
correctWalls_(correctWalls),
nUnset_(0)
{}
......@@ -46,28 +71,8 @@ Foam::patchDist::patchDist
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::patchDist::y() const
bool Foam::patchDistMethods::meshWave::correct(volScalarField& y)
{
tmp<volScalarField> ty
(
new volScalarField
(
IOobject
(
"y",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("y", dimLength, GREAT)
)
);
volScalarField& y = ty();
// Calculate distance starting from patch faces
patchWave wave(mesh_, patchIDs_, correctWalls_);
......@@ -88,7 +93,7 @@ Foam::tmp<Foam::volScalarField> Foam::patchDist::y() const
// Transfer number of unset values
nUnset_ = wave.nUnset();
return ty;
return nUnset_ > 0;
}
......
......@@ -39,36 +39,32 @@ Description
takes the pointFaces() of the wall point to look for the nearest point.
SourceFiles
patchDist.C
meshWavePatchDistMethod.C
\*---------------------------------------------------------------------------*/
#ifndef patchDist_H
#define patchDist_H
#ifndef meshWavePatchDistMethod_H
#define meshWavePatchDistMethod_H
#include "volFields.H"
#include "patchDistMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
namespace patchDistMethods
{
/*---------------------------------------------------------------------------*\
Class patchDist Declaration
Class meshWave Declaration
\*---------------------------------------------------------------------------*/
class patchDist
class meshWave
:
public patchDistMethod
{
// Private Member Data
//- Reference to the mesh
const fvMesh& mesh_;
//- Set of patch IDs
const labelHashSet patchIDs_;
//- Do accurate distance calculation for near-wall cells.
const bool correctWalls_;
......@@ -79,20 +75,33 @@ class patchDist
// Private Member Functions
//- Disallow default bitwise copy construct
patchDist(const patchDist&);
meshWave(const meshWave&);
//- Disallow default bitwise assignment
void operator=(const patchDist&);
void operator=(const meshWave&);
public:
//- Runtime type information
TypeName("meshWave");
// Constructors
//- Construct from mesh and flag whether or not to correct wall.
// Calculate for all cells.
meshWave
(
const dictionary& dict,
const fvMesh& mesh,
const labelHashSet& patchIDs
);
//- 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.
patchDist
meshWave
(
const fvMesh& mesh,
const labelHashSet& patchIDs,
......@@ -102,19 +111,19 @@ public:
// Member Functions
//- Calculate and return the distance to nearest patch
// for all cells and boundary
tmp<volScalarField> y() const;
label nUnset() const
{
return nUnset_;
}
//- Correct the given distance-to-patch field
virtual bool correct(volScalarField& y);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace patchDistMethods
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "patchDistMethod.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(patchDistMethod, 0);
defineRunTimeSelectionTable(patchDistMethod, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchDistMethod::patchDistMethod
(
const fvMesh& mesh,
const labelHashSet& patchIDs
)
:
mesh_(mesh),
patchIDs_(patchIDs)
{}
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New
(
const dictionary& dict,
const fvMesh& mesh,
const labelHashSet& patchIDs
)
{
word patchDistMethodType(dict.lookup("method"));
Info<< "Selecting patchDistMethod " << patchDistMethodType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(patchDistMethodType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("patchDistMethod::New")
<< "Unknown patchDistMethodType type "
<< patchDistMethodType << endl << endl
<< "Valid patchDistMethod types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(dict, mesh, patchIDs);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchDistMethod::~patchDistMethod()
{}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 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