mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
wallDist: Added nRequired option to the wallDist dict
This commit is contained in:
@ -58,6 +58,10 @@ Description
|
||||
wallDist
|
||||
{
|
||||
method Poisson;
|
||||
|
||||
// Optional entry enabling the calculation
|
||||
// of the normal-to-wall field
|
||||
nRequired false;
|
||||
}
|
||||
\endverbatim
|
||||
Also the solver specification for yPsi is required in fvSolution, e.g.
|
||||
|
||||
@ -99,7 +99,10 @@ bool Foam::patchDistMethods::advectionDiffusion::correct
|
||||
(
|
||||
"ny",
|
||||
mesh_.time().timeName(),
|
||||
mesh_
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimensionedVector("ny", dimless, vector::zero),
|
||||
|
||||
@ -58,6 +58,10 @@ Description
|
||||
{
|
||||
method advectionDiffusion;
|
||||
|
||||
// Optional entry enabling the calculation
|
||||
// of the normal-to-wall field
|
||||
nRequired false;
|
||||
|
||||
advectionDiffusionCoeffs
|
||||
{
|
||||
method Poisson;
|
||||
|
||||
@ -39,6 +39,10 @@ Description
|
||||
wallDist
|
||||
{
|
||||
method meshWave;
|
||||
|
||||
// Optional entry enabling the calculation
|
||||
// of the normal-to-wall field
|
||||
nRequired false;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
@ -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 * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallDist::wallDist(const fvMesh& mesh)
|
||||
@ -60,33 +91,16 @@ Foam::wallDist::wallDist(const fvMesh& mesh)
|
||||
dimensionedScalar("yWall", dimLength, SMALL),
|
||||
patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs())
|
||||
),
|
||||
n_(NULL)
|
||||
{
|
||||
// Temporarily always construct n
|
||||
// until the demand-driven interface is complete
|
||||
n_ = tmp<volVectorField>
|
||||
nRequired_
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"nWall",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
static_cast<const fvSchemes&>(mesh).subDict("wallDist")
|
||||
.lookupOrDefault<Switch>("nRequired", false)
|
||||
),
|
||||
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)
|
||||
n_(volVectorField::null())
|
||||
{
|
||||
if (nRequired_)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
n_().boundaryField()[patchi] == patches[patchi].nf();
|
||||
constructn();
|
||||
}
|
||||
|
||||
movePoints();
|
||||
@ -101,6 +115,24 @@ Foam::wallDist::~wallDist()
|
||||
|
||||
// * * * * * * * * * * * * * * * 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()
|
||||
{
|
||||
if (pdm_->movePoints())
|
||||
|
||||
@ -26,7 +26,24 @@ Class
|
||||
|
||||
Description
|
||||
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
|
||||
wallDist.C
|
||||
@ -57,17 +74,23 @@ class wallDist
|
||||
// Private data
|
||||
|
||||
//- Run-time selected method to generate the distance-to-wall field
|
||||
autoPtr<patchDistMethod> pdm_;
|
||||
mutable autoPtr<patchDistMethod> pdm_;
|
||||
|
||||
//- Distance-to-wall field
|
||||
volScalarField y_;
|
||||
mutable volScalarField y_;
|
||||
|
||||
//- Distance-to-wall field
|
||||
tmp<volVectorField> n_;
|
||||
//- Flag to indicate if the distance-to-wall field is required
|
||||
mutable bool nRequired_;
|
||||
|
||||
//- Normal-to-wall field
|
||||
mutable tmp<volVectorField> n_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Construct the normal-to-wall field as required
|
||||
void constructn() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
wallDist(const wallDist&);
|
||||
|
||||
@ -100,10 +123,7 @@ public:
|
||||
}
|
||||
|
||||
//- Return reference to cached normal-to-wall field
|
||||
const volVectorField& n() const
|
||||
{
|
||||
return n_();
|
||||
}
|
||||
const volVectorField& n() const;
|
||||
|
||||
//- Update the y-field when the mesh moves
|
||||
virtual bool movePoints();
|
||||
|
||||
Reference in New Issue
Block a user