wallDist: Added nRequired option to the wallDist dict

This commit is contained in:
Henry
2015-01-09 23:17:24 +00:00
parent 4b4fce2c02
commit c29c13b742
6 changed files with 102 additions and 35 deletions

View File

@ -58,6 +58,10 @@ Description
wallDist wallDist
{ {
method Poisson; method Poisson;
// Optional entry enabling the calculation
// of the normal-to-wall field
nRequired false;
} }
\endverbatim \endverbatim
Also the solver specification for yPsi is required in fvSolution, e.g. Also the solver specification for yPsi is required in fvSolution, e.g.

View File

@ -99,7 +99,10 @@ bool Foam::patchDistMethods::advectionDiffusion::correct
( (
"ny", "ny",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_ mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
), ),
mesh_, mesh_,
dimensionedVector("ny", dimless, vector::zero), dimensionedVector("ny", dimless, vector::zero),

View File

@ -58,6 +58,10 @@ Description
{ {
method advectionDiffusion; method advectionDiffusion;
// Optional entry enabling the calculation
// of the normal-to-wall field
nRequired false;
advectionDiffusionCoeffs advectionDiffusionCoeffs
{ {
method Poisson; method Poisson;

View File

@ -39,6 +39,10 @@ Description
wallDist wallDist
{ {
method meshWave; method meshWave;
// Optional entry enabling the calculation
// of the normal-to-wall field
nRequired false;
} }
\endverbatim \endverbatim

View File

@ -34,6 +34,37 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::wallDist::constructn() const
{
n_ = tmp<volVectorField>
(
new volVectorField
(
IOobject
(
"nWall",
mesh().time().timeName(),
mesh()
),
mesh(),
dimensionedVector("nWall", dimless, vector::zero),
patchDistMethod::patchTypes<vector>(mesh(), pdm_->patchIDs())
)
);
const labelHashSet& patchIDs = pdm_->patchIDs();
const fvPatchList& patches = mesh().boundary();
forAllConstIter(labelHashSet, patchIDs, iter)
{
label patchi = iter.key();
n_().boundaryField()[patchi] == patches[patchi].nf();
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wallDist::wallDist(const fvMesh& mesh) Foam::wallDist::wallDist(const fvMesh& mesh)
@ -60,33 +91,16 @@ Foam::wallDist::wallDist(const fvMesh& mesh)
dimensionedScalar("yWall", dimLength, SMALL), dimensionedScalar("yWall", dimLength, SMALL),
patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs()) patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs())
), ),
n_(NULL) nRequired_
{
// Temporarily always construct n
// until the demand-driven interface is complete
n_ = tmp<volVectorField>
( (
new volVectorField static_cast<const fvSchemes&>(mesh).subDict("wallDist")
( .lookupOrDefault<Switch>("nRequired", false)
IOobject
(
"nWall",
mesh.time().timeName(),
mesh
), ),
mesh, n_(volVectorField::null())
dimensionedVector("nWall", dimless, vector::zero), {
patchDistMethod::patchTypes<vector>(mesh, pdm_->patchIDs()) if (nRequired_)
)
);
const labelHashSet& patchIDs = pdm_->patchIDs();
const fvPatchList& patches = mesh.boundary();
forAllConstIter(labelHashSet, patchIDs, iter)
{ {
label patchi = iter.key(); constructn();
n_().boundaryField()[patchi] == patches[patchi].nf();
} }
movePoints(); movePoints();
@ -101,6 +115,24 @@ Foam::wallDist::~wallDist()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::volVectorField& Foam::wallDist::n() const
{
if (isNull(n_()))
{
WarningIn("Foam::wallDist::n()")
<< "n requested but 'nRequired' not specified in the wallDist "
"dictionary" << nl
<< " Recalculating y and n fields." << endl;
nRequired_ = true;
constructn();
pdm_->correct(y_, n_());
}
return n_();
}
bool Foam::wallDist::movePoints() bool Foam::wallDist::movePoints()
{ {
if (pdm_->movePoints()) if (pdm_->movePoints())

View File

@ -26,7 +26,24 @@ Class
Description Description
Interface to run-time selectable methods to calculate the distance-to-wall Interface to run-time selectable methods to calculate the distance-to-wall
field. and normal-to-wall fields.
Example of the wallDist specification in fvSchemes:
\verbatim
wallDist
{
method meshWave;
// Optional entry enabling the calculation
// of the normal-to-wall field
nRequired false;
}
\endverbatim
SeeAlso
Foam::patchDistMethod::meshWave
Foam::patchDistMethod::Poisson
Foam::patchDistMethod::advectionDiffusion
SourceFiles SourceFiles
wallDist.C wallDist.C
@ -57,17 +74,23 @@ class wallDist
// Private data // Private data
//- Run-time selected method to generate the distance-to-wall field //- Run-time selected method to generate the distance-to-wall field
autoPtr<patchDistMethod> pdm_; mutable autoPtr<patchDistMethod> pdm_;
//- Distance-to-wall field //- Distance-to-wall field
volScalarField y_; mutable volScalarField y_;
//- Distance-to-wall field //- Flag to indicate if the distance-to-wall field is required
tmp<volVectorField> n_; mutable bool nRequired_;
//- Normal-to-wall field
mutable tmp<volVectorField> n_;
// Private Member Functions // Private Member Functions
//- Construct the normal-to-wall field as required
void constructn() const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
wallDist(const wallDist&); wallDist(const wallDist&);
@ -100,10 +123,7 @@ public:
} }
//- Return reference to cached normal-to-wall field //- Return reference to cached normal-to-wall field
const volVectorField& n() const const volVectorField& n() const;
{
return n_();
}
//- Update the y-field when the mesh moves //- Update the y-field when the mesh moves
virtual bool movePoints(); virtual bool movePoints();