From 0f4c6572bc2fe4ab3ab802e425eafb48dbf4dbbd Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Thu, 27 Sep 2018 12:46:48 +0100 Subject: [PATCH] ENH: polyPatch - added areaFraction method Helper function to calculate the current face area vs the area returned from the current point locations. Useful for ACMI-type baffles where we scale the face areas without moving points. --- .../polyPatches/polyPatch/polyPatch.C | 19 +++++++++++++++++++ .../polyPatches/polyPatch/polyPatch.H | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index d48d7e30ca..324203cf26 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -330,6 +330,25 @@ Foam::tmp Foam::polyPatch::faceCellCentres() const } +Foam::tmp Foam::polyPatch::areaFraction() const +{ + tmp tfraction(new scalarField(size())); + scalarField& fraction = tfraction.ref(); + + const vectorField::subField faceAreas = this->faceAreas(); + const pointField& points = this->points(); + + forAll(*this, facei) + { + const face& curFace = this->operator[](facei); + fraction[facei] = + mag(faceAreas[facei])/(curFace.mag(points) + ROOTVSMALL); + } + + return tfraction; +} + + const Foam::labelUList& Foam::polyPatch::faceCells() const { if (!faceCellsPtr_) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index a43c9e9844..0a185878d4 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -372,6 +372,10 @@ public: //- Return face cell centres tmp faceCellCentres() const; + //- Return the area fraction as the ratio of the stored face area + //- and the area given by the face points + tmp areaFraction() const; + // Addressing into mesh