From 58e969c37658e9e61b57fbfeede50ab306274440 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Tue, 24 Aug 2010 12:39:32 +0100
Subject: [PATCH] ENH: structuredDecomp : new decomposition method.
 fixedNormalSlip : variant of slip point bc with user-specified normal.

---
 src/OpenFOAM/Make/files                       |   1 +
 .../fixedNormalSlipPointPatchField.C          | 114 ++++++++++
 .../fixedNormalSlipPointPatchField.H          | 170 +++++++++++++++
 .../fixedNormalSlipPointPatchFields.C         |  43 ++++
 .../fixedNormalSlipPointPatchFields.H         |  49 +++++
 .../decompose/decompositionMethods/Make/files |   2 +
 .../decompositionMethods/Make/options         |   6 +-
 .../decompositionMethod/decompositionMethod.H |   2 +-
 .../structuredDecomp/structuredDecomp.C       | 201 ++++++++++++++++++
 .../structuredDecomp/structuredDecomp.H       | 142 +++++++++++++
 .../structuredDecomp/topoDistanceData.C       |  51 +++++
 .../structuredDecomp/topoDistanceData.H       | 192 +++++++++++++++++
 .../structuredDecomp/topoDistanceDataI.H      | 194 +++++++++++++++++
 .../SnakeRiverCanyon/0/pointDisplacement      |  12 +-
 .../SnakeRiverCanyon/constant/dynamicMeshDict |  10 +-
 .../constant/polyMesh/blockMeshDict           |  29 +--
 .../SnakeRiverCanyon/system/controlDict       |   6 +-
 17 files changed, 1194 insertions(+), 30 deletions(-)
 create mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
 create mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.H
 create mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.C
 create mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.H
 create mode 100644 src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.C
 create mode 100644 src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.H
 create mode 100644 src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.C
 create mode 100644 src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H
 create mode 100644 src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceDataI.H

diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 9560986fbdf..ec202a76eed 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -530,6 +530,7 @@ $(constraintPointPatchFields)/processorCyclic/processorCyclicPointPatchFields.C
 
 derivedPointPatchFields = $(pointPatchFields)/derived
 $(derivedPointPatchFields)/slip/slipPointPatchFields.C
+$(derivedPointPatchFields)/fixedNormalSlip/fixedNormalSlipPointPatchFields.C
 /*
 $(derivedPointPatchFields)/global/globalPointPatchFields.C
 */
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
new file mode 100644
index 00000000000..196ed0b8178
--- /dev/null
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "fixedNormalSlipPointPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
+(
+    const pointPatch& p,
+    const DimensionedField<Type, pointMesh>& iF
+)
+:
+    slipPointPatchField<Type>(p, iF),
+    n_(vector::max)
+{}
+
+
+template<class Type>
+fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
+(
+    const pointPatch& p,
+    const DimensionedField<Type, pointMesh>& iF,
+    const dictionary& dict
+)
+:
+    slipPointPatchField<Type>(p, iF, dict),
+    n_(dict.lookup("n"))
+{}
+
+
+template<class Type>
+fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
+(
+    const fixedNormalSlipPointPatchField<Type>& ptf,
+    const pointPatch& p,
+    const DimensionedField<Type, pointMesh>& iF,
+    const pointPatchFieldMapper& mapper
+)
+:
+    slipPointPatchField<Type>(ptf, p, iF, mapper),
+    n_(ptf.n_)
+{}
+
+
+template<class Type>
+fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
+(
+    const fixedNormalSlipPointPatchField<Type>& ptf,
+    const DimensionedField<Type, pointMesh>& iF
+)
+:
+    slipPointPatchField<Type>(ptf, iF),
+    n_(ptf.n_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void fixedNormalSlipPointPatchField<Type>::evaluate(const Pstream::commsTypes)
+{
+    tmp<Field<Type> > tvalues =
+        transform(I - n_*n_, this->patchInternalField());
+
+    // Get internal field to insert values into
+    Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
+
+    setInInternalField(iF, tvalues());
+}
+
+
+template<class Type>
+void fixedNormalSlipPointPatchField<Type>::write(Ostream& os) const
+{
+    slipPointPatchField<Type>::write(os);
+    os.writeKeyword("n")
+        << n_ << token::END_STATEMENT << nl;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.H
new file mode 100644
index 00000000000..61f9e10bcf9
--- /dev/null
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.H
@@ -0,0 +1,170 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::fixedNormalSlipPointPatchField
+
+Description
+    slip with user-specified normal
+
+SourceFiles
+    fixedNormalSlipPointPatchField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef fixedNormalSlipPointPatchField_H
+#define fixedNormalSlipPointPatchField_H
+
+#include "slipPointPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of friend functions and operators
+
+template<class Type>
+class fixedNormalSlipPointPatchField;
+
+template<class Type>
+Ostream& operator<<
+(
+    Ostream&,
+    const fixedNormalSlipPointPatchField<Type>&
+);
+
+
+/*---------------------------------------------------------------------------*\
+                        Class fixedNormalSlipPointPatchField Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class fixedNormalSlipPointPatchField
+:
+    public slipPointPatchField<Type>
+{
+    // Private data
+
+        //- User specified normal
+        vector n_;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("fixedNormalSlip");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        fixedNormalSlipPointPatchField
+        (
+            const pointPatch&,
+            const DimensionedField<Type, pointMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        fixedNormalSlipPointPatchField
+        (
+            const pointPatch&,
+            const DimensionedField<Type, pointMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given patchField<Type> onto a new patch
+        fixedNormalSlipPointPatchField
+        (
+            const fixedNormalSlipPointPatchField<Type>&,
+            const pointPatch&,
+            const DimensionedField<Type, pointMesh>&,
+            const pointPatchFieldMapper&
+        );
+
+        //- Construct and return a clone
+        virtual autoPtr<pointPatchField<Type> > clone() const
+        {
+            return autoPtr<pointPatchField<Type> >
+            (
+                new fixedNormalSlipPointPatchField<Type>
+                (
+                    *this
+                )
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        fixedNormalSlipPointPatchField
+        (
+            const fixedNormalSlipPointPatchField<Type>&,
+            const DimensionedField<Type, pointMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual autoPtr<pointPatchField<Type> > clone
+        (
+            const DimensionedField<Type, pointMesh>& iF
+        ) const
+        {
+            return autoPtr<pointPatchField<Type> >
+            (
+                new fixedNormalSlipPointPatchField<Type>
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the patch field
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::blocking
+            );
+
+
+        //- Write
+        virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#    include "fixedNormalSlipPointPatchField.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.C b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.C
new file mode 100644
index 00000000000..b00ab9988a6
--- /dev/null
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.C
@@ -0,0 +1,43 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "fixedNormalSlipPointPatchFields.H"
+#include "pointPatchFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+makePointPatchFields(fixedNormalSlip);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.H b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.H
new file mode 100644
index 00000000000..9f9edc4b9a3
--- /dev/null
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchFields.H
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef fixedNormalSlipPointPatchFields_H
+#define fixedNormalSlipPointPatchFields_H
+
+#include "fixedNormalSlipPointPatchField.H"
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePointPatchFieldTypedefs(fixedNormalSlip);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/Make/files b/src/parallel/decompose/decompositionMethods/Make/files
index fccb8b7c8f6..b21f2c70bda 100644
--- a/src/parallel/decompose/decompositionMethods/Make/files
+++ b/src/parallel/decompose/decompositionMethods/Make/files
@@ -4,5 +4,7 @@ simpleGeomDecomp/simpleGeomDecomp.C
 hierarchGeomDecomp/hierarchGeomDecomp.C
 manualDecomp/manualDecomp.C
 multiLevelDecomp/multiLevelDecomp.C
+structuredDecomp/topoDistanceData.C
+structuredDecomp/structuredDecomp.C
 
 LIB = $(FOAM_LIBBIN)/libdecompositionMethods
diff --git a/src/parallel/decompose/decompositionMethods/Make/options b/src/parallel/decompose/decompositionMethods/Make/options
index 30ba3a8df32..1c8b0769e9e 100644
--- a/src/parallel/decompose/decompositionMethods/Make/options
+++ b/src/parallel/decompose/decompositionMethods/Make/options
@@ -1,4 +1,6 @@
-EXE_INC =
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude
 
-LIB_LIBS =
+LIB_LIBS = \
+    -lfiniteVolume
 
diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
index e5995a403d5..e0355c19835 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
+++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
@@ -53,7 +53,7 @@ protected:
 
     // Protected data
 
-        const dictionary& decompositionDict_;
+        const dictionary decompositionDict_;
         label nProcessors_;
 
 
diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.C b/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.C
new file mode 100644
index 00000000000..9843b4550b7
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.C
@@ -0,0 +1,201 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2010-2010 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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "structuredDecomp.H"
+#include "addToRunTimeSelectionTable.H"
+#include "IFstream.H"
+#include "FaceCellWave.H"
+#include "topoDistanceData.H"
+#include "fvMeshSubset.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(structuredDecomp, 0);
+
+    addToRunTimeSelectionTable
+    (
+        decompositionMethod,
+        structuredDecomp,
+        dictionary
+    );
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::structuredDecomp::structuredDecomp(const dictionary& decompositionDict)
+:
+    decompositionMethod(decompositionDict)
+{
+    dictionary myDict = decompositionDict_.subDict(typeName + "Coeffs");
+    myDict.set("numberOfSubdomains", nDomains());
+    method_ = decompositionMethod::New(myDict);
+    patches_ = wordList(myDict.lookup("patches"));
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::structuredDecomp::parallelAware() const
+{
+    return method_().parallelAware();
+}
+
+
+Foam::labelList Foam::structuredDecomp::decompose
+(
+    const polyMesh& mesh,
+    const pointField& cc,
+    const scalarField& cWeights
+)
+{
+    labelList patchIDs(patches_.size());
+    const polyBoundaryMesh& pbm = mesh.boundaryMesh();
+
+    label nFaces = 0;
+    forAll(patches_, i)
+    {
+        patchIDs[i] = pbm.findPatchID(patches_[i]);
+
+        if (patchIDs[i] == -1)
+        {
+            FatalErrorIn("structuredDecomp::decompose(..)")
+                << "Cannot find patch " << patches_[i] << endl
+                << "Valid patches are " << pbm.names()
+                << exit(FatalError);
+        }
+        nFaces += pbm[patchIDs[i]].size();
+    }
+
+    // Extract a submesh.
+    labelHashSet patchCells(2*nFaces);
+    forAll(patchIDs, i)
+    {
+        const unallocLabelList& fc = pbm[patchIDs[i]].faceCells();
+        forAll(fc, i)
+        {
+            patchCells.insert(fc[i]);
+        }
+    }
+
+    // Subset the layer of cells next to the patch
+    fvMeshSubset subsetter(dynamic_cast<const fvMesh&>(mesh));
+    subsetter.setLargeCellSubset(patchCells);
+    const fvMesh& subMesh = subsetter.subMesh();
+    pointField subCc(cc, subsetter.cellMap());
+    scalarField subWeights(cWeights, subsetter.cellMap());
+
+    // Decompose the layer of cells
+    labelList subDecomp(method_().decompose(subMesh, subCc, subWeights));
+
+
+    // Transfer to final decomposition
+    labelList finalDecomp(cc.size(), -1);
+    forAll(subDecomp, i)
+    {
+        finalDecomp[subsetter.cellMap()[i]] = subDecomp[i];
+    }
+
+    // Field on cells and faces.
+    List<topoDistanceData> cellData(mesh.nCells());
+    List<topoDistanceData> faceData(mesh.nFaces());
+
+    // Start of changes
+    labelList patchFaces(nFaces);
+    List<topoDistanceData> patchData(nFaces);
+    nFaces = 0;
+    forAll(patchIDs, i)
+    {
+        const polyPatch& pp = pbm[patchIDs[i]];
+        const unallocLabelList& fc = pp.faceCells();
+        forAll(fc, i)
+        {
+            patchFaces[nFaces] = pp.start()+i;
+            patchData[nFaces] = topoDistanceData(finalDecomp[fc[i]], 0);
+            nFaces++;
+        }
+    }
+
+    // Propagate information inwards
+    FaceCellWave<topoDistanceData> deltaCalc
+    (
+        mesh,
+        patchFaces,
+        patchData,
+        faceData,
+        cellData,
+        mesh.globalData().nTotalCells()
+    );
+
+    // And extract
+    bool haveWarned = false;
+    forAll(finalDecomp, cellI)
+    {
+        if (!cellData[cellI].valid())
+        {
+            if (!haveWarned)
+            {
+                WarningIn("structuredDecomp::decompose(..)")
+                    << "Did not visit some cells, e.g. cell " << cellI
+                    << " at " << mesh.cellCentres()[cellI] << endl
+                    << "Assigning  these cells to domain 0." << endl;
+                haveWarned = true;
+            }
+            finalDecomp[cellI] = 0;
+        }
+        else
+        {
+            finalDecomp[cellI] = cellData[cellI].data();
+        }
+    }
+
+    return finalDecomp;
+}
+
+
+Foam::labelList Foam::structuredDecomp::decompose
+(
+    const labelListList& globalPointPoints,
+    const pointField& points,
+    const scalarField& pointWeights
+)
+{
+    notImplemented
+    (
+        "structuredDecomp::decompose\n"
+        "(\n"
+        "    const labelListList&,\n"
+        "    const pointField&,\n"
+        "    const scalarField&\n"
+        ")\n"
+    );
+
+    return labelList::null();
+}
+
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.H b/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.H
new file mode 100644
index 00000000000..d3f17687c6a
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/structuredDecomp.H
@@ -0,0 +1,142 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2010-2010 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 <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::structuredDecomp
+
+Description
+    Decomposition given using consecutive application of decomposers.
+
+SourceFiles
+    structuredDecomp.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef structuredDecomp_H
+#define structuredDecomp_H
+
+#include "decompositionMethod.H"
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class structuredDecomp Declaration
+\*---------------------------------------------------------------------------*/
+
+class structuredDecomp
+:
+    public decompositionMethod
+{
+    // Private data
+
+        autoPtr<decompositionMethod> method_;
+
+        wordList patches_;
+
+
+    // Private Member Functions
+
+        //- Given connectivity across processors work out connectivity
+        //  for a (consistent) subset
+        void subsetGlobalCellCells
+        (
+            const label nDomains,
+            const label domainI,
+            const labelList& dist,
+
+            const labelListList& cellCells,
+            const labelList& set,
+            labelListList& subCellCells,
+            labelList& cutConnections
+        ) const;
+
+        //- Decompose level methodI without addressing
+        void decompose
+        (
+            const labelListList& pointPoints,
+            const pointField& points,
+            const scalarField& pointWeights,
+            const labelList& pointMap,  // map back to original points
+            const label levelI,
+
+            labelField& finalDecomp
+        );
+
+        //- Disallow default bitwise copy construct and assignment
+        void operator=(const structuredDecomp&);
+        structuredDecomp(const structuredDecomp&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("structured");
+
+
+    // Constructors
+
+        //- Construct given the decomposition dictionary
+        structuredDecomp(const dictionary& decompositionDict);
+
+
+    //- Destructor
+    virtual ~structuredDecomp()
+    {}
+
+
+    // Member Functions
+
+        //- Is method parallel aware (i.e. does it synchronize domains across
+        //  proc boundaries)
+        virtual bool parallelAware() const;
+
+        //- Return for every coordinate the wanted processor number. Use the
+        //  mesh connectivity (if needed)
+        virtual labelList decompose
+        (
+            const polyMesh& mesh,
+            const pointField& points,
+            const scalarField& pointWeights
+        );
+
+        //- Return for every coordinate the wanted processor number. Explicitly
+        //  provided connectivity - does not use mesh_.
+        virtual labelList decompose
+        (
+            const labelListList& globalCellCells,
+            const pointField& cc,
+            const scalarField& cWeights
+        );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.C b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.C
new file mode 100644
index 00000000000..f9b99318c63
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.C
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 2 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, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "topoDistanceData.H"
+
+// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+
+Foam::Ostream& Foam::operator<<
+(
+    Foam::Ostream& os,
+    const Foam::topoDistanceData& wDist
+)
+{
+    return os << wDist.data_ << token::SPACE << wDist.distance_;
+}
+
+
+Foam::Istream& Foam::operator>>
+(
+    Foam::Istream& is,
+    Foam::topoDistanceData& wDist
+)
+{
+    return is >> wDist.data_ >> wDist.distance_;
+}
+
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H
new file mode 100644
index 00000000000..d5c6e840d8b
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceData.H
@@ -0,0 +1,192 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 2 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, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+    Foam::topoDistanceData
+
+Description
+    For use with FaceCellWave. Determines topological distance to starting faces
+
+SourceFiles
+    topoDistanceDataI.H
+    topoDistanceData.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef topoDistanceData_H
+#define topoDistanceData_H
+
+#include "point.H"
+#include "tensor.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class polyPatch;
+class polyMesh;
+
+/*---------------------------------------------------------------------------*\
+                           Class topoDistanceData Declaration
+\*---------------------------------------------------------------------------*/
+
+class topoDistanceData
+{
+    // Private data
+
+        //- Starting data
+        label data_;
+
+        //- Distance
+        label distance_;
+
+
+public:
+
+    // Constructors
+
+        //- Construct null
+        inline topoDistanceData();
+
+        //- Construct from count
+        inline topoDistanceData
+        (
+            const label data,
+            const label distance
+        );
+
+
+    // Member Functions
+
+        // Access
+
+
+            inline label data() const
+            {
+                return data_;
+            }
+            inline label distance() const
+            {
+                return distance_;
+            }
+
+
+        // Needed by FaceCellWave
+
+            //- Check whether origin has been changed at all or
+            //  still contains original (invalid) value.
+            inline bool valid() const;
+
+            //- Check for identical geometrical data. Used for cyclics checking.
+            inline bool sameGeometry
+            (
+                const polyMesh&,
+                const topoDistanceData&,
+                const scalar
+            ) const;
+
+            //- Convert any absolute coordinates into relative to (patch)face
+            //  centre
+            inline void leaveDomain
+            (
+                const polyMesh&,
+                const polyPatch&,
+                const label patchFaceI,
+                const point& faceCentre
+            );
+
+            //- Reverse of leaveDomain
+            inline void enterDomain
+            (
+                const polyMesh&,
+                const polyPatch&,
+                const label patchFaceI,
+                const point& faceCentre
+            );
+
+            //- Apply rotation matrix to any coordinates
+            inline void transform
+            (
+                const polyMesh&,
+                const tensor&
+            );
+
+            //- Influence of neighbouring face.
+            inline bool updateCell
+            (
+                const polyMesh&,
+                const label thisCellI,
+                const label neighbourFaceI,
+                const topoDistanceData& neighbourInfo,
+                const scalar tol
+            );
+
+            //- Influence of neighbouring cell.
+            inline bool updateFace
+            (
+                const polyMesh&,
+                const label thisFaceI,
+                const label neighbourCellI,
+                const topoDistanceData& neighbourInfo,
+                const scalar tol
+            );
+
+            //- Influence of different value on same face.
+            inline bool updateFace
+            (
+                const polyMesh&,
+                const label thisFaceI,
+                const topoDistanceData& neighbourInfo,
+                const scalar tol
+            );
+
+    // Member Operators
+
+        // Needed for List IO
+        inline bool operator==(const topoDistanceData&) const;
+
+        inline bool operator!=(const topoDistanceData&) const;
+
+
+    // IOstream Operators
+
+        friend Ostream& operator<<(Ostream&, const topoDistanceData&);
+        friend Istream& operator>>(Istream&, topoDistanceData&);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "topoDistanceDataI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceDataI.H b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceDataI.H
new file mode 100644
index 00000000000..5fcf99511ce
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/structuredDecomp/topoDistanceDataI.H
@@ -0,0 +1,194 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2010 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 2 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, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "polyMesh.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+// Null constructor
+inline Foam::topoDistanceData::topoDistanceData()
+:
+    data_(-1),
+    distance_(-1)
+{}
+
+
+// Construct from components
+inline Foam::topoDistanceData::topoDistanceData
+(
+    const label data,
+    const label distance
+)
+:
+    data_(data),
+    distance_(distance)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline bool Foam::topoDistanceData::valid() const
+{
+    return distance_ != -1;
+}
+
+
+// No geometric data so never any problem on cyclics
+inline bool Foam::topoDistanceData::sameGeometry
+(
+    const polyMesh&,
+    const topoDistanceData&,
+    const scalar
+) const
+{
+    return true;
+}
+
+
+// No geometric data.
+inline void Foam::topoDistanceData::leaveDomain
+(
+    const polyMesh&,
+    const polyPatch& patch,
+    const label patchFaceI,
+    const point& faceCentre
+)
+{}
+
+
+// No geometric data.
+inline void Foam::topoDistanceData::transform
+(
+    const polyMesh&,
+    const tensor& rotTensor
+)
+{}
+
+
+// No geometric data.
+inline void Foam::topoDistanceData::enterDomain
+(
+    const polyMesh&,
+    const polyPatch& patch,
+    const label patchFaceI,
+    const point& faceCentre
+)
+{}
+
+
+// Update cell with neighbouring face information
+inline bool Foam::topoDistanceData::updateCell
+(
+    const polyMesh&,
+    const label thisCellI,
+    const label neighbourFaceI,
+    const topoDistanceData& neighbourInfo,
+    const scalar tol
+)
+{
+    if (distance_ == -1)
+    {
+        data_ = neighbourInfo.data_;
+        distance_ = neighbourInfo.distance_ + 1;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+// Update face with neighbouring cell information
+inline bool Foam::topoDistanceData::updateFace
+(
+    const polyMesh& mesh,
+    const label thisFaceI,
+    const label neighbourCellI,
+    const topoDistanceData& neighbourInfo,
+    const scalar tol
+)
+{
+    // From cell to its faces.
+
+    if (distance_ == -1)
+    {
+        operator=(neighbourInfo);
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+// Update face with coupled face information
+inline bool Foam::topoDistanceData::updateFace
+(
+    const polyMesh&,
+    const label thisFaceI,
+    const topoDistanceData& neighbourInfo,
+    const scalar tol
+)
+{
+    // From face to face (e.g. coupled faces)
+    if (distance_ == -1)
+    {
+        operator=(neighbourInfo);
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+inline bool Foam::topoDistanceData::operator==
+(
+    const Foam::topoDistanceData& rhs
+) const
+{
+    return data() == rhs.data() && distance() == rhs.distance();
+}
+
+
+inline bool Foam::topoDistanceData::operator!=
+(
+    const Foam::topoDistanceData& rhs
+) const
+{
+    return !(*this == rhs);
+}
+
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/0/pointDisplacement b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/0/pointDisplacement
index 5b70c942ff0..90b91e5ba2d 100644
--- a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/0/pointDisplacement
+++ b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/0/pointDisplacement
@@ -84,22 +84,26 @@ boundaryField
 
     maxX
     {
-        type            slip;
+        type            fixedNormalSlip;
+        n               (1 0 0);
     }
 
     minX
     {
-        type            slip;
+        type            fixedNormalSlip;
+        n               (1 0 0);
     }
 
     minY
     {
-        type            slip;
+        type            fixedNormalSlip;
+        n               (0 1 0);
     }
 
     maxY
     {
-        type            slip;
+        type            fixedNormalSlip;
+        n               (0 1 0);
     }
 }
 
diff --git a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict
index 0ed92968f90..88894194181 100644
--- a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict
+++ b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict
@@ -20,15 +20,13 @@ dynamicFvMesh dynamicMotionSolverFvMesh;
 
 motionSolverLibs ("libfvMotionSolvers.so");
 
-solver displacementSBRStress;   //displacementLaplacian;   //displacementSBRStress;
-diffusivity quadratic quadratic inverseDistance 1(minZ);
-
+solver displacementSBRStress;   //displacementLaplacian;
 //solver velocityComponentLaplacian z;
+
 //diffusivity  uniform;
 //diffusivity  directional (1 200 0);
-// diffusivity  motionDirectional (1 1000 0);
-// diffusivity  file motionDiffusivity;
+//diffusivity  motionDirectional (1 1000 0);
+//diffusivity  file motionDiffusivity;
 diffusivity  quadratic inverseDistance 1(minZ);
-// diffusivity  exponential 2000 inverseDistance 1(movingWall);
 
 // ************************************************************************* //
diff --git a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/polyMesh/blockMeshDict b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/polyMesh/blockMeshDict
index f930dadc112..fd92f759042 100644
--- a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/polyMesh/blockMeshDict
+++ b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/polyMesh/blockMeshDict
@@ -19,14 +19,14 @@ convertToMeters 1;
 
 vertices
 (
-    ( 659531  4.7513e+06   1028)
-    ( 659531  4.7513e+06   2100)
-    ( 662381  4.7513e+06   2100)
-    ( 662381  4.7513e+06   1028)
-    ( 659531  4.75454e+06  1028)
-    ( 659531  4.75454e+06  2100)
-    ( 662381  4.75454e+06  2100)
-    ( 662381  4.75454e+06  1028)
+    ( 659600  4.7514e+06  1028)
+    ( 659600  4.7514e+06  2100)
+    ( 662300  4.7514e+06  2100)
+    ( 662300  4.7514e+06  1028)
+    ( 659600  4.7545e+06  1028)
+    ( 659600  4.7545e+06  2100)
+    ( 662300  4.7545e+06  2100)
+    ( 662300  4.7545e+06  1028)
 );
 blocks
 (
@@ -34,33 +34,34 @@ blocks
 );
 
 
+edges           
 edges
 (
 );
 
 patches
 (
-    wall maxX
+    patch maxX 
     (
         (3 7 6 2)
     )
-    wall minZ
+    patch minZ
     (
         (0 4 7 3)
     )
-    wall maxZ
+    patch maxZ
     (
         (2 6 5 1)
     )
-    wall minX
+    patch minX
     (
         (1 5 4 0)
     )
-    wall minY
+    patch minY
     (
         (0 3 2 1)
     )
-    wall maxY
+    patch maxY
     (
         (4 5 6 7)
     )
diff --git a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/system/controlDict b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/system/controlDict
index 7a7a9fa49a9..d5741d69766 100644
--- a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/system/controlDict
+++ b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/system/controlDict
@@ -33,17 +33,17 @@ writeInterval   5;
 
 purgeWrite      0;
 
-writeFormat     ascii;
+writeFormat     binary;
 
 writePrecision  6;
 
-writeCompression off;
+writeCompression uncompressed;
 
 timeFormat      general;
 
 timePrecision   6;
 
-runTimeModifiable true;
+runTimeModifiable yes;
 
 
 // ************************************************************************* //
-- 
GitLab