ENH: make tetIndices contiguous, noexcept, sortable, comparable

ENH: make interpolation constructors explicit etc
This commit is contained in:
Mark Olesen 2022-02-02 14:44:00 +01:00
parent 2919c9b675
commit 7a6891905e
21 changed files with 350 additions and 344 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,57 +30,25 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::tetIndices::maxNWarnings = 100;
Foam::label Foam::tetIndices::nWarnings = 0;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tetIndices::tetIndices()
:
celli_(-1),
facei_(-1),
tetPti_(-1)
{}
Foam::tetIndices::tetIndices
(
label celli,
label facei,
label tetPtI
)
:
celli_(celli),
facei_(facei),
tetPti_(tetPtI)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tetIndices::~tetIndices()
{}
int Foam::tetIndices::nWarnings_ = 0;
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, tetIndices& tI)
Foam::Istream& Foam::operator>>(Istream& is, tetIndices& rhs)
{
is >> tI.cell() >> tI.face() >> tI.tetPt();
is >> rhs.cell() >> rhs.face() >> rhs.tetPt();
is.check(FUNCTION_NAME);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const tetIndices& tI)
Foam::Ostream& Foam::operator<<(Ostream& os, const tetIndices& rhs)
{
os << tI.cell() << token::SPACE
<< tI.face() << token::SPACE
<< tI.tetPt() << token::SPACE
<< endl;
os << rhs.cell() << token::SPACE
<< rhs.face() << token::SPACE
<< rhs.tetPt() << nl;
os.check(FUNCTION_NAME);
return os;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,8 +55,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef tetIndices_H
#define tetIndices_H
#ifndef Foam_tetIndices_H
#define Foam_tetIndices_H
#include "label.H"
#include "tetPointRef.H"
@ -69,8 +70,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
// Forward Declarations
class tetIndices;
Istream& operator>>(Istream&, tetIndices&);
@ -83,7 +83,7 @@ Ostream& operator<<(Ostream&, const tetIndices&);
class tetIndices
{
// Private data
// Private Data
//- Cell that this is a decomposed tet of
label celli_;
@ -91,90 +91,106 @@ class tetIndices
//- Face that holds this decomposed tet
label facei_;
//- Point on the face, *relative to the base point*, which
// characterises this tet on the face.
//- Point on the face, *relative to the base point*,
//- which characterises this tet on the face.
label tetPti_;
// Private static data
// Private Static Data
//- Maximum number of bad tet warnings
static const label maxNWarnings;
static constexpr int maxNWarnings = 100;
//- Current number of bad tet warnings. Warnings stop when this reaches
// the maximum number.
static label nWarnings;
//- Current number of bad tet warnings.
//- Warnings stop when this reaches the maximum number.
static int nWarnings_;
public:
// Constructors
//- Construct null
tetIndices();
//- Default construct, with invalid labels (-1)
inline constexpr tetIndices() noexcept;
//- Construct from components
tetIndices(label celli, label facei, label tetPtI);
inline constexpr tetIndices
(
label celli,
label facei,
label tetPointi
) noexcept;
//- Destructor
~tetIndices();
~tetIndices() = default;
// Member Functions
// Access
// Access
//- Return the cell
inline label cell() const;
//- Return the cell index
label cell() const noexcept { return celli_; }
//- Return non-const access to the cell
inline label& cell();
//- Non-const access to the cell index
label& cell() noexcept { return celli_; }
//- Return the face
inline label face() const;
//- Return the face index
label face() const noexcept { return facei_; }
//- Return non-const access to the face
inline label& face();
//- Non-const access to the face index
label& face() noexcept { return facei_; }
//- Return the characterising tetPtI
inline label tetPt() const;
//- Return the characterising tet point index
label tetPt() const noexcept { return tetPti_; }
//- Return non-const access to the characterising tetPtI
inline label& tetPt();
//- Return the indices corresponding to the tri on the face for
// this tet. The normal of the tri points out of the cell
inline triFace faceTriIs
(
const polyMesh& mesh,
const bool warn = true
) const;
//- Return the local indices corresponding to the tri on the face
// for this tet. The normal of the tri points out of the cell
inline triFace triIs
(
const polyMesh& mesh,
const bool warn = true
) const;
//- Return the geometry corresponding to this tet
inline tetPointRef tet(const polyMesh& mesh) const;
//- Return the geometry corresponding to the tri on the face for
// this tet. The normal of the tri points out of the cell
inline triPointRef faceTri(const polyMesh& mesh) const;
//- Return the geometry corresponding to the tri on the face for
// this tet using the old positions
inline triPointRef oldFaceTri(const polyMesh& mesh) const;
//- Non-const access to the characterising tet point index
label& tetPt() noexcept { return tetPti_; }
// Member Operators
// Searching
inline bool operator==(const tetIndices&) const;
inline bool operator!=(const tetIndices&) const;
//- Return the indices corresponding to the tri on the face for
// this tet. The normal of the tri points out of the cell
inline triFace faceTriIs
(
const polyMesh& mesh,
const bool warn = true
) const;
//- Return the local indices corresponding to the tri on the face
//- for this tet. The normal of the tri points out of the cell
inline triFace triIs
(
const polyMesh& mesh,
const bool warn = true
) const;
//- Return the geometry corresponding to this tet
inline tetPointRef tet(const polyMesh& mesh) const;
//- Return the geometry corresponding to the tri on the face for
//- this tet. The normal of the tri points out of the cell
inline triPointRef faceTri(const polyMesh& mesh) const;
//- Return the geometry corresponding to the tri on the face for
//- this tet using the old positions
inline triPointRef oldFaceTri(const polyMesh& mesh) const;
// Other
//- Compare tetIndices for equality.
//- Compares cell, face, tetPt elements in order, stopping at the
//- first inequality.
//
// \returns negative/zero/positive from the last element compared
static inline label compare
(
const tetIndices& a,
const tetIndices& b
) noexcept;
// IOstream Operators
@ -184,6 +200,42 @@ public:
};
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for tetIndices
template<> struct is_contiguous<tetIndices> : std::true_type {};
//- Contiguous label data for tetIndices
template<> struct is_contiguous_label<tetIndices> : std::true_type {};
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
inline bool operator==(const tetIndices& a, const tetIndices& b) noexcept;
inline bool operator!=(const tetIndices& a, const tetIndices& b) noexcept;
inline bool operator<(const tetIndices& a, const tetIndices& b) noexcept
{
return (tetIndices::compare(a, b) < 0);
}
inline bool operator<=(const tetIndices& a, const tetIndices& b) noexcept
{
return (tetIndices::compare(a, b) <= 0);
}
inline bool operator>(const tetIndices& a, const tetIndices& b) noexcept
{
return (tetIndices::compare(a, b) > 0);
}
inline bool operator>=(const tetIndices& a, const tetIndices& b) noexcept
{
return (tetIndices::compare(a, b) >= 0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,44 +26,31 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline constexpr Foam::tetIndices::tetIndices() noexcept
:
celli_(-1),
facei_(-1),
tetPti_(-1)
{}
inline constexpr Foam::tetIndices::tetIndices
(
label celli,
label facei,
label tetPointi
) noexcept
:
celli_(celli),
facei_(facei),
tetPti_(tetPointi)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::tetIndices::cell() const
{
return celli_;
}
inline Foam::label& Foam::tetIndices::cell()
{
return celli_;
}
inline Foam::label Foam::tetIndices::face() const
{
return facei_;
}
inline Foam::label& Foam::tetIndices::face()
{
return facei_;
}
inline Foam::label Foam::tetIndices::tetPt() const
{
return tetPti_;
}
inline Foam::label& Foam::tetIndices::tetPt()
{
return tetPti_;
}
inline Foam::triFace Foam::tetIndices::faceTriIs
(
const polyMesh& mesh,
@ -78,20 +65,16 @@ inline Foam::triFace Foam::tetIndices::faceTriIs
{
faceBasePtI = 0;
if (warn)
if (warn && nWarnings_ < maxNWarnings)
{
if (nWarnings < maxNWarnings)
{
WarningInFunction
<< "No base point for face " << face() << ", " << f
<< ", produces a valid tet decomposition." << endl;
++nWarnings;
}
if (nWarnings == maxNWarnings)
++nWarnings_;
WarningInFunction
<< "No base point for face " << face() << ", " << f
<< ", produces a valid tet decomposition." << endl;
if (nWarnings_ == maxNWarnings)
{
Warning
<< "Suppressing any further warnings." << endl;
++nWarnings;
}
}
}
@ -122,20 +105,16 @@ inline Foam::triFace Foam::tetIndices::triIs
{
faceBasePtI = 0;
if (warn)
if (warn && nWarnings_ < maxNWarnings)
{
if (nWarnings < maxNWarnings)
{
WarningInFunction
<< "No base point for face " << face() << ", " << f
<< ", produces a valid tet decomposition." << endl;
++nWarnings;
}
if (nWarnings == maxNWarnings)
++nWarnings_;
WarningInFunction
<< "No base point for face " << face() << ", " << f
<< ", produces a valid tet decomposition." << endl;
if (nWarnings_ == maxNWarnings)
{
Warning
<< "Suppressing any further warnings." << endl;
++nWarnings;
}
}
}
@ -198,20 +177,39 @@ inline Foam::triPointRef Foam::tetIndices::oldFaceTri
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::tetIndices::operator==(const Foam::tetIndices& rhs) const
inline Foam::label Foam::tetIndices::compare
(
const tetIndices& a,
const tetIndices& b
) noexcept
{
label diff;
return
cell() == rhs.cell()
&& face() == rhs.face()
&& tetPt() == rhs.tetPt();
(
((diff = (a.cell() - b.cell())) != 0) ? diff
: ((diff = (a.face() - b.face())) != 0) ? diff
: (a.tetPt() - b.tetPt())
);
}
inline bool Foam::tetIndices::operator!=(const Foam::tetIndices& rhs) const
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
inline bool Foam::operator==(const tetIndices& a, const tetIndices& b) noexcept
{
return !(*this == rhs);
// Possibly slightly faster version than compare
return
(
a.cell() == b.cell()
&& a.face() == b.face()
&& a.tetPt() == b.tetPt()
);
}
inline bool Foam::operator!=(const tetIndices& a, const tetIndices& b) noexcept
{
return !(a == b);
}

View File

@ -316,10 +316,10 @@ $(interpolation)/interpolation/interpolations.C
$(interpolation)/interpolationCell/makeInterpolationCell.C
$(interpolation)/interpolationCellPatchConstrained/makeInterpolationCellPatchConstrained.C
$(interpolation)/interpolationCellPoint/cellPointWeight/cellPointWeight.C
$(interpolation)/interpolationCellPoint/cellPointWeight.C
$(interpolation)/interpolationCellPoint/makeInterpolationCellPoint.C
$(interpolation)/interpolationCellPointFace/makeInterpolationCellPointFace.C
$(interpolation)/interpolationCellPointWallModified/cellPointWeightWallModified/cellPointWeightWallModified.C
$(interpolation)/interpolationCellPointWallModified/cellPointWeightWallModified.C
$(interpolation)/interpolationCellPointWallModified/makeInterpolationCellPointWallModified.C
$(interpolation)/interpolationPointMVC/pointMVCWeight.C
$(interpolation)/interpolationPointMVC/makeInterpolationPointMVC.C

View File

@ -28,27 +28,28 @@ Class
Foam::interpolation
Description
Abstract base class for interpolation
Abstract base class for volume field interpolation
\*---------------------------------------------------------------------------*/
#ifndef interpolation_H
#define interpolation_H
#ifndef Foam_interpolation_H
#define Foam_interpolation_H
#include "faceList.H"
#include "volFieldsFwd.H"
#include "pointFields.H"
#include "typeInfo.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "tetIndices.H"
#include "typeInfo.H"
#include "barycentric.H"
#include "tetIndices.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class polyMesh;
/*---------------------------------------------------------------------------*\
@ -58,10 +59,9 @@ class polyMesh;
template<class Type>
class interpolation
{
protected:
// Protected data
// Protected Data
const GeometricField<Type, fvPatchField, volMesh>& psi_;
@ -112,7 +112,7 @@ public:
// Constructors
//- Construct from components
interpolation
explicit interpolation
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);
@ -125,7 +125,7 @@ public:
// Member Functions
//- Return the field to be interpolated
const GeometricField<Type, fvPatchField, volMesh>& psi() const
const GeometricField<Type, fvPatchField, volMesh>& psi() const noexcept
{
return psi_;
}
@ -139,9 +139,9 @@ public:
) const = 0;
//- Interpolate field to the given coordinates in the tetrahedron
// defined by the given indices. Calls interpolate function
// above here except where overridden by derived
// interpolation types.
//- defined by the given indices.
// Calls interpolate function (vector, cell, face) except
// where overridden by derived interpolation types.
virtual Type interpolate
(
const barycentric& coordinates,

View File

@ -40,18 +40,4 @@ Foam::interpolationCell<Type>::interpolationCell
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::interpolationCell<Type>::interpolate
(
const vector&,
const label celli,
const label
) const
{
return this->psi_[celli];
}
// ************************************************************************* //

View File

@ -27,12 +27,12 @@ Class
Foam::interpolationCell
Description
Uses the cell value for any point in the cell
Uses the cell value for any location within the cell
\*---------------------------------------------------------------------------*/
#ifndef interpolationCell_H
#define interpolationCell_H
#ifndef Foam_interpolationCell_H
#define Foam_interpolationCell_H
#include "interpolation.H"
@ -52,7 +52,6 @@ class interpolationCell
:
public interpolation<Type>
{
public:
//- Runtime type information
@ -62,7 +61,7 @@ public:
// Constructors
//- Construct from components
interpolationCell
explicit interpolationCell
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);
@ -70,25 +69,26 @@ public:
// Member Functions
//- Interpolate field to the given point in the given cell
Type interpolate
(
const vector& position,
const label celli,
const label facei = -1
) const;
//- Interpolate field to the given coordinates in the tetrahedron
// defined by the given indices. This is an optimisation which skips
// calculating the position, as cell interpolation doesn't need it.
//- Returns the cell value
inline Type interpolate
(
const barycentric& coordinates,
const tetIndices& tetIs,
const label facei = -1
const vector& position, /* (unused) */
const label celli,
const label facei = -1 /* (unused) */
) const
{
return interpolate(vector::zero, tetIs.cell(), facei);
return this->psi_[celli];
}
//- Returns the cell value corresponding to the given tetrahedron
inline Type interpolate
(
const barycentric& coordinates, /* (unused) */
const tetIndices& tetIs,
const label facei = -1 /* (unused) */
) const
{
return this->psi_[tetIs.cell()];
}
};

View File

@ -43,8 +43,6 @@ Description
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class interpolationCellPatchConstrained Declaration
\*---------------------------------------------------------------------------*/
@ -54,7 +52,6 @@ class interpolationCellPatchConstrained
:
public interpolation<Type>
{
public:
//- Runtime type information
@ -75,7 +72,7 @@ public:
//- Interpolate field to the given point in the given cell
Type interpolate
(
const vector& position,
const vector& position, /* (unused) */
const label celli,
const label facei = -1
) const;
@ -85,7 +82,7 @@ public:
// calculating the position, as cell interpolation doesn't need it.
inline Type interpolate
(
const barycentric& coordinates,
const barycentric& coordinates, /* (unused) */
const tetIndices& tetIs,
const label facei = -1
) const

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cellPointWeight_H
#define cellPointWeight_H
#ifndef Foam_cellPointWeight_H
#define Foam_cellPointWeight_H
#include "vector.H"
#include "barycentric.H"
@ -46,6 +46,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class polyMesh;
/*---------------------------------------------------------------------------*\
@ -56,13 +57,13 @@ class cellPointWeight
{
protected:
// Protected data
// Protected Data
//- Cell index
const label celli_;
//- Weights applied to tet vertices. Equal to the barycentric coordinates
// of the interpolation position.
//- Weights applied to tet vertices.
// Equal to the barycentric coordinates of the interpolation position.
barycentric weights_;
//- Face vertex indices
@ -111,19 +112,19 @@ public:
// Member Functions
//- Cell index
inline label cell() const
label cell() const noexcept
{
return celli_;
}
//- Interpolation weights
inline const barycentric& weights() const
const barycentric& weights() const noexcept
{
return weights_;
}
//- Interpolation addressing for points on face
inline const triFace& faceVertices() const
const triFace& faceVertices() const noexcept
{
return faceVertices_;
}

View File

@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef interpolationCellPoint_H
#define interpolationCellPoint_H
#ifndef Foam_interpolationCellPoint_H
#define Foam_interpolationCellPoint_H
#include "interpolation.H"
#include "cellPointWeight.H"
@ -54,7 +54,7 @@ class interpolationCellPoint
{
protected:
// Protected data
// Protected Data
//- Interpolated volfield
const GeometricField<Type, pointPatchField, pointMesh> psip_;
@ -69,7 +69,7 @@ public:
// Constructors
//- Construct from components
interpolationCellPoint
explicit interpolationCellPoint
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);

View File

@ -81,13 +81,15 @@ inline Type Foam::interpolationCellPoint<Type>::interpolate
}
}
const triFace triIs = tetIs.faceTriIs(this->pMesh_);
const triFace faceVertices(tetIs.faceTriIs(this->pMesh_));
return
(
this->psi_[tetIs.cell()]*coordinates[0]
+ psip_[triIs[0]]*coordinates[1]
+ psip_[triIs[1]]*coordinates[2]
+ psip_[triIs[2]]*coordinates[3];
+ psip_[faceVertices[0]]*coordinates[1]
+ psip_[faceVertices[1]]*coordinates[2]
+ psip_[faceVertices[2]]*coordinates[3]
);
}

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef interpolationCellPointFace_H
#define interpolationCellPointFace_H
#ifndef Foam_interpolationCellPointFace_H
#define Foam_interpolationCellPointFace_H
#include "interpolation.H"
@ -50,7 +50,7 @@ class interpolationCellPointFace
:
public interpolation<Type>
{
// Private data
// Private Data
//- Interpolated volfield
const GeometricField<Type, pointPatchField, pointMesh> psip_;
@ -89,7 +89,7 @@ public:
// Constructors
//- Construct from components
interpolationCellPointFace
explicit interpolationCellPointFace
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +27,32 @@ License
\*---------------------------------------------------------------------------*/
#include "cellPointWeightWallModified.H"
#include "polyMesh.H"
#include "polyBoundaryMesh.H"
#include "wallPolyPatch.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::cellPointWeightWallModified::onWall
(
const polyMesh& mesh,
const label facei
)
{
if (facei >= 0)
{
const polyBoundaryMesh& bm = mesh.boundaryMesh();
const label patchi = bm.whichPatch(facei);
if (patchi != -1 && isA<wallPolyPatch>(bm[patchi]))
{
return true;
}
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -39,24 +66,13 @@ Foam::cellPointWeightWallModified::cellPointWeightWallModified
:
cellPointWeight(mesh, position, celli, facei)
{
// findTetrahedron or findTriangle will already have been called
// by the cellPointWeight constructor
if (facei >= 0)
if (facei >= 0 && cellPointWeightWallModified::onWall(mesh, facei))
{
const polyBoundaryMesh& bm = mesh.boundaryMesh();
label patchi = bm.whichPatch(facei);
if (patchi != -1)
{
if (isA<wallPolyPatch>(bm[patchi]))
{
// Apply cell centre value wall faces
weights_[0] = 1.0;
weights_[1] = 0.0;
weights_[2] = 0.0;
weights_[3] = 0.0;
}
}
// Apply cell centre value for wall faces
weights_[0] = 1;
weights_[1] = 0;
weights_[2] = 0;
weights_[3] = 0;
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,21 +35,16 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cellPointWeightWallModified_H
#define cellPointWeightWallModified_H
#ifndef Foam_cellPointWeightWallModified_H
#define Foam_cellPointWeightWallModified_H
#include "cellPointWeight.H"
#include "wallPolyPatch.H"
#include "polyMesh.H"
#include "polyBoundaryMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
/*---------------------------------------------------------------------------*\
Class cellPointWeightWallModified Declaration
\*---------------------------------------------------------------------------*/
@ -69,6 +65,12 @@ public:
const label celli,
const label facei = -1
);
// Member Functions
//- True if face is on a wall path
static bool onWall(const polyMesh& mesh, const label facei);
};

View File

@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef interpolationCellPointWallModified_H
#define interpolationCellPointWallModified_H
#ifndef Foam_interpolationCellPointWallModified_H
#define Foam_interpolationCellPointWallModified_H
#include "interpolationCellPoint.H"
#include "cellPointWeightWallModified.H"
@ -61,7 +61,7 @@ public:
// Constructors
//- Construct from components
interpolationCellPointWallModified
explicit interpolationCellPointWallModified
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);
@ -70,7 +70,7 @@ public:
// Member Functions
//- Interpolate field for the given cellPointWeight
inline Type interpolate(const cellPointWeightWallModified& cpw) const;
inline Type interpolate(const cellPointWeight& cpw) const;
//- Interpolate field to the given point in the given cell
inline Type interpolate

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,18 +31,10 @@ License
template<class Type>
inline Type Foam::interpolationCellPointWallModified<Type>::interpolate
(
const cellPointWeightWallModified& cpw
const cellPointWeight& cpw
) const
{
const barycentric& weights = cpw.weights();
const triFace& faceVertices = cpw.faceVertices();
Type t = this->psi_[cpw.cell()]*weights[0];
t += this->psip_[faceVertices[0]]*weights[1];
t += this->psip_[faceVertices[1]]*weights[2];
t += this->psip_[faceVertices[2]]*weights[3];
return t;
return interpolationCellPoint<Type>::interpolate(cpw);
}
@ -53,7 +46,7 @@ inline Type Foam::interpolationCellPointWallModified<Type>::interpolate
const label facei
) const
{
return interpolate
return interpolationCellPoint<Type>::interpolate
(
cellPointWeightWallModified
(
@ -84,17 +77,9 @@ inline Type Foam::interpolationCellPointWallModified<Type>::interpolate
<< exit(FatalError);
}
const polyBoundaryMesh& bm = this->pMesh_.boundaryMesh();
label patchi = bm.whichPatch(facei);
if (patchi != -1)
if (cellPointWeightWallModified::onWall(this->pMesh_, facei))
{
if (isA<wallPolyPatch>(bm[patchi]))
{
Type t = this->psi_[tetIs.cell()];
return t;
}
return this->psi_[tetIs.cell()];
}
}

View File

@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef interpolationPointMVC_H
#define interpolationPointMVC_H
#ifndef Foam_interpolationPointMVC_H
#define Foam_interpolationPointMVC_H
#include "interpolation.H"
#include "pointMVCWeight.H"
@ -54,7 +54,7 @@ class interpolationPointMVC
{
protected:
// Protected data
// Protected Data
//- Interpolated volfield
const GeometricField<Type, pointPatchField, pointMesh> psip_;
@ -69,7 +69,7 @@ public:
// Constructors
//- Construct from components
interpolationPointMVC
explicit interpolationPointMVC
(
const GeometricField<Type, fvPatchField, volMesh>& psi
);

View File

@ -35,15 +35,13 @@ Description
2006 paper Eurographics Symposium on Geometry Processing
by Torsten Langer, Alexander Belyaev and Hans-Peter Seide
SourceFiles
pointMVCWeight.C
\*---------------------------------------------------------------------------*/
#ifndef pointMVCWeight_H
#define pointMVCWeight_H
#ifndef Foam_pointMVCWeight_H
#define Foam_pointMVCWeight_H
#include "scalarField.H"
#include "vectorField.H"
@ -56,12 +54,13 @@ SourceFiles
namespace Foam
{
class polyMesh;
// Forward Declarations
class face;
class pointMesh;
template<class T> class pointPatchField;
class polyMesh;
template<class Type> class pointPatchField;
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField;
class face;
/*---------------------------------------------------------------------------*\
Class pointMVCWeight Declaration
@ -71,7 +70,7 @@ class pointMVCWeight
{
protected:
// Protected data
// Protected Data
//- Cell index
const label cellIndex_;
@ -129,13 +128,13 @@ public:
// Member Functions
//- Cell index
inline label cell() const
label cell() const noexcept
{
return cellIndex_;
}
//- Interpolation weights (in order of cellPoints)
inline const scalarField& weights() const
const scalarField& weights() const noexcept
{
return weights_;
}

View File

@ -458,52 +458,52 @@ public:
inline label getNewParticleID() const;
//- Return the mesh database
inline const polyMesh& mesh() const;
inline const polyMesh& mesh() const noexcept;
//- Return current particle coordinates
inline const barycentric& coordinates() const;
inline const barycentric& coordinates() const noexcept;
//- Return current cell particle is in
inline label cell() const;
inline label cell() const noexcept;
//- Return current cell particle is in for manipulation
inline label& cell();
inline label& cell() noexcept;
//- Return current tet face particle is in
inline label tetFace() const;
inline label tetFace() const noexcept;
//- Return current tet face particle is in for manipulation
inline label& tetFace();
inline label& tetFace() noexcept;
//- Return current tet face particle is in
inline label tetPt() const;
inline label tetPt() const noexcept;
//- Return current tet face particle is in for manipulation
inline label& tetPt();
inline label& tetPt() noexcept;
//- Return current face particle is on otherwise -1
inline label face() const;
inline label face() const noexcept;
//- Return current face particle is on for manipulation
inline label& face();
inline label& face() noexcept;
//- Return the fraction of time-step completed
inline scalar stepFraction() const;
inline scalar stepFraction() const noexcept;
//- Return the fraction of time-step completed
inline scalar& stepFraction();
inline scalar& stepFraction() noexcept;
//- Return the originating processor ID
inline label origProc() const;
inline label origProc() const noexcept;
//- Return the originating processor ID
inline label& origProc();
inline label& origProc() noexcept;
//- Return the particle ID on the originating processor
inline label origId() const;
inline label origId() const noexcept;
//- Return the particle ID on the originating processor
inline label& origId();
inline label& origId() noexcept;
// Check
@ -519,9 +519,8 @@ public:
// from the stored step fraction due to sub-cycling.
inline scalar currentTimeFraction() const;
//- Return the indices of the current tet that the
// particle occupies.
inline tetIndices currentTetIndices() const;
//- Return indices of the current tet that the particle occupies.
inline tetIndices currentTetIndices() const noexcept;
//- Return the current tet transformation tensor
inline barycentricTensor currentTetTransform() const;
@ -530,13 +529,13 @@ public:
inline vector normal() const;
//- Is the particle on a face?
inline bool onFace() const;
inline bool onFace() const noexcept;
//- Is the particle on an internal face?
inline bool onInternalFace() const;
inline bool onInternalFace() const noexcept;
//- Is the particle on a boundary face?
inline bool onBoundaryFace() const;
inline bool onBoundaryFace() const noexcept;
//- Return the index of patch that the particle is on
inline label patch() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018, 2020 OpenFOAM Foundation
Copyright (C) 2011-2020 OpenCFD Ltd.
Copyright (C) 2011-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -134,97 +134,97 @@ inline Foam::label Foam::particle::getNewParticleID() const
}
inline const Foam::polyMesh& Foam::particle::mesh() const
inline const Foam::polyMesh& Foam::particle::mesh() const noexcept
{
return mesh_;
}
inline const Foam::barycentric& Foam::particle::coordinates() const
inline const Foam::barycentric& Foam::particle::coordinates() const noexcept
{
return coordinates_;
}
inline Foam::label Foam::particle::cell() const
inline Foam::label Foam::particle::cell() const noexcept
{
return celli_;
}
inline Foam::label& Foam::particle::cell()
inline Foam::label& Foam::particle::cell() noexcept
{
return celli_;
}
inline Foam::label Foam::particle::tetFace() const
inline Foam::label Foam::particle::tetFace() const noexcept
{
return tetFacei_;
}
inline Foam::label& Foam::particle::tetFace()
inline Foam::label& Foam::particle::tetFace() noexcept
{
return tetFacei_;
}
inline Foam::label Foam::particle::tetPt() const
inline Foam::label Foam::particle::tetPt() const noexcept
{
return tetPti_;
}
inline Foam::label& Foam::particle::tetPt()
inline Foam::label& Foam::particle::tetPt() noexcept
{
return tetPti_;
}
inline Foam::label Foam::particle::face() const
inline Foam::label Foam::particle::face() const noexcept
{
return facei_;
}
inline Foam::label& Foam::particle::face()
inline Foam::label& Foam::particle::face() noexcept
{
return facei_;
}
inline Foam::scalar Foam::particle::stepFraction() const
inline Foam::scalar Foam::particle::stepFraction() const noexcept
{
return stepFraction_;
}
inline Foam::scalar& Foam::particle::stepFraction()
inline Foam::scalar& Foam::particle::stepFraction() noexcept
{
return stepFraction_;
}
inline Foam::label Foam::particle::origProc() const
inline Foam::label Foam::particle::origProc() const noexcept
{
return origProc_;
}
inline Foam::label& Foam::particle::origProc()
inline Foam::label& Foam::particle::origProc() noexcept
{
return origProc_;
}
inline Foam::label Foam::particle::origId() const
inline Foam::label Foam::particle::origId() const noexcept
{
return origId_;
}
inline Foam::label& Foam::particle::origId()
inline Foam::label& Foam::particle::origId() noexcept
{
return origId_;
}
@ -262,7 +262,7 @@ inline Foam::scalar Foam::particle::currentTimeFraction() const
}
inline Foam::tetIndices Foam::particle::currentTetIndices() const
inline Foam::tetIndices Foam::particle::currentTetIndices() const noexcept
{
return tetIndices(celli_, tetFacei_, tetPti_);
}
@ -287,19 +287,19 @@ inline Foam::vector Foam::particle::normal() const
}
inline bool Foam::particle::onFace() const
inline bool Foam::particle::onFace() const noexcept
{
return facei_ >= 0;
}
inline bool Foam::particle::onInternalFace() const
inline bool Foam::particle::onInternalFace() const noexcept
{
return onFace() && mesh_.isInternalFace(facei_);
}
inline bool Foam::particle::onBoundaryFace() const
inline bool Foam::particle::onBoundaryFace() const noexcept
{
return onFace() && !mesh_.isInternalFace(facei_);
}
@ -320,8 +320,8 @@ inline Foam::vector Foam::particle::position() const
inline void Foam::particle::reset()
{
stepFraction_ = 0;
nBehind_ = 0;
behind_ = 0;
nBehind_ = 0;
}