mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
wallDist: moved patchTypes into patchDistMethod
This commit is contained in:
@ -67,8 +67,8 @@ Foam::patchDistMethods::advectionDiffusion::advectionDiffusion
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
epsilon_(coeffs_.lookupOrDefault<scalar>("epsilon", 0.1)),
|
epsilon_(coeffs_.lookupOrDefault<scalar>("epsilon", 0.1)),
|
||||||
maxIter_(coeffs_.lookupOrDefault<int>("maxIter", 10)),
|
tolerance_(coeffs_.lookupOrDefault<scalar>("tolerance", 1e-3)),
|
||||||
tolerance_(coeffs_.lookupOrDefault<scalar>("tolerance", 1e-3))
|
maxIter_(coeffs_.lookupOrDefault<int>("maxIter", 10))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -79,30 +79,6 @@ bool Foam::patchDistMethods::advectionDiffusion::correct(volScalarField& y)
|
|||||||
return correct(y, const_cast<volVectorField&>(volVectorField::null()));
|
return correct(y, const_cast<volVectorField&>(volVectorField::null()));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
template<class Type>
|
|
||||||
wordList 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::patchDistMethods::advectionDiffusion::correct
|
bool Foam::patchDistMethods::advectionDiffusion::correct
|
||||||
(
|
(
|
||||||
@ -112,36 +88,38 @@ bool Foam::patchDistMethods::advectionDiffusion::correct
|
|||||||
{
|
{
|
||||||
pdmPredictor_->correct(y);
|
pdmPredictor_->correct(y);
|
||||||
|
|
||||||
|
volVectorField ny
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"ny",
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedVector("nWall", dimless, vector::zero),
|
||||||
|
patchTypes<vector>(mesh_, patchIDs_)
|
||||||
|
);
|
||||||
|
|
||||||
|
const fvPatchList& patches = mesh_.boundary();
|
||||||
|
|
||||||
|
forAllConstIter(labelHashSet, patchIDs_, iter)
|
||||||
|
{
|
||||||
|
label patchi = iter.key();
|
||||||
|
ny.boundaryField()[patchi] == -patches[patchi].nf();
|
||||||
|
}
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
scalar initialResidual = 0;
|
scalar initialResidual = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
volVectorField ny
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"ny",
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
mesh_
|
|
||||||
),
|
|
||||||
mesh_,
|
|
||||||
dimensionedVector("nWall", dimless, vector::zero),
|
|
||||||
patchTypes<vector>(mesh_, patchIDs_)
|
|
||||||
);
|
|
||||||
|
|
||||||
const fvPatchList& patches = mesh_.boundary();
|
|
||||||
|
|
||||||
forAllConstIter(labelHashSet, patchIDs_, iter)
|
|
||||||
{
|
|
||||||
label patchi = iter.key();
|
|
||||||
ny.boundaryField()[patchi] == -patches[patchi].nf();
|
|
||||||
}
|
|
||||||
|
|
||||||
ny = fvc::grad(y);
|
ny = fvc::grad(y);
|
||||||
ny /= (mag(ny) + SMALL);
|
ny /= (mag(ny) + SMALL);
|
||||||
|
|
||||||
surfaceVectorField nf(fvc::interpolate(ny));
|
surfaceVectorField nf(fvc::interpolate(ny));
|
||||||
nf /= (mag(nf) + SMALL);
|
nf /= (mag(nf) + SMALL);
|
||||||
|
|
||||||
surfaceScalarField yPhi("yPhi", mesh_.Sf() & nf);
|
surfaceScalarField yPhi("yPhi", mesh_.Sf() & nf);
|
||||||
|
|
||||||
fvScalarMatrix yEqn
|
fvScalarMatrix yEqn
|
||||||
@ -155,15 +133,14 @@ bool Foam::patchDistMethods::advectionDiffusion::correct
|
|||||||
|
|
||||||
yEqn.relax();
|
yEqn.relax();
|
||||||
initialResidual = yEqn.solve().initialResidual();
|
initialResidual = yEqn.solve().initialResidual();
|
||||||
|
|
||||||
// Only calculate n if the field is defined
|
|
||||||
if (notNull(n))
|
|
||||||
{
|
|
||||||
n = -ny;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (initialResidual > tolerance_ && ++iter < maxIter_);
|
} while (initialResidual > tolerance_ && ++iter < maxIter_);
|
||||||
|
|
||||||
|
// Only calculate n if the field is defined
|
||||||
|
if (notNull(n))
|
||||||
|
{
|
||||||
|
n = -ny;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,9 +39,10 @@ SourceFiles
|
|||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
|
#include "fixedValueFvPatchFields.H"
|
||||||
|
#include "zeroGradientFvPatchFields.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -66,7 +67,6 @@ protected:
|
|||||||
//- Set of patch IDs
|
//- Set of patch IDs
|
||||||
const labelHashSet patchIDs_;
|
const labelHashSet patchIDs_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
@ -124,6 +124,18 @@ public:
|
|||||||
virtual ~patchDistMethod();
|
virtual ~patchDistMethod();
|
||||||
|
|
||||||
|
|
||||||
|
// Static Functions
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
(
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const labelHashSet& patchIDs
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the patchIDs
|
//- Return the patchIDs
|
||||||
@ -154,6 +166,31 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -25,8 +25,6 @@ License
|
|||||||
|
|
||||||
#include "wallDist.H"
|
#include "wallDist.H"
|
||||||
#include "wallPolyPatch.H"
|
#include "wallPolyPatch.H"
|
||||||
#include "fixedValueFvPatchFields.H"
|
|
||||||
#include "zeroGradientFvPatchFields.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -36,26 +34,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::wordList Foam::wallDist::patchTypes(const labelHashSet& patchIDs) const
|
|
||||||
{
|
|
||||||
wordList yTypes
|
|
||||||
(
|
|
||||||
mesh().boundary().size(),
|
|
||||||
zeroGradientFvPatchField<Type>::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
|
||||||
{
|
|
||||||
yTypes[iter.key()] = fixedValueFvPatchField<Type>::typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return yTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::wallDist::wallDist(const fvMesh& mesh)
|
Foam::wallDist::wallDist(const fvMesh& mesh)
|
||||||
@ -80,7 +58,7 @@ Foam::wallDist::wallDist(const fvMesh& mesh)
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar("yWall", dimLength, SMALL),
|
dimensionedScalar("yWall", dimLength, SMALL),
|
||||||
patchTypes<scalar>(pdm_->patchIDs())
|
patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs())
|
||||||
),
|
),
|
||||||
n_(NULL)
|
n_(NULL)
|
||||||
{
|
{
|
||||||
@ -98,7 +76,7 @@ Foam::wallDist::wallDist(const fvMesh& mesh)
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedVector("nWall", dimless, vector::zero),
|
dimensionedVector("nWall", dimless, vector::zero),
|
||||||
patchTypes<vector>(pdm_->patchIDs())
|
patchDistMethod::patchTypes<vector>(mesh, pdm_->patchIDs())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -68,11 +68,6 @@ class wallDist
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Return the patch types for y and n
|
|
||||||
// These are fixedValue for the set provided otherwise zero-gradient
|
|
||||||
template<class Type>
|
|
||||||
wordList patchTypes(const labelHashSet& patchIDs) const;
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
wallDist(const wallDist&);
|
wallDist(const wallDist&);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user