nearWallDist, wallDist: Parallel consistentency and finer control
The near wall distances calculated for use in wall functions and the
corrections applied to near wall cells as part of the meshWave
wall/patch distance method have been made consistent across processor
and cyclic boundaries.
The extent to which these corrections are performed in the meshWave
method is now controllable by an nCorrectors entry. This defaults to 2,
which produces a result rougly equivalent to the previous correction
procedure. A higher level of correction could be specified as follows,
in system/fvSchemes:
wallDist
{
method meshWave;
nCorrectors 3;
}
Corrections replace basic cell-centre-face-centre distances with more
accurate cell-centre-face-polygon calculations in which all the points
and edges of the wall face are taken into account. The number of
correctors represents the number of layers of cells that these
corrections propagate into the mesh from the wall faces in question.
Note that correctors are expensive, and returns diminish as the number
of corrections increase, as the error in the basic calculation reduces
with distance from the wall faces. It is unlikely that more than 2 or
3 correctors would ever be warranted. Indeed, this control is
potentially more useful in reducing the number of corrections to 1 or 0
in order to reduce the computational expense in dynamic mesh cases where
distances are being constantly recomputed.
This commit is contained in:
@ -26,7 +26,7 @@ License
|
||||
#include "vanDriestDelta.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "fvWallPointYPlus.H"
|
||||
#include "FvWallInfoYPlus.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -51,11 +51,11 @@ void Foam::LESModels::vanDriestDelta::calcDelta()
|
||||
const volScalarField& nu = tnu();
|
||||
tmp<volScalarField> nuSgs = momentumTransportModel_.nut();
|
||||
|
||||
volScalarField ystar
|
||||
volScalarField yStar
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"ystar",
|
||||
"yStar",
|
||||
mesh.time().constant(),
|
||||
mesh
|
||||
),
|
||||
@ -64,7 +64,7 @@ void Foam::LESModels::vanDriestDelta::calcDelta()
|
||||
);
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
volScalarField::Boundary& ystarBf = ystar.boundaryFieldRef();
|
||||
volScalarField::Boundary& yStarBf = yStar.boundaryFieldRef();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
@ -74,32 +74,33 @@ void Foam::LESModels::vanDriestDelta::calcDelta()
|
||||
const scalarField& nuw = nu.boundaryField()[patchi];
|
||||
const scalarField& nuSgsw = nuSgs().boundaryField()[patchi];
|
||||
|
||||
ystarBf[patchi] =
|
||||
yStarBf[patchi] =
|
||||
nuw/sqrt((nuw + nuSgsw)*mag(Uw.snGrad()) + vSmall);
|
||||
}
|
||||
}
|
||||
|
||||
fvWallPointYPlus::trackData td;
|
||||
td.yPlusCutOff = yPlusCutOff_;
|
||||
volScalarField y
|
||||
(
|
||||
volScalarField::New("y", mesh, dimensionedScalar(dimLength, great))
|
||||
);
|
||||
fvPatchDistWave::wave<fvWallPointYPlus, fvWallPointYPlus::trackData>
|
||||
|
||||
FvWallInfoYPlus<wallPoint>::trackData td;
|
||||
td.yPlusCutOff = yPlusCutOff_;
|
||||
|
||||
fvPatchDistWave::calculateAndCorrect<FvWallInfoYPlus>
|
||||
(
|
||||
mesh,
|
||||
mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(),
|
||||
ystar.boundaryField(),
|
||||
2, // <-- roughly equivalent to old point-cell corrections
|
||||
y,
|
||||
ystar,
|
||||
true,
|
||||
yStar,
|
||||
td
|
||||
);
|
||||
|
||||
delta_ = min
|
||||
(
|
||||
static_cast<const volScalarField&>(geometricDelta_()),
|
||||
(kappa_/Cdelta_)*((scalar(1) + small) - exp(-y/ystar/Aplus_))*y
|
||||
(kappa_/Cdelta_)*((scalar(1) + small) - exp(-y/yStar/Aplus_))*y
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ $(meshWave)/FvFaceCellWaveName.C
|
||||
|
||||
|
||||
wallDist = fvMesh/wallDist
|
||||
$(wallDist)/fvPatchDistWave/fvPatchDistWave.C
|
||||
$(wallDist)/nearWallDist/nearWallDist.C
|
||||
$(wallDist)/wallDist/wallDist.C
|
||||
$(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C
|
||||
|
||||
@ -22,22 +22,22 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::fvWallPoint
|
||||
Foam::FvWallInfo
|
||||
|
||||
Description
|
||||
Holds information regarding nearest wall point. Used in wall distance
|
||||
calculation.
|
||||
|
||||
SourceFiles
|
||||
fvWallPointI.H
|
||||
fvWallPoint.C
|
||||
FvWallInfoI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvWallPoint_H
|
||||
#define fvWallPoint_H
|
||||
#ifndef FvWallInfo_H
|
||||
#define FvWallInfo_H
|
||||
|
||||
#include "wallPoint.H"
|
||||
#include "wallFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,21 +49,21 @@ class fvPatch;
|
||||
class fvMesh;
|
||||
class transformer;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvWallPoint Declaration
|
||||
Class FvWallInfoBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fvWallPoint
|
||||
template<class WallInfo, class Derived>
|
||||
class FvWallInfoBase
|
||||
:
|
||||
public wallPoint
|
||||
public WallInfo::template type<Derived>
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Inherit constructors
|
||||
using wallPoint::wallPoint;
|
||||
using WallInfo::template type<Derived>::type;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -87,7 +87,7 @@ public:
|
||||
const fvMesh&,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPoint& neighbourInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -99,7 +99,7 @@ public:
|
||||
const fvMesh&,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPoint& neighbourInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -110,19 +110,27 @@ public:
|
||||
(
|
||||
const fvMesh&,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPoint& neighbourInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FvWallInfo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Data associated with fvWallPoint type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<fvWallPoint>()
|
||||
template<class WallInfo>
|
||||
class FvWallInfo
|
||||
:
|
||||
public FvWallInfoBase<WallInfo, FvWallInfo<WallInfo>>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
|
||||
using
|
||||
FvWallInfoBase<WallInfo, FvWallInfo<WallInfo>>::
|
||||
FvWallInfoBase;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -131,7 +139,7 @@ inline bool contiguous<fvWallPoint>()
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "fvWallPointI.H"
|
||||
#include "FvWallInfoI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
208
src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H
Normal file
208
src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H
Normal file
@ -0,0 +1,208 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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::FvWallInfoData
|
||||
|
||||
Description
|
||||
Holds information (coordinate and normal) regarding nearest wall point.
|
||||
|
||||
Is like FvWallInfo but transfer extra (passive) data.
|
||||
Used e.g. in wall distance calculation with wall reflection vectors.
|
||||
|
||||
SourceFiles
|
||||
FvWallInfoDataI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FvWallInfoData_H
|
||||
#define FvWallInfoData_H
|
||||
|
||||
#include "FvWallInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
class FvWallInfoDataBase;
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream&,
|
||||
FvWallInfoDataBase<WallInfo, Type, Derived>&
|
||||
);
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const FvWallInfoDataBase<WallInfo, Type, Derived>&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FvWallInfoDataBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
class FvWallInfoDataBase
|
||||
:
|
||||
public FvWallInfoBase<WallInfo, Derived>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Data at nearest wall center
|
||||
Type data_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Evaluate distance to point. Update distSqr, origin from whomever
|
||||
// is nearer pt. Return true if w2 is closer to point.
|
||||
template<class TrackingData>
|
||||
inline bool update
|
||||
(
|
||||
const point&,
|
||||
const FvWallInfoDataBase<WallInfo, Type, Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class FvWallInfoBase<WallInfo, Derived>;
|
||||
|
||||
|
||||
typedef Type dataType;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline FvWallInfoDataBase();
|
||||
|
||||
//- Construct from data and other geometry
|
||||
template<class ... Geometry>
|
||||
inline FvWallInfoDataBase
|
||||
(
|
||||
const Type& data,
|
||||
const Geometry& ... geometry
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const Type& data() const;
|
||||
|
||||
inline Type& data();
|
||||
|
||||
template<class TrackingData>
|
||||
inline const Type& data(TrackingData& td) const;
|
||||
|
||||
|
||||
// Needed by meshWave
|
||||
|
||||
//- Transform across an interface
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const fvPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <WallInfo, Type, Derived>
|
||||
(
|
||||
Ostream&,
|
||||
const FvWallInfoDataBase<WallInfo, Type, Derived>&
|
||||
);
|
||||
|
||||
friend Istream& operator>> <WallInfo, Type, Derived>
|
||||
(
|
||||
Istream&,
|
||||
FvWallInfoDataBase<WallInfo, Type, Derived>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FvWallInfoData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class WallInfo, class Type>
|
||||
class FvWallInfoData
|
||||
:
|
||||
public FvWallInfoDataBase<WallInfo, Type, FvWallInfoData<WallInfo, Type>>
|
||||
{
|
||||
public:
|
||||
|
||||
using
|
||||
FvWallInfoDataBase<WallInfo, Type, FvWallInfoData<WallInfo, Type>>::
|
||||
FvWallInfoDataBase;
|
||||
};
|
||||
|
||||
|
||||
#define DefineFvWallInfoType(Type, nullArg) \
|
||||
\
|
||||
template<class WallInfo> \
|
||||
using CAT(FvWallInfo, CAPITALIZE(Type)) = FvWallInfoData<WallInfo, Type>; \
|
||||
\
|
||||
template<> \
|
||||
inline bool contiguous<CAT(FvWallInfo, CAPITALIZE(Type))<wallPoint>>() \
|
||||
{ \
|
||||
return contiguous<FvWallInfo<wallPoint>>(); \
|
||||
}
|
||||
|
||||
DefineFvWallInfoType(bool, nullArg)
|
||||
DefineFvWallInfoType(label, nullArg)
|
||||
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType);
|
||||
|
||||
#undef DefineFvWallInfoType
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "FvWallInfoDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
153
src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H
Normal file
153
src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H
Normal file
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "FvWallInfoData.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::update
|
||||
(
|
||||
const point& pt,
|
||||
const FvWallInfoDataBase<WallInfo, Type, Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const bool result =
|
||||
FvWallInfoBase<WallInfo, Derived>::update(pt, w2, tol, td);
|
||||
|
||||
if (result)
|
||||
{
|
||||
data_ = w2.data();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
inline Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::FvWallInfoDataBase()
|
||||
:
|
||||
FvWallInfoBase<WallInfo, Derived>(),
|
||||
data_()
|
||||
{}
|
||||
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
template<class ... Geometry>
|
||||
inline Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::FvWallInfoDataBase
|
||||
(
|
||||
const Type& data,
|
||||
const Geometry& ... geometry
|
||||
)
|
||||
:
|
||||
FvWallInfoBase<WallInfo, Derived>(geometry ...),
|
||||
data_(data)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
inline const Type&
|
||||
Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
inline Type&
|
||||
Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
template<class TrackingData>
|
||||
inline const Type&
|
||||
Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::data(TrackingData& td) const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
template<class TrackingData>
|
||||
inline void Foam::FvWallInfoDataBase<WallInfo, Type, Derived>::transform
|
||||
(
|
||||
const fvPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
FvWallInfoBase<WallInfo, Derived>::transform
|
||||
(
|
||||
patch,
|
||||
patchFacei,
|
||||
transform,
|
||||
td
|
||||
);
|
||||
|
||||
data_ = transform.transform(data_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const FvWallInfoDataBase<WallInfo, Type, Derived>& w
|
||||
)
|
||||
{
|
||||
return os
|
||||
<< static_cast<const FvWallInfoBase<WallInfo, Derived>&>(w)
|
||||
<< token::SPACE
|
||||
<< w.data();
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Type, class Derived>
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
FvWallInfoDataBase<WallInfo, Type, Derived>& w
|
||||
)
|
||||
{
|
||||
return is
|
||||
>> static_cast<FvWallInfoBase<WallInfo, Derived>&>(w)
|
||||
>> w.data_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,15 +23,16 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvWallPoint.H"
|
||||
#include "FvWallInfo.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Derived>
|
||||
template<class TrackingData>
|
||||
inline void Foam::fvWallPoint::transform
|
||||
inline void Foam::FvWallInfoBase<WallInfo, Derived>::transform
|
||||
(
|
||||
const fvPatch& patch,
|
||||
const label patchFacei,
|
||||
@ -39,39 +40,47 @@ inline void Foam::fvWallPoint::transform
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
wallPoint::transform(patch.patch(), patchFacei, transform, td);
|
||||
WallInfo::template type<Derived>::transform
|
||||
(
|
||||
patch.patch(),
|
||||
patchFacei,
|
||||
transform,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::fvWallPoint::updateCell
|
||||
inline bool Foam::FvWallInfoBase<WallInfo, Derived>::updateCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPoint& neighbourWallInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
this->update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.C()[thisCelli],
|
||||
neighbourWallInfo,
|
||||
static_cast<const Derived&>(neighbourWallInfo),
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::fvWallPoint::updateFace
|
||||
inline bool Foam::FvWallInfoBase<WallInfo, Derived>::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPoint& neighbourWallInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
@ -80,24 +89,25 @@ inline bool Foam::fvWallPoint::updateFace
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return
|
||||
this->update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
static_cast<const Derived&>(neighbourWallInfo),
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class WallInfo, class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::fvWallPoint::updateFace
|
||||
inline bool Foam::FvWallInfoBase<WallInfo, Derived>::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPoint& neighbourWallInfo,
|
||||
const FvWallInfoBase<WallInfo, Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
@ -106,12 +116,12 @@ inline bool Foam::fvWallPoint::updateFace
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return
|
||||
this->update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
static_cast<const Derived&>(neighbourWallInfo),
|
||||
tol,
|
||||
td
|
||||
);
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::fvWallPointYPlus
|
||||
Foam::FvWallInfoYPlus
|
||||
|
||||
Description
|
||||
Holds information (coordinate and yStar) regarding nearest wall point.
|
||||
@ -32,33 +32,29 @@ Description
|
||||
the damping function becomes 1, since y gets initialised to great and
|
||||
yStar to 1.
|
||||
|
||||
Note: should feed the additional argument (yPlusCutoff) through as a
|
||||
template argument into FvFaceCellWave
|
||||
|
||||
SourceFiles
|
||||
fvWallPointYPlusI.H
|
||||
fvWallPointYPlus.C
|
||||
FvWallInfoYPlusI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvWallPointYPlus_H
|
||||
#define fvWallPointYPlus_H
|
||||
#ifndef FvWallInfoYPlus_H
|
||||
#define FvWallInfoYPlus_H
|
||||
|
||||
#include "fvWallPointData.H"
|
||||
#include "FvWallInfoData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvWallPointYPlus Declaration
|
||||
Class FvWallInfoYPlusBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fvWallPointYPlus
|
||||
template<class WallInfo, class Derived>
|
||||
class FvWallInfoYPlusBase
|
||||
:
|
||||
public fvWallPointData<scalar>
|
||||
public FvWallInfoDataBase<WallInfo, scalar, Derived>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -72,9 +68,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
// Private Member Functions
|
||||
friend class FvWallInfoBase<WallInfo, Derived>;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Evaluate distance to point. Update distSqr, origin from whomever
|
||||
// is nearer pt. Return true if w2 is closer to point,
|
||||
@ -83,7 +82,7 @@ private:
|
||||
inline bool update
|
||||
(
|
||||
const point& pt,
|
||||
const fvWallPointYPlus& w2,
|
||||
const FvWallInfoYPlusBase<WallInfo, Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -94,68 +93,28 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline fvWallPointYPlus();
|
||||
inline FvWallInfoYPlusBase();
|
||||
|
||||
//- Construct from origin, yStar, distance
|
||||
inline fvWallPointYPlus
|
||||
(
|
||||
const point& origin,
|
||||
const scalar yStar,
|
||||
const scalar distSqr
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Needed by FvFaceCellWave
|
||||
|
||||
//- Influence of neighbouring face.
|
||||
// Calls update(...) with cellCentre of celli
|
||||
template<class TrackingData>
|
||||
inline bool updateCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell.
|
||||
// Calls update(...) with faceCentre of facei
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same face.
|
||||
// Merge new and old info.
|
||||
// Calls update(...) with faceCentre of facei
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
//- Inherit constructors
|
||||
using FvWallInfoDataBase<WallInfo, scalar, Derived>::FvWallInfoDataBase;
|
||||
};
|
||||
|
||||
|
||||
//- Data associated with pointEdgePoint type as contiguous as underlying type
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointYPlus>()
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FvWallInfoYPlus Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class WallInfo>
|
||||
class FvWallInfoYPlus
|
||||
:
|
||||
public FvWallInfoYPlusBase<WallInfo, FvWallInfoYPlus<WallInfo>>
|
||||
{
|
||||
return contiguous<fvWallPointData<scalar>>();
|
||||
}
|
||||
public:
|
||||
|
||||
using
|
||||
FvWallInfoYPlusBase<WallInfo, FvWallInfoYPlus<WallInfo>>::
|
||||
FvWallInfoYPlusBase;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -164,7 +123,7 @@ inline bool contiguous<fvWallPointYPlus>()
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "fvWallPointYPlusI.H"
|
||||
#include "FvWallInfoYPlusI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -23,18 +23,50 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "wallPoint.H"
|
||||
#include "FvWallInfoYPlus.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::wallPoint& wDist)
|
||||
template<class WallInfo, class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::FvWallInfoYPlusBase<WallInfo, Derived>::update
|
||||
(
|
||||
const point& pt,
|
||||
const FvWallInfoYPlusBase<WallInfo, Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return os << wDist.origin() << token::SPACE << wDist.distSqr();
|
||||
FvWallInfoYPlusBase<WallInfo, Derived> copy(*this);
|
||||
|
||||
bool result =
|
||||
FvWallInfoDataBase<WallInfo, scalar, Derived>::update(pt, w2, tol, td);
|
||||
|
||||
if (result)
|
||||
{
|
||||
const scalar yPlus = sqrt(this->distSqr())/w2.data();
|
||||
|
||||
if (yPlus >= td.yPlusCutOff)
|
||||
{
|
||||
*this = copy;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::wallPoint& wDist)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class WallInfo, class Derived>
|
||||
inline Foam::FvWallInfoYPlusBase<WallInfo, Derived>::FvWallInfoYPlusBase()
|
||||
:
|
||||
FvWallInfoDataBase<WallInfo, scalar, Derived>()
|
||||
{
|
||||
return is >> wDist.origin() >> wDist.distSqr();
|
||||
// Important: The value of yStar where the meshWave does not come.
|
||||
this->data() = 1.0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,42 +23,39 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvWallPointData.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
Foam::List<Foam::labelPair> Foam::fvPatchDistWave::getChangedPatchAndFaces
|
||||
(
|
||||
Ostream& os,
|
||||
const fvWallPointData<Type>& wDist
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs
|
||||
)
|
||||
{
|
||||
return os
|
||||
<< static_cast<const fvWallPoint&>(wDist)
|
||||
<< token::SPACE
|
||||
<< wDist.data();
|
||||
}
|
||||
label nChangedFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
nChangedFaces += mesh.boundary()[iter.key()].size();
|
||||
}
|
||||
|
||||
List<labelPair> changedPatchAndFaces(nChangedFaces);
|
||||
label changedFacei = 0;
|
||||
|
||||
template<class Type>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream& is,
|
||||
fvWallPointData<Type>& wDist
|
||||
)
|
||||
{
|
||||
return is >> static_cast<fvWallPoint&>(wDist) >> wDist.data_;
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
const fvPatch& patch = mesh.boundary()[patchi];
|
||||
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
changedPatchAndFaces[changedFacei] = labelPair(patchi, patchFacei);
|
||||
changedFacei++;
|
||||
}
|
||||
}
|
||||
|
||||
return changedPatchAndFaces;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -38,6 +38,8 @@ SourceFiles
|
||||
|
||||
#include "FvFaceCellWave.H"
|
||||
#include "volFields.H"
|
||||
#include "wallPoint.H"
|
||||
#include "wallFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,74 +50,126 @@ namespace fvPatchDistWave
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Set initial set of changed faces
|
||||
template<class PatchPointType, class ... InitialPatchData>
|
||||
void setChangedFaces
|
||||
//- Get initial set of changed faces
|
||||
List<labelPair> getChangedPatchAndFaces
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
List<labelPair>& changedPatchAndFaces,
|
||||
List<PatchPointType>& faceDist,
|
||||
const InitialPatchData& ... initialPatchData
|
||||
const labelHashSet& patchIDs
|
||||
);
|
||||
|
||||
//- Copy FvFaceCellWave values into the cell fields
|
||||
//- Wave distance (and maybe additional) data from faces. If nCorrections is
|
||||
// negative (-1) then the wave propagates through the entire mesh and all
|
||||
// values are calculated. If nCorrections is positive, then this many wave
|
||||
// steps are computed and the result is corrected only on cells and faces that
|
||||
// the wave reaches. Don't use this directly. Use
|
||||
// calculate/correct/calculateAndCorrect functions below.
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class WallInfo,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class ... DataType
|
||||
>
|
||||
label getCellValues
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>& waveInfo,
|
||||
Field<DataType>& cellValues,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue = pTraits<DataType>::zero
|
||||
);
|
||||
|
||||
//- Copy FvFaceCellWave values into the patch field-fields
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
>
|
||||
label getPatchValues
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>& wave,
|
||||
GeometricBoundaryField<DataType, fvPatchField, volMesh>& valuesBf,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue = pTraits<DataType>::zero
|
||||
);
|
||||
|
||||
//- Wave distance data from the patches to the cells and other patch faces
|
||||
template<class PatchPointType, class TrackingData = int>
|
||||
label wave
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
volScalarField& distance,
|
||||
bool correct = true,
|
||||
TrackingData& td = FvFaceCellWave<PatchPointType>::defaultTrackingData_
|
||||
const List<labelPair>& changedPatchAndFaces,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
TrackingData& td,
|
||||
GeometricField<DataType, PatchField, GeoMesh>& ... data
|
||||
);
|
||||
|
||||
//- Wave distance and auxiliary data from the patches to the cells and other
|
||||
// patch faces
|
||||
template<class PatchPointType, class TrackingData = int>
|
||||
label wave
|
||||
//- Calculate distance data from patches
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
label calculate
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const GeometricBoundaryField
|
||||
<typename PatchPointType::dataType, fvPatchField, volMesh>&
|
||||
initialPatchData,
|
||||
volScalarField& distance,
|
||||
VolField<typename PatchPointType::dataType>& data,
|
||||
bool correct = true,
|
||||
TrackingData& td = FvFaceCellWave<PatchPointType>::defaultTrackingData_
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
);
|
||||
|
||||
//- Correct distance data from patches
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
void correct
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
);
|
||||
|
||||
//- Calculate and correct distance data from patches
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
label calculateAndCorrect
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
);
|
||||
|
||||
//- Calculate distance and additional data from patches
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData = int
|
||||
>
|
||||
label calculate
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td =
|
||||
FvFaceCellWave<WallInfoData<wallPoint>>::defaultTrackingData_
|
||||
);
|
||||
|
||||
//- Correct distance and additional data from patches
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData = int
|
||||
>
|
||||
void correct
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td =
|
||||
FvFaceCellWave<WallInfoData<wallPoint>>::defaultTrackingData_
|
||||
);
|
||||
|
||||
//- Calculate and correct distance and additional data from patches
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData = int
|
||||
>
|
||||
label calculateAndCorrect
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td =
|
||||
FvFaceCellWave<WallInfoData<wallPoint>>::defaultTrackingData_
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -24,319 +24,353 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "patchDistFuncs.H"
|
||||
#include "FvWallInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class PatchPointType, class ... InitialPatchData>
|
||||
void Foam::fvPatchDistWave::setChangedFaces
|
||||
namespace Foam
|
||||
{
|
||||
namespace fvPatchDistWave
|
||||
{
|
||||
|
||||
template<class WallInfo, class TrackingData>
|
||||
const List<WallInfo>& getInternalInfo
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
List<labelPair>& changedPatchAndFaces,
|
||||
List<PatchPointType>& changedFacesInfo,
|
||||
const InitialPatchData& ... initialPatchData
|
||||
const volScalarField& distance,
|
||||
FvFaceCellWave<WallInfo, TrackingData>& wave
|
||||
)
|
||||
{
|
||||
label nChangedFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
nChangedFaces += mesh.boundary()[iter.key()].size();
|
||||
}
|
||||
|
||||
changedPatchAndFaces.resize(nChangedFaces);
|
||||
changedFacesInfo.resize(nChangedFaces);
|
||||
|
||||
label changedFacei = 0;
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
|
||||
const fvPatch& patch = mesh.boundary()[patchi];
|
||||
|
||||
forAll(patch.Cf(), patchFacei)
|
||||
{
|
||||
changedPatchAndFaces[changedFacei] = {patchi, patchFacei};
|
||||
|
||||
changedFacesInfo[changedFacei] =
|
||||
PatchPointType
|
||||
(
|
||||
patch.Cf()[patchFacei],
|
||||
initialPatchData[patchi][patchFacei] ...,
|
||||
scalar(0)
|
||||
);
|
||||
|
||||
changedFacei++;
|
||||
}
|
||||
}
|
||||
return wave.cellInfo();
|
||||
}
|
||||
|
||||
template<class WallInfo, class TrackingData>
|
||||
const List<WallInfo>& getInternalInfo
|
||||
(
|
||||
const surfaceScalarField& distance,
|
||||
FvFaceCellWave<WallInfo, TrackingData>& wave
|
||||
)
|
||||
{
|
||||
return wave.internalFaceInfo();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class WallInfo,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class ... DataType
|
||||
>
|
||||
Foam::label Foam::fvPatchDistWave::getCellValues
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>& waveInfo,
|
||||
Field<DataType>& cellValues,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue
|
||||
)
|
||||
{
|
||||
const List<PatchPointType>& cellInfo = waveInfo.cellInfo();
|
||||
|
||||
label nInvalid = 0;
|
||||
|
||||
forAll(cellInfo, celli)
|
||||
{
|
||||
cellValues[celli] =
|
||||
(cellInfo[celli].*method)(waveInfo.data())
|
||||
+ stabiliseValue;
|
||||
|
||||
nInvalid += !cellInfo[celli].valid(waveInfo.data());
|
||||
}
|
||||
|
||||
return nInvalid;
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
>
|
||||
Foam::label Foam::fvPatchDistWave::getPatchValues
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>& waveInfo,
|
||||
GeometricBoundaryField<DataType, fvPatchField, volMesh>& valuesBf,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue
|
||||
)
|
||||
{
|
||||
const List<List<PatchPointType>>& patchFaceInfo = waveInfo.patchFaceInfo();
|
||||
|
||||
label nInvalid = 0;
|
||||
|
||||
forAll(valuesBf, patchi)
|
||||
{
|
||||
forAll(valuesBf[patchi], patchFacei)
|
||||
{
|
||||
valuesBf[patchi][patchFacei] =
|
||||
(patchFaceInfo[patchi][patchFacei].*method)(waveInfo.data())
|
||||
+ stabiliseValue;
|
||||
|
||||
nInvalid +=
|
||||
!patchFaceInfo[patchi][patchFacei].valid(waveInfo.data());
|
||||
}
|
||||
}
|
||||
|
||||
return nInvalid;
|
||||
}
|
||||
|
||||
|
||||
template<class PatchPointType, class TrackingData>
|
||||
Foam::label Foam::fvPatchDistWave::wave
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
volScalarField& distance,
|
||||
const bool correct,
|
||||
TrackingData& td
|
||||
const List<labelPair>& changedPatchAndFaces,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
TrackingData& td,
|
||||
GeometricField<DataType, PatchField, GeoMesh>& ... data
|
||||
)
|
||||
{
|
||||
// If the number of corrections is less than 0 (i.e., -1) then this is a
|
||||
// calculation across the entire mesh. Otherwise it is a correction for the
|
||||
// cells/faces near the changed faces.
|
||||
const bool calculate = nCorrections < 0;
|
||||
|
||||
// Quick return if no corrections
|
||||
if (!calculate && nCorrections == 0) return 0;
|
||||
|
||||
// Initialise changedFacesInfo to face centres on patches
|
||||
List<labelPair> changedPatchAndFaces;
|
||||
List<PatchPointType> changedFacesInfo;
|
||||
setChangedFaces
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
changedPatchAndFaces,
|
||||
changedFacesInfo
|
||||
);
|
||||
List<WallInfo> changedFacesInfo(changedPatchAndFaces.size());
|
||||
forAll(changedPatchAndFaces, changedFacei)
|
||||
{
|
||||
const label patchi =
|
||||
changedPatchAndFaces[changedFacei].first();
|
||||
const label patchFacei =
|
||||
changedPatchAndFaces[changedFacei].second();
|
||||
|
||||
changedFacesInfo[changedFacei] =
|
||||
WallInfo
|
||||
(
|
||||
data.boundaryField()[patchi][patchFacei] ...,
|
||||
mesh.boundaryMesh()[patchi][patchFacei],
|
||||
mesh.points(),
|
||||
mesh.Cf().boundaryField()[patchi][patchFacei],
|
||||
scalar(0)
|
||||
);
|
||||
}
|
||||
|
||||
// Do calculate patch distance by 'growing' from faces.
|
||||
List<PatchPointType> internalFaceInfo(mesh.nInternalFaces());
|
||||
List<List<PatchPointType>> patchFaceInfo
|
||||
List<WallInfo> internalFaceInfo(mesh.nInternalFaces());
|
||||
List<List<WallInfo>> patchFaceInfo
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>::template
|
||||
sizesListList<List<List<PatchPointType>>>
|
||||
FvFaceCellWave<WallInfo, TrackingData>::template
|
||||
sizesListList<List<List<WallInfo>>>
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>::template
|
||||
FvFaceCellWave<WallInfo, TrackingData>::template
|
||||
listListSizes(mesh.boundary()),
|
||||
PatchPointType()
|
||||
WallInfo()
|
||||
)
|
||||
);
|
||||
List<PatchPointType> cellInfo(mesh.nCells());
|
||||
FvFaceCellWave<PatchPointType, TrackingData> wave
|
||||
List<WallInfo> cellInfo(mesh.nCells());
|
||||
|
||||
// Do the wave
|
||||
FvFaceCellWave<WallInfo, TrackingData> wave
|
||||
(
|
||||
mesh,
|
||||
changedPatchAndFaces,
|
||||
changedFacesInfo,
|
||||
internalFaceInfo,
|
||||
patchFaceInfo,
|
||||
cellInfo,
|
||||
mesh.globalData().nTotalCells() + 1, // max iterations
|
||||
td
|
||||
);
|
||||
|
||||
// Copy distance into return field
|
||||
const label nUnset =
|
||||
getCellValues
|
||||
(
|
||||
wave,
|
||||
distance.primitiveFieldRef(),
|
||||
&PatchPointType::template dist<int>
|
||||
)
|
||||
+ getPatchValues
|
||||
(
|
||||
wave,
|
||||
distance.boundaryFieldRef(),
|
||||
&PatchPointType::template dist<int>,
|
||||
small
|
||||
);
|
||||
|
||||
// Correct patch cells for true distance
|
||||
if (correct)
|
||||
wave.setFaceInfo(changedPatchAndFaces, changedFacesInfo);
|
||||
if (calculate)
|
||||
{
|
||||
Map<labelPair> nearestFace(2*changedFacesInfo.size());
|
||||
patchDistFuncs::correctBoundaryFaceCells
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
distance.primitiveFieldRef(),
|
||||
nearestFace
|
||||
);
|
||||
patchDistFuncs::correctBoundaryPointCells
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
distance.primitiveFieldRef(),
|
||||
nearestFace
|
||||
);
|
||||
// Calculation. Wave to completion.
|
||||
wave.iterate(mesh.globalData().nTotalCells() + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Correction. Wave the specified number of times then stop. We care
|
||||
// about cell values, so avoid the final cellToFace by doing n - 1
|
||||
// iterations than a final faceToCell.
|
||||
wave.iterate(nCorrections - 1);
|
||||
wave.faceToCell();
|
||||
}
|
||||
|
||||
// Copy distances into field
|
||||
const List<WallInfo>& internalInfo = getInternalInfo(distance, wave);
|
||||
label nUnset = 0;
|
||||
forAll(internalInfo, internali)
|
||||
{
|
||||
const bool valid = internalInfo[internali].valid(td);
|
||||
|
||||
if (calculate || valid)
|
||||
{
|
||||
nUnset += !valid;
|
||||
|
||||
distance.primitiveFieldRef()[internali] =
|
||||
internalInfo[internali].dist(td);
|
||||
|
||||
std::initializer_list<nil>
|
||||
{(
|
||||
data.primitiveFieldRef()[internali] =
|
||||
internalInfo[internali].data(td),
|
||||
nil()
|
||||
) ... };
|
||||
}
|
||||
}
|
||||
forAll(patchFaceInfo, patchi)
|
||||
{
|
||||
forAll(patchFaceInfo[patchi], patchFacei)
|
||||
{
|
||||
const bool valid = patchFaceInfo[patchi][patchFacei].valid(td);
|
||||
|
||||
if (calculate || valid)
|
||||
{
|
||||
nUnset += !valid;
|
||||
|
||||
distance.boundaryFieldRef()[patchi][patchFacei] =
|
||||
patchFaceInfo[patchi][patchFacei].dist(td) + small;
|
||||
|
||||
std::initializer_list<nil>
|
||||
{(
|
||||
data.boundaryFieldRef()[patchi][patchFacei] =
|
||||
patchFaceInfo[patchi][patchFacei].data(td),
|
||||
nil()
|
||||
) ... };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nUnset;
|
||||
}
|
||||
|
||||
|
||||
template<class PatchPointType, class TrackingData>
|
||||
Foam::label Foam::fvPatchDistWave::wave
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
Foam::label Foam::fvPatchDistWave::calculate
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const GeometricBoundaryField
|
||||
<typename PatchPointType::dataType, fvPatchField, volMesh>&
|
||||
initialPatchData,
|
||||
volScalarField& distance,
|
||||
VolField<typename PatchPointType::dataType>& data,
|
||||
const bool correct,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
)
|
||||
{
|
||||
return
|
||||
wave<FvWallInfo<wallPoint>>
|
||||
(
|
||||
mesh,
|
||||
getChangedPatchAndFaces(mesh, patchIDs),
|
||||
-1,
|
||||
distance,
|
||||
FvFaceCellWave<FvWallInfo<wallPoint>>::defaultTrackingData_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
void Foam::fvPatchDistWave::correct
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
)
|
||||
{
|
||||
wave<FvWallInfo<wallFace>>
|
||||
(
|
||||
mesh,
|
||||
getChangedPatchAndFaces(mesh, patchIDs),
|
||||
nCorrections,
|
||||
distance,
|
||||
FvFaceCellWave<FvWallInfo<wallFace>>::defaultTrackingData_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class PatchField, class GeoMesh>
|
||||
Foam::label Foam::fvPatchDistWave::calculateAndCorrect
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance
|
||||
)
|
||||
{
|
||||
const List<labelPair> changedPatchAndFaces =
|
||||
getChangedPatchAndFaces(mesh, patchIDs);
|
||||
|
||||
const label nUnset =
|
||||
wave<FvWallInfo<wallPoint>>
|
||||
(
|
||||
mesh,
|
||||
changedPatchAndFaces,
|
||||
-1,
|
||||
distance,
|
||||
FvFaceCellWave<FvWallInfo<wallPoint>>::defaultTrackingData_
|
||||
);
|
||||
|
||||
wave<FvWallInfo<wallFace>>
|
||||
(
|
||||
mesh,
|
||||
changedPatchAndFaces,
|
||||
nCorrections,
|
||||
distance,
|
||||
FvFaceCellWave<FvWallInfo<wallFace>>::defaultTrackingData_
|
||||
);
|
||||
|
||||
return nUnset;
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData
|
||||
>
|
||||
Foam::label Foam::fvPatchDistWave::calculate
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
// Initialise changedFacesInfo to face centres on patches
|
||||
List<labelPair> changedPatchAndFaces;
|
||||
List<PatchPointType> changedFacesInfo;
|
||||
setChangedFaces
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
changedPatchAndFaces,
|
||||
changedFacesInfo,
|
||||
initialPatchData
|
||||
);
|
||||
|
||||
// Do calculate patch distance by 'growing' from faces.
|
||||
List<PatchPointType> internalFaceInfo(mesh.nInternalFaces());
|
||||
List<List<PatchPointType>> patchFaceInfo
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>::template
|
||||
sizesListList<List<List<PatchPointType>>>
|
||||
return
|
||||
wave<WallInfoData<wallPoint>, TrackingData>
|
||||
(
|
||||
FvFaceCellWave<PatchPointType, TrackingData>::template
|
||||
listListSizes(mesh.boundary()),
|
||||
PatchPointType()
|
||||
)
|
||||
);
|
||||
List<PatchPointType> cellInfo(mesh.nCells());
|
||||
FvFaceCellWave<PatchPointType, TrackingData> wave
|
||||
mesh,
|
||||
getChangedPatchAndFaces(mesh, patchIDs),
|
||||
-1,
|
||||
distance,
|
||||
td,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData
|
||||
>
|
||||
void Foam::fvPatchDistWave::correct
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
wave<WallInfoData<wallFace>, TrackingData>
|
||||
(
|
||||
mesh,
|
||||
changedPatchAndFaces,
|
||||
changedFacesInfo,
|
||||
internalFaceInfo,
|
||||
patchFaceInfo,
|
||||
cellInfo,
|
||||
mesh.globalData().nTotalCells() + 1, // max iterations
|
||||
td
|
||||
getChangedPatchAndFaces(mesh, patchIDs),
|
||||
nCorrections,
|
||||
distance,
|
||||
td,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
template<class> class WallInfoData,
|
||||
template<class> class PatchField,
|
||||
class GeoMesh,
|
||||
class TrackingData
|
||||
>
|
||||
Foam::label Foam::fvPatchDistWave::calculateAndCorrect
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const label nCorrections,
|
||||
GeometricField<scalar, PatchField, GeoMesh>& distance,
|
||||
GeometricField
|
||||
<typename WallInfoData<wallPoint>::dataType, PatchField, GeoMesh>&
|
||||
data,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const List<labelPair> changedPatchAndFaces =
|
||||
getChangedPatchAndFaces(mesh, patchIDs);
|
||||
|
||||
// Copy distance into return field
|
||||
const label nUnset =
|
||||
getCellValues
|
||||
(
|
||||
wave,
|
||||
distance.primitiveFieldRef(),
|
||||
&PatchPointType::template dist<TrackingData>
|
||||
)
|
||||
+ getPatchValues
|
||||
(
|
||||
wave,
|
||||
distance.boundaryFieldRef(),
|
||||
&PatchPointType::template dist<TrackingData>,
|
||||
small
|
||||
);
|
||||
|
||||
// Copy data into the return field
|
||||
getCellValues
|
||||
(
|
||||
wave,
|
||||
data.primitiveFieldRef(),
|
||||
&PatchPointType::template data<TrackingData>
|
||||
);
|
||||
getPatchValues
|
||||
(
|
||||
wave,
|
||||
data.boundaryFieldRef(),
|
||||
&PatchPointType::template data<TrackingData>
|
||||
);
|
||||
|
||||
// Correct patch cells for true distance
|
||||
if (correct)
|
||||
{
|
||||
Map<labelPair> nearestPatchAndFace(2*changedFacesInfo.size());
|
||||
patchDistFuncs::correctBoundaryFaceCells
|
||||
wave<WallInfoData<wallPoint>, TrackingData>
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
distance.primitiveFieldRef(),
|
||||
nearestPatchAndFace
|
||||
);
|
||||
patchDistFuncs::correctBoundaryPointCells
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
distance.primitiveFieldRef(),
|
||||
nearestPatchAndFace
|
||||
getChangedPatchAndFaces(mesh, patchIDs),
|
||||
-1,
|
||||
distance,
|
||||
td,
|
||||
data
|
||||
);
|
||||
|
||||
// Transfer data from nearest face to cell
|
||||
forAllConstIter(Map<labelPair>, nearestPatchAndFace, iter)
|
||||
{
|
||||
const label celli = iter.key();
|
||||
const label patchi = iter().first();
|
||||
const label patchFacei = iter().second();
|
||||
data.primitiveFieldRef()[celli] =
|
||||
wave.patchFaceInfo()[patchi][patchFacei].data();
|
||||
}
|
||||
}
|
||||
wave<WallInfoData<wallFace>, TrackingData>
|
||||
(
|
||||
mesh,
|
||||
changedPatchAndFaces,
|
||||
nCorrections,
|
||||
distance,
|
||||
td,
|
||||
data
|
||||
);
|
||||
|
||||
return nUnset;
|
||||
}
|
||||
|
||||
@ -1,248 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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::fvWallPointData
|
||||
|
||||
Description
|
||||
Holds information (coordinate and normal) regarding nearest wall point.
|
||||
|
||||
Is like fvWallPoint but transfer extra (passive) data.
|
||||
Used e.g. in wall distance calculation with wall reflection vectors.
|
||||
|
||||
SourceFiles
|
||||
fvWallPointDataI.H
|
||||
fvWallPointData.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvWallPointData_H
|
||||
#define fvWallPointData_H
|
||||
|
||||
#include "fvWallPoint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type> class fvWallPointData;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
template<class Type>
|
||||
Istream& operator>>(Istream&, fvWallPointData<Type>&);
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const fvWallPointData<Type>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvWallPointData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fvWallPointData
|
||||
:
|
||||
public fvWallPoint
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Data at nearest wall center
|
||||
Type data_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Evaluate distance to point. Update distSqr, origin from whomever
|
||||
// is nearer pt. Return true if w2 is closer to point,
|
||||
// false otherwise.
|
||||
template<class TrackingData>
|
||||
inline bool update
|
||||
(
|
||||
const point&,
|
||||
const fvWallPointData<Type>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef Type dataType;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline fvWallPointData();
|
||||
|
||||
//- Construct from origin, normal, distance
|
||||
inline fvWallPointData
|
||||
(
|
||||
const point& origin,
|
||||
const Type& data,
|
||||
const scalar distSqr
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const Type& data() const;
|
||||
|
||||
inline Type& data();
|
||||
|
||||
template<class TrackingData>
|
||||
inline const Type& data(TrackingData& td) const;
|
||||
|
||||
|
||||
// Needed by meshWave
|
||||
|
||||
//- Transform across an interface
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const fvPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring face.
|
||||
// Calls update(...) with cellCentre of celli
|
||||
template<class TrackingData>
|
||||
inline bool updateCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell.
|
||||
// Calls update(...) with faceCentre of facei
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same face.
|
||||
// Merge new and old info.
|
||||
// Calls update(...) with faceCentre of facei
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream&,
|
||||
const fvWallPointData<Type>&
|
||||
);
|
||||
|
||||
friend Istream& operator>> <Type>
|
||||
(
|
||||
Istream&,
|
||||
fvWallPointData<Type>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
//- Data associated with fvWallPointData type are contiguous. List the usual
|
||||
// ones.
|
||||
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<bool>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<label>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<scalar>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<vector>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<sphericalTensor>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<symmTensor>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
template<>
|
||||
inline bool contiguous<fvWallPointData<tensor>>()
|
||||
{
|
||||
return contiguous<fvWallPoint>();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fvWallPointData.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "fvWallPointDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,217 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "fvWallPointData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointData<Type>::update
|
||||
(
|
||||
const point& pt,
|
||||
const fvWallPointData<Type>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
scalar dist2 = magSqr(pt - w2.origin());
|
||||
|
||||
if (valid(td))
|
||||
{
|
||||
scalar diff = distSqr() - dist2;
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Either *this is not yet valid or w2 is closer
|
||||
{
|
||||
// current not yet set so use any value
|
||||
distSqr() = dist2;
|
||||
origin() = w2.origin();
|
||||
data_ = w2.data();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline fvWallPointData<Type>::fvWallPointData()
|
||||
:
|
||||
fvWallPoint(),
|
||||
data_()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline fvWallPointData<Type>::fvWallPointData
|
||||
(
|
||||
const point& origin,
|
||||
const Type& data,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
fvWallPoint(origin, distSqr),
|
||||
data_(data)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline const Type& fvWallPointData<Type>::data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type& fvWallPointData<Type>::data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline const Type& fvWallPointData<Type>::data(TrackingData& td) const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline void Foam::fvWallPointData<Type>::transform
|
||||
(
|
||||
const fvPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
fvWallPoint::transform(patch, patchFacei, transform, td);
|
||||
data_ = transform.transform(data_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointData<Type>::updateCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return update
|
||||
(
|
||||
mesh.C()[thisCelli],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointData<Type>::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const label thisPatchi = thisPatchAndFacei.first();
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointData<Type>::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const label thisPatchi = thisPatchAndFacei.first();
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,187 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "fvWallPointYPlus.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointYPlus::update
|
||||
(
|
||||
const point& pt,
|
||||
const fvWallPointYPlus& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
scalar dist2 = magSqr(pt - w2.origin());
|
||||
|
||||
if (valid(td))
|
||||
{
|
||||
scalar diff = distSqr() - dist2;
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Either *this is not yet valid or w2 is closer
|
||||
{
|
||||
// only propagate if interesting (i.e. y+ < 100)
|
||||
scalar yPlus = Foam::sqrt(dist2)/w2.data();
|
||||
|
||||
if (yPlus < td.yPlusCutOff)
|
||||
{
|
||||
// update with new values
|
||||
distSqr() = dist2;
|
||||
origin() = w2.origin();
|
||||
data() = w2.data();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline fvWallPointYPlus::fvWallPointYPlus()
|
||||
:
|
||||
fvWallPointData<scalar>()
|
||||
{
|
||||
// Important: The value of yStar where the meshWave does not come.
|
||||
data() = 1.0;
|
||||
}
|
||||
|
||||
|
||||
inline fvWallPointYPlus::fvWallPointYPlus
|
||||
(
|
||||
const point& origin,
|
||||
const scalar yStar,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
fvWallPointData<scalar>(origin, yStar, distSqr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointYPlus::updateCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const label thisCelli,
|
||||
const labelPair& neighbourPatchAndFacei,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return update
|
||||
(
|
||||
mesh.C()[thisCelli],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointYPlus::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const label neighbourCelli,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const label thisPatchi = thisPatchAndFacei.first();
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool fvWallPointYPlus::updateFace
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelPair& thisPatchAndFacei,
|
||||
const fvWallPointYPlus& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const label thisPatchi = thisPatchAndFacei.first();
|
||||
const label thisFacei = thisPatchAndFacei.second();
|
||||
|
||||
return update
|
||||
(
|
||||
thisPatchi == -1
|
||||
? mesh.Cf()[thisFacei]
|
||||
: mesh.Cf().boundaryField()[thisPatchi][thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nearWallDist.H"
|
||||
#include "patchDistFuncs.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "wallPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -39,12 +39,24 @@ namespace Foam
|
||||
|
||||
void Foam::nearWallDist::correct()
|
||||
{
|
||||
patchDistFuncs::correctBoundaryFaceFaceCells
|
||||
volScalarField yVf(volScalarField::New("y", mesh(), dimLength));
|
||||
|
||||
fvPatchDistWave::correct
|
||||
(
|
||||
mesh(),
|
||||
mesh().boundaryMesh().findPatchIDs<wallPolyPatch>(),
|
||||
y_
|
||||
2,
|
||||
yVf
|
||||
);
|
||||
|
||||
forAll(y_, patchi)
|
||||
{
|
||||
const labelUList& faceCells = mesh().boundary()[patchi].faceCells();
|
||||
forAll(y_[patchi], patchFacei)
|
||||
{
|
||||
y_[patchi][patchFacei] = yVf[faceCells[patchFacei]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "fvWallPointData.H"
|
||||
#include "FvWallInfoData.H"
|
||||
#include "emptyFvPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -52,7 +52,7 @@ Foam::patchDistMethods::meshWave::meshWave
|
||||
)
|
||||
:
|
||||
patchDistMethod(mesh, patchIDs),
|
||||
correctWalls_(dict.lookupOrDefault<Switch>("correctWalls", true))
|
||||
nCorrectors_(dict.lookupOrDefault<label>("nCorrectors", 2))
|
||||
{}
|
||||
|
||||
|
||||
@ -60,11 +60,11 @@ Foam::patchDistMethods::meshWave::meshWave
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const bool correctWalls
|
||||
const label nCorrectors
|
||||
)
|
||||
:
|
||||
patchDistMethod(mesh, patchIDs),
|
||||
correctWalls_(correctWalls)
|
||||
nCorrectors_(nCorrectors)
|
||||
{}
|
||||
|
||||
|
||||
@ -75,12 +75,12 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y)
|
||||
y = dimensionedScalar(dimLength, great);
|
||||
|
||||
const label nUnset =
|
||||
fvPatchDistWave::wave<fvWallPoint>
|
||||
fvPatchDistWave::calculateAndCorrect
|
||||
(
|
||||
mesh_,
|
||||
patchIDs_,
|
||||
y,
|
||||
correctWalls_
|
||||
nCorrectors_,
|
||||
y
|
||||
);
|
||||
|
||||
// Update coupled and transform BCs
|
||||
@ -99,14 +99,13 @@ bool Foam::patchDistMethods::meshWave::correct
|
||||
y = dimensionedScalar(dimLength, great);
|
||||
|
||||
const label nUnset =
|
||||
fvPatchDistWave::wave<fvWallPointData<vector>>
|
||||
fvPatchDistWave::calculateAndCorrect<FvWallInfoVector>
|
||||
(
|
||||
mesh_,
|
||||
patchIDs_,
|
||||
n.boundaryField(),
|
||||
nCorrectors_,
|
||||
y,
|
||||
n,
|
||||
correctWalls_
|
||||
n
|
||||
);
|
||||
|
||||
// Update coupled and transform BCs
|
||||
|
||||
@ -31,8 +31,8 @@ Description
|
||||
For regular/un-distorted meshes this method is accurate but for skewed,
|
||||
non-orthogonal meshes it is approximate with the error increasing with the
|
||||
degree of mesh distortion. The distance from the near-wall cells to the
|
||||
boundary may optionally be corrected for mesh distortion by setting
|
||||
correctWalls = true.
|
||||
boundary may optionally be corrected for mesh distortion by setting a
|
||||
number of correction iterations.
|
||||
|
||||
Example of the wallDist specification in fvSchemes:
|
||||
\verbatim
|
||||
@ -40,6 +40,9 @@ Description
|
||||
{
|
||||
method meshWave;
|
||||
|
||||
// Number of corrections
|
||||
nCorrectors 3;
|
||||
|
||||
// Optional entry enabling the calculation
|
||||
// of the normal-to-wall field
|
||||
nRequired false;
|
||||
@ -78,7 +81,7 @@ class meshWave
|
||||
// Private Member Data
|
||||
|
||||
//- Do accurate distance calculation for near-wall cells.
|
||||
const bool correctWalls_;
|
||||
const label nCorrectors_;
|
||||
|
||||
|
||||
public:
|
||||
@ -98,15 +101,13 @@ public:
|
||||
const labelHashSet& patchIDs
|
||||
);
|
||||
|
||||
//- Construct from mesh, fixed-value patch set and flag specifying
|
||||
// whether or not to correct wall.
|
||||
// Calculate for all cells. correctWalls : correct wall (face&point)
|
||||
// cells for correct distance, searching neighbours.
|
||||
//- Construct from mesh, fixed-value patch set, and number of wall
|
||||
// correction iterations
|
||||
meshWave
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const bool correctWalls = true
|
||||
const label nCorrectors = 2
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "inverseDistanceDiffusivity.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "fvWallPoint.H"
|
||||
#include "HashSet.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
@ -85,12 +84,11 @@ Foam::inverseDistanceDiffusivity::operator()() const
|
||||
|
||||
if (patchNames_.size())
|
||||
{
|
||||
fvPatchDistWave::wave<fvWallPoint>
|
||||
fvPatchDistWave::calculate
|
||||
(
|
||||
mesh(),
|
||||
mesh().boundaryMesh().patchSet(patchNames_),
|
||||
y,
|
||||
false
|
||||
y
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -25,8 +25,7 @@ License
|
||||
|
||||
#include "inverseFaceDistanceDiffusivity.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "FvFaceCellWave.H"
|
||||
#include "fvWallPoint.H"
|
||||
#include "fvPatchDistWave.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -68,112 +67,51 @@ Foam::inverseFaceDistanceDiffusivity::~inverseFaceDistanceDiffusivity()
|
||||
Foam::tmp<Foam::surfaceScalarField>
|
||||
Foam::inverseFaceDistanceDiffusivity::operator()() const
|
||||
{
|
||||
surfaceScalarField y
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"y",
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
),
|
||||
mesh(),
|
||||
dimensionedScalar(dimless, 1)
|
||||
);
|
||||
|
||||
const labelHashSet patchIDs(mesh().boundaryMesh().patchSet(patchNames_));
|
||||
|
||||
const surfaceVectorField::Boundary& CfBf = mesh().Cf().boundaryField();
|
||||
|
||||
// Create changed face information
|
||||
List<labelPair> changedPatchAndFaces;
|
||||
List<fvWallPoint> changedFacesInfo;
|
||||
if (patchNames_.size())
|
||||
{
|
||||
label changedFacei = 0;
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
changedFacei += mesh().boundary()[patchi].size();
|
||||
}
|
||||
fvPatchDistWave::calculate
|
||||
(
|
||||
mesh(),
|
||||
patchIDs,
|
||||
y
|
||||
);
|
||||
|
||||
changedPatchAndFaces.resize(changedFacei);
|
||||
changedFacesInfo.resize(changedFacei);
|
||||
|
||||
changedFacei = 0;
|
||||
// Use cell distance on faces that are part of the patch set. This
|
||||
// avoids divide-by-zero issues.
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
|
||||
forAll(mesh().boundary()[patchi], patchFacei)
|
||||
const labelUList& patchCells =
|
||||
mesh().boundary()[patchi].faceCells();
|
||||
|
||||
forAll(patchCells, patchFacei)
|
||||
{
|
||||
changedPatchAndFaces[changedFacei] =
|
||||
labelPair(patchi, patchFacei);
|
||||
changedFacesInfo[changedFacei] =
|
||||
fvWallPoint(CfBf[patchi][patchFacei], 0);
|
||||
|
||||
changedFacei ++;
|
||||
y.boundaryFieldRef()[patchi][patchFacei] =
|
||||
mag
|
||||
(
|
||||
mesh().Cf().boundaryField()[patchi][patchFacei]
|
||||
- mesh().C()[patchCells[patchFacei]]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise wave storage
|
||||
List<fvWallPoint> internalFaceInfo(mesh().nInternalFaces());
|
||||
List<List<fvWallPoint>> patchFaceInfo
|
||||
(
|
||||
FvFaceCellWave<fvWallPoint>::template
|
||||
sizesListList<List<List<fvWallPoint>>>
|
||||
(
|
||||
FvFaceCellWave<fvWallPoint>::template
|
||||
listListSizes(mesh().boundary()),
|
||||
fvWallPoint()
|
||||
)
|
||||
);
|
||||
List<fvWallPoint> cellInfo(mesh().nCells());
|
||||
|
||||
// Wave through the mesh
|
||||
FvFaceCellWave<fvWallPoint> wave
|
||||
(
|
||||
mesh(),
|
||||
changedPatchAndFaces,
|
||||
changedFacesInfo,
|
||||
internalFaceInfo,
|
||||
patchFaceInfo,
|
||||
cellInfo,
|
||||
mesh().globalData().nTotalCells() + 1 // max iterations
|
||||
);
|
||||
|
||||
// Create the diffusivity field
|
||||
tmp<surfaceScalarField> tfaceDiffusivity
|
||||
(
|
||||
new surfaceScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faceDiffusivity",
|
||||
mesh().time().timeName(),
|
||||
mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh(),
|
||||
dimensionedScalar(dimless, 1.0)
|
||||
)
|
||||
);
|
||||
surfaceScalarField& faceDiffusivity = tfaceDiffusivity.ref();
|
||||
|
||||
// Convert waved distance data into diffusivities
|
||||
forAll(internalFaceInfo, facei)
|
||||
{
|
||||
const scalar dist = internalFaceInfo[facei].dist(wave.data());
|
||||
faceDiffusivity[facei] = 1/dist;
|
||||
}
|
||||
forAll(patchFaceInfo, patchi)
|
||||
{
|
||||
// Use cell distance on faces that are part of the patch set. This
|
||||
// avoids divide-by-zero issues.
|
||||
const bool useCellDist = patchIDs.found(patchi);
|
||||
|
||||
const labelUList& patchCells = mesh().boundary()[patchi].faceCells();
|
||||
|
||||
forAll(patchFaceInfo[patchi], patchFacei)
|
||||
{
|
||||
const scalar dist =
|
||||
useCellDist
|
||||
? cellInfo[patchCells[patchFacei]].dist(wave.data())
|
||||
: patchFaceInfo[patchi][patchFacei].dist(wave.data());
|
||||
|
||||
faceDiffusivity.boundaryFieldRef()[patchi][patchFacei] = 1/dist;
|
||||
}
|
||||
}
|
||||
|
||||
return tfaceDiffusivity;
|
||||
return surfaceScalarField::New("faceDiffusivity", 1/y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,8 +44,7 @@ cellClassification/cellInfo.C
|
||||
|
||||
cellQuality/cellQuality.C
|
||||
|
||||
patchDist/patchDistFuncs/patchDistFuncs.C
|
||||
patchDist/wallPoint/wallPoint.C
|
||||
patchDist/patchDistWave/patchDistWave.C
|
||||
|
||||
cellFeatures/cellFeatures.C
|
||||
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "patchDistFuncs.H"
|
||||
#include "polyMesh.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "polyBoundaryMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Foam::patchDistFuncs::NoMap<Foam::labelPair>
|
||||
Foam::patchDistFuncs::NoMap<Foam::labelPair>::null =
|
||||
Foam::patchDistFuncs::NoMap<Foam::labelPair>();
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::patchDistFuncs::smallestDist
|
||||
(
|
||||
const point& p,
|
||||
const polyPatch& patch,
|
||||
const labelUList& wallFaces,
|
||||
label& minPatchFacei
|
||||
)
|
||||
{
|
||||
const pointField& points = patch.points();
|
||||
|
||||
scalar minDist = great;
|
||||
minPatchFacei = -1;
|
||||
|
||||
forAll(wallFaces, wallFacei)
|
||||
{
|
||||
const label patchFacei = wallFaces[wallFacei];
|
||||
|
||||
pointHit curHit = patch[patchFacei].nearestPoint(p, points);
|
||||
|
||||
if (curHit.distance() < minDist)
|
||||
{
|
||||
minDist = curHit.distance();
|
||||
minPatchFacei = patchFacei;
|
||||
}
|
||||
}
|
||||
|
||||
return minDist;
|
||||
}
|
||||
|
||||
|
||||
void Foam::patchDistFuncs::getPointNeighbours
|
||||
(
|
||||
const primitivePatch& patch,
|
||||
const label patchFacei,
|
||||
DynamicList<label>& neighbours
|
||||
)
|
||||
{
|
||||
neighbours.clear();
|
||||
|
||||
// Add myself
|
||||
neighbours.append(patchFacei);
|
||||
|
||||
// Add all face neighbours
|
||||
const labelList& faceNeighbours = patch.faceFaces()[patchFacei];
|
||||
forAll(faceNeighbours, faceNeighbourI)
|
||||
{
|
||||
neighbours.append(faceNeighbours[faceNeighbourI]);
|
||||
}
|
||||
|
||||
// Remember part of neighbours that contains edge-connected faces.
|
||||
const label nEdgeNbs = neighbours.size();
|
||||
|
||||
// Add all point-only neighbours by linear searching in edge neighbours.
|
||||
// Assumes that point-only neighbours are not using multiple points on
|
||||
// face.
|
||||
const face& f = patch.localFaces()[patchFacei];
|
||||
forAll(f, fp)
|
||||
{
|
||||
const label pointi = f[fp];
|
||||
|
||||
const labelList& pointNbs = patch.pointFaces()[pointi];
|
||||
|
||||
forAll(pointNbs, nbI)
|
||||
{
|
||||
const label facei = pointNbs[nbI];
|
||||
|
||||
// Check for facei in edge-neighbours part of neighbours
|
||||
if (findIndex(SubList<label>(neighbours, nEdgeNbs), facei) == -1)
|
||||
{
|
||||
neighbours.append(facei);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::patchDistFuncs::maxPatchSize
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs
|
||||
)
|
||||
{
|
||||
label maxSize = 0;
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
maxSize = Foam::max(maxSize, mesh.boundaryMesh()[iter.key()].size());
|
||||
}
|
||||
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,155 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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::patchDistFuncs
|
||||
|
||||
Description
|
||||
Collection of functions used in patch distance calculation.
|
||||
|
||||
SourceFiles
|
||||
patchDistFuncs.C
|
||||
patchDistFuncsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchDistFuncs_H
|
||||
#define patchDistFuncs_H
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "HashSet.H"
|
||||
#include "Map.H"
|
||||
#include "wordReList.H"
|
||||
#include "scalarField.H"
|
||||
#include "FieldField.H"
|
||||
#include "point.H"
|
||||
#include "labelPair.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "className.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
class polyPatch;
|
||||
class polyBoundaryMesh;
|
||||
|
||||
namespace patchDistFuncs
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
struct NoMap
|
||||
{
|
||||
inline bool insert(const label, const Type&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool found(const label)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static NoMap<Type> null;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Calculate smallest true distance (and face index) from pt to faces
|
||||
// wallFaces.
|
||||
scalar smallestDist
|
||||
(
|
||||
const point& p,
|
||||
const polyPatch& patch,
|
||||
const labelUList& wallFaces,
|
||||
label& patchFacei
|
||||
);
|
||||
|
||||
// Get point neighbours of patchFacei (including patchFacei). Note: Uses a
|
||||
// linear search to determine uniqueness. For polygonal faces this might be
|
||||
// quite inefficient.
|
||||
void getPointNeighbours
|
||||
(
|
||||
const primitivePatch&,
|
||||
const label patchFacei,
|
||||
DynamicList<label>& neighbours
|
||||
);
|
||||
|
||||
//- Size of largest patch (out of supplied subset of patches)
|
||||
label maxPatchSize(const polyMesh& mesh, const labelHashSet& patchIDs);
|
||||
|
||||
//- Correct all cells connected to boundary (via face). Sets values in
|
||||
// wallDistCorrected. Sets nearest wallFace in nearestPatchAndFace.
|
||||
template<template<class> class MapType=NoMap>
|
||||
void correctBoundaryFaceCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace = NoMap<labelPair>::null
|
||||
);
|
||||
|
||||
//- Correct all face-cells connected to boundary. Sets values in
|
||||
// wallDistCorrected. Sets nearest wallFace in nearestPatchAndFace.
|
||||
template<template<class> class PatchField, template<class> class MapType=NoMap>
|
||||
void correctBoundaryFaceFaceCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
FieldField<PatchField, scalar>& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace = NoMap<labelPair>::null
|
||||
);
|
||||
|
||||
//- Correct all cells connected to wall (via point). Sets values in
|
||||
// wallDistCorrected. Uses/sets nearest wallFace in nearestPatchAndFace.
|
||||
template<template<class> class MapType=NoMap>
|
||||
void correctBoundaryPointCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace = NoMap<labelPair>::null
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace patchDistFuncs
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "patchDistFuncsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,196 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "patchDistFuncs.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<template<class> class MapType>
|
||||
void Foam::patchDistFuncs::correctBoundaryFaceCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace
|
||||
)
|
||||
{
|
||||
// Size neighbours array for maximum possible (= size of largest patch)
|
||||
DynamicList<label> neighbours(maxPatchSize(mesh, patchIDs));
|
||||
|
||||
// Correct all cells with face on wall
|
||||
const vectorField& cellCentres = mesh.cellCentres();
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
// Check cells with face on wall
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
const label celli = patch.faceCells()[patchFacei];
|
||||
|
||||
getPointNeighbours
|
||||
(
|
||||
patch,
|
||||
patchFacei,
|
||||
neighbours
|
||||
);
|
||||
|
||||
label minPatchFacei = -1;
|
||||
|
||||
wallDistCorrected[celli] =
|
||||
smallestDist
|
||||
(
|
||||
cellCentres[celli],
|
||||
patch,
|
||||
neighbours,
|
||||
minPatchFacei
|
||||
);
|
||||
|
||||
// Store wallCell and its nearest neighbour
|
||||
nearestPatchAndFace.insert
|
||||
(
|
||||
celli,
|
||||
labelPair(patchi, minPatchFacei)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class PatchField, template<class> class MapType>
|
||||
void Foam::patchDistFuncs::correctBoundaryFaceFaceCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
FieldField<PatchField, scalar>& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace
|
||||
)
|
||||
{
|
||||
// Size neighbours array for maximum possible (= size of largest patch)
|
||||
DynamicList<label> neighbours(maxPatchSize(mesh, patchIDs));
|
||||
|
||||
// Correct all faces on a wall
|
||||
const vectorField& cellCentres = mesh.cellCentres();
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
// Check cells with face on wall
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
const label celli = patch.faceCells()[patchFacei];
|
||||
|
||||
getPointNeighbours
|
||||
(
|
||||
patch,
|
||||
patchFacei,
|
||||
neighbours
|
||||
);
|
||||
|
||||
label minPatchFacei = -1;
|
||||
|
||||
wallDistCorrected[patchi][patchFacei] =
|
||||
smallestDist
|
||||
(
|
||||
cellCentres[celli],
|
||||
patch,
|
||||
neighbours,
|
||||
minPatchFacei
|
||||
);
|
||||
|
||||
// Store wallCell and its nearest neighbour
|
||||
nearestPatchAndFace.insert
|
||||
(
|
||||
celli,
|
||||
labelPair(patchi, minPatchFacei)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class MapType>
|
||||
void Foam::patchDistFuncs::correctBoundaryPointCells
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& wallDistCorrected,
|
||||
MapType<labelPair>& nearestPatchAndFace
|
||||
)
|
||||
{
|
||||
// Correct all (non-visited) cells with point on wall
|
||||
const vectorField& cellCentres = mesh.cellCentres();
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const label patchi = iter.key();
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
const labelList& meshPoints = patch.meshPoints();
|
||||
const labelListList& pointFaces = patch.pointFaces();
|
||||
|
||||
forAll(meshPoints, meshPointi)
|
||||
{
|
||||
const labelList& neighbours =
|
||||
mesh.pointCells(meshPoints[meshPointi]);
|
||||
|
||||
forAll(neighbours, neighbourI)
|
||||
{
|
||||
const label celli = neighbours[neighbourI];
|
||||
|
||||
if (!nearestPatchAndFace.found(celli))
|
||||
{
|
||||
const labelList& wallFaces = pointFaces[meshPointi];
|
||||
|
||||
label minPatchFacei = -1;
|
||||
|
||||
wallDistCorrected[celli] =
|
||||
smallestDist
|
||||
(
|
||||
cellCentres[celli],
|
||||
patch,
|
||||
wallFaces,
|
||||
minPatchFacei
|
||||
);
|
||||
|
||||
// Store wallCell and its nearest neighbour
|
||||
nearestPatchAndFace.insert
|
||||
(
|
||||
celli,
|
||||
labelPair(patchi, minPatchFacei)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,18 +24,15 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "patchDistWave.H"
|
||||
#include "patchDistFuncs.H"
|
||||
#include "FaceCellWave.H"
|
||||
#include "wallPoint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class PatchPointType, class ... InitialPatchData>
|
||||
void Foam::patchDistWave::setChangedFaces
|
||||
Foam::labelList Foam::patchDistWave::getChangedFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
List<PatchPointType>& changedFacesInfo,
|
||||
const InitialPatchData& ... initialPatchData
|
||||
const labelHashSet& patchIDs
|
||||
)
|
||||
{
|
||||
label nChangedFaces = 0;
|
||||
@ -44,9 +41,7 @@ void Foam::patchDistWave::setChangedFaces
|
||||
nChangedFaces += mesh.boundaryMesh()[iter.key()].size();
|
||||
}
|
||||
|
||||
changedFaces.resize(nChangedFaces);
|
||||
changedFacesInfo.resize(nChangedFaces);
|
||||
|
||||
labelList changedFaces(nChangedFaces);
|
||||
label changedFacei = 0;
|
||||
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
@ -61,117 +56,65 @@ void Foam::patchDistWave::setChangedFaces
|
||||
|
||||
changedFaces[changedFacei] = meshFacei;
|
||||
|
||||
changedFacesInfo[changedFacei] =
|
||||
PatchPointType
|
||||
(
|
||||
patch.faceCentres()[patchFacei],
|
||||
initialPatchData[patchi][patchFacei] ...,
|
||||
scalar(0)
|
||||
);
|
||||
|
||||
changedFacei++;
|
||||
}
|
||||
}
|
||||
|
||||
return changedFaces;
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
>
|
||||
Foam::label Foam::patchDistWave::getCellValues
|
||||
(
|
||||
FaceCellWave<PatchPointType, TrackingData>& waveInfo,
|
||||
Field<DataType>& cellValues,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue
|
||||
)
|
||||
{
|
||||
const List<PatchPointType>& cellInfo = waveInfo.allCellInfo();
|
||||
|
||||
label nInvalid = 0;
|
||||
|
||||
forAll(cellInfo, celli)
|
||||
{
|
||||
cellValues[celli] =
|
||||
(cellInfo[celli].*method)(waveInfo.data())
|
||||
+ stabiliseValue;
|
||||
|
||||
nInvalid += !cellInfo[celli].valid(waveInfo.data());
|
||||
}
|
||||
|
||||
return nInvalid;
|
||||
}
|
||||
|
||||
|
||||
template<class PatchPointType, class TrackingData>
|
||||
Foam::label Foam::patchDistWave::wave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& cellDistance,
|
||||
const bool correct,
|
||||
TrackingData& td
|
||||
const labelList& changedFaces,
|
||||
scalarField& cellDistance
|
||||
)
|
||||
{
|
||||
// Initialise changedFacesInfo to face centres on patches
|
||||
List<PatchPointType> changedFacesInfo;
|
||||
labelList changedFaces;
|
||||
setChangedFaces
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
changedFaces,
|
||||
changedFacesInfo
|
||||
);
|
||||
List<wallPoint> changedFacesInfo;
|
||||
forAll(changedFaces, changedFacei)
|
||||
{
|
||||
const label facei = changedFaces[changedFacei];
|
||||
|
||||
changedFacesInfo[changedFacei] =
|
||||
wallPoint(mesh.faceCentres()[facei], scalar(0));
|
||||
}
|
||||
|
||||
// Do calculate patch distance by 'growing' from faces.
|
||||
List<PatchPointType> faceInfo(mesh.nFaces()), cellInfo(mesh.nCells());
|
||||
FaceCellWave<PatchPointType, TrackingData> wave
|
||||
List<wallPoint> faceInfo(mesh.nFaces()), cellInfo(mesh.nCells());
|
||||
FaceCellWave<wallPoint> wave
|
||||
(
|
||||
mesh,
|
||||
changedFaces,
|
||||
changedFacesInfo,
|
||||
faceInfo,
|
||||
cellInfo,
|
||||
mesh.globalData().nTotalCells() + 1, // max iterations
|
||||
td
|
||||
mesh.globalData().nTotalCells() + 1 // max iterations
|
||||
);
|
||||
|
||||
// Copy distance into return field
|
||||
const label nUnset =
|
||||
getCellValues
|
||||
(
|
||||
wave,
|
||||
cellDistance,
|
||||
&PatchPointType::template dist<TrackingData>
|
||||
);
|
||||
|
||||
// Correct patch cells for true distance
|
||||
if (correct)
|
||||
// Copy distances into field
|
||||
label nUnset = 0;
|
||||
forAll(cellInfo, celli)
|
||||
{
|
||||
Map<labelPair> nearestFace(2*changedFacesInfo.size());
|
||||
patchDistFuncs::correctBoundaryFaceCells
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
cellDistance,
|
||||
nearestFace
|
||||
);
|
||||
patchDistFuncs::correctBoundaryPointCells
|
||||
(
|
||||
mesh,
|
||||
patchIDs,
|
||||
cellDistance,
|
||||
nearestFace
|
||||
);
|
||||
nUnset += !cellInfo[celli].valid(wave.data());
|
||||
|
||||
cellDistance[celli] = cellInfo[celli].dist(wave.data());
|
||||
}
|
||||
|
||||
return nUnset;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::patchDistWave::calculate
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& cellDistance
|
||||
)
|
||||
{
|
||||
return wave(mesh, getChangedFaces(mesh, patchIDs), cellDistance);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -37,10 +37,6 @@ SourceFiles
|
||||
#define patchDistWave_H
|
||||
|
||||
#include "polyMesh.H"
|
||||
#include "FaceCellWave.H"
|
||||
#include "Field.H"
|
||||
#include "FieldField.H"
|
||||
#include "UPtrList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,42 +47,27 @@ namespace patchDistWave
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Set initial set of changed faces
|
||||
template<class PatchPointType, class ... InitialPatchData>
|
||||
void setChangedFaces
|
||||
//- Get initial set of changed faces
|
||||
labelList getChangedFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
List<PatchPointType>& faceDist,
|
||||
const InitialPatchData& ... initialPatchData
|
||||
const labelHashSet& patchIDs
|
||||
);
|
||||
|
||||
//- Copy FaceCellWave values into the cell fields
|
||||
template
|
||||
<
|
||||
class PatchPointType,
|
||||
class TrackingData,
|
||||
class DataType,
|
||||
class DataMethod
|
||||
>
|
||||
label getCellValues
|
||||
(
|
||||
FaceCellWave<PatchPointType, TrackingData>& waveInfo,
|
||||
Field<DataType>& cellValues,
|
||||
DataMethod method,
|
||||
const DataType& stabiliseValue = pTraits<DataType>::zero
|
||||
);
|
||||
|
||||
//- Wave distance data from the patches to the cells
|
||||
template<class PatchPointType, class TrackingData = int>
|
||||
//- Wave distance data from faces
|
||||
label wave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& changedFaces,
|
||||
scalarField& cellDistance
|
||||
);
|
||||
|
||||
//- Calculate distance data from patches
|
||||
label calculate
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
scalarField& cellDistance,
|
||||
bool correct = true,
|
||||
TrackingData& td = FaceCellWave<PatchPointType>::defaultTrackingData_
|
||||
scalarField& cellDistance
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -96,12 +77,6 @@ label wave
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "patchDistWaveTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
253
src/meshTools/patchDist/wallFace/wallFace.H
Normal file
253
src/meshTools/patchDist/wallFace/wallFace.H
Normal file
@ -0,0 +1,253 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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::wallFace
|
||||
|
||||
Description
|
||||
Holds information regarding nearest wall point. Used in wall distance
|
||||
calculation.
|
||||
|
||||
SourceFiles
|
||||
wallFaceI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallFace_H
|
||||
#define wallFace_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
class transformer;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class Derived>
|
||||
class WallFaceBase;
|
||||
template<class Derived>
|
||||
Ostream& operator<<(Ostream&, const WallFaceBase<Derived>&);
|
||||
template<class Derived>
|
||||
Istream& operator>>(Istream&, WallFaceBase<Derived>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class WallFaceBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Derived>
|
||||
class WallFaceBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Face points
|
||||
pointField points_;
|
||||
|
||||
//- Normal distance (squared) from cell center to face
|
||||
scalar distSqr_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- ...
|
||||
template<class TrackingData>
|
||||
inline bool update
|
||||
(
|
||||
const point& pt,
|
||||
const WallFaceBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline WallFaceBase();
|
||||
|
||||
//- Construct from face, distance
|
||||
inline WallFaceBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& points,
|
||||
const scalar distSqr
|
||||
);
|
||||
|
||||
//- Construct from face, distance
|
||||
inline WallFaceBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& points,
|
||||
const point& centre,
|
||||
const scalar distSqr
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const pointField& points() const;
|
||||
|
||||
inline pointField& points();
|
||||
|
||||
inline scalar distSqr() const;
|
||||
|
||||
inline scalar& distSqr();
|
||||
|
||||
template<class TrackingData>
|
||||
inline scalar dist(TrackingData& td) const;
|
||||
|
||||
|
||||
// Needed by FaceCellWave
|
||||
|
||||
//- Check whether the WallFaceBase has been changed at all or still
|
||||
// contains original (invalid) value.
|
||||
template<class TrackingData>
|
||||
inline bool valid(TrackingData& td) const;
|
||||
|
||||
//- Check for identical geometrical data. Used for checking
|
||||
// consistency across cyclics.
|
||||
template<class TrackingData>
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const WallFaceBase<Derived>&,
|
||||
const scalar,
|
||||
TrackingData& td
|
||||
) const;
|
||||
|
||||
//- Transform across an interface
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring face
|
||||
template<class TrackingData>
|
||||
inline bool updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisCelli,
|
||||
const label neighbourFacei,
|
||||
const WallFaceBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFacei,
|
||||
const label neighbourCelli,
|
||||
const WallFaceBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same face
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFacei,
|
||||
const WallFaceBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Test equality
|
||||
template<class TrackingData>
|
||||
inline bool equal
|
||||
(
|
||||
const WallFaceBase<Derived>&,
|
||||
TrackingData& td
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
inline bool operator==(const WallFaceBase<Derived>&) const;
|
||||
inline bool operator!=(const WallFaceBase<Derived>&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <Derived>
|
||||
(
|
||||
Ostream&,
|
||||
const WallFaceBase<Derived>&
|
||||
);
|
||||
|
||||
friend Istream& operator>> <Derived>
|
||||
(
|
||||
Istream&,
|
||||
WallFaceBase<Derived>&
|
||||
);
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallFace Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallFace
|
||||
:
|
||||
public WallFaceBase<wallFace>
|
||||
{
|
||||
public:
|
||||
|
||||
using WallFaceBase<wallFace>::WallFaceBase;
|
||||
|
||||
template<class Derived> using type = WallFaceBase<Derived>;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "wallFaceI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
320
src/meshTools/patchDist/wallFace/wallFaceI.H
Normal file
320
src/meshTools/patchDist/wallFace/wallFaceI.H
Normal file
@ -0,0 +1,320 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 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 "wallFace.H"
|
||||
#include "polyMesh.H"
|
||||
#include "transformer.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::update
|
||||
(
|
||||
const point& pt,
|
||||
const WallFaceBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const scalar dist2 =
|
||||
sqr
|
||||
(
|
||||
face(identity(w2.points().size()))
|
||||
.nearestPoint(pt, w2.points())
|
||||
.distance()
|
||||
);
|
||||
|
||||
if (valid(td))
|
||||
{
|
||||
scalar diff = distSqr() - dist2;
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Either *this is not yet valid or w2 is closer
|
||||
distSqr() = dist2;
|
||||
points() = w2.points();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::WallFaceBase<Derived>::WallFaceBase()
|
||||
:
|
||||
points_(0),
|
||||
distSqr_(-great)
|
||||
{}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::WallFaceBase<Derived>::WallFaceBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& points,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
points_(f.points(points)),
|
||||
distSqr_(distSqr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::WallFaceBase<Derived>::WallFaceBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& points,
|
||||
const point& centre,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
points_(f.points(points)),
|
||||
distSqr_(distSqr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
inline const Foam::pointField& Foam::WallFaceBase<Derived>::points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::pointField& Foam::WallFaceBase<Derived>::points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::scalar Foam::WallFaceBase<Derived>::distSqr() const
|
||||
{
|
||||
return distSqr_;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::scalar& Foam::WallFaceBase<Derived>::distSqr()
|
||||
{
|
||||
return distSqr_;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline Foam::scalar Foam::WallFaceBase<Derived>::dist(TrackingData& td) const
|
||||
{
|
||||
return valid(td) ? sqrt(distSqr_) : great;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::valid(TrackingData& td) const
|
||||
{
|
||||
return distSqr_ > -small;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const WallFaceBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
scalar diff = mag(distSqr() - w2.distSqr());
|
||||
|
||||
if (diff < small)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((distSqr() > small) && ((diff/distSqr()) < tol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline void Foam::WallFaceBase<Derived>::transform
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchFacei,
|
||||
const transformer& transform,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
transform.transformPosition(points_, points_);
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::updateCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisCelli,
|
||||
const label neighbourFacei,
|
||||
const WallFaceBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.cellCentres()[thisCelli],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const label neighbourCelli,
|
||||
const WallFaceBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.faceCentres()[thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const WallFaceBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.faceCentres()[thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::WallFaceBase<Derived>::equal
|
||||
(
|
||||
const WallFaceBase<Derived>& rhs,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
return operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
inline bool Foam::WallFaceBase<Derived>::operator==
|
||||
(
|
||||
const Foam::WallFaceBase<Derived>& rhs
|
||||
) const
|
||||
{
|
||||
return points() == rhs.points();
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline bool Foam::WallFaceBase<Derived>::operator!=
|
||||
(
|
||||
const Foam::WallFaceBase<Derived>& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const WallFaceBase<Derived>& w)
|
||||
{
|
||||
return os << w.points() << token::SPACE << w.distSqr();
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, WallFaceBase<Derived>& w)
|
||||
{
|
||||
return is >> w.points() >> w.distSqr();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -30,17 +30,14 @@ Description
|
||||
|
||||
SourceFiles
|
||||
wallPointI.H
|
||||
wallPoint.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallPoint_H
|
||||
#define wallPoint_H
|
||||
|
||||
#include "point.H"
|
||||
#include "label.H"
|
||||
#include "scalar.H"
|
||||
#include "tensor.H"
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -52,20 +49,20 @@ class polyPatch;
|
||||
class polyMesh;
|
||||
class transformer;
|
||||
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class wallPoint;
|
||||
|
||||
Ostream& operator<<(Ostream&, const wallPoint&);
|
||||
Istream& operator>>(Istream&, wallPoint&);
|
||||
|
||||
template<class Derived>
|
||||
class WallPointBase;
|
||||
template<class Derived>
|
||||
Ostream& operator<<(Ostream&, const WallPointBase<Derived>&);
|
||||
template<class Derived>
|
||||
Istream& operator>>(Istream&, WallPointBase<Derived>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallPoint Declaration
|
||||
Class WallPointBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallPoint
|
||||
template<class Derived>
|
||||
class WallPointBase
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -87,7 +84,7 @@ protected:
|
||||
inline bool update
|
||||
(
|
||||
const point&,
|
||||
const wallPoint& w2,
|
||||
const WallPointBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -98,10 +95,19 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline wallPoint();
|
||||
inline WallPointBase();
|
||||
|
||||
//- Construct from origin, distance
|
||||
inline wallPoint(const point& origin, const scalar distSqr);
|
||||
inline WallPointBase(const point& origin, const scalar distSqr);
|
||||
|
||||
//- Construct from face, distance
|
||||
inline WallPointBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& ps,
|
||||
const point& centre,
|
||||
const scalar distSqr
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -132,7 +138,7 @@ public:
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const wallPoint&,
|
||||
const WallPointBase<Derived>&,
|
||||
const scalar,
|
||||
TrackingData& td
|
||||
) const;
|
||||
@ -154,7 +160,7 @@ public:
|
||||
const polyMesh&,
|
||||
const label thisCelli,
|
||||
const label neighbourFacei,
|
||||
const wallPoint& neighbourInfo,
|
||||
const WallPointBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -166,7 +172,7 @@ public:
|
||||
const polyMesh&,
|
||||
const label thisFacei,
|
||||
const label neighbourCelli,
|
||||
const wallPoint& neighbourInfo,
|
||||
const WallPointBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
@ -177,27 +183,55 @@ public:
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFacei,
|
||||
const wallPoint& neighbourInfo,
|
||||
const WallPointBase<Derived>& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Same (like operator==)
|
||||
template<class TrackingData>
|
||||
inline bool equal(const wallPoint&, TrackingData& td) const;
|
||||
inline bool equal
|
||||
(
|
||||
const WallPointBase<Derived>&,
|
||||
TrackingData& td
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Needed for List IO
|
||||
inline bool operator==(const wallPoint&) const;
|
||||
inline bool operator!=(const wallPoint&) const;
|
||||
inline bool operator==(const WallPointBase<Derived>&) const;
|
||||
inline bool operator!=(const WallPointBase<Derived>&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const wallPoint&);
|
||||
friend Istream& operator>>(Istream&, wallPoint&);
|
||||
friend Ostream& operator<< <Derived>
|
||||
(
|
||||
Ostream&,
|
||||
const WallPointBase<Derived>&
|
||||
);
|
||||
|
||||
friend Istream& operator>> <Derived>
|
||||
(
|
||||
Istream&,
|
||||
WallPointBase<Derived>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallPoint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallPoint
|
||||
:
|
||||
public WallPointBase<wallPoint>
|
||||
{
|
||||
public:
|
||||
|
||||
using WallPointBase<wallPoint>::WallPointBase;
|
||||
|
||||
template<class Derived> using type = WallPointBase<Derived>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -23,126 +23,138 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "wallPoint.H"
|
||||
#include "polyMesh.H"
|
||||
#include "transformer.H"
|
||||
#include "SubField.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::update
|
||||
inline bool Foam::WallPointBase<Derived>::update
|
||||
(
|
||||
const point& pt,
|
||||
const wallPoint& w2,
|
||||
const WallPointBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
// Already done in calling algorithm
|
||||
// if (w2.origin() == origin_)
|
||||
//{
|
||||
// // Shortcut. Same input so same distance.
|
||||
// return false;
|
||||
//}
|
||||
const scalar dist2 = magSqr(pt - w2.origin());
|
||||
|
||||
scalar dist2 = magSqr(pt - w2.origin());
|
||||
|
||||
if (!valid(td))
|
||||
if (valid(td))
|
||||
{
|
||||
// current not yet set so use any value
|
||||
distSqr_ = dist2;
|
||||
origin_ = w2.origin();
|
||||
const scalar diff = distSqr() - dist2;
|
||||
|
||||
return true;
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
scalar diff = distSqr_ - dist2;
|
||||
// Either *this is not yet valid or w2 is closer
|
||||
distSqr() = dist2;
|
||||
origin() = w2.origin();
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < small) || ((distSqr_ > small) && (diff/distSqr_ < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update with new values
|
||||
distSqr_ = dist2;
|
||||
origin_ = w2.origin();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::wallPoint::wallPoint()
|
||||
template<class Derived>
|
||||
inline Foam::WallPointBase<Derived>::WallPointBase()
|
||||
:
|
||||
origin_(point::max),
|
||||
distSqr_(-great)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::wallPoint::wallPoint(const point& origin, const scalar distSqr)
|
||||
template<class Derived>
|
||||
inline Foam::WallPointBase<Derived>::WallPointBase
|
||||
(
|
||||
const point& origin,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
origin_(origin),
|
||||
distSqr_(distSqr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
inline Foam::WallPointBase<Derived>::WallPointBase
|
||||
(
|
||||
const face& f,
|
||||
const pointField& points,
|
||||
const point& centre,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
origin_(centre),
|
||||
distSqr_(distSqr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::point& Foam::wallPoint::origin() const
|
||||
template<class Derived>
|
||||
inline const Foam::point& Foam::WallPointBase<Derived>::origin() const
|
||||
{
|
||||
return origin_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point& Foam::wallPoint::origin()
|
||||
template<class Derived>
|
||||
inline Foam::point& Foam::WallPointBase<Derived>::origin()
|
||||
{
|
||||
return origin_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::wallPoint::distSqr() const
|
||||
template<class Derived>
|
||||
inline Foam::scalar Foam::WallPointBase<Derived>::distSqr() const
|
||||
{
|
||||
return distSqr_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar& Foam::wallPoint::distSqr()
|
||||
template<class Derived>
|
||||
inline Foam::scalar& Foam::WallPointBase<Derived>::distSqr()
|
||||
{
|
||||
return distSqr_;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline Foam::scalar Foam::wallPoint::dist(TrackingData& td) const
|
||||
inline Foam::scalar Foam::WallPointBase<Derived>::dist(TrackingData& td) const
|
||||
{
|
||||
return valid(td) ? sqrt(distSqr_) : great;
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::valid(TrackingData& td) const
|
||||
inline bool Foam::WallPointBase<Derived>::valid(TrackingData& td) const
|
||||
{
|
||||
return distSqr_ > -small;
|
||||
}
|
||||
|
||||
|
||||
// Checks for cyclic faces
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::sameGeometry
|
||||
inline bool Foam::WallPointBase<Derived>::sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const wallPoint& w2,
|
||||
const WallPointBase<Derived>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
) const
|
||||
@ -167,8 +179,9 @@ inline bool Foam::wallPoint::sameGeometry
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline void Foam::wallPoint::transform
|
||||
inline void Foam::WallPointBase<Derived>::transform
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchFacei,
|
||||
@ -181,43 +194,43 @@ inline void Foam::wallPoint::transform
|
||||
}
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::updateCell
|
||||
inline bool Foam::WallPointBase<Derived>::updateCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisCelli,
|
||||
const label neighbourFacei,
|
||||
const wallPoint& neighbourWallInfo,
|
||||
const WallPointBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.cellCentres()[thisCelli],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::updateFace
|
||||
inline bool Foam::WallPointBase<Derived>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const label neighbourCelli,
|
||||
const wallPoint& neighbourWallInfo,
|
||||
const WallPointBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.faceCentres()[thisFacei],
|
||||
neighbourWallInfo,
|
||||
@ -226,19 +239,20 @@ inline bool Foam::wallPoint::updateFace
|
||||
);
|
||||
}
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::updateFace
|
||||
inline bool Foam::WallPointBase<Derived>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const wallPoint& neighbourWallInfo,
|
||||
const WallPointBase<Derived>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
update
|
||||
static_cast<Derived&>(*this).update
|
||||
(
|
||||
mesh.faceCentres()[thisFacei],
|
||||
neighbourWallInfo,
|
||||
@ -248,10 +262,11 @@ inline bool Foam::wallPoint::updateFace
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::equal
|
||||
inline bool Foam::WallPointBase<Derived>::equal
|
||||
(
|
||||
const wallPoint& rhs,
|
||||
const WallPointBase<Derived>& rhs,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
@ -261,16 +276,40 @@ inline bool Foam::wallPoint::equal
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::wallPoint::operator==(const Foam::wallPoint& rhs) const
|
||||
template<class Derived>
|
||||
inline bool Foam::WallPointBase<Derived>::operator==
|
||||
(
|
||||
const Foam::WallPointBase<Derived>& rhs
|
||||
) const
|
||||
{
|
||||
return origin() == rhs.origin();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::wallPoint::operator!=(const Foam::wallPoint& rhs) const
|
||||
template<class Derived>
|
||||
inline bool Foam::WallPointBase<Derived>::operator!=
|
||||
(
|
||||
const Foam::WallPointBase<Derived>& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Derived>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const WallPointBase<Derived>& w)
|
||||
{
|
||||
return os << w.origin() << token::SPACE << w.distSqr();
|
||||
}
|
||||
|
||||
|
||||
template<class Derived>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, WallPointBase<Derived>& w)
|
||||
{
|
||||
return is >> w.origin() >> w.distSqr();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -43,7 +43,7 @@ void Foam::patchDistanceToCell::combine(topoSet& set, const bool add) const
|
||||
{
|
||||
// Mesh wave to determine wall distance
|
||||
scalarField distance(mesh_.nCells());
|
||||
patchDistWave::wave<wallPoint>
|
||||
patchDistWave::calculate
|
||||
(
|
||||
mesh_,
|
||||
mesh_.boundaryMesh().patchSet(patches_),
|
||||
|
||||
Reference in New Issue
Block a user