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 7900e9ea9e
commit 6f0b2c1727
28 changed files with 132 additions and 1006 deletions

View File

@ -44,8 +44,6 @@ $(wallDist)/nearWallDist/nearWallDist.C
$(wallDist)/wallDist/wallDist.C
$(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C
$(wallDist)/patchDistMethods/meshWave/meshWavePatchDistMethod.C
$(wallDist)/wallDistReflection/reflectionVectors.C
$(wallDist)/wallDistReflection/wallDistReflection.C
fvMeshMapper = fvMesh/fvMeshMapper

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

@ -1,91 +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/>.
Class
Foam::meshWaveWallDist
Description
Specialisation of patchDist for wall distance calculation
SourceFiles
meshWaveWallDist.C
\*---------------------------------------------------------------------------*/
#ifndef meshWaveWallDist_H
#define meshWaveWallDist_H
#include "patchDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class meshWaveWallDist Declaration
\*---------------------------------------------------------------------------*/
class meshWaveWallDist
:
public patchDist
{
// Private Member Functions
//- Disallow default bitwise copy construct
meshWaveWallDist(const meshWaveWallDist&);
//- Disallow default bitwise assignment
void operator=(const meshWaveWallDist&);
public:
// Constructors
//- 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
(
const fvMesh& mesh,
const bool correctWalls = true
);
//- Destructor
virtual ~meshWaveWallDist();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

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

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "wallDist.H"
#include "wallPolyPatch.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -58,8 +58,36 @@ Foam::wallDist::wallDist(const fvMesh& mesh)
),
mesh,
dimensionedScalar("yWall", dimLength, GREAT)
)
),
n_(NULL)
{
// Temporarily always construct n
// until the demand-driven interface is complete
n_ = tmp<volVectorField>
(
new volVectorField
(
IOobject
(
"nWall",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedVector("nWall", dimless, vector::zero)
)
);
const fvPatchList& patches = mesh.boundary();
forAll(patches, patchi)
{
if (isA<wallFvPatch>(patches[patchi]))
{
n_().boundaryField()[patchi] = patches[patchi].nf();
}
}
movePoints();
}
@ -76,7 +104,7 @@ bool Foam::wallDist::movePoints()
{
if (pdm_->movePoints())
{
return pdm_->correct(y_);
return pdm_->correct(y_, n_());
}
else
{
@ -88,7 +116,7 @@ bool Foam::wallDist::movePoints()
void Foam::wallDist::updateMesh(const mapPolyMesh& mpm)
{
pdm_->updateMesh(mpm);
pdm_->correct(y_);
pdm_->correct(y_, n_());
}

View File

@ -62,6 +62,9 @@ class wallDist
//- Distance-to-wall field
volScalarField y_;
//- Distance-to-wall field
tmp<volVectorField> n_;
// Private Member Functions
@ -90,11 +93,18 @@ public:
// Member Functions
//- Return reference to cached distance-to-wall field
const volScalarField& y() const
{
return y_;
}
//- Return reference to cached normal-to-wall field
const volVectorField& n() const
{
return n_();
}
//- Update the y-field when the mesh moves
virtual bool movePoints();

View File

@ -1,72 +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 "reflectionVectors.H"
#include "wallFvPatch.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::reflectionVectors::reflectionVectors(const Foam::fvMesh& mesh)
:
n_
(
IOobject
(
"reflectionVectors",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedVector("n", dimless, vector::zero)
)
{
correct();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::reflectionVectors::correct()
{
const fvMesh& mesh = n_.mesh();
const fvPatchList& patches = mesh.boundary();
forAll(patches, patchi)
{
// find the nearest face for every cell
if (isA<wallFvPatch>(patches[patchi]))
{
n_.boundaryField()[patchi] =
mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi];
}
}
}
// ************************************************************************* //

View File

@ -1,98 +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/>.
Class
Foam::reflectionVectors
Description
Container for reflection vectors (= unit normal of nearest wall)
SourceFiles
reflectionVectors.C
\*---------------------------------------------------------------------------*/
#ifndef reflectionVectors_H
#define reflectionVectors_H
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class reflectionVectors Declaration
\*---------------------------------------------------------------------------*/
class reflectionVectors
{
protected:
// Protected data
volVectorField n_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
reflectionVectors(const reflectionVectors&);
//- Disallow default bitwise assignment
void operator=(const reflectionVectors&);
public:
// Constructors
//- Construct from mesh
reflectionVectors(const fvMesh& mesh);
// Member Functions
const volVectorField& n() const
{
return n_;
}
//- Correct for mesh geom/topo changes
void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,57 +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 "wallDistReflection.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::wallDistReflection::wallDistReflection
(
const Foam::fvMesh& mesh,
const bool correctWalls
)
:
reflectionVectors(mesh),
wallDistData<wallPointData<vector> >
(
mesh,
reflectionVectors::n_,
correctWalls
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Correct for mesh geom/topo changes
void Foam::wallDistReflection::correct()
{
reflectionVectors::correct();
wallDistData<wallPointData<vector> >::correct();
}
// ************************************************************************* //

View File

@ -1,90 +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/>.
Class
Foam::wallDistReflection
Description
Wall distance and reflection vector calculation. See wallDist.H
SourceFiles
wallDistReflection.C
\*---------------------------------------------------------------------------*/
#ifndef wallDistReflection_H
#define wallDistReflection_H
#include "reflectionVectors.H"
#include "wallDistData.H"
#include "wallPointData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class wallDistReflection Declaration
\*---------------------------------------------------------------------------*/
class wallDistReflection
:
public reflectionVectors,
public wallDistData<wallPointData<vector> >
{
// Private Member Functions
//- Disallow default bitwise copy construct
wallDistReflection(const wallDistReflection&);
//- Disallow default bitwise assignment
void operator=(const wallDistReflection&);
public:
// Constructors
//- 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.
wallDistReflection(const fvMesh& mesh, bool correctWalls = true);
// Member Functions
//- Correct for mesh geom/topo changes
void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -184,7 +184,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
)
),
yr_(mesh_),
n_(wallDist::New(mesh_).n()),
y_(wallDist::New(mesh_).y()),
R_
(
@ -373,11 +374,6 @@ void LaunderGibsonRSTM::correct()
RASModel::correct();
if (mesh_.changing())
{
yr_.correct();
}
volSymmTensorField P(-twoSymm(R_ & fvc::grad(U_)));
volScalarField G(GName(), 0.5*mag(tr(P)));
@ -443,10 +439,10 @@ void LaunderGibsonRSTM::correct()
// wall reflection terms
+ symm
(
I*((yr_.n() & reflect) & yr_.n())
- 1.5*(yr_.n()*(reflect & yr_.n())
+ (yr_.n() & reflect)*yr_.n())
)*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*yr_*epsilon_)
I*((n_ & reflect) & n_)
- 1.5*(n_*(reflect & n_)
+ (n_ & reflect)*n_)
)*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*y_*epsilon_)
);
REqn().relax();

View File

@ -60,7 +60,7 @@ SourceFiles
#define compressibleLaunderGibsonRSTM_H
#include "RASModel.H"
#include "wallDistReflection.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -109,7 +109,8 @@ protected:
// Fields
wallDistReflection yr_;
const volVectorField& n_;
const volScalarField& y_;
volSymmTensorField R_;
volScalarField k_;

View File

@ -25,7 +25,6 @@ License
#include "IDDESDelta.H"
#include "addToRunTimeSelectionTable.H"
#include "wallDistReflection.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,10 +42,8 @@ void Foam::IDDESDelta::calcDelta()
{
const volScalarField& hmax = hmax_();
// initialise wallNorm
wallDistReflection wallNorm(mesh());
const volVectorField& n = wallNorm.n();
// Wall-reflection vectors
const volVectorField& n = wallDist::New(mesh()).n();
tmp<volScalarField> tfaceToFacenMax
(

View File

@ -174,7 +174,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
)
),
yr_(mesh_),
n_(wallDist::New(mesh_).n()),
y_(wallDist::New(mesh_).y()),
R_
(
@ -380,11 +381,6 @@ void LaunderGibsonRSTM::correct()
return;
}
if (mesh_.changing())
{
yr_.correct();
}
volSymmTensorField P(-twoSymm(R_ & fvc::grad(U_)));
volScalarField G(GName(), 0.5*mag(tr(P)));
@ -450,10 +446,10 @@ void LaunderGibsonRSTM::correct()
// wall reflection terms
+ symm
(
I*((yr_.n() & reflect) & yr_.n())
- 1.5*(yr_.n()*(reflect & yr_.n())
+ (yr_.n() & reflect)*yr_.n())
)*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*yr_*epsilon_)
I*((n_ & reflect) & n_)
- 1.5*(n_*(reflect & n_)
+ (n_ & reflect)*n_)
)*pow(Cmu_, 0.75)*pow(k_, 1.5)/(kappa_*y_*epsilon_)
);
REqn().relax();

View File

@ -59,7 +59,7 @@ SourceFiles
#define LaunderGibsonRSTM_H
#include "RASModel.H"
#include "wallDistReflection.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -106,7 +106,8 @@ protected:
// Fields
wallDistReflection yr_;
const volVectorField& n_;
const volScalarField& y_;
volSymmTensorField R_;
volScalarField k_;