mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add directionalMeshWave functionality
For a given point within a given mesh, the existing `meshWave` method gives the orthogonal distance to a patch. In meshes with very steep terrain (e.g. a hill of 90 [deg], this might be problematic for the fields that require the distance to the patch associated with the terrain surface. `directionalMeshWave` is a variant of `meshWave` distance-to-patch method, which ignores the component in the specified direction. Can be used e.g. to calculate the distance in the z-direction only. TUT: add example of directionalMeshWave to mesh/moveDynamicMesh/SnakeCanyon Requirement by CENER Implementation by Mattijs Janssens
This commit is contained in:
@ -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
|
||||
|
||||
@ -0,0 +1,160 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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);
|
||||
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,197 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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> {};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "directionalWallPointData.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "directionalWallPointDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,192 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool directionalWallPointData<Type>::update
|
||||
(
|
||||
const point& pt,
|
||||
const directionalWallPointData<Type>& w2,
|
||||
const scalar tol,
|
||||
TrackingData& n
|
||||
)
|
||||
{
|
||||
vector d(pt - w2.origin());
|
||||
// Knock out component in direction of n
|
||||
d -= n*(d&n);
|
||||
scalar dist2 = magSqr(d);
|
||||
|
||||
if (this->valid(n))
|
||||
{
|
||||
vector d(pt - this->origin());
|
||||
// Knock out component in direction of n
|
||||
d -= n*(d&n);
|
||||
scalar currentDistSqr(magSqr(d));
|
||||
|
||||
scalar diff = currentDistSqr - dist2;
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(diff < SMALL)
|
||||
|| ((currentDistSqr > SMALL) && (diff/currentDistSqr < 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
|
||||
this->distSqr() = magSqr(pt - w2.origin());
|
||||
this->origin() = w2.origin();
|
||||
this->data() = w2.data();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template<class Type>
|
||||
inline directionalWallPointData<Type>::directionalWallPointData()
|
||||
:
|
||||
wallPointData<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
inline directionalWallPointData<Type>::directionalWallPointData
|
||||
(
|
||||
const point& origin,
|
||||
const Type& data,
|
||||
const scalar distSqr
|
||||
)
|
||||
:
|
||||
wallPointData<Type>(origin, data, distSqr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool directionalWallPointData<Type>::updateCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisCelli,
|
||||
const label,
|
||||
const directionalWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
|
||||
|
||||
return update
|
||||
(
|
||||
cellCentres[thisCelli],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool directionalWallPointData<Type>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const label,
|
||||
const directionalWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const vectorField& faceCentres = mesh.faceCentres();
|
||||
|
||||
return update
|
||||
(
|
||||
faceCentres[thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool directionalWallPointData<Type>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFacei,
|
||||
const directionalWallPointData<Type>& neighbourWallInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
const vectorField& faceCentres = mesh.faceCentres();
|
||||
|
||||
return update
|
||||
(
|
||||
faceCentres[thisFacei],
|
||||
neighbourWallInfo,
|
||||
tol,
|
||||
td
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,11 +28,17 @@ License
|
||||
|
||||
#include "patchDataWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class TransferType, class TrackingData>
|
||||
int Foam::patchDataWave<TransferType, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Set initial set of changed faces (= all wall faces)
|
||||
template<class TransferType>
|
||||
void Foam::patchDataWave<TransferType>::setChangedFaces
|
||||
template<class TransferType, class TrackingData>
|
||||
void Foam::patchDataWave<TransferType, TrackingData>::setChangedFaces
|
||||
(
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
@ -72,10 +79,10 @@ void Foam::patchDataWave<TransferType>::setChangedFaces
|
||||
|
||||
|
||||
// Copy from MeshWave data into *this (distance) and field_ (transported data)
|
||||
template<class TransferType>
|
||||
Foam::label Foam::patchDataWave<TransferType>::getValues
|
||||
template<class TransferType, class TrackingData>
|
||||
Foam::label Foam::patchDataWave<TransferType, TrackingData>::getValues
|
||||
(
|
||||
const MeshWave<TransferType>& waveInfo
|
||||
const MeshWave<TransferType, TrackingData>& waveInfo
|
||||
)
|
||||
{
|
||||
const polyMesh& mesh = cellDistFuncs::mesh();
|
||||
@ -169,41 +176,43 @@ Foam::label Foam::patchDataWave<TransferType>::getValues
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class TransferType>
|
||||
Foam::patchDataWave<TransferType>::patchDataWave
|
||||
template<class TransferType, class TrackingData>
|
||||
Foam::patchDataWave<TransferType, TrackingData>::patchDataWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const UPtrList<Field<Type>>& initialPatchValuePtrs,
|
||||
const bool correctWalls
|
||||
const bool correctWalls,
|
||||
TrackingData& td
|
||||
)
|
||||
:
|
||||
cellDistFuncs(mesh),
|
||||
patchIDs_(patchIDs),
|
||||
initialPatchValuePtrs_(initialPatchValuePtrs),
|
||||
correctWalls_(correctWalls),
|
||||
td_(td),
|
||||
nUnset_(0),
|
||||
distance_(mesh.nCells()),
|
||||
patchDistance_(mesh.boundaryMesh().size()),
|
||||
cellData_(mesh.nCells()),
|
||||
patchData_(mesh.boundaryMesh().size())
|
||||
{
|
||||
patchDataWave<TransferType>::correct();
|
||||
patchDataWave<TransferType, TrackingData>::correct();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class TransferType>
|
||||
Foam::patchDataWave<TransferType>::~patchDataWave()
|
||||
template<class TransferType, class TrackingData>
|
||||
Foam::patchDataWave<TransferType, TrackingData>::~patchDataWave()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Correct for mesh geom/topo changes
|
||||
template<class TransferType>
|
||||
void Foam::patchDataWave<TransferType>::correct()
|
||||
template<class TransferType, class TrackingData>
|
||||
void Foam::patchDataWave<TransferType, TrackingData>::correct()
|
||||
{
|
||||
//
|
||||
// Set initial changed faces: set TransferType for wall faces
|
||||
@ -222,12 +231,13 @@ void Foam::patchDataWave<TransferType>::correct()
|
||||
// Do calculate wall distance by 'growing' from faces.
|
||||
//
|
||||
|
||||
MeshWave<TransferType> waveInfo
|
||||
MeshWave<TransferType, TrackingData> waveInfo
|
||||
(
|
||||
mesh(),
|
||||
changedFaces,
|
||||
faceDist,
|
||||
mesh().globalData().nTotalCells()+1 // max iterations
|
||||
mesh().globalData().nTotalCells()+1, // max iterations
|
||||
td_
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,7 +63,7 @@ class wallPoint;
|
||||
Class patchDataWave Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class TransferType>
|
||||
template<class TransferType, class TrackingData = int>
|
||||
class patchDataWave
|
||||
:
|
||||
public cellDistFuncs
|
||||
@ -84,6 +85,10 @@ private:
|
||||
//- Do accurate distance calculation for near-wall cells.
|
||||
bool correctWalls_;
|
||||
|
||||
//- Additional data to be passed into underlying containers
|
||||
TrackingData& td_;
|
||||
|
||||
|
||||
//
|
||||
// After construction:
|
||||
//
|
||||
@ -115,7 +120,14 @@ private:
|
||||
) const;
|
||||
|
||||
//- Copy MeshWave values into *this
|
||||
label getValues(const MeshWave<TransferType>&);
|
||||
label getValues(const MeshWave<TransferType, TrackingData>&);
|
||||
|
||||
|
||||
// Private static data
|
||||
|
||||
//- Used as default trackdata value to satisfy default template
|
||||
// argument.
|
||||
static int dummyTrackData_;
|
||||
|
||||
|
||||
public:
|
||||
@ -131,7 +143,8 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const labelHashSet& patchIDs,
|
||||
const UPtrList<Field<Type>>& initialPatchValuePtrs,
|
||||
bool correctWalls = true
|
||||
const bool correctWalls = true,
|
||||
TrackingData& td = dummyTrackData_
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ FoamFile
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class pointVectorField;
|
||||
location "0";
|
||||
object pointDisplacement;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
8
tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/Allclean
Executable file
8
tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/Allclean
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
cleanCase0
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
19
tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/Allrun
Executable file
19
tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/Allrun
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
restore0Dir
|
||||
|
||||
runApplication blockMesh
|
||||
|
||||
runApplication decomposePar
|
||||
|
||||
runParallel $(getApplication)
|
||||
|
||||
runParallel redistributePar -reconstruct
|
||||
|
||||
# test `directionalMeshWave`
|
||||
runApplication checkMesh -writeAllFields -latestTime
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -13,7 +13,6 @@ FoamFile
|
||||
location "system";
|
||||
object dynamicMeshDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dynamicFvMesh dynamicMotionSolverFvMesh;
|
||||
|
||||
@ -12,7 +12,6 @@ FoamFile
|
||||
class dictionary;
|
||||
object blockMeshDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
scale 1;
|
||||
|
||||
@ -46,5 +46,11 @@ snGradSchemes
|
||||
default corrected;
|
||||
}
|
||||
|
||||
wallDist
|
||||
{
|
||||
method directionalMeshWave;
|
||||
n (0 0 1);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user