From a4dc9966eda70f06933c541d08d9ef0bfbf3b6a2 Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Fri, 7 Dec 2018 17:24:13 +0000
Subject: [PATCH] ENH: Added new AMIWeights function object
Reports the min|max|average AMI weights to text file and optionally
writes VTK surfaces of the sum of the weights, and mask field for
ACMI patches.
Example usage:
AMIWeights
{
type AMIWeights;
libs ("libfieldFunctionObjects.so");
writeControl writeTime;
writeFields yes;
}
---
.../postProcessing/fields/AMIWeights | 20 +
.../field/AMIWeights/AMIWeights.C | 396 ++++++++++++++++++
.../field/AMIWeights/AMIWeights.H | 163 +++++++
src/functionObjects/field/Make/files | 2 +
.../RAS/propeller/system/AMIWeights | 17 +
.../RAS/propeller/system/controlDict | 1 +
6 files changed, 599 insertions(+)
create mode 100644 etc/caseDicts/postProcessing/fields/AMIWeights
create mode 100644 src/functionObjects/field/AMIWeights/AMIWeights.C
create mode 100644 src/functionObjects/field/AMIWeights/AMIWeights.H
create mode 100644 tutorials/incompressible/pimpleFoam/RAS/propeller/system/AMIWeights
diff --git a/etc/caseDicts/postProcessing/fields/AMIWeights b/etc/caseDicts/postProcessing/fields/AMIWeights
new file mode 100644
index 0000000000..3bbda0fcc5
--- /dev/null
+++ b/etc/caseDicts/postProcessing/fields/AMIWeights
@@ -0,0 +1,20 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Version: v1806
+ \\ / A nd | Web: www.OpenFOAM.com
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+Description
+ Calculates and writes the second largest eigenvalue of the sum of the
+ square of the symmetrical and anti-symmetrical parts of the velocity
+ gradient tensor.
+
+\*---------------------------------------------------------------------------*/
+
+type AMIWeights;
+libs ("libfieldFunctionObjects.so");
+writeFields yes;
+writeControl writeTime;
+
+// ************************************************************************* //
diff --git a/src/functionObjects/field/AMIWeights/AMIWeights.C b/src/functionObjects/field/AMIWeights/AMIWeights.C
new file mode 100644
index 0000000000..4f0952442c
--- /dev/null
+++ b/src/functionObjects/field/AMIWeights/AMIWeights.C
@@ -0,0 +1,396 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
+ \\/ 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "AMIWeights.H"
+#include "fvMesh.H"
+#include "vtkSurfaceWriter.H"
+#include "PatchTools.H"
+#include "cyclicACMIPolyPatch.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+ defineTypeNameAndDebug(AMIWeights, 0);
+ addToRunTimeSelectionTable(functionObject, AMIWeights, dictionary);
+}
+}
+
+// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
+
+void Foam::functionObjects::AMIWeights::writeFileHeader(Ostream& os)
+{
+ writeHeader(os, "AMI");
+
+ writeCommented(os, "Time");
+ forAll(patchIDs_, patchi)
+ {
+ writeTabbed(os, "Patch");
+ writeTabbed(os, "nbr_patch");
+
+ if (Pstream::parRun())
+ {
+ writeTabbed(os, "distributed");
+ }
+
+ writeTabbed(os, "src_min_weight");
+ writeTabbed(os, "src_max_weight");
+ writeTabbed(os, "src_average_weight");
+ writeTabbed(os, "src_min_neighbours");
+ writeTabbed(os, "src_max_neighbours");
+ writeTabbed(os, "src_average_neighbours");
+ writeTabbed(os, "tgt_min_weight");
+ writeTabbed(os, "tgt_max_weight");
+ writeTabbed(os, "tgt_average_weight");
+ writeTabbed(os, "tgt_min_neighbours");
+ writeTabbed(os, "tgt_max_neighbours");
+ writeTabbed(os, "tgt_average_neighbours");
+ }
+
+ os << endl;
+}
+
+
+void Foam::functionObjects::AMIWeights::reportPatch
+(
+ const cyclicAMIPolyPatch& pp
+)
+{
+ const word& nbrPatchName = pp.neighbPatchName();
+
+ const Switch distributed = pp.AMI().singlePatchProc() == -1;
+
+ const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum();
+ const scalar srcMinWeight = gMin(srcWeightsSum);
+ const scalar srcMaxWeight = gMax(srcWeightsSum);
+ const scalar srcAveWeight = gAverage(srcWeightsSum);
+
+ const labelListList& srcAddress = pp.AMI().srcAddress();
+ label srcMinNbr = labelMax;
+ label srcMaxNbr = labelMin;
+ scalar srcAveNbr = 0;
+ for (const labelList& srcFace : srcAddress)
+ {
+ const label n = srcFace.size();
+ srcAveNbr += n;
+ srcMinNbr = min(srcMinNbr, n);
+ srcMaxNbr = max(srcMaxNbr, n);
+ }
+
+ reduce(srcMinNbr, minOp