wallDist: separate the meshWaveWallDist from the wallDist interface

In preparation for run-time selectable methods
This commit is contained in:
Henry
2015-01-06 17:31:02 +00:00
parent 0a7ade60a3
commit 5085a9807b
22 changed files with 244 additions and 116 deletions

View File

@ -47,8 +47,6 @@ const Foam::volScalarField& Foam::wallDependentModel::yWall() const
{ {
if (!mesh_.foundObject<volScalarField>("yWall")) if (!mesh_.foundObject<volScalarField>("yWall"))
{ {
wallDist w(mesh_);
volScalarField* yPtr volScalarField* yPtr
( (
new volScalarField new volScalarField
@ -62,7 +60,7 @@ const Foam::volScalarField& Foam::wallDependentModel::yWall() const
IOobject::NO_WRITE, IOobject::NO_WRITE,
true true
), ),
w.y() wallDist(mesh_).y()
) )
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
if (timeI == 0 || state != fvMesh::UNCHANGED) if (timeI == 0 || state != fvMesh::UNCHANGED)
{ {
Info<< "Calculating wall distance\n" << endl; Info<< "Calculating wall distance\n" << endl;
wallDist y(mesh, true); wallDist y(mesh);
Info<< "Writing wall distance to field " Info<< "Writing wall distance to field "
<< y.name() << nl << endl; << y.name() << nl << endl;
y.write(); y.write();

View File

@ -208,7 +208,7 @@ int main(int argc, char *argv[])
if (timeI == 0 || state != fvMesh::UNCHANGED) if (timeI == 0 || state != fvMesh::UNCHANGED)
{ {
Info<< "Calculating wall distance\n" << endl; Info<< "Calculating wall distance\n" << endl;
wallDist y(mesh, true); wallDist y(mesh);
Info<< "Writing wall distance to field " << y.name() << nl << endl; Info<< "Writing wall distance to field " << y.name() << nl << endl;
y.write(); y.write();
} }

View File

@ -38,13 +38,14 @@ $(derivedFvPatches)/regionCoupled/regionCoupledWallFvPatch.C
wallDist = fvMesh/wallDist wallDist = fvMesh/wallDist
$(wallDist)/patchDist.C
$(wallDist)/wallPointYPlus/wallPointYPlus.C $(wallDist)/wallPointYPlus/wallPointYPlus.C
$(wallDist)/nearWallDistNoSearch.C $(wallDist)/nearWallDist/nearWallDistNoSearch.C
$(wallDist)/nearWallDist.C $(wallDist)/nearWallDist/nearWallDist.C
$(wallDist)/wallDist.C $(wallDist)/wallDist/wallDist.C
$(wallDist)/reflectionVectors.C $(wallDist)/meshWaveWallDist/patchDist.C
$(wallDist)/wallDistReflection.C $(wallDist)/meshWaveWallDist/meshWaveWallDist.C
$(wallDist)/wallDistReflection/reflectionVectors.C
$(wallDist)/wallDistReflection/wallDistReflection.C
fvMeshMapper = fvMesh/fvMeshMapper fvMeshMapper = fvMesh/fvMeshMapper

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,54 +37,58 @@ Foam::patchDist::patchDist
const bool correctWalls const bool correctWalls
) )
: :
volScalarField mesh_(mesh),
(
IOobject
(
"y",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("y", dimLength, GREAT)
),
patchIDs_(patchIDs), patchIDs_(patchIDs),
correctWalls_(correctWalls), correctWalls_(correctWalls),
nUnset_(0) nUnset_(0)
{
patchDist::correct();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchDist::~patchDist()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchDist::correct() Foam::tmp<Foam::volScalarField> Foam::patchDist::y() const
{ {
tmp<volScalarField> ty
(
new volScalarField
(
IOobject
(
"y",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("y", dimLength, GREAT)
)
);
volScalarField& y = ty();
// Calculate distance starting from patch faces // Calculate distance starting from patch faces
patchWave wave(mesh(), patchIDs_, correctWalls_); patchWave wave(mesh_, patchIDs_, correctWalls_);
// Transfer cell values from wave into *this // Transfer cell values from wave into *this
transfer(wave.distance()); y.transfer(wave.distance());
// Transfer values on patches into boundaryField of *this // Transfer values on patches into boundaryField of *this
forAll(boundaryField(), patchI) forAll(y.boundaryField(), patchI)
{ {
if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI])) if (!isA<emptyFvPatchScalarField>(y.boundaryField()[patchI]))
{ {
scalarField& waveFld = wave.patchDistance()[patchI]; scalarField& waveFld = wave.patchDistance()[patchI];
boundaryField()[patchI].transfer(waveFld); y.boundaryField()[patchI].transfer(waveFld);
} }
} }
// Transfer number of unset values // Transfer number of unset values
nUnset_ = wave.nUnset(); nUnset_ = wave.nUnset();
return ty;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,14 +25,12 @@ Class
Foam::patchDist Foam::patchDist
Description Description
Calculation of distance to nearest patch for all cells and boundary. Calculation of distance to nearest patch for all cells and boundary
Uses meshWave to do actual calculation. using meshWave.
Distance correction: Distance correction (correctWalls = true):
For each cell with face on wall calculate the true nearest point (by
if correctWalls = true: triangle decomposition) on that face and do the same for that face's
For each cell with face on wall calculate the true nearest point
(by triangle decomposition) on that face and do the same for that face's
pointNeighbours. This will find the true nearest distance in almost all pointNeighbours. This will find the true nearest distance in almost all
cases. Only very skewed cells or cells close to another wall might be cases. Only very skewed cells or cells close to another wall might be
missed. missed.
@ -40,19 +38,6 @@ Description
For each cell with only one point on wall the same is done except now it For each cell with only one point on wall the same is done except now it
takes the pointFaces() of the wall point to look for the nearest point. takes the pointFaces() of the wall point to look for the nearest point.
Note
correct() : for now does complete recalculation. (which usually is
ok since mesh is smoothed). However for topology change where geometry
in most of domain does not change you could think of starting from the
old cell values. Tried but not done since:
- meshWave would have to be called with old cellInfo.
This is List\<wallInfo\> of nCells.
- cannot construct from distance (y_) only since we don't know a value
for origin_. (origin_ = GREAT already used to denote illegal value.)
- so we would have to store a List\<wallInfo\> which unfortunately does
not get resized/mapped automatically upon mesh changes.
SourceFiles SourceFiles
patchDist.C patchDist.C
@ -75,23 +60,20 @@ class fvMesh;
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class patchDist class patchDist
:
public volScalarField
{ {
private:
// Private Member Data // Private Member Data
//- Reference to the mesh
const fvMesh& mesh_;
//- Set of patch IDs //- Set of patch IDs
labelHashSet patchIDs_; const labelHashSet patchIDs_;
//- Do accurate distance calculation for near-wall cells. //- Do accurate distance calculation for near-wall cells.
bool correctWalls_; const bool correctWalls_;
//- Number of unset cells and faces. //- Number of unset cells and faces.
label nUnset_; mutable label nUnset_;
// Private Member Functions // Private Member Functions
@ -118,24 +100,16 @@ public:
); );
//- Destructor
virtual ~patchDist();
// Member Functions // Member Functions
const volScalarField& y() const //- Calculate and return the distance to nearest patch
{ // for all cells and boundary
return *this; tmp<volScalarField> y() const;
}
label nUnset() const label nUnset() const
{ {
return nUnset_; return nUnset_;
} }
//- Correct for mesh geom/topo changes
virtual void correct();
}; };

View File

@ -24,24 +24,26 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "wallDist.H" #include "wallDist.H"
#include "fvMesh.H" #include "meshWaveWallDist.H"
#include "wallPolyPatch.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wallDist::wallDist Foam::wallDist::wallDist(const fvMesh& mesh)
(
const fvMesh& mesh,
const bool correctWalls
)
: :
patchDist volScalarField
( (
IOobject
(
"y",
mesh.time().timeName(),
mesh
),
mesh, mesh,
mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(), dimensionedScalar("y", dimLength, GREAT)
correctWalls
) )
{} {
correct();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -50,4 +52,12 @@ Foam::wallDist::~wallDist()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::wallDist::correct()
{
volScalarField::operator=(meshWaveWallDist(mesh()).y());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -35,26 +35,21 @@ SourceFiles
#ifndef wallDist_H #ifndef wallDist_H
#define wallDist_H #define wallDist_H
#include "patchDist.H" #include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
class fvMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class wallDist Declaration Class wallDist Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class wallDist class wallDist
: :
public patchDist public volScalarField
{ {
private:
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -68,18 +63,23 @@ public:
// Constructors // Constructors
//- Construct from mesh and flag whether or not to correct wall. //- Construct from mesh
// Calculate for all cells. correctWalls : correct wall (face&point) wallDist(const fvMesh& mesh);
// cells for correct distance, searching neighbours.
wallDist
(
const fvMesh& mesh,
const bool correctWalls = true
);
//- Destructor //- Destructor
virtual ~wallDist(); virtual ~wallDist();
// Member Functions
const volScalarField& y() const
{
return *this;
}
//- Correct for mesh changes
virtual void correct();
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,9 +60,6 @@ class wallPointYPlus
: :
public wallPointData<scalar> public wallPointData<scalar>
{ {
private:
// Private Member Functions // Private Member Functions
//- Evaluate distance to point. Update distSqr, origin from whomever //- Evaluate distance to point. Update distSqr, origin from whomever
@ -77,6 +74,7 @@ private:
TrackingData& td TrackingData& td
); );
public: public:
// Static data members // Static data members
@ -154,7 +152,6 @@ inline bool contiguous<wallPointYPlus>()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -68,7 +68,7 @@ void contactAngleForce::initialise()
patchDist dist(owner_.regionMesh(), patchIDs); patchDist dist(owner_.regionMesh(), patchIDs);
mask_ = pos(dist - dimensionedScalar("dLim", dimLength, dLim)); mask_ = pos(dist.y() - dimensionedScalar("dLim", dimLength, dLim));
} }
} }