From 4f50e3030ac09a4d56c48152c9afa523a8edf2f0 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 21 Apr 2016 08:50:13 +0100
Subject: [PATCH] ENH: cyclicAMI: added 'method' specification

---
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C   | 32 +++++++++++++++++--
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H   |  3 ++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
index fb69047afe5..25d5507eb5d 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -495,6 +495,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
     rotationAngle_(0.0),
     separationVector_(vector::zero),
     AMIPtr_(NULL),
+    AMIMethod_(AMIPatchToPatchInterpolation::imFaceAreaWeight),
     AMIReverse_(false),
     AMIRequireMatch_(true),
     AMILowWeightCorrection_(-1.0),
@@ -525,6 +526,20 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
     rotationAngle_(0.0),
     separationVector_(vector::zero),
     AMIPtr_(NULL),
+    AMIMethod_
+    (
+        AMIPatchToPatchInterpolation::wordTointerpolationMethod
+        (
+            dict.lookupOrDefault
+            (
+                "method",
+                AMIPatchToPatchInterpolation::interpolationMethodToWord
+                (
+                    AMIPatchToPatchInterpolation::imFaceAreaWeight
+                )
+            )
+        )
+    ),
     AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
     AMIRequireMatch_(true),
     AMILowWeightCorrection_(dict.lookupOrDefault("lowWeightCorrection", -1.0)),
@@ -614,6 +629,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
     rotationAngle_(pp.rotationAngle_),
     separationVector_(pp.separationVector_),
     AMIPtr_(NULL),
+    AMIMethod_(pp.AMIMethod_),
     AMIReverse_(pp.AMIReverse_),
     AMIRequireMatch_(pp.AMIRequireMatch_),
     AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
@@ -645,6 +661,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
     rotationAngle_(pp.rotationAngle_),
     separationVector_(pp.separationVector_),
     AMIPtr_(NULL),
+    AMIMethod_(pp.AMIMethod_),
     AMIReverse_(pp.AMIReverse_),
     AMIRequireMatch_(pp.AMIRequireMatch_),
     AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
@@ -683,6 +700,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
     rotationAngle_(pp.rotationAngle_),
     separationVector_(pp.separationVector_),
     AMIPtr_(NULL),
+    AMIMethod_(pp.AMIMethod_),
     AMIReverse_(pp.AMIReverse_),
     AMIRequireMatch_(pp.AMIRequireMatch_),
     AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
@@ -791,7 +809,7 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI() const
 
     if (!AMIPtr_.valid())
     {
-        resetAMI();
+        resetAMI(AMIMethod_);
     }
 
     return AMIPtr_();
@@ -1080,6 +1098,16 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
         }
     }
 
+    if (AMIMethod_ != AMIPatchToPatchInterpolation::imFaceAreaWeight)
+    {
+        os.writeKeyword("method")
+            <<  AMIPatchToPatchInterpolation::interpolationMethodToWord
+                (
+                    AMIMethod_
+                )
+            << token::END_STATEMENT << nl;
+    }
+
     if (AMIReverse_)
     {
         os.writeKeyword("flipNormals") << AMIReverse_
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
index fe783cd2e3b..1a415ba5fa0 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
+++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
@@ -111,6 +111,9 @@ protected:
         //- AMI interpolation class
         mutable autoPtr<AMIPatchToPatchInterpolation> AMIPtr_;
 
+        //- AMI method
+        const AMIPatchToPatchInterpolation::interpolationMethod AMIMethod_;
+
         //- Flag to indicate that slave patch should be reversed for AMI
         const bool AMIReverse_;
 
-- 
GitLab