mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
wallDist: Add support for distance to any patch set
This commit is contained in:
@ -77,7 +77,6 @@ private:
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const patchDistMethod&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -129,7 +128,7 @@ public:
|
||||
//- Return the patch types for y and n
|
||||
// These are fixedValue for the set provided otherwise zero-gradient
|
||||
template<class Type>
|
||||
static inline wordList patchTypes
|
||||
static wordList patchTypes
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs
|
||||
@ -166,30 +165,11 @@ public:
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Foam::wordList Foam::patchDistMethod::patchTypes
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs
|
||||
)
|
||||
{
|
||||
wordList yTypes
|
||||
(
|
||||
mesh.boundary().size(),
|
||||
zeroGradientFvPatchField<Type>::typeName
|
||||
);
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
yTypes[iter.key()] = fixedValueFvPatchField<Type>::typeName;
|
||||
}
|
||||
|
||||
return yTypes;
|
||||
}
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "patchDistMethodTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -44,20 +44,19 @@ void Foam::wallDist::constructn() const
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"nWall",
|
||||
"n" & patchTypeName_,
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
),
|
||||
mesh(),
|
||||
dimensionedVector("nWall", dimless, vector::zero),
|
||||
patchDistMethod::patchTypes<vector>(mesh(), pdm_->patchIDs())
|
||||
dimensionedVector("n" & patchTypeName_, dimless, vector::zero),
|
||||
patchDistMethod::patchTypes<vector>(mesh(), patchIDs_)
|
||||
)
|
||||
);
|
||||
|
||||
const labelHashSet& patchIDs = pdm_->patchIDs();
|
||||
const fvPatchList& patches = mesh().boundary();
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
forAllConstIter(labelHashSet, patchIDs_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
n_().boundaryField()[patchi] == patches[patchi].nf();
|
||||
@ -67,33 +66,84 @@ void Foam::wallDist::constructn() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallDist::wallDist(const fvMesh& mesh)
|
||||
Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName)
|
||||
:
|
||||
MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh),
|
||||
patchIDs_(mesh.boundaryMesh().findPatchIDs<wallPolyPatch>()),
|
||||
patchTypeName_(patchTypeName),
|
||||
pdm_
|
||||
(
|
||||
patchDistMethod::New
|
||||
(
|
||||
static_cast<const fvSchemes&>(mesh).subDict("wallDist"),
|
||||
static_cast<const fvSchemes&>(mesh)
|
||||
.subDict(patchTypeName_ & "Dist"),
|
||||
mesh,
|
||||
mesh.boundaryMesh().findPatchIDs<wallPolyPatch>()
|
||||
patchIDs_
|
||||
)
|
||||
),
|
||||
y_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"yWall",
|
||||
"y" & patchTypeName_,
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("yWall", dimLength, SMALL),
|
||||
patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs())
|
||||
dimensionedScalar("y" & patchTypeName_, dimLength, SMALL),
|
||||
patchDistMethod::patchTypes<scalar>(mesh, patchIDs_)
|
||||
),
|
||||
nRequired_
|
||||
(
|
||||
static_cast<const fvSchemes&>(mesh).subDict("wallDist")
|
||||
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
|
||||
.lookupOrDefault<Switch>("nRequired", false)
|
||||
),
|
||||
n_(volVectorField::null())
|
||||
{
|
||||
if (nRequired_)
|
||||
{
|
||||
constructn();
|
||||
}
|
||||
|
||||
movePoints();
|
||||
}
|
||||
|
||||
|
||||
Foam::wallDist::wallDist
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const word& patchTypeName
|
||||
)
|
||||
:
|
||||
MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh),
|
||||
patchIDs_(patchIDs),
|
||||
patchTypeName_(patchTypeName),
|
||||
pdm_
|
||||
(
|
||||
patchDistMethod::New
|
||||
(
|
||||
static_cast<const fvSchemes&>(mesh)
|
||||
.subDict(patchTypeName_ & "Dist"),
|
||||
mesh,
|
||||
patchIDs_
|
||||
)
|
||||
),
|
||||
y_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"y" & patchTypeName_,
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("y" & patchTypeName_, dimLength, SMALL),
|
||||
patchDistMethod::patchTypes<scalar>(mesh, patchIDs_)
|
||||
),
|
||||
nRequired_
|
||||
(
|
||||
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
|
||||
.lookupOrDefault<Switch>("nRequired", false)
|
||||
),
|
||||
n_(volVectorField::null())
|
||||
@ -120,8 +170,8 @@ 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
|
||||
<< "n requested but 'nRequired' not specified in the "
|
||||
<< (patchTypeName_ & "Dist") << " dictionary" << nl
|
||||
<< " Recalculating y and n fields." << endl;
|
||||
|
||||
nRequired_ = true;
|
||||
|
||||
@ -55,7 +55,6 @@ SourceFiles
|
||||
|
||||
#include "MeshObject.H"
|
||||
#include "patchDistMethod.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -73,6 +72,12 @@ class wallDist
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Set of patch IDs
|
||||
const labelHashSet patchIDs_;
|
||||
|
||||
//- Name for the patch set, e.g. "wall"
|
||||
const word patchTypeName_;
|
||||
|
||||
//- Run-time selected method to generate the distance-to-wall field
|
||||
mutable autoPtr<patchDistMethod> pdm_;
|
||||
|
||||
@ -106,8 +111,20 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh
|
||||
wallDist(const fvMesh& mesh);
|
||||
//- Construct from mesh and optional patch type name
|
||||
wallDist
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& patchTypeName = "wall"
|
||||
);
|
||||
|
||||
//- Construct from mesh, patch IDs and optional patch type name
|
||||
wallDist
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const word& patchTypeName = "patch"
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -116,6 +133,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the patchIDs
|
||||
const labelHashSet& patchIDs() const
|
||||
{
|
||||
return patchIDs_;
|
||||
}
|
||||
|
||||
//- Return reference to cached distance-to-wall field
|
||||
const volScalarField& y() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user