From a539298fc2cf4dfe8dac16b0dab3cde2348bb3f4 Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Fri, 11 Nov 2011 16:56:05 +0000
Subject: [PATCH] ENH: Refactored mappedPatchBase

---
 .../mappedPolyPatch/mappedPatchBase.H         | 211 +++++-------------
 .../mappedPolyPatch/mappedPatchBaseI.H        |  88 ++++++++
 .../mappedPatchBaseTemplates.C                | 136 +++++++++++
 3 files changed, 278 insertions(+), 157 deletions(-)
 create mode 100644 src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
 create mode 100644 src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C

diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H
index b2f0f4eb92e..d6de7c96564 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H
@@ -290,184 +290,71 @@ public:
 
         void clearOut();
 
-        //- What to sample
-        const sampleMode& mode() const
-        {
-            return mode_;
-        }
+        // Access
 
-        //- Region to sample
-        const word& sampleRegion() const
-        {
-            return sampleRegion_;
-        }
+            //- What to sample
+            inline const sampleMode& mode() const;
 
-        //- Patch (only if NEARESTPATCHFACE)
-        const word& samplePatch() const
-        {
-            return samplePatch_;
-        }
+            //- Region to sample
+            inline const word& sampleRegion() const;
 
-        //- Offset vector (from patch faces to destination mesh objects)
-        const vector& offset() const
-        {
-            return offset_;
-        }
+            //- Patch (only if NEARESTPATCHFACE)
+            inline const word& samplePatch() const;
 
-        //- Offset vector (from patch faces to destination mesh objects)
-        const vectorField& offsets() const
-        {
-            return offsets_;
-        }
+            //- Offset vector (from patch faces to destination mesh objects)
+            inline const vector& offset() const;
 
-        //- Wrapper around map/interpolate data distribution
-        template<class Type>
-        void distribute(List<Type>& lst) const
-        {
-            switch (mode_)
-            {
-                case NEARESTPATCHFACEAMI:
-                {
-                    lst = AMI().interpolateToSource(Field<Type>(lst.xfer()));
-                    break;
-                }
-                default:
-                {
-                    map().distribute(lst);
-                }
-            }
-        }
+            //- Offset vector (from patch faces to destination mesh objects)
+            inline const vectorField& offsets() const;
 
+            //- Cached sampleRegion != mesh.name()
+            inline bool sameRegion() const;
 
-        //- Wrapper around map/interpolate data distribution with supplied op
-        template<class Type, class BinaryOp>
-        void distribute(List<Type>& lst, const BinaryOp& bop) const
-        {
-            switch (mode_)
-            {
-                case NEARESTPATCHFACEAMI:
-                {
-                    lst = AMI().interpolateToSource
-                        (
-                            Field<Type>(lst.xfer()),
-                            bop
-                        );
-                    break;
-                }
-                default:
-                {
-                    map().distribute
-                    (
-                        Pstream::defaultCommsType,
-                        map().schedule(),
-                        map().constructSize(),
-                        map().subMap(),
-                        map().constructMap(),
-                        lst,
-                        bop,
-                        pTraits<Type>::zero
-                    );
-                }
-            }
-        }
+            //- Return reference to the parallel distribution map
+            inline const mapDistribute& map() const;
 
+            //- Return reference to the AMI interpolator
+            inline const AMIPatchToPatchInterpolation& AMI
+            (
+                const bool forceUpdate = false
+            ) const;
 
-        //- Wrapper around map/interpolate data distribution
-        template<class Type>
-        void reverseDistribute(List<Type>& lst) const
-        {
-            switch (mode_)
-            {
-                case NEARESTPATCHFACEAMI:
-                {
-                    lst = AMI().interpolateToTarget(Field<Type>(lst.xfer()));
-                    break;
-                }
-                default:
-                {
-                    label cSize = patch_.size();
-                    map().reverseDistribute(cSize, lst);
-                }
-            }
-        }
+            //- Return a pointer to the AMI projection surface
+            const autoPtr<Foam::searchableSurface>& surfPtr() const;
 
+            //- Get the region mesh
+            const polyMesh& sampleMesh() const;
 
-        //- Wrapper around map/interpolate data distribution with supplied op
-        template<class Type, class BinaryOp>
-        void reverseDistribute(List<Type>& lst, const BinaryOp& bop) const
-        {
-            switch (mode_)
-            {
-                case NEARESTPATCHFACEAMI:
-                {
-                    lst = AMI().interpolateToTarget
-                        (
-                            Field<Type>(lst.xfer()),
-                            bop
-                        );
-                    break;
-                }
-                default:
-                {
-                    label cSize = patch_.size();
-                    map().distribute
-                    (
-                        Pstream::defaultCommsType,
-                        map().schedule(),
-                        cSize,
-                        map().constructMap(),
-                        map().subMap(),
-                        lst,
-                        bop,
-                        pTraits<Type>::zero
-                    );
-                }
-            }
-        }
+            //- Get the patch on the region
+            const polyPatch& samplePolyPatch() const;
 
+            //- Get the sample points
+            tmp<pointField> samplePoints() const;
 
-        //- Return reference to the parallel distribution map
-        const mapDistribute& map() const
-        {
-            if (mapPtr_.empty())
-            {
-                calcMapping();
-            }
 
-            return mapPtr_();
-        }
-
-        //- Return reference to the AMI interpolator
-        const AMIPatchToPatchInterpolation& AMI(bool forceUpdate = false) const
-        {
-            if (forceUpdate || AMIPtr_.empty())
-            {
-                calcAMI();
-            }
+        // Distribute
 
-            return AMIPtr_();
-        }
+            //- Wrapper around map/interpolate data distribution
+            template<class Type>
+            void distribute(List<Type>& lst) const;
 
-        //- Return a pointer to the AMI projection surface
-        const autoPtr<Foam::searchableSurface>& surfPtr() const;
+            //- Wrapper around map/interpolate data distribution with operation
+            template<class Type, class BinaryOp>
+            void distribute(List<Type>& lst, const BinaryOp& bop) const;
 
-        //- Cached sampleRegion != mesh.name()
-        bool sameRegion() const
-        {
-            return sameRegion_;
-        }
+            //- Wrapper around map/interpolate data distribution
+            template<class Type>
+            void reverseDistribute(List<Type>& lst) const;
 
-        //- Get the region mesh
-        const polyMesh& sampleMesh() const;
+            //- Wrapper around map/interpolate data distribution with operation
+            template<class Type, class BinaryOp>
+            void reverseDistribute(List<Type>& lst, const BinaryOp& bop) const;
 
-        //- Get the patch on the region
-        const polyPatch& samplePolyPatch() const;
 
-        //- Get the sample points
-        tmp<pointField> samplePoints() const;
+        // I/O
 
-        //- Write as a dictionary
-        virtual void write(Ostream&) const;
+            //- Write as a dictionary
+            virtual void write(Ostream&) const;
 };
 
 
@@ -477,6 +364,16 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "mappedPatchBaseI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+    #include "mappedPatchBaseTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
new file mode 100644
index 00000000000..5814a1e824e
--- /dev/null
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+     \\/     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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+inline const Foam::mappedPatchBase::sampleMode&
+Foam::mappedPatchBase::mode() const
+{
+    return mode_;
+}
+
+
+inline const Foam::word& Foam::mappedPatchBase::sampleRegion() const
+{
+    return sampleRegion_;
+}
+
+
+inline const Foam::word& Foam::mappedPatchBase::samplePatch() const
+{
+    return samplePatch_;
+}
+
+
+inline const Foam::vector& Foam::mappedPatchBase::offset() const
+{
+    return offset_;
+}
+
+
+inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const
+{
+    return offsets_;
+}
+
+
+inline bool Foam::mappedPatchBase::sameRegion() const
+{
+    return sameRegion_;
+}
+
+
+inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const
+{
+    if (mapPtr_.empty())
+    {
+        calcMapping();
+    }
+
+    return mapPtr_();
+}
+
+
+inline const Foam::AMIPatchToPatchInterpolation& Foam::mappedPatchBase::AMI
+(
+    bool forceUpdate
+) const
+{
+    if (forceUpdate || AMIPtr_.empty())
+    {
+        calcAMI();
+    }
+
+    return AMIPtr_();
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C
new file mode 100644
index 00000000000..47067b00f66
--- /dev/null
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C
@@ -0,0 +1,136 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+     \\/     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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+void Foam::mappedPatchBase::distribute(List<Type>& lst) const
+{
+    switch (mode_)
+    {
+        case NEARESTPATCHFACEAMI:
+        {
+            lst = AMI().interpolateToSource(Field<Type>(lst.xfer()));
+            break;
+        }
+        default:
+        {
+            map().distribute(lst);
+        }
+    }
+}
+
+
+template<class Type, class BinaryOp>
+void Foam::mappedPatchBase::distribute
+(
+    List<Type>& lst,
+    const BinaryOp& bop
+) const
+{
+    switch (mode_)
+    {
+        case NEARESTPATCHFACEAMI:
+        {
+            lst = AMI().interpolateToSource
+                (
+                    Field<Type>(lst.xfer()),
+                    bop
+                );
+            break;
+        }
+        default:
+        {
+            map().distribute
+            (
+                Pstream::defaultCommsType,
+                map().schedule(),
+                map().constructSize(),
+                map().subMap(),
+                map().constructMap(),
+                lst,
+                bop,
+                pTraits<Type>::zero
+            );
+        }
+    }
+}
+
+
+template<class Type>
+void Foam::mappedPatchBase::reverseDistribute(List<Type>& lst) const
+{
+    switch (mode_)
+    {
+        case NEARESTPATCHFACEAMI:
+        {
+            lst = AMI().interpolateToTarget(Field<Type>(lst.xfer()));
+            break;
+        }
+        default:
+        {
+            label cSize = patch_.size();
+            map().reverseDistribute(cSize, lst);
+        }
+    }
+}
+
+
+template<class Type, class BinaryOp>
+void Foam::mappedPatchBase::reverseDistribute
+(
+    List<Type>& lst,
+    const BinaryOp& bop
+) const
+{
+    switch (mode_)
+    {
+        case NEARESTPATCHFACEAMI:
+        {
+            lst = AMI().interpolateToTarget
+                (
+                    Field<Type>(lst.xfer()),
+                    bop
+                );
+            break;
+        }
+        default:
+        {
+            label cSize = patch_.size();
+            map().distribute
+            (
+                Pstream::defaultCommsType,
+                map().schedule(),
+                cSize,
+                map().constructMap(),
+                map().subMap(),
+                lst,
+                bop,
+                pTraits<Type>::zero
+            );
+        }
+    }
+}
+
+
+// ************************************************************************* //
-- 
GitLab