wallDist: Add support for cached wall-reflection vectors

Currently these vectors are generated at the same time as the wall-distance field
by the same run-time selected algorithm.  This will be changed so that the wall-reflection
vectors are only generated and stored if required.
This commit is contained in:
Henry
2015-01-08 16:08:53 +00:00
parent 917852b74e
commit c4804e5a0b
28 changed files with 132 additions and 1006 deletions

View File

@ -27,6 +27,8 @@ License
#include "fvMesh.H"
#include "volFields.H"
#include "patchWave.H"
#include "patchDataWave.H"
#include "wallPointData.H"
#include "emptyFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
@ -76,10 +78,10 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y)
// Calculate distance starting from patch faces
patchWave wave(mesh_, patchIDs_, correctWalls_);
// Transfer cell values from wave into *this
// Transfer cell values from wave into y
y.transfer(wave.distance());
// Transfer values on patches into boundaryField of *this
// Transfer values on patches into boundaryField of y
forAll(y.boundaryField(), patchI)
{
if (!isA<emptyFvPatchScalarField>(y.boundaryField()[patchI]))
@ -97,4 +99,54 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y)
}
bool Foam::patchDistMethods::meshWave::correct
(
volScalarField& y,
volVectorField& n
)
{
// Collect pointers to data on patches
UPtrList<vectorField> patchData(mesh_.boundaryMesh().size());
forAll(n.boundaryField(), patchI)
{
patchData.set(patchI, &n.boundaryField()[patchI]);
}
// Do mesh wave
patchDataWave<wallPointData<vector> > wave
(
mesh_,
patchIDs_,
patchData,
correctWalls_
);
// Transfer cell values from wave into y and n
y.transfer(wave.distance());
n.transfer(wave.cellData());
// Transfer values on patches into boundaryField of y and n
forAll(y.boundaryField(), patchI)
{
scalarField& waveFld = wave.patchDistance()[patchI];
if (!isA<emptyFvPatchScalarField>(y.boundaryField()[patchI]))
{
y.boundaryField()[patchI].transfer(waveFld);
vectorField& wavePatchData = wave.patchData()[patchI];
n.boundaryField()[patchI].transfer(wavePatchData);
}
}
// Transfer number of unset values
nUnset_ = wave.nUnset();
return nUnset_ > 0;
}
// ************************************************************************* //

View File

@ -118,6 +118,9 @@ public:
//- Correct the given distance-to-patch field
virtual bool correct(volScalarField& y);
//- Correct the given distance-to-patch and normal-to-patch fields
virtual bool correct(volScalarField& y, volVectorField& n);
};

View File

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 "meshWaveWallDist.H"
#include "fvMesh.H"
#include "wallPolyPatch.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::meshWaveWallDist::meshWaveWallDist
(
const fvMesh& mesh,
const bool correctWalls
)
:
patchDist
(
mesh,
mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(),
correctWalls
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::meshWaveWallDist::~meshWaveWallDist()
{}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 "wallDistData.H"
#include "patchDataWave.H"
#include "wallPolyPatch.H"
#include "emptyFvPatchFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class TransferType>
Foam::wallDistData<TransferType>::wallDistData
(
const Foam::fvMesh& mesh,
GeometricField<Type, fvPatchField, volMesh>& field,
const bool correctWalls
)
:
volScalarField
(
IOobject
(
"y",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("y", dimLength, GREAT)
),
cellDistFuncs(mesh),
field_(field),
correctWalls_(correctWalls),
nUnset_(0)
{
correct();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class TransferType>
Foam::wallDistData<TransferType>::~wallDistData()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Correct for mesh geom/topo changes
template<class TransferType>
void Foam::wallDistData<TransferType>::correct()
{
const polyMesh& mesh = cellDistFuncs::mesh();
//
// Fill data on wall patches with initial values
//
// Get patchids of walls
labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
// Collect pointers to data on patches
UPtrList<Field<Type> > patchData(mesh.boundaryMesh().size());
forAll(field_.boundaryField(), patchI)
{
patchData.set(patchI, &field_.boundaryField()[patchI]);
}
// Do mesh wave
patchDataWave<TransferType> wave
(
mesh,
wallPatchIDs,
patchData,
correctWalls_
);
// Transfer cell values from wave into *this and field_
transfer(wave.distance());
field_.transfer(wave.cellData());
// Transfer values on patches into boundaryField of *this and field_
forAll(boundaryField(), patchI)
{
scalarField& waveFld = wave.patchDistance()[patchI];
if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI]))
{
boundaryField()[patchI].transfer(waveFld);
Field<Type>& wavePatchData = wave.patchData()[patchI];
field_.boundaryField()[patchI].transfer(wavePatchData);
}
}
// Transfer number of unset values
nUnset_ = wave.nUnset();
}
// ************************************************************************* //

View File

@ -22,43 +22,70 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::meshWaveWallDist
Foam::wallDistData
Description
Specialisation of patchDist for wall distance calculation
Wall distance calculation. Like wallDist but also transports extra
data (template argument).
Used for e.g reflection vector calculation or vanDriest damping.
Templated on two parameters:
- TransferType: type of overall data transported
(e.g. wallPointData\<vector\>)
SourceFiles
meshWaveWallDist.C
wallDistData.C
\*---------------------------------------------------------------------------*/
#ifndef meshWaveWallDist_H
#define meshWaveWallDist_H
#ifndef wallDistData_H
#define wallDistData_H
#include "patchDist.H"
#include "cellDistFuncs.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class meshWaveWallDist Declaration
Class wallDistData Declaration
\*---------------------------------------------------------------------------*/
class meshWaveWallDist
template<class TransferType>
class wallDistData
:
public patchDist
public volScalarField,
public cellDistFuncs
{
private:
typedef typename TransferType::dataType Type;
// Private Member Data
//- Reference to field whose data to use (on walls) and update
// (every cell and non-wall face)
GeometricField<Type, fvPatchField, volMesh>& field_;
//- Do accurate distance calculation for near-wall cells.
bool correctWalls_;
//- Number of unset cells and faces.
label nUnset_;
// Private Member Functions
//- Disallow default bitwise copy construct
meshWaveWallDist(const meshWaveWallDist&);
wallDistData(const wallDistData&);
//- Disallow default bitwise assignment
void operator=(const meshWaveWallDist&);
void operator=(const wallDistData&);
public:
@ -68,15 +95,38 @@ public:
//- 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.
meshWaveWallDist
wallDistData
(
const fvMesh& mesh,
const bool correctWalls = true
GeometricField<Type, fvPatchField, volMesh>&,
bool correctWalls = true
);
//- Destructor
virtual ~meshWaveWallDist();
virtual ~wallDistData();
// Member Functions
const volScalarField& y() const
{
return *this;
}
label nUnset() const
{
return nUnset_;
}
//- Access field
const GeometricField<Type, fvPatchField, volMesh>& data() const
{
return field_;
}
//- Correct for mesh geom/topo changes
virtual void correct();
};
@ -86,6 +136,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "wallDistData.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //