Commit aeebdc3c authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

Merge branch 'feature-directionalMeshWave' into 'develop'

WIP-ENH: add directionalMeshWave functionality

See merge request !356
parents 50055b3d ea16cb4b
......@@ -46,6 +46,7 @@ $(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C
$(wallDist)/patchDistMethods/meshWave/meshWavePatchDistMethod.C
$(wallDist)/patchDistMethods/Poisson/PoissonPatchDistMethod.C
$(wallDist)/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C
$(wallDist)/patchDistMethods/directionalMeshWave/directionalMeshWavePatchDistMethod.C
fvMeshMapper = fvMesh/fvMeshMapper
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "patchDataWave.H"
#include "directionalMeshWavePatchDistMethod.H"
#include "fvMesh.H"
#include "volFields.H"
#include "directionalWallPointData.H"
#include "emptyFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace patchDistMethods
{
defineTypeNameAndDebug(directionalMeshWave, 0);
addToRunTimeSelectionTable
(
patchDistMethod,
directionalMeshWave,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchDistMethods::directionalMeshWave::directionalMeshWave
(
const dictionary& dict,
const fvMesh& mesh,
const labelHashSet& patchIDs
)
:
Foam::patchDistMethods::meshWave(dict, mesh, patchIDs),
n_(dict.get<vector>("n"))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::patchDistMethods::directionalMeshWave::correct(volScalarField& y)
{
y = dimensionedScalar(dimLength, GREAT);
volVectorField n
(
IOobject
(
"nWall",
y.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedVector(dimless, Zero),
patchDistMethod::patchTypes<scalar>(mesh_, patchIDs_)
);
const fvPatchList& patches = mesh_.boundary();
volVectorField::Boundary& nbf = n.boundaryFieldRef();
for (const label patchi : patchIDs_)
{
nbf[patchi] == patches[patchi].nf();
}
return correct(y, n);
}
bool Foam::patchDistMethods::directionalMeshWave::correct
(
volScalarField& y,
volVectorField& n
)
{
y = dimensionedScalar(dimLength, GREAT);
// Collect pointers to data on patches
UPtrList<vectorField> patchData(mesh_.boundaryMesh().size());
volVectorField::Boundary& nbf = n.boundaryFieldRef();
forAll(nbf, patchi)
{
patchData.set(patchi, &nbf[patchi]);
}
// Do mesh wave
vector testDirection(n_);
patchDataWave<directionalWallPointData<vector>, vector> wave
(
mesh_,
patchIDs_,
patchData,
correctWalls_,
testDirection
);
// Transfer cell values from wave into y and n
y.transfer(wave.distance());
n.transfer(wave.cellData());
// Transfer values on patches into boundaryField of y and n
volScalarField::Boundary& ybf = y.boundaryFieldRef();
forAll(ybf, patchi)
{
scalarField& waveFld = wave.patchDistance()[patchi];
if (!isA<emptyFvPatchScalarField>(ybf[patchi]))
{
ybf[patchi].transfer(waveFld);
vectorField& wavePatchData = wave.patchData()[patchi];
nbf[patchi].transfer(wavePatchData);
}
}
// Transfer number of unset values
this->nUnset_ = wave.nUnset();
return this->nUnset_ > 0;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::patchDistMethods::directionalMeshWave
Description
Variant of \c meshWave distance-to-patch method.
Ignores the component in the specified direction. Can be used e.g. to
calculate the distance in the z-direction only.
Usage
Example of specification in \c fvSchemes.wallDist:
\verbatim
wallDist
{
// Mandatory entries (unmodifiable)
method directionalMeshWave;
n (0 0 1);
// Optional (inherited) entries (unmodifiable)
...
}
\endverbatim
where the entries mean:
\table
Property | Description | Type | Req'd | Dflt
method | Method name: directionalMeshWave | word | yes | -
n | The direction component to ignore | vector | yes | -
\endtable
The inherited entries are elaborated in:
- \link meshWavePatchDistMethod.H \endlink
See also
Foam::wallDist
Foam::patchDistMethod::meshWave
Foam::patchDistMethod::Poisson
Foam::directionalWallPoint
SourceFiles
directionalMeshWavePatchDistMethod.C
\*---------------------------------------------------------------------------*/
#ifndef directionalMeshWavePatchDistMethod_H
#define directionalMeshWavePatchDistMethod_H
#include "meshWavePatchDistMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace patchDistMethods
{
/*---------------------------------------------------------------------------*\
Class directionalMeshWave Declaration
\*---------------------------------------------------------------------------*/
class directionalMeshWave
:
public meshWave
{
// Private Member Data
//- The direction component to ignore
const vector n_;
//- No copy construct
directionalMeshWave(const directionalMeshWave&) = delete;
//- No copy assignment
void operator=(const directionalMeshWave&) = delete;
public:
//- Runtime type information
TypeName("directionalMeshWave");
// Constructors
//- Construct from coefficients dictionary, mesh
//- and fixed-value patch set
directionalMeshWave
(
const dictionary& dict,
const fvMesh& mesh,
const labelHashSet& patchIDs
);
// Member Functions
//- Correct the given distance-to-patch field
virtual bool correct(volScalarField& y);
//- Correct the given distance-to-patch and normal-to-patch fields
virtual bool correct(volScalarField& y, volVectorField& n);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace patchDistMethods
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -77,7 +78,9 @@ class meshWave
:
public patchDistMethod
{
// Private Member Data
protected:
// Protected Member Data
//- Do accurate distance calculation for near-wall cells.
const bool correctWalls_;
......@@ -86,6 +89,8 @@ class meshWave
mutable label nUnset_;
private:
// Private Member Functions
//- No copy construct
......@@ -126,11 +131,6 @@ public:
// Member Functions
label nUnset() const
{
return nUnset_;
}
//- Correct the given distance-to-patch field
virtual bool correct(volScalarField& y);
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "Ostream.H"
#include "Istream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class Type>
Ostream& operator<<
(
Ostream& os,
const directionalWallPointData<Type>& wDist
)
{
return os<< static_cast<const wallPointData<Type>&>(wDist);
}
template<class Type>
Istream& operator>>
(
Istream& is,
directionalWallPointData<Type>& wDist
)
{
return is>> static_cast<wallPointData<Type>&>(wDist);
}
// ************************************************************************* //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::directionalWallPointData
Description
Holds information (coordinate and normal) regarding the nearest wall point.
Variant of \c wallPointData that ignores the specified normal component
before comparing. This is used e.g. to find the distance to the wall
in the z-direction only.
SourceFiles
directionalWallPointDataI.H
directionalWallPointData.C
\*---------------------------------------------------------------------------*/
#ifndef directionalWallPointData_H
#define directionalWallPointData_H
#include "wallPointData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type> class directionalWallPointData;
// Forward declaration of friend functions and operators
template<class Type> Istream&
operator>>(Istream&, directionalWallPointData<Type>&);
template<class Type> Ostream&
operator<<(Ostream&, const directionalWallPointData<Type>&);
/*---------------------------------------------------------------------------*\
Class directionalWallPointData Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class directionalWallPointData
:
public wallPointData<Type>
{
// 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 directionalWallPointData<Type>& w2,
const scalar tol,
TrackingData& td
);
public:
typedef Type dataType;
// Constructors
//- Construct null
inline directionalWallPointData();
//- Construct from origin, normal, distance
inline directionalWallPointData
(
const point& origin,
const Type& data,
const scalar distSqr
);
// Member Functions
// Needed by meshWave
//- Influence of neighbouring face.
// Calls update(...) with cellCentre of celli
template<class TrackingData>
inline bool updateCell
(
const polyMesh& mesh,
const label thisCelli,
const label neighbourFacei,
const directionalWallPointData<Type>& neighbourWallInfo,
const scalar tol,
TrackingData& td
);
//- Influence of neighbouring cell.
// Calls update(...) with faceCentre of facei
template<class TrackingData>
inline bool updateFace
(
const polyMesh& mesh,
const label thisFacei,
const label neighbourCelli,
const directionalWallPointData<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 polyMesh& mesh,
const label thisFacei,
const directionalWallPointData<Type>& neighbourWallInfo,
const scalar tol,
TrackingData& td
);
// Member Operators
// IOstream Operators
friend Ostream& operator<< <Type>
(
Ostream&,
const directionalWallPointData<Type>&
);
friend Istream& operator>> <Type>
(
Istream&,
directionalWallPointData<Type>&
);
};
// Data associated with directionalWallPointData type are contiguous. List the
// usual ones.
template<> struct is_contiguous<directionalWallPointData<bool>> :
is_contiguous<wallPoint> {};
template<> struct is_contiguous<directionalWallPointData<label>> :
is_contiguous_label<wallPoint> {};
template<> struct is_contiguous<directionalWallPointData<scalar>> :
is_contiguous_scalar<wallPoint> {};