diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/files b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..d6a7819c0e016c560a996d803a3b0e160ebce735
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/files
@@ -0,0 +1,3 @@
+buoyantBoussinesqFoam.C
+
+EXE = $(FOAM_APPBIN)/buoyantBoussinesqFoam
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/options b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..a53061a93cc503d9368d9d3a900ac6ef801015ba
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/options
@@ -0,0 +1,12 @@
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels \
+    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
+    -I$(LIB_SRC)/transportModels \
+    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
+
+EXE_LIBS = \
+    -lfiniteVolume \
+    -lmeshTools \
+    -lincompressibleRASModels \
+    -lincompressibleTransportModels
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/TEqn.H
new file mode 100644
index 0000000000000000000000000000000000000000..e2a89d1441582292fcb5a33ec7e092eac455a5a5
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/TEqn.H
@@ -0,0 +1,18 @@
+{
+    volScalarField kappaEff
+    (
+        "kappaEff",
+        turbulence->nu() + turbulence->nut()/Prt
+    );
+
+    fvScalarMatrix TEqn
+    (
+        fvm::ddt(T)
+      + fvm::div(phi, T)
+      - fvm::laplacian(kappaEff, T)
+    );
+
+    TEqn.relax();
+
+    TEqn.solve();
+}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/UEqn.H
new file mode 100644
index 0000000000000000000000000000000000000000..3b5b5be24923c1b410d47c34fd14da319e117026
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/UEqn.H
@@ -0,0 +1,23 @@
+    // Solve the momentum equation
+
+    tmp<fvVectorMatrix> UEqn
+    (
+        fvm::ddt(U)
+      + fvm::div(phi, U)
+      + turbulence->divDevReff(U)
+    );
+
+    UEqn().relax();
+
+    solve
+    (
+        UEqn()
+      ==
+       -fvc::reconstruct
+        (
+            (
+                fvc::snGrad(pd)
+              - betaghf*fvc::snGrad(T)
+            ) * mesh.magSf()
+        )
+    );
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C
new file mode 100644
index 0000000000000000000000000000000000000000..72aab39ac044b8fe3ce59501c04204be4ce2808e
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C
@@ -0,0 +1,108 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+Application
+    buoyantBoussinesqSimpleFoam
+
+Description
+    Steady-state solver for buoyant, turbulent flow of incompressible fluids
+
+    Uses the Boussinesq approximation:
+    \f[
+        rho_{eff} = 1 - beta(T - T_{ref})
+    \f]
+
+    where:
+        \f$ rho_{eff} \f$ = the effective (driving) density
+        beta = thermal expansion coefficient [1/K]
+        T = temperature [K]
+        \f$ T_{ref} \f$ = reference temperature [K]
+
+    Valid when:
+    \f[
+        rho_{eff} << 1
+    \f]
+
+\*---------------------------------------------------------------------------*/
+
+#include "fvCFD.H"
+#include "singlePhaseTransportModel.H"
+#include "RASModel.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+
+#   include "setRootCase.H"
+#   include "createTime.H"
+#   include "createMesh.H"
+#   include "readEnvironmentalProperties.H"
+#   include "createFields.H"
+#   include "initContinuityErrs.H"
+#   include "readTimeControls.H"
+#   include "CourantNo.H"
+#   include "setInitialDeltaT.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+    Info<< "\nStarting time loop\n" << endl;
+
+    for (runTime++; !runTime.end(); runTime++)
+    {
+        Info<< "Time = " << runTime.timeName() << nl << endl;
+
+#       include "readTimeControls.H"
+#       include "readPISOControls.H"
+#       include "CourantNo.H"
+#       include "setDeltaT.H"
+
+#       include "UEqn.H"
+
+        // --- PISO loop
+        for (int corr=0; corr<nCorr; corr++)
+        {
+#           include "TEqn.H"
+#           include "pdEqn.H"
+        }
+
+        turbulence->correct();
+
+        if (runTime.write())
+        {
+#           include "writeAdditionalFields.H"
+        }
+
+        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
+            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
+            << nl << endl;
+    }
+
+    Info<< "End\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/createFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..5f3f13626db0a860d7058e76ce5a90f397558c95
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/createFields.H
@@ -0,0 +1,67 @@
+    Info<< "Reading thermophysical properties\n" << endl;
+
+    Info<< "Reading field T\n" << endl;
+    volScalarField T
+    (
+        IOobject
+        (
+            "T",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    // kinematic pd
+    Info<< "Reading field pd\n" << endl;
+    volScalarField pd
+    (
+        IOobject
+        (
+            "pd",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    Info<< "Reading field U\n" << endl;
+    volVectorField U
+    (
+        IOobject
+        (
+            "U",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+#   include "createPhi.H"
+
+#   include "readTransportProperties.H"
+
+    Info<< "Creating turbulence model\n" << endl;
+    autoPtr<incompressible::RASModel> turbulence
+    (
+        incompressible::RASModel::New(U, phi, laminarTransport)
+    );
+
+    Info<< "Calculating field beta*(g.h)\n" << endl;
+    surfaceScalarField betaghf("betagh", beta*(g & mesh.Cf()));
+
+    label pdRefCell = 0;
+    scalar pdRefValue = 0.0;
+    setRefCell
+    (
+        pd,
+        mesh.solutionDict().subDict("SIMPLE"),
+        pdRefCell,
+        pdRefValue
+    );
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/pdEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/pdEqn.H
new file mode 100644
index 0000000000000000000000000000000000000000..25e2a9817fbe680f3b52b91b5a7fc187d52a3643
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/pdEqn.H
@@ -0,0 +1,42 @@
+{
+    volScalarField rUA("rUA", 1.0/UEqn().A());
+    surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA));
+
+    U = rUA*UEqn().H();
+    UEqn.clear();
+
+    surfaceScalarField phiU
+    (
+        (fvc::interpolate(U) & mesh.Sf())
+      + fvc::ddtPhiCorr(rUA, U, phi)
+    );
+
+    phi = phiU + betaghf*fvc::snGrad(T)*rUAf*mesh.magSf();
+
+    for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
+    {
+        fvScalarMatrix pdEqn
+        (
+            fvm::laplacian(rUAf, pd) == fvc::div(phi)
+        );
+
+        if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
+        {
+            pdEqn.solve(mesh.solver(pd.name() + "Final"));
+        }
+        else
+        {
+            pdEqn.solve(mesh.solver(pd.name()));
+        }
+
+        if (nonOrth == nNonOrthCorr)
+        {
+            phi += pdEqn.flux();
+        }
+    }
+
+    U -= rUA*fvc::reconstruct((phi - phiU)/rUAf);
+    U.correctBoundaryConditions();
+
+    #include "continuityErrs.H"
+}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/readTransportProperties.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/readTransportProperties.H
new file mode 100644
index 0000000000000000000000000000000000000000..585128dfdeb7d5e5212f9412d9b415c05c15b752
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/readTransportProperties.H
@@ -0,0 +1,13 @@
+    singlePhaseTransportModel laminarTransport(U, phi);
+
+    // thermal expansion coefficient [1/K]
+    dimensionedScalar beta(laminarTransport.lookup("beta"));
+
+    // reference temperature [K]
+    dimensionedScalar TRef(laminarTransport.lookup("TRef"));
+
+    // reference kinematic pressure [m2/s2]
+    dimensionedScalar pRef(laminarTransport.lookup("pRef"));
+
+    // turbulent Prandtl number
+    dimensionedScalar Prt(laminarTransport.lookup("Prt"));
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/writeAdditionalFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/writeAdditionalFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..20f7c6ae1dcff80630dc2ca21253b1e824ea5d77
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/writeAdditionalFields.H
@@ -0,0 +1,29 @@
+{
+    volScalarField rhoEff
+    (
+        IOobject
+        (
+            "rhoEff",
+            runTime.timeName(),
+            mesh,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        1.0 - beta*(T - TRef)
+    );
+    rhoEff.write();
+
+    volScalarField p
+    (
+        IOobject
+        (
+            "p",
+            runTime.timeName(),
+            mesh,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        pd + rhoEff*(g & mesh.C()) + pRef
+    );
+    p.write();
+}
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
index 5b794252011bb6b0bd6db87ea1b93b82b5f259a6..21059f5064914672975bace6a4bffdaf9a4f48c5 100644
--- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
+++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
@@ -47,6 +47,7 @@ int main(int argc, char *argv[])
 #   include "createMesh.H"
 #   include "readEnvironmentalProperties.H"
 #   include "createFields.H"
+#   include "createRadiationModel.H"
 #   include "initContinuityErrs.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/convergenceCheck.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/convergenceCheck.H
deleted file mode 100644
index 8958063193af348a058fd8f3baecb2547c00da3c..0000000000000000000000000000000000000000
--- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/convergenceCheck.H
+++ /dev/null
@@ -1,9 +0,0 @@
-// check convergence
-
-if (maxResidual < convergenceCriterion)
-{
-    Info<< "reached convergence criterion: " << convergenceCriterion << endl;
-    runTime.writeAndEnd();
-    Info<< "latestTime = " << runTime.timeName() << endl;
-}
-
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H
deleted file mode 100644
index 62c06ec38d63955dbf901df2659d3b3c0af4328e..0000000000000000000000000000000000000000
--- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H
+++ /dev/null
@@ -1,97 +0,0 @@
-    Info<< "Reading thermophysical properties\n" << endl;
-
-    autoPtr<basicThermo> thermo
-    (
-        basicThermo::New(mesh)
-    );
-
-    volScalarField rho
-    (
-        IOobject
-        (
-            "rho",
-            runTime.timeName(),
-            mesh,
-            IOobject::NO_READ,
-            IOobject::NO_WRITE
-        ),
-        thermo->rho()
-    );
-
-    volScalarField& p = thermo->p();
-    volScalarField& h = thermo->h();
-    const volScalarField& T = thermo->T();
-
-
-    Info<< "Reading field U\n" << endl;
-    volVectorField U
-    (
-        IOobject
-        (
-            "U",
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
-        ),
-        mesh
-    );
-
-#   include "compressibleCreatePhi.H"
-
-
-    Info<< "Creating turbulence model\n" << endl;
-    autoPtr<compressible::RASModel> turbulence
-    (
-        compressible::RASModel::New
-        (
-            rho,
-            U,
-            phi,
-            thermo()
-        )
-    );
-
-    Info<< "Calculating field g.h\n" << endl;
-    volScalarField gh("gh", g & mesh.C());
-    surfaceScalarField ghf("gh", g & mesh.Cf());
-
-    dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
-
-    Info<< "Creating field pd\n" << endl;
-    volScalarField pd
-    (
-        IOobject
-        (
-            "pd",
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
-        ),
-        mesh
-    );
-
-    p = pd + rho*gh + pRef;
-    thermo->correct();
-
-
-    label pdRefCell = 0;
-    scalar pdRefValue = 0.0;
-    setRefCell
-    (
-        pd,
-        mesh.solutionDict().subDict("SIMPLE"),
-        pdRefCell,
-        pdRefValue
-    );
-
-
-    Info<< "Creating radiation model\n" << endl;
-    autoPtr<radiation::radiationModel> radiation
-    (
-        radiation::radiationModel::New(T)
-    );
-
-
-    dimensionedScalar initialMass = fvc::domainIntegrate(rho);
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createRadiationModel.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createRadiationModel.H
new file mode 100644
index 0000000000000000000000000000000000000000..babe3c4dbe103dfafed9d392eebf0ea11d51ea4d
--- /dev/null
+++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createRadiationModel.H
@@ -0,0 +1,5 @@
+    Info<< "Creating radiation model\n" << endl;
+    autoPtr<radiation::radiationModel> radiation
+    (
+        radiation::radiationModel::New(thermo->T())
+    );
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/initConvergenceCheck.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/initConvergenceCheck.H
deleted file mode 100644
index b56197f22a50cfd07b04fc14d40b9a5454da8c5b..0000000000000000000000000000000000000000
--- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/initConvergenceCheck.H
+++ /dev/null
@@ -1,7 +0,0 @@
-// initialize values for convergence checks
-
-    scalar eqnResidual = 1, maxResidual = 0;
-    scalar convergenceCriterion = 0;
-
-    simple.readIfPresent("convergence", convergenceCriterion);
-
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C
index e671a256c9a84900d458336fc45fa16aa64d3d3d..5f04825a948eadb30ac76c39eea7d7e552936a6a 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.H
index 4bdfb84fcb80830cb87e557e8422fc56fb62fefe..329b8cce65ec4d8e74cd310abc463c490051aa7e 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
index d421649f13402f04c8f545bbeab03936d10d6aa2..7f2202d5937d4e17ab988aef292979339269aabb 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
@@ -12,6 +12,6 @@
 
     thermo.correct();
 
-    Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
-        << endl;
+    Info<< "Min/max T:" << min(thermo.T()).value() << ' '
+        << max(thermo.T()).value() << endl;
 }
diff --git a/applications/test/PackedList/PackedListTest.C b/applications/test/PackedList/PackedListTest.C
index f1f58f3abcad7d5450102a969c996664934c448f..41796562bade616f5b2336e26755cc1d3e43ac83 100644
--- a/applications/test/PackedList/PackedListTest.C
+++ b/applications/test/PackedList/PackedListTest.C
@@ -52,27 +52,47 @@ int main(int argc, char *argv[])
     list1 = -1;
     list1.print(Info);
 
+    Info<< "\ntest zero\n";
+    list1 = 0;
+    list1.print(Info);
+
+    Info<< "\ntest set() with default argument (max_value)\n";
+    list1.set(3);
+    list1.print(Info);
+
     Info<< "\ntest assign between references\n";
     list1[2] = 3;
     list1[4] = list1[2];
     list1.print(Info);
 
     Info<< "\ntest assign between references, with chaining\n";
-    list1[4] = list1[2] = 1;
+    list1[0] = list1[4] = 1;
+    list1.print(Info);
+
+    Info<< "\ntest assign between references, with chaining and auto-vivify\n";
+    list1[1] = list1[8] = list1[10] = list1[14] = 2;
     list1.print(Info);
 
     {
         const PackedList<3>& constLst = list1;
         Info<< "\ntest operator[] const with out-of-range index\n";
         constLst.print(Info);
-        if (!constLst[20])
+        if (constLst[20])
+        {
+            Info<< "[20] is true (unexpected)\n";
+        }
+        else
         {
             Info<< "[20] is false (expected) list size should be unchanged (const)\n";
         }
         constLst.print(Info);
 
         Info<< "\ntest operator[] non-const with out-of-range index\n";
-        if (!list1[20])
+        if (list1[20])
+        {
+            Info<< "[20] is true (unexpected)\n";
+        }
+        else
         {
             Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
         }
@@ -91,6 +111,14 @@ int main(int argc, char *argv[])
     list1.resize(8, list1.max_value());
     list1.print(Info);
 
+    Info<< "\ntest flip() function\n";
+    list1.flip();
+    list1.print(Info);
+
+    Info<< "\nre-flip()\n";
+    list1.flip();
+    list1.print(Info);
+
     Info<< "\ntest set() function\n";
     list1.set(1, 5);
     list1.print(Info);
@@ -188,15 +216,23 @@ int main(int argc, char *argv[])
     {
         Info<< "\ntest assignment of iterator\n";
         list1.print(Info);
-        PackedList<3>::iterator cit = list1[25];
-        cit.print(Info);
+        Info<< "cend()\n";
         list1.end().print(Info);
+        PackedList<3>::iterator cit = list1[100];
+        Info<< "out-of-range: ";
+        cit.print(Info);
+        cit = list1[15];
+        Info<< "in-range: ";
+        cit.print(Info);
+        Info<< "out-of-range: ";
+        cit = list1[1000];
+        cit.print(Info);
     }
 
 
     for
     (
-        PackedList<3>::iterator cit = list1[5];
+        PackedList<3>::iterator cit = list1[30];
         cit != list1.end();
         ++cit
     )
@@ -204,14 +240,19 @@ int main(int argc, char *argv[])
         cit.print(Info);
     }
 
-//     Info<< "\ntest operator[] auto-vivify\n";
-//     const unsigned int val = list1[45];
-//
-//     Info<< "list[45]:" << val << "\n";
-//     list1[45] = list1.max_value();
-//     Info<< "list[45]:" << list1[45] << "\n";
-//     list1[49] = list1.max_value();
-//     list1.print(Info);
+    Info<< "\ntest operator[] auto-vivify\n";
+    Info<< "size:" << list1.size() << "\n";
+
+    const unsigned int val = list1[45];
+
+    Info<< "list[45]:" << val << "\n";
+    Info<< "size after read:" << list1.size() << "\n";
+
+    list1[45] = list1.max_value();
+    Info<< "size after write:" << list1.size() << "\n";
+    Info<< "list[45]:" << list1[45] << "\n";
+    list1[49] = list1[100];
+    list1.print(Info);
 
 
     Info<< "\ntest copy constructor + append\n";
@@ -235,6 +276,23 @@ int main(int argc, char *argv[])
     Info<< "removed final value: " << list3.remove() << endl;
     list3.print(Info);
 
+
+    List<bool> list4(4, true);
+    {
+        const List<bool>& constLst = list4;
+        Info<< "\ntest operator[] const with out-of-range index\n";
+        Info<< constLst << endl;
+        if (constLst[20])
+        {
+            Info<< "[20] is true (unexpected)\n";
+        }
+        else
+        {
+            Info<< "[20] is false (expected) list size should be unchanged (const)\n";
+        }
+        Info<< constLst << endl;
+    }
+
     Info<< "\n\nDone.\n";
 
     return 0;
diff --git a/applications/test/fileName/fileNameTest.C b/applications/test/fileName/fileNameTest.C
index f5a4a93542ac7a1cac740a6aab5e3053ad9af84c..c4791f6f385b208c6484ae05e89e72a455873ec7 100644
--- a/applications/test/fileName/fileNameTest.C
+++ b/applications/test/fileName/fileNameTest.C
@@ -32,6 +32,7 @@ Description
 
 #include "fileName.H"
 #include "SubList.H"
+#include "IOobject.H"
 #include "IOstreams.H"
 #include "OSspecific.H"
 
@@ -61,7 +62,8 @@ int main()
         << endl;
 
     // try with different combination
-    for (label start = 0; start < wrdList.size(); ++start)
+    // The final one should emit warnings
+    for (label start = 0; start <= wrdList.size(); ++start)
     {
         fileName instance, local;
         word name;
@@ -69,26 +71,28 @@ int main()
         fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
         fileName path2 = "." / path;
 
-        path.IOobjectComponents
+        IOobject::fileNameComponents
         (
+            path,
             instance,
             local,
             name
         );
 
-        Info<< "IOobjectComponents for " << path << nl
+        Info<< "IOobject::fileNameComponents for " << path << nl
             << "  instance = " << instance << nl
             << "  local    = " << local << nl
             << "  name     = " << name << endl;
 
-        path2.IOobjectComponents
+        IOobject::fileNameComponents
         (
+            path2,
             instance,
             local,
             name
         );
 
-        Info<< "IOobjectComponents for " << path2 << nl
+        Info<< "IOobject::fileNameComponents for " << path2 << nl
             << "  instance = " << instance << nl
             << "  local    = " << local << nl
             << "  name     = " << name << endl;
diff --git a/applications/test/primitivePatch/testPrimitivePatch.C b/applications/test/primitivePatch/testPrimitivePatch.C
index 7130e90628f2cfb4fc87000802ac59f6d4053a95..e19b7d0512ba0517975e2395a3d5c5da8bc1694b 100644
--- a/applications/test/primitivePatch/testPrimitivePatch.C
+++ b/applications/test/primitivePatch/testPrimitivePatch.C
@@ -69,7 +69,7 @@ void checkFaceEdges
 
         forAll(f, fp)
         {
-            label fp1 = (fp + 1) % f.size();
+            label fp1 = f.fcIndex(fp);
 
             if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
             {
diff --git a/applications/test/sha1/Make/files b/applications/test/sha1/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..2da85a30dd748d9320273e20d5e8d596c1296d71
--- /dev/null
+++ b/applications/test/sha1/Make/files
@@ -0,0 +1,3 @@
+testSHA1.C
+
+EXE = $(FOAM_USER_APPBIN)/testSHA1
diff --git a/tutorials/interFoam/nozzleFlow2D/0/data/Ubulk b/applications/test/sha1/Make/options
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/data/Ubulk
rename to applications/test/sha1/Make/options
diff --git a/applications/test/sha1/testSHA1.C b/applications/test/sha1/testSHA1.C
new file mode 100644
index 0000000000000000000000000000000000000000..9a2ac37c487dd2fe31d78c23d33c13eb21916e8c
--- /dev/null
+++ b/applications/test/sha1/testSHA1.C
@@ -0,0 +1,135 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+Application
+    testSHA1
+
+Description
+
+
+\*---------------------------------------------------------------------------*/
+
+#include "OSHA1stream.H"
+#include "IStringStream.H"
+#include "dictionary.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char * argv[])
+{
+    SHA1 sha;
+    SHA1Digest shaDig;
+
+    std::string str("The quick brown fox jumps over the lazy dog");
+    Info<< shaDig << nl;
+    Info<< SHA1("The quick brown fox jumps over the lazy dog") << nl;
+
+    sha.append("The quick brown fox jumps over the lazy dog");
+    Info<< sha << nl;
+
+    sha.clear();
+    sha.append("The quick brown fox jumps over the lazy dog");
+    shaDig = sha;
+
+    sha.append("\n");
+    Info<< sha << nl;
+    Info<< shaDig << nl;
+
+    if (sha == shaDig)
+    {
+        Info<<"SHA1 digests are identical\n";
+    }
+    else
+    {
+        Info<<"SHA1 digests are different\n";
+    }
+    Info<<"lhs:" << sha << " rhs:" << shaDig << endl;
+
+    // start over:
+    sha.clear();
+    sha.append(str);
+
+    SHA1Digest shaDig_A = sha;
+
+    SHA1 sha_A = sha;
+
+    sha.append("\n");
+
+    Info<< "digest1: " << sha_A << nl;
+    Info<< "digest2: " << sha << nl;
+
+    // start over:
+    sha.clear();
+    sha.append("\"");
+    sha.append(str);
+    sha.append("\"");
+
+    Info<< "digest3: " << sha << nl;
+
+    // try the output buffer interface
+    {
+        OSHA1stream os;
+
+        os << str;
+        Info<< os.digest() << endl;
+
+        os << str;
+        Info<< os.digest() << endl;
+
+        os.rewind();
+        os << "The quick brown fox jumps over the lazy dog";
+        Info<< os.digest() << endl;
+
+    }
+
+    {
+        dictionary dict
+        (
+            IStringStream
+            (
+                "parent { Default_Boundary_Region { type zeroGradient; } }"
+                "inlet_1 { value inlet_1; }"
+                "inlet_2 { value inlet_2; }"
+                "inlet_3 { value inlet_3; }"
+                "\"inlet_.*\" { value XXX; }"
+            ) ()
+        );
+
+        Info<< "dict:" << endl;
+        dict.write(Info, false);
+
+        dictionary dict2(dict);
+
+        OSHA1stream os;
+        dict.write(os, false);
+        Info<< os.digest() << endl;
+
+        Info<< dict2.digest() << endl;
+    }
+
+
+    return 0;
+}
diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
index a780d8aecb09804c771eec42d4c469da73ce993c..e87078cc397294edf650a2fa371d7bb49bdd43ce 100644
--- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
+++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
@@ -74,20 +74,17 @@ labelList getSortedEdges
         const edge& e = edges[edgeI];
 
         label fp = findIndex(f, e[0]);
-
-        label fp1 = (fp+1) % f.size();
+        label fp1 = f.fcIndex(fp);
 
         if (f[fp1] == e[1])
         {
-            // Edgei in fp-fp1 order
+            // EdgeI between fp -> fp1
             faceEdges[fp] = edgeI;
         }
         else
         {
-            // Edgei between fp-1 and fp
-            label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
-
-            faceEdges[fpMin1] = edgeI;
+            // EdgeI between fp-1 -> fp
+            faceEdges[f.rcIndex(fp)] = edgeI;
         }
     }
 
diff --git a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
index ce532b979f67e0494842e3a828b9994d2f074c8e..3ae39131a10a8348efb9e1fcb530187840eb4ea0 100644
--- a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
+++ b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
@@ -211,7 +211,7 @@ void Foam::cellSplitter::setRefinement
 
         // Add other pyramids
         for (label i = 1; i < cFaces.size(); i++)
-        {    
+        {
             label addedCellI =
                 meshMod.setAction
                 (
@@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement
 
                 label index = findIndex(f0, e[0]);
 
-                bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]);
+                bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
 
                 // Check if cellI is the face owner
 
@@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement
 
                 label index = findIndex(f1, e[0]);
 
-                bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]);
+                bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
 
                 // Check if cellI is the face owner
 
@@ -362,7 +362,7 @@ void Foam::cellSplitter::setRefinement
             }
         }
     }
-            
+
 
     //
     // Update all existing faces for split owner or neighbour.
@@ -441,7 +441,7 @@ void Foam::cellSplitter::setRefinement
 
                 label patchID, zoneID, zoneFlip;
                 getFaceInfo(faceI, patchID, zoneID, zoneFlip);
-                
+
                 meshMod.setAction
                 (
                     polyModifyFace
@@ -458,7 +458,7 @@ void Foam::cellSplitter::setRefinement
                     )
                 );
             }
-    
+
             faceUpToDate[faceI] = true;
         }
     }
diff --git a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C
index 025709fac89815dbe8d1c1b00474f801aba11d38..47ec7f913746b0c9582f5a286f1217788708b9be 100644
--- a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C
+++ b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C
@@ -615,7 +615,7 @@ int main(int argc, char *argv[])
     {
         fileName ccmFile(args.additionalArgs()[0]);
 
-        if (!exists(ccmFile))
+        if (!isFile(ccmFile))
         {
             FatalErrorIn(args.executable())
                 << "Cannot read file " << ccmFile
diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C
index 7fcf2a586b57d510fc0ca648cd393dc27cc30c34..486041c71457b39787121d453d06c3bc7fa52b98 100644
--- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C
+++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C
@@ -129,14 +129,14 @@ int main(int argc, char *argv[])
         Info<< "Reading .face file for boundary information" << nl << endl;
     }
 
-    if (!exists(nodeFile) || !exists(eleFile))
+    if (!isFile(nodeFile) || !isFile(eleFile))
     {
         FatalErrorIn(args.executable())
             << "Cannot read " << nodeFile << " or " << eleFile
             << exit(FatalError);
     }
 
-    if (readFaceFile && !exists(faceFile))
+    if (readFaceFile && !isFile(faceFile))
     {
         FatalErrorIn(args.executable())
             << "Cannot read " << faceFile << endl
diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C
index 69439764c7052e3a1dbf78d0b24a279dd1d22f7c..815f082ec7dd179b6a1aba308a0c8c1d4c6c6b1a 100644
--- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C
+++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C
@@ -108,7 +108,11 @@ int main(int argc, char *argv[])
         (
             new IOobject
             (
-                ( dictPath.isDir() ? dictPath/dictName : dictPath ),
+                (
+                    isDir(dictPath)
+                  ? dictPath/dictName 
+                  : dictPath
+                ),
                 runTime,
                 IOobject::MUST_READ,
                 IOobject::NO_WRITE,
diff --git a/applications/utilities/mesh/manipulation/cellSet/cellSetDict b/applications/utilities/mesh/manipulation/cellSet/cellSetDict
index 8dafcd3fa22cfa391ab30bed5d4fad5fde61b036..95465d8f5421d2316b2a74f0404ea79e10700010 100644
--- a/applications/utilities/mesh/manipulation/cellSet/cellSetDict
+++ b/applications/utilities/mesh/manipulation/cellSet/cellSetDict
@@ -79,6 +79,22 @@ topoSetSources
        k        (10 10 10);
     }
 
+    // Cells with centre within cylinder
+    cylinderToCell
+    {
+       p1       (0.2 0.2 -10); // start point on cylinder axis
+       p2       (0.2 0.2 0);   // end point on cylinder axis
+       radius   5.0;
+    }
+
+
+    // Cells with centre within sphere
+    sphereToCell
+    {
+       centre   (0.2 0.2 -10);
+       radius   5.0;
+    }
+
     // Cells in cell zone
     zoneToCell
     {
diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C
index 8f49a947665988024e48fe7b9948e5a830b5612c..a5909c398ab77f69b9dcefb1842266d06cac3101 100644
--- a/applications/utilities/mesh/manipulation/setSet/setSet.C
+++ b/applications/utilities/mesh/manipulation/setSet/setSet.C
@@ -746,7 +746,8 @@ int main(int argc, char *argv[])
 
         Pout<< "Reading commands from file " << batchFile << endl;
 
-        if (!exists(batchFile))
+        // we also cannot handle .gz files
+        if (!isFile(batchFile, false))
         {
             FatalErrorIn(args.executable())
                 << "Cannot open file " << batchFile << exit(FatalError);
diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
index aa83952b88f0bd77ea374fcbc4aede65c65131a5..582a6ca9bf6b2bb9da89ca9397576fb5c1bce45e 100644
--- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
+++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
@@ -627,7 +627,7 @@ autoPtr<mapPolyMesh> createRegionMesh
         Info<< "Testing:" << io.objectPath() << endl;
 
         if (!io.headerOk())
-        //if (!exists(io.objectPath()))
+        // if (!exists(io.objectPath()))
         {
             Info<< "Writing dummy " << regionName/io.name() << endl;
             dictionary dummyDict;
diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummary.C b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
index 17eba3631155abb5e95bb0528d3220f472417c27..8195e4d9dc69bd9a3f59048bcf863fb067693356 100644
--- a/applications/utilities/miscellaneous/patchSummary/patchSummary.C
+++ b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
@@ -63,7 +63,6 @@ int main(int argc, char *argv[])
         Info<< "Time = " << runTime.timeName() << nl << endl;
 
         const IOobjectList fieldObjs(mesh, runTime.timeName());
-
         const wordList objNames = fieldObjs.names();
 
         PtrList<volScalarField> vsf(objNames.size());
@@ -99,7 +98,7 @@ int main(int argc, char *argv[])
         const polyBoundaryMesh& bm = mesh.boundaryMesh();
         forAll(bm, patchI)
         {
-            Info<< "Patch: " << bm[patchI].name() << nl;
+            Info<< bm[patchI].type() << ": " << bm[patchI].name() << nl;
             outputFieldList<scalar>(vsf, patchI);
             outputFieldList<vector>(vvf, patchI);
             outputFieldList<sphericalTensor>(vsptf, patchI);
diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
index b6eaf392589828b6bbac197779f451a63ad6e1b0..a7328cb48737d06d58b992c8885033b7e1d903dc 100644
--- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
+++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 
     // determine the existing processor count directly
     label nProcs = 0;
-    while (dir(runTime.path()/(word("processor") + name(nProcs))))
+    while (isDir(runTime.path()/(word("processor") + name(nProcs))))
     {
         ++nProcs;
     }
@@ -480,7 +480,7 @@ int main(int argc, char *argv[])
     // Any uniform data to copy/link?
     fileName uniformDir("uniform");
 
-    if (dir(runTime.timePath()/uniformDir))
+    if (isDir(runTime.timePath()/uniformDir))
     {
         Info<< "Detected additional non-decomposed files in "
             << runTime.timePath()/uniformDir
diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict
index 7ece22c5ae7d4a9158f8c18a02eae815af126fdf..288797ed1e444b4e1d76b9bd9c053bd7bdbc6873 100644
--- a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict
+++ b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict
@@ -59,7 +59,7 @@ manualCoeffs
 }
 
 
-//// Is the case distributred
+//// Is the case distributed
 //distributed     yes;
 //// Per slave (so nProcs-1 entries) the directory above the case.
 //roots           
diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
index ac08b176453c5b54f0824787ce08f58f61c0b599..20def06b9c9cae6f6b0f1b3d9d7b8c33ddf6a5da 100644
--- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
+++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
 
     // determine the processor count directly
     label nProcs = 0;
-    while (dir(args.path()/(word("processor") + name(nProcs))))
+    while (isDir(args.path()/(word("processor") + name(nProcs))))
     {
         ++nProcs;
     }
@@ -383,7 +383,7 @@ int main(int argc, char *argv[])
         // the master processor.
 
         fileName uniformDir0 = databases[0].timePath()/"uniform";
-        if (dir(uniformDir0))
+        if (isDir(uniformDir0))
         {
             cp(uniformDir0, runTime.timePath());
         }
diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
index 1e102fb0e5053922fbffdc2ff8aa1bee09ff0102..627f2b15b48a26984c4ced5ec54ff1ece41a4b34 100644
--- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
+++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C
@@ -355,7 +355,7 @@ int main(int argc, char *argv[])
 
     while
     (
-        exists
+        isDir
         (
             args.rootPath()
           / args.caseName()
diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C
index 379dd70b9166c580c66786bc637a83cb0b39bcf2..c46a41b2738795d7335106179fdd9dd9c343b9e9 100644
--- a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C
+++ b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C
@@ -503,7 +503,7 @@ int main(int argc, char *argv[])
 #   include "setRootCase.H"
 
     // Create processor directory if non-existing
-    if (!Pstream::master() && !dir(args.path()))
+    if (!Pstream::master() && !isDir(args.path()))
     {
         Pout<< "Creating case directory " << args.path() << endl;
         mkDir(args.path());
@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
     const fileName meshDir = runTime.path()/masterInstDir/polyMesh::meshSubDir;
 
     boolList haveMesh(Pstream::nProcs(), false);
-    haveMesh[Pstream::myProcNo()] = dir(meshDir);
+    haveMesh[Pstream::myProcNo()] = isDir(meshDir);
     Pstream::gatherList(haveMesh);
     Pstream::scatterList(haveMesh);
     Info<< "Per processor mesh availability : " << haveMesh << endl;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
index 8fc7636f2a89376763533c6c720d1eff6694eaea..bb7c1880f00cc7a8fd9d5a304c84100ac8924b75 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
 
     if (Pstream::master())
     {
-        if (dir(postProcPath))
+        if (isDir(postProcPath))
         {
             rmDir(postProcPath);
         }
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
index 1d31a4e31c6e292bc2a3dcd1e7fc956e90b03a6b..329dda87f9ebbbb4f3821ee6b93f2125e7c288f4 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
     // Ensight and Ensight/data directories must exist
     // do not remove old data - we might wish to convert new results
     // or a particular time interval
-    if (dir(ensightDir))
+    if (isDir(ensightDir))
     {
         Info<<"Warning: reusing existing directory" << nl
             << "    " << ensightDir << endl;
@@ -324,7 +324,7 @@ int main(int argc, char *argv[])
         {
             const word& cloudName = cloudIter.key();
 
-            if (!dir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
+            if (!isDir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
             {
                 continue;
             }
diff --git a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C
index 81ac4facac9209f06fe61ba8e5503c60f0764260..7fc54a8cf2f76293c0a0e528a3d9f21260771db2 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
     // make a directory called FieldView in the case
     fileName fvPath(runTime.path()/"Fieldview");
 
-    if (dir(fvPath))
+    if (isDir(fvPath))
     {
         rmDir(fvPath);
     }
@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
 
         // Output the magic number.
         writeInt(fvFile, FV_MAGIC);
-        
+
         // Output file header and version number.
         writeStr80(fvFile, "FIELDVIEW");
 
@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
         {
             if (volFieldPtrs[fieldI] == NULL)
             {
-                Info<< "    dummy field for "   
+                Info<< "    dummy field for "
                     << volFieldNames[fieldI].c_str() << endl;
             }
 
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
index 45c5f3799691e479e453dd664af447a2f45895bc..e03c76c05727a9f2ef596241372bb29c979e5eaa 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
@@ -333,7 +333,7 @@ int main(int argc, char *argv[])
         regionPrefix = regionName;
     }
 
-    if (dir(fvPath))
+    if (isDir(fvPath))
     {
         if
         (
diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C
index 779cddac39ba5c59282cdc093363755f11d63121..7a8fd89e9ed1529b86acfcf3c82f67a11dd474fd 100644
--- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C
+++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C
@@ -228,7 +228,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
     // avoid argList and get rootPath/caseName directly from the file
     fileName fullCasePath(fileName(FileName).path());
 
-    if (!dir(fullCasePath))
+    if (!isDir(fullCasePath))
     {
         return;
     }
@@ -518,7 +518,7 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
 
             if
             (
-                file(runTime.path()/timeName/meshDir_/"points")
+                isFile(runTime.path()/timeName/meshDir_/"points")
              && IOobject("points", timeName, meshDir_, runTime).headerOk()
             )
             {
diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H
index cb25ac50895f3a6ccc5d85b97822ff91ebf65bb4..af0fb849a4f46b594232e25fe1d67fdde6864ead 100644
--- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H
+++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H
@@ -156,7 +156,7 @@ class vtkPV3Foam
 
             bool empty() const
             {
-                return (size_ == 0);
+                return !size_;
             }
 
             void reset()
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C
index 6d6eef9b5fbcd6c3c13f6f2bac0ec14e9cd01e60..6a1830b5d14dd60a851496247830f9a6942c983c 100644
--- a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C
@@ -194,7 +194,7 @@ void Foam::vtkFoam::updateSelectedRegions()
     // Read the selected patches and add to the region list
     for (int i=0; i<nRegions; i++)
     {
-        selectedRegions_[i] = 
+        selectedRegions_[i] =
             reader_->GetRegionSelection()->GetArraySetting(i);
     }
 }
@@ -282,7 +282,7 @@ void Foam::vtkFoam::convertMesh()
             else
             {
                 // A patch already existent in the list and which
-                // continues to exist found 
+                // continues to exist found
                 regioni++;
             }
         }
@@ -391,7 +391,7 @@ Foam::vtkFoam::vtkFoam(const char* const FileName, vtkFoamReader* reader)
 {
     fileName fullCasePath(fileName(FileName).path());
 
-    if (!dir(fullCasePath))
+    if (!isDir(fullCasePath))
     {
         return;
     }
@@ -572,7 +572,7 @@ void Foam::vtkFoam::Update()
         {
             Info<< "Reading Mesh" << endl;
         }
-        meshPtr_ = 
+        meshPtr_ =
             new fvMesh
             (
                 IOobject
diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H
index f01839a9308d826bfe3fdb26c5bda279ee437e39..90f2d3f415ab396b48720e58f20c9bb4f9f2b7ac 100644
--- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H
+++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H
@@ -47,7 +47,7 @@ int USERD_set_filenames
     }
     caseDir = tmp;
 
-    if (!dir(rootDir/caseDir))
+    if (!isDir(rootDir/caseDir))
     {
        Info<< rootDir/caseDir << " is not a valid directory."
            << endl;
@@ -144,7 +144,7 @@ int USERD_set_filenames
         }
         isTensor[n] = isitTensor;
     }
-    
+
     bool lagrangianNamesFound = false;
     label n = 0;
     while (!lagrangianNamesFound && n < Num_time_steps)
@@ -176,7 +176,7 @@ int USERD_set_filenames
         Info << "[Found lagrangian]" << endl;
 
         delete sprayPtr;
-        
+
         sprayPtr = new Cloud<passiveParticle>(*meshPtr);
 
         IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian");
diff --git a/applications/utilities/postProcessing/graphics/fieldview9Reader/fieldview9Reader.C b/applications/utilities/postProcessing/graphics/fieldview9Reader/fieldview9Reader.C
index 10b29fc8b31d1814b1c2a461157f8465b408feb2..11fd038f16a5bab083da0b514d65b79d418bbc7a 100644
--- a/applications/utilities/postProcessing/graphics/fieldview9Reader/fieldview9Reader.C
+++ b/applications/utilities/postProcessing/graphics/fieldview9Reader/fieldview9Reader.C
@@ -132,8 +132,8 @@ static void errorMsg(const string& msg)
 // Simple check if directory is valid case directory.
 static bool validCase(const fileName& rootAndCase)
 {
-    //if (dir(rootAndCase/"system") && dir(rootAndCase/"constant"))
-    if (dir(rootAndCase/"constant"))
+    //if (isDir(rootAndCase/"system") && isDir(rootAndCase/"constant"))
+    if (isDir(rootAndCase/"constant"))
     {
         return true;
     }
@@ -528,7 +528,7 @@ void user_query_file_function
 
             return;
         }
-        
+
     }
 
     fileName rootDir(rootAndCase.path());
diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict
index b605f29e571320a1f4d3af3ca93e04841594f833..215add79a79ed840f9959e7e88e3076c0efae065 100644
--- a/applications/utilities/postProcessing/sampling/sample/sampleDict
+++ b/applications/utilities/postProcessing/sampling/sample/sampleDict
@@ -180,7 +180,7 @@ surfaces
 
     triangleCut
     {
-        // Cutingplaneusing iso surface
+        // Cutingplane using iso surface
         type            cuttingPlane;
         planeType       pointAndNormal;
         pointAndNormalDict
diff --git a/applications/utilities/postProcessing/velocityField/Mach/Mach.C b/applications/utilities/postProcessing/velocityField/Mach/Mach.C
index 917a53668f25c7171fd12bd1c5ce6567a361ac00..02c69df34a07f8b44668dc2a69190ae62ad80101 100644
--- a/applications/utilities/postProcessing/velocityField/Mach/Mach.C
+++ b/applications/utilities/postProcessing/velocityField/Mach/Mach.C
@@ -63,7 +63,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
 
         volVectorField U(Uheader, mesh);
 
-        if (file(runTime.constantPath()/"thermophysicalProperties"))
+        if (isFile(runTime.constantPath()/"thermophysicalProperties"))
         {
             // thermophysical Mach
             autoPtr<basicThermo> thermo
diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files b/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files
deleted file mode 100644
index b937625a7106b357ef66d84217a6277e5e0d03e5..0000000000000000000000000000000000000000
--- a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-surfaceCoordinateSystemTransform.C
-
-EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform
diff --git a/applications/utilities/surface/surfaceMeshConvert/Make/options b/applications/utilities/surface/surfaceMeshConvert/Make/options
index 5293dabe4c122761812eeaeffa263c844e60d8e9..42b30c86523f83efafbd2dbe5d52cc7487ec4101 100644
--- a/applications/utilities/surface/surfaceMeshConvert/Make/options
+++ b/applications/utilities/surface/surfaceMeshConvert/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(LIB_SRC)/triSurface/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
     -I$(LIB_SRC)/surfMesh/lnInclude
 
-EXE_LIBS = -lsurfMesh
+EXE_LIBS = -lmeshTools -lsurfMesh
diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/coordinateSystems b/applications/utilities/surface/surfaceMeshConvert/coordinateSystems
similarity index 100%
rename from applications/utilities/surface/surfaceCoordinateSystemTransform/coordinateSystems
rename to applications/utilities/surface/surfaceMeshConvert/coordinateSystems
diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C
index 9b5c2cb8f7c9bf37175b88611ea827241cef3403..3a48a5deda74c71e13ace6dea886cb5b3fa03c35 100644
--- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C
+++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C
@@ -26,25 +26,30 @@ Application
     surfaceMeshConvert
 
 Description
-    Converts from one surface mesh format to another
+
+    Convert between surface formats with optional scaling or
+    transformations (rotate/translate) on a coordinateSystem.
 
 Usage
     - surfaceMeshConvert inputFile outputFile [OPTION]
 
     @param -clean \n
-    Perform some surface checking/cleanup on the input surface
+    Perform some surface checking/cleanup on the input surface.
+
+    @param -scaleIn \<scale\> \n
+    Specify a scaling factor when reading files.
 
-    @param -orient \n
-    Check face orientation on the input surface
+    @param -scaleOut \<scale\> \n
+    Specify a scaling factor when writing files.
 
-    @param -scale \<scale\> \n
-    Specify a scaling factor for writing the files
+    @param -dict \<dictionary\> \n
+    Specify an alternative dictionary for constant/coordinateSystems.
 
-    @param -triSurface \n
-    Use triSurface library for input/output
+    @param -from \<coordinateSystem\> \n
+    Specify a coordinate System when reading files.
 
-    @param -keyed \n
-    Use keyedSurface for input/output
+    @param -to \<coordinateSystem\> \n
+    Specify a coordinate System when writing files.
 
 Note
     The filename extensions are used to determine the file format type.
@@ -54,12 +59,9 @@ Note
 #include "argList.H"
 #include "timeSelector.H"
 #include "Time.H"
-#include "polyMesh.H"
-#include "triSurface.H"
-#include "PackedBoolList.H"
 
 #include "MeshedSurfaces.H"
-#include "UnsortedMeshedSurfaces.H"
+#include "coordinateSystems.H"
 
 using namespace Foam;
 
@@ -71,24 +73,21 @@ int main(int argc, char *argv[])
     argList::noParallel();
     argList::validArgs.append("inputFile");
     argList::validArgs.append("outputFile");
-    argList::validOptions.insert("clean", "");
-    argList::validOptions.insert("orient", "");
-    argList::validOptions.insert("scale", "scale");
-    argList::validOptions.insert("triSurface", "");
-    argList::validOptions.insert("unsorted", "");
-    argList::validOptions.insert("triFace", "");
-#   include "setRootCase.H"
+    argList::validOptions.insert("clean",  "scale");
+    argList::validOptions.insert("scaleIn",  "scale");
+    argList::validOptions.insert("scaleOut", "scale");
+    argList::validOptions.insert("dict", "coordinateSystemsDict");
+    argList::validOptions.insert("from", "sourceCoordinateSystem");
+    argList::validOptions.insert("to",   "targetCoordinateSystem");
+
+    argList args(argc, argv);
+    Time runTime(args.rootPath(), args.caseName());
     const stringList& params = args.additionalArgs();
 
-    scalar scaleFactor = 0;
-    if (args.options().found("scale"))
-    {
-        IStringStream(args.options()["scale"])() >> scaleFactor;
-    }
-
     fileName importName(params[0]);
     fileName exportName(params[1]);
 
+    // disable inplace editing
     if (importName == exportName)
     {
         FatalErrorIn(args.executable())
@@ -96,165 +95,161 @@ int main(int argc, char *argv[])
             << exit(FatalError);
     }
 
+    // check that reading/writing is supported
     if
     (
-        !meshedSurface::canRead(importName, true)
-     || !meshedSurface::canWriteType(exportName.ext(), true)
+        !MeshedSurface<face>::canRead(importName, true)
+     || !MeshedSurface<face>::canWriteType(exportName.ext(), true)
     )
     {
         return 1;
     }
 
-    if (args.options().found("triSurface"))
-    {
-        triSurface surf(importName);
 
-        Info<< "Read surface:" << endl;
-        surf.writeStats(Info);
-        Info<< endl;
+    // get the coordinate transformations
+    autoPtr<coordinateSystem> fromCsys;
+    autoPtr<coordinateSystem> toCsys;
 
-        if (args.options().found("orient"))
-        {
-            Info<< "Checking surface orientation" << endl;
-            PatchTools::checkOrientation(surf, true);
-            Info<< endl;
-        }
-
-        if (args.options().found("clean"))
-        {
-            Info<< "Cleaning up surface" << endl;
-            surf.cleanup(true);
-            surf.writeStats(Info);
-            Info<< endl;
-        }
+    if (args.options().found("from") || args.options().found("to"))
+    {
+        autoPtr<IOobject> csDictIoPtr;
 
-        Info<< "writing " << exportName;
-        if (scaleFactor <= 0)
+        if (args.options().found("dict"))
         {
-            Info<< " without scaling" << endl;
+            fileName dictPath(args.options()["dict"]);
+
+            csDictIoPtr.set
+            (
+                new IOobject
+                (
+                    (
+                        isDir(dictPath)
+                      ? dictPath/coordinateSystems::typeName
+                      : dictPath
+                    ),
+                    runTime,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                )
+            );
         }
         else
         {
-            Info<< " with scaling " << scaleFactor << endl;
-            surf.scalePoints(scaleFactor);
-            surf.writeStats(Info);
-            Info<< endl;
+            csDictIoPtr.set
+            (
+                new IOobject
+                (
+                    coordinateSystems::typeName,
+                    runTime.constant(),
+                    runTime,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                )
+            );
         }
 
-        // write sorted by region
-        surf.write(exportName, true);
-    }
-    else if (args.options().found("unsorted"))
-    {
-        UnsortedMeshedSurface<face> surf(importName);
-
-        Info<< "Read surface:" << endl;
-        surf.writeStats(Info);
-        Info<< endl;
 
-        if (args.options().found("orient"))
+        if (!csDictIoPtr->headerOk())
         {
-            Info<< "Checking surface orientation" << endl;
-            PatchTools::checkOrientation(surf, true);
-            Info<< endl;
+            FatalErrorIn(args.executable())
+                << "Cannot open coordinateSystems file\n    "
+                << csDictIoPtr->objectPath() << nl
+                << exit(FatalError);
         }
 
-        if (args.options().found("clean"))
+        coordinateSystems csLst(csDictIoPtr());
+
+        if (args.options().found("from"))
         {
-            Info<< "Cleaning up surface" << endl;
-            surf.cleanup(true);
-            surf.writeStats(Info);
-            Info<< endl;
+            const word csName(args.options()["from"]);
+
+            label csId = csLst.find(csName);
+            if (csId < 0)
+            {
+                FatalErrorIn(args.executable())
+                    << "Cannot find -from " << csName << nl
+                    << "available coordinateSystems: " << csLst.toc() << nl
+                    << exit(FatalError);
+            }
+
+            fromCsys.reset(new coordinateSystem(csLst[csId]));
         }
 
-        Info<< "writing " << exportName;
-        if (scaleFactor <= 0)
+        if (args.options().found("to"))
         {
-            Info<< " without scaling" << endl;
+            const word csName(args.options()["to"]);
+
+            label csId = csLst.find(csName);
+            if (csId < 0)
+            {
+                FatalErrorIn(args.executable())
+                    << "Cannot find -to " << csName << nl
+                    << "available coordinateSystems: " << csLst.toc() << nl
+                    << exit(FatalError);
+            }
+
+            toCsys.reset(new coordinateSystem(csLst[csId]));
         }
-        else
+
+
+        // maybe fix this later
+        if (fromCsys.valid() && toCsys.valid())
         {
-            Info<< " with scaling " << scaleFactor << endl;
-            surf.scalePoints(scaleFactor);
-            surf.writeStats(Info);
-            Info<< endl;
+            FatalErrorIn(args.executable())
+                << "Only allowed  '-from' or '-to' option at the moment."
+                << exit(FatalError);
         }
-        surf.write(exportName);
     }
-#if 1
-    else if (args.options().found("triFace"))
+
+    scalar scaleIn = 0;
+    scalar scaleOut = 0;
+    if (args.options().found("scaleIn"))
+    {
+        IStringStream(args.options()["scaleIn"])() >> scaleIn;
+    }
+    if (args.options().found("scaleOut"))
     {
-        MeshedSurface<triFace> surf(importName);
+        IStringStream(args.options()["scaleOut"])() >> scaleOut;
+    }
 
-        Info<< "Read surface:" << endl;
-        surf.writeStats(Info);
-        Info<< endl;
 
-        if (args.options().found("orient"))
-        {
-            Info<< "Checking surface orientation" << endl;
-            PatchTools::checkOrientation(surf, true);
-            Info<< endl;
-        }
+    {
+        MeshedSurface<face> surf(importName);
 
         if (args.options().found("clean"))
         {
-            Info<< "Cleaning up surface" << endl;
             surf.cleanup(true);
-            surf.writeStats(Info);
-            Info<< endl;
         }
 
-        Info<< "writing " << exportName;
-        if (scaleFactor <= 0)
+        if (scaleIn > 0)
         {
-            Info<< " without scaling" << endl;
+            Info<< " -scaleIn " << scaleIn << endl;
+            surf.scalePoints(scaleIn);
         }
-        else
+
+        if (fromCsys.valid())
         {
-            Info<< " with scaling " << scaleFactor << endl;
-            surf.scalePoints(scaleFactor);
-            surf.writeStats(Info);
-            Info<< endl;
+            Info<< " -from " << fromCsys().name() << endl;
+            tmp<pointField> tpf = fromCsys().localPosition(surf.points());
+            surf.movePoints(tpf());
         }
-        surf.write(exportName);
-    }
-#endif
-    else
-    {
-        MeshedSurface<face> surf(importName);
-
-        Info<< "Read surface:" << endl;
-        surf.writeStats(Info);
-        Info<< endl;
 
-        if (args.options().found("orient"))
+        if (toCsys.valid())
         {
-            Info<< "Checking surface orientation" << endl;
-            PatchTools::checkOrientation(surf, true);
-            Info<< endl;
+            Info<< " -to " << toCsys().name() << endl;
+            tmp<pointField> tpf = toCsys().globalPosition(surf.points());
+            surf.movePoints(tpf());
         }
 
-        if (args.options().found("clean"))
+        if (scaleOut > 0)
         {
-            Info<< "Cleaning up surface" << endl;
-            surf.cleanup(true);
-            surf.writeStats(Info);
-            Info<< endl;
+            Info<< " -scaleOut " << scaleOut << endl;
+            surf.scalePoints(scaleOut);
         }
 
         Info<< "writing " << exportName;
-        if (scaleFactor <= 0)
-        {
-            Info<< " without scaling" << endl;
-        }
-        else
-        {
-            Info<< " with scaling " << scaleFactor << endl;
-            surf.scalePoints(scaleFactor);
-            surf.writeStats(Info);
-            Info<< endl;
-        }
         surf.write(exportName);
     }
 
diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/files b/applications/utilities/surface/surfaceMeshConvertTesting/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..6fd163a0548ac9993f75cf0336b7e00d8080913a
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshConvertTesting/Make/files
@@ -0,0 +1,3 @@
+surfaceMeshConvertTesting.C
+
+EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting
diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/options b/applications/utilities/surface/surfaceMeshConvertTesting/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..3b91e457ea3c734c71ad0a6d8d26f457c5433728
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshConvertTesting/Make/options
@@ -0,0 +1,5 @@
+EXE_INC = \
+    -I$(LIB_SRC)/triSurface/lnInclude \
+    -I$(LIB_SRC)/surfMesh/lnInclude
+
+EXE_LIBS = -ltriSurface -lsurfMesh
diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C
new file mode 100644
index 0000000000000000000000000000000000000000..ccd85d8e5a07731dff79d6449f5f4f1c4c2c819c
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C
@@ -0,0 +1,348 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+Application
+    surfaceMeshConvertTesting
+
+Description
+    Converts from one surface mesh format to another, but primarily
+    used for testing functionality.
+
+Usage
+    - surfaceMeshConvertTesting inputFile outputFile [OPTION]
+
+    @param -clean \n
+    Perform some surface checking/cleanup on the input surface
+
+    @param -orient \n
+    Check face orientation on the input surface
+
+    @param -scale \<scale\> \n
+    Specify a scaling factor for writing the files
+
+    @param -triSurface \n
+    Use triSurface library for input/output
+
+    @param -keyed \n
+    Use keyedSurface for input/output
+
+Note
+    The filename extensions are used to determine the file format type.
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "timeSelector.H"
+#include "Time.H"
+#include "polyMesh.H"
+#include "triSurface.H"
+#include "surfMesh.H"
+#include "surfFields.H"
+#include "surfPointFields.H"
+#include "PackedBoolList.H"
+
+#include "MeshedSurfaces.H"
+#include "UnsortedMeshedSurfaces.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noParallel();
+    argList::validArgs.append("inputFile");
+    argList::validArgs.append("outputFile");
+    argList::validOptions.insert("clean", "");
+    argList::validOptions.insert("orient", "");
+    argList::validOptions.insert("surfMesh", "");
+    argList::validOptions.insert("scale", "scale");
+    argList::validOptions.insert("triSurface", "");
+    argList::validOptions.insert("unsorted", "");
+    argList::validOptions.insert("triFace", "");
+#   include "setRootCase.H"
+    const stringList& params = args.additionalArgs();
+
+    scalar scaleFactor = 0;
+    if (args.options().found("scale"))
+    {
+        IStringStream(args.options()["scale"])() >> scaleFactor;
+    }
+
+    fileName importName(params[0]);
+    fileName exportName(params[1]);
+
+    if (importName == exportName)
+    {
+        FatalErrorIn(args.executable())
+            << "Output file " << exportName << " would overwrite input file."
+            << exit(FatalError);
+    }
+
+    if
+    (
+        !MeshedSurface<face>::canRead(importName, true)
+     || !MeshedSurface<face>::canWriteType(exportName.ext(), true)
+    )
+    {
+        return 1;
+    }
+
+    if (args.options().found("triSurface"))
+    {
+        triSurface surf(importName);
+
+        Info<< "Read surface:" << endl;
+        surf.writeStats(Info);
+        Info<< endl;
+
+        if (args.options().found("orient"))
+        {
+            Info<< "Checking surface orientation" << endl;
+            PatchTools::checkOrientation(surf, true);
+            Info<< endl;
+        }
+
+        if (args.options().found("clean"))
+        {
+            Info<< "Cleaning up surface" << endl;
+            surf.cleanup(true);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+
+        Info<< "writing " << exportName;
+        if (scaleFactor <= 0)
+        {
+            Info<< " without scaling" << endl;
+        }
+        else
+        {
+            Info<< " with scaling " << scaleFactor << endl;
+            surf.scalePoints(scaleFactor);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+
+        // write sorted by region
+        surf.write(exportName, true);
+    }
+    else if (args.options().found("unsorted"))
+    {
+        UnsortedMeshedSurface<face> surf(importName);
+
+        Info<< "Read surface:" << endl;
+        surf.writeStats(Info);
+        Info<< endl;
+
+        if (args.options().found("orient"))
+        {
+            Info<< "Checking surface orientation" << endl;
+            PatchTools::checkOrientation(surf, true);
+            Info<< endl;
+        }
+
+        if (args.options().found("clean"))
+        {
+            Info<< "Cleaning up surface" << endl;
+            surf.cleanup(true);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+
+        Info<< "writing " << exportName;
+        if (scaleFactor <= 0)
+        {
+            Info<< " without scaling" << endl;
+        }
+        else
+        {
+            Info<< " with scaling " << scaleFactor << endl;
+            surf.scalePoints(scaleFactor);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+        surf.write(exportName);
+    }
+#if 1
+    else if (args.options().found("triFace"))
+    {
+        MeshedSurface<triFace> surf(importName);
+
+        Info<< "Read surface:" << endl;
+        surf.writeStats(Info);
+        Info<< endl;
+
+        if (args.options().found("orient"))
+        {
+            Info<< "Checking surface orientation" << endl;
+            PatchTools::checkOrientation(surf, true);
+            Info<< endl;
+        }
+
+        if (args.options().found("clean"))
+        {
+            Info<< "Cleaning up surface" << endl;
+            surf.cleanup(true);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+
+        Info<< "writing " << exportName;
+        if (scaleFactor <= 0)
+        {
+            Info<< " without scaling" << endl;
+        }
+        else
+        {
+            Info<< " with scaling " << scaleFactor << endl;
+            surf.scalePoints(scaleFactor);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+        surf.write(exportName);
+    }
+#endif
+    else
+    {
+        MeshedSurface<face> surf(importName);
+
+        Info<< "Read surface:" << endl;
+        surf.writeStats(Info);
+        Info<< endl;
+
+        if (args.options().found("orient"))
+        {
+            Info<< "Checking surface orientation" << endl;
+            PatchTools::checkOrientation(surf, true);
+            Info<< endl;
+        }
+
+        if (args.options().found("clean"))
+        {
+            Info<< "Cleaning up surface" << endl;
+            surf.cleanup(true);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+
+
+        Info<< "writing " << exportName;
+        if (scaleFactor <= 0)
+        {
+            Info<< " without scaling" << endl;
+        }
+        else
+        {
+            Info<< " with scaling " << scaleFactor << endl;
+            surf.scalePoints(scaleFactor);
+            surf.writeStats(Info);
+            Info<< endl;
+        }
+        surf.write(exportName);
+
+        if (args.options().found("surfMesh"))
+        {
+            Foam::Time runTime
+            (
+                args.rootPath(),
+                args.caseName()
+            );
+
+            surfMesh surfOut
+            (
+                IOobject
+                (
+                    "mySurf",
+                    runTime.instance(),
+                    runTime
+                ),
+                surf.xfer()
+            );
+
+            Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
+            surfOut.write();
+
+            surfLabelField zoneIds
+            (
+                IOobject
+                (
+                    "zoneIds",
+                    surfOut.instance(),
+                    surfOut,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE
+                ),
+                surfOut,
+                dimless
+            );
+
+            const surfZoneList& zones = surfOut.surfZones();
+            forAll(zones, zoneI)
+            {
+                SubList<label>
+                (
+                    zoneIds,
+                    zones[zoneI].size(),
+                    zones[zoneI].start()
+                ) = zoneI;
+            }
+
+            Info<< "write zoneIds (for testing only): "
+                << zoneIds.objectPath() << endl;
+            zoneIds.write();
+
+            surfPointLabelField pointIds
+            (
+                IOobject
+                (
+                    "pointIds",
+                    surfOut.instance(),
+                    "pointFields",
+                    surfOut,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE
+                ),
+                surfOut,
+                dimless
+            );
+
+            forAll(pointIds, i)
+            {
+                pointIds[i] = i;
+            }
+
+            Info<< "write pointIds (for testing only): "
+                << pointIds.objectPath() << endl;
+            pointIds.write();
+        }
+    }
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceMeshExport/Make/files b/applications/utilities/surface/surfaceMeshExport/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..ea05f5bc24d08b90cfb7c7aef9a3a6e655c2cab3
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshExport/Make/files
@@ -0,0 +1,3 @@
+surfaceMeshExport.C
+
+EXE = $(FOAM_APPBIN)/surfaceMeshExport
diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options b/applications/utilities/surface/surfaceMeshExport/Make/options
similarity index 100%
rename from applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options
rename to applications/utilities/surface/surfaceMeshExport/Make/options
diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C
similarity index 56%
rename from applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C
rename to applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C
index cabebafc56803bdb070c005f5c010ecc548410e3..41c8a43d6dcea882f0d6e4c3c3703d6d11509996 100644
--- a/applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C
+++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C
@@ -23,27 +23,36 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Application
-    surfaceMeshCoordinateSystemTransform
+    surfaceMeshExport
 
 Description
-
-    Transform (scale/rotate/translate) a surface based on
-    a coordinateSystem.
+    Export from surfMesh to various third-party surface formats with
+    optional scaling or transformations (rotate/translate) on a
+    coordinateSystem.
 
 Usage
-    - surfaceMeshCoordinateSystemTransform inputFile outputFile [OPTION]
+    - surfaceMeshExport outputFile [OPTION]
 
     @param -clean \n
-    Perform some surface checking/cleanup on the input surface
+    Perform some surface checking/cleanup on the input surface.
+
+    @param -name \<name\> \n
+    Specify an alternative surface name when writing.
 
-    @param -scale \<scale\> \n
-    Specify a scaling factor for writing the files
+    @param -scaleIn \<scale\> \n
+    Specify a scaling factor when reading files.
 
-    @param -triSurface \n
-    Use triSurface library for input/output
+    @param -scaleOut \<scale\> \n
+    Specify a scaling factor when writing files.
 
     @param -dict \<dictionary\> \n
-    Specify an alternative dictionary for coordinateSystems.
+    Specify an alternative dictionary for constant/coordinateSystems.
+
+    @param -from \<coordinateSystem\> \n
+    Specify a coordinate System when reading files.
+
+    @param -to \<coordinateSystem\> \n
+    Specify a coordinate System when writing files.
 
 Note
     The filename extensions are used to determine the file format type.
@@ -55,7 +64,6 @@ Note
 #include "Time.H"
 
 #include "MeshedSurfaces.H"
-#include "UnsortedMeshedSurfaces.H"
 #include "coordinateSystems.H"
 
 using namespace Foam;
@@ -66,36 +74,55 @@ using namespace Foam;
 int main(int argc, char *argv[])
 {
     argList::noParallel();
-    argList::validArgs.append("inputFile");
     argList::validArgs.append("outputFile");
-    argList::validOptions.insert("scale", "scale");
-    argList::validOptions.insert("unsorted", "");
+    argList::validOptions.insert("name",  "name");
+    argList::validOptions.insert("clean",  "scale");
+    argList::validOptions.insert("scaleIn",  "scale");
+    argList::validOptions.insert("scaleOut", "scale");
+    argList::validOptions.insert("dict", "coordinateSystemsDict");
     argList::validOptions.insert("from", "sourceCoordinateSystem");
-    argList::validOptions.insert("to", "targetCoordinateSystem");
-    argList::validOptions.insert("dict", "dictionary");
+    argList::validOptions.insert("to",   "targetCoordinateSystem");
 
     argList args(argc, argv);
     Time runTime(args.rootPath(), args.caseName());
     const stringList& params = args.additionalArgs();
 
-    const word dictName("coordinateSystems");
+    fileName exportName(params[0]);
+    word importName("default");
+
+    // check that writing is supported
+    if (!MeshedSurface<face>::canWriteType(exportName.ext(), true))
+    {
+        return 1;
+    }
+
+    if (args.options().found("name"))
+    {
+        importName = args.options()["name"];
+    }
 
+
+    // get the coordinate transformations
     autoPtr<coordinateSystem> fromCsys;
     autoPtr<coordinateSystem> toCsys;
 
     if (args.options().found("from") || args.options().found("to"))
     {
-        autoPtr<IOobject> csDictIoPtr;
+        autoPtr<IOobject> ioPtr;
 
         if (args.options().found("dict"))
         {
             fileName dictPath(args.options()["dict"]);
 
-            csDictIoPtr.set
+            ioPtr.set
             (
                 new IOobject
                 (
-                    ( dictPath.isDir() ? dictPath/dictName : dictPath ),
+                    (
+                        isDir(dictPath)
+                      ? dictPath/coordinateSystems::typeName
+                      : dictPath
+                    ),
                     runTime,
                     IOobject::MUST_READ,
                     IOobject::NO_WRITE,
@@ -105,11 +132,11 @@ int main(int argc, char *argv[])
         }
         else
         {
-            csDictIoPtr.set
+            ioPtr.set
             (
                 new IOobject
                 (
-                    dictName,
+                    coordinateSystems::typeName,
                     runTime.constant(),
                     runTime,
                     IOobject::MUST_READ,
@@ -120,15 +147,15 @@ int main(int argc, char *argv[])
         }
 
 
-        if (!csDictIoPtr->headerOk())
+        if (!ioPtr->headerOk())
         {
             FatalErrorIn(args.executable())
                 << "Cannot open coordinateSystems file\n    "
-                << csDictIoPtr->objectPath() << nl
+                << ioPtr->objectPath() << nl
                 << exit(FatalError);
         }
 
-        coordinateSystems csLst(csDictIoPtr());
+        coordinateSystems csLst(ioPtr());
 
         if (args.options().found("from"))
         {
@@ -167,69 +194,80 @@ int main(int argc, char *argv[])
         if (fromCsys.valid() && toCsys.valid())
         {
             FatalErrorIn(args.executable())
-                << "Only allowed  -from  or  -to  option at the moment."
+                << "Only allowed  '-from' or '-to' option at the moment."
                 << exit(FatalError);
         }
     }
 
-    scalar scaleFactor = 0;
-    if (args.options().found("scale"))
+
+    surfMesh smesh
+    (
+        IOobject
+        (
+            importName,
+            runTime.constant(),
+            runTime,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        )
+    );
+
+    Info<< "read surfMesh:\n  " << smesh.objectPath() << endl;
+
+
+    // Simply copy for now, but really should have a separate write method
+
+    MeshedSurface<face> surf(smesh);
+
+    if (args.options().found("clean"))
     {
-        IStringStream(args.options()["scale"])() >> scaleFactor;
+        surf.cleanup(true);
     }
 
-    fileName importName(params[0]);
-    fileName exportName(params[1]);
-
-    if (importName == exportName)
+    scalar scaleIn = 0;
+    scalar scaleOut = 0;
+    if (args.options().found("scaleIn"))
+    {
+        IStringStream(args.options()["scaleIn"])() >> scaleIn;
+    }
+    if (args.options().found("scaleOut"))
     {
-        FatalErrorIn(args.executable())
-            << "Output file " << exportName << " would overwrite input file."
-            << exit(FatalError);
+        IStringStream(args.options()["scaleOut"])() >> scaleOut;
     }
 
-    if
-    (
-        !meshedSurface::canRead(importName, true)
-     || !meshedSurface::canWriteType(exportName.ext(), true)
-    )
+
+    if (scaleIn > 0)
     {
-        return 1;
+        Info<< " -scaleIn " << scaleIn << endl;
+        surf.scalePoints(scaleIn);
     }
 
+    if (fromCsys.valid())
+    {
+        Info<< " -from " << fromCsys().name() << endl;
+        tmp<pointField> tpf = fromCsys().localPosition(surf.points());
+        surf.movePoints(tpf());
+    }
 
+    if (toCsys.valid())
     {
-        MeshedSurface<face> surf(importName);
+        Info<< " -to " << toCsys().name() << endl;
+        tmp<pointField> tpf = toCsys().globalPosition(surf.points());
+        surf.movePoints(tpf());
+    }
 
-        if (args.options().found("clean"))
-        {
-            surf.cleanup(true);
-        }
+    if (scaleOut > 0)
+    {
+        Info<< " -scaleOut " << scaleOut << endl;
+        surf.scalePoints(scaleOut);
+    }
 
-        if (fromCsys.valid())
-        {
-            tmp<pointField> tpf = fromCsys().localPosition(surf.points());
-            surf.movePoints(tpf());
-        }
 
-        if (toCsys.valid())
-        {
-            tmp<pointField> tpf = toCsys().globalPosition(surf.points());
-            surf.movePoints(tpf());
-        }
+    surf.writeStats(Info);
+    Info<< endl;
 
-        Info<< "writing " << exportName;
-        if (scaleFactor <= 0)
-        {
-            Info<< " without scaling" << endl;
-        }
-        else
-        {
-            Info<< " with scaling " << scaleFactor << endl;
-            surf.scalePoints(scaleFactor);
-        }
-        surf.write(exportName);
-    }
+    Info<< "writing " << exportName << endl;
+    surf.write(exportName);
 
     Info<< "\nEnd\n" << endl;
 
diff --git a/applications/utilities/surface/surfaceMeshImport/Make/files b/applications/utilities/surface/surfaceMeshImport/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..d1fb24d300f55ef5085b68cdbb82ff1674b38176
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshImport/Make/files
@@ -0,0 +1,3 @@
+surfaceMeshImport.C
+
+EXE = $(FOAM_APPBIN)/surfaceMeshImport
diff --git a/applications/utilities/surface/surfaceMeshImport/Make/options b/applications/utilities/surface/surfaceMeshImport/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..42b30c86523f83efafbd2dbe5d52cc7487ec4101
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshImport/Make/options
@@ -0,0 +1,5 @@
+EXE_INC = \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/surfMesh/lnInclude
+
+EXE_LIBS = -lmeshTools -lsurfMesh
diff --git a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C
new file mode 100644
index 0000000000000000000000000000000000000000..01ef15d74e60c8bd81b08b9c8842c2aed9c75d77
--- /dev/null
+++ b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C
@@ -0,0 +1,284 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+Application
+    surfaceMeshImport
+
+Description
+    Import from various third-party surface formats into surfMesh
+    with optional scaling or transformations (rotate/translate)
+    on a coordinateSystem.
+
+Usage
+    - surfaceMeshImport inputFile [OPTION]
+
+    @param -clean \n
+    Perform some surface checking/cleanup on the input surface.
+
+    @param -name \<name\> \n
+    Specify an alternative surface name when writing.
+
+    @param -scaleIn \<scale\> \n
+    Specify a scaling factor when reading files.
+
+    @param -scaleOut \<scale\> \n
+    Specify a scaling factor when writing files.
+
+    @param -dict \<dictionary\> \n
+    Specify an alternative dictionary for constant/coordinateSystems.
+
+    @param -from \<coordinateSystem\> \n
+    Specify a coordinate System when reading files.
+
+    @param -to \<coordinateSystem\> \n
+    Specify a coordinate System when writing files.
+
+Note
+    The filename extensions are used to determine the file format type.
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "timeSelector.H"
+#include "Time.H"
+
+#include "MeshedSurfaces.H"
+#include "coordinateSystems.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noParallel();
+    argList::validArgs.append("inputFile");
+    argList::validOptions.insert("name",  "name");
+    argList::validOptions.insert("clean",  "scale");
+    argList::validOptions.insert("scaleIn",  "scale");
+    argList::validOptions.insert("scaleOut", "scale");
+    argList::validOptions.insert("dict", "coordinateSystemsDict");
+    argList::validOptions.insert("from", "sourceCoordinateSystem");
+    argList::validOptions.insert("to",   "targetCoordinateSystem");
+
+#   include "setRootCase.H"
+#   include "createTime.H"
+
+    const stringList& params = args.additionalArgs();
+
+    // try for the latestTime, but create "constant" as needed
+    instantList Times = runTime.times();
+    if (Times.size())
+    {
+        label startTime = Times.size()-1;
+        runTime.setTime(Times[startTime], startTime);
+    }
+    else
+    {
+        runTime.setTime(instant(0, runTime.constant()), 0);
+    }
+
+
+    fileName importName(params[0]);
+    word exportName("default");
+
+    // check that reading is supported
+    if (!MeshedSurface<face>::canRead(importName, true))
+    {
+        return 1;
+    }
+
+    if (args.options().found("name"))
+    {
+        exportName = args.options()["name"];
+    }
+
+
+    // get the coordinate transformations
+    autoPtr<coordinateSystem> fromCsys;
+    autoPtr<coordinateSystem> toCsys;
+
+    if (args.options().found("from") || args.options().found("to"))
+    {
+        autoPtr<IOobject> ioPtr;
+
+        if (args.options().found("dict"))
+        {
+            fileName dictPath(args.options()["dict"]);
+
+            ioPtr.set
+            (
+                new IOobject
+                (
+                    (
+                        isDir(dictPath)
+                      ? dictPath/coordinateSystems::typeName
+                      : dictPath
+                    ),
+                    runTime,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                )
+            );
+        }
+        else
+        {
+            ioPtr.set
+            (
+                new IOobject
+                (
+                    coordinateSystems::typeName,
+                    runTime.constant(),
+                    runTime,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                )
+            );
+        }
+
+
+        if (!ioPtr->headerOk())
+        {
+            FatalErrorIn(args.executable())
+                << "Cannot open coordinateSystems file\n    "
+                << ioPtr->objectPath() << nl
+                << exit(FatalError);
+        }
+
+        coordinateSystems csLst(ioPtr());
+
+        if (args.options().found("from"))
+        {
+            const word csName(args.options()["from"]);
+
+            label csId = csLst.find(csName);
+            if (csId < 0)
+            {
+                FatalErrorIn(args.executable())
+                    << "Cannot find -from " << csName << nl
+                    << "available coordinateSystems: " << csLst.toc() << nl
+                    << exit(FatalError);
+            }
+
+            fromCsys.reset(new coordinateSystem(csLst[csId]));
+        }
+
+        if (args.options().found("to"))
+        {
+            const word csName(args.options()["to"]);
+
+            label csId = csLst.find(csName);
+            if (csId < 0)
+            {
+                FatalErrorIn(args.executable())
+                    << "Cannot find -to " << csName << nl
+                    << "available coordinateSystems: " << csLst.toc() << nl
+                    << exit(FatalError);
+            }
+
+            toCsys.reset(new coordinateSystem(csLst[csId]));
+        }
+
+
+        // maybe fix this later
+        if (fromCsys.valid() && toCsys.valid())
+        {
+            FatalErrorIn(args.executable())
+                << "Only allowed  '-from' or '-to' option at the moment."
+                << exit(FatalError);
+        }
+    }
+
+
+
+    MeshedSurface<face> surf(importName);
+
+    if (args.options().found("clean"))
+    {
+        surf.cleanup(true);
+    }
+
+
+    scalar scaleIn = 0;
+    scalar scaleOut = 0;
+    if (args.options().found("scaleIn"))
+    {
+        IStringStream(args.options()["scaleIn"])() >> scaleIn;
+    }
+    if (args.options().found("scaleOut"))
+    {
+        IStringStream(args.options()["scaleOut"])() >> scaleOut;
+    }
+
+
+    if (scaleIn > 0)
+    {
+        Info<< " -scaleIn " << scaleIn << endl;
+        surf.scalePoints(scaleIn);
+    }
+
+    if (fromCsys.valid())
+    {
+        Info<< " -from " << fromCsys().name() << endl;
+        tmp<pointField> tpf = fromCsys().localPosition(surf.points());
+        surf.movePoints(tpf());
+    }
+
+    if (toCsys.valid())
+    {
+        Info<< " -to " << toCsys().name() << endl;
+        tmp<pointField> tpf = toCsys().globalPosition(surf.points());
+        surf.movePoints(tpf());
+    }
+
+    if (scaleOut > 0)
+    {
+        Info<< " -scaleOut " << scaleOut << endl;
+        surf.scalePoints(scaleOut);
+    }
+
+    surfMesh smesh
+    (
+        IOobject
+        (
+            exportName,
+            runTime.constant(),
+            runTime
+        ),
+        surf.xfer()
+    );
+
+
+    Info<< "writing surfMesh:\n  " << smesh.objectPath() << endl;
+    smesh.write();
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
index 8968831e6445d0c6b16ec4d4719b5ec674555453..f7131d87db8483e4763ebb03ddac4fb6ffbcb7ed 100644
--- a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
+++ b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
@@ -351,7 +351,7 @@ label otherEdge
 
     return -1;
 }
-    
+
 
 // Starting from startPoint on startEdge on startFace walk along border
 // and insert faces along the way. Walk keeps always one point or one edge
@@ -461,18 +461,8 @@ label sharedFace
 
     label startIndex = findIndex(f, e.start());
 
-    bool edgeOrder;
-
-    if (f[(startIndex + 1) % f.size()] == e.end())
-    {
-        // points in face in same order as edge
-        edgeOrder = true;
-    }
-    else
-    {
-        // points in face in reverse order as edge
-        edgeOrder = false;
-    }
+    // points in face in same order as edge
+    bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
 
     // Get faces using edge in sorted order. (sorted such that walking
     // around them in anti-clockwise order corresponds to edge vector
@@ -485,25 +475,18 @@ label sharedFace
     if (edgeOrder)
     {
         // Get face before firstFaceI
-        if (faceIndex == 0)
-        {
-            return eFaces[eFaces.size() - 1];
-        }
-        else
-        {
-            return eFaces[faceIndex - 1];
-        }
+        return eFaces[eFaces.rcIndex(faceIndex)];
     }
     else
     {
         // Get face after firstFaceI
-        return eFaces[(faceIndex+1) % eFaces.size()];
+        return eFaces[eFaces.fcIndex(faceIndex)];
     }
 }
 
 
 // Calculate (inward pointing) normals on edges shared by faces in faceToEdge and
-// averages them to pointNormals. 
+// averages them to pointNormals.
 void calcPointVecs
 (
     const triSurface& surf,
@@ -602,7 +585,7 @@ void calcPointVecs
             }
 
             scalar magMidVec = mag(midVec);
-    
+
             if (magMidVec > SMALL)
             {
                 midVec /= magMidVec;
@@ -925,7 +908,7 @@ int main(int argc, char *argv[])
                 newPoints[newPointI] = newPoints[pointI] + 0.1 * minLen * n;
             }
         }
-        
+
 
         //
         // Renumber all faces in connectedFaces
diff --git a/src/Allwmake b/src/Allwmake
index 39ce3f16f1a731872fe2a93aa85c12e5f9de9209..f22e0729dbe8e50694ee43a373205494b0a2a536 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -17,11 +17,12 @@ wmake libso lagrangian/basic
 wmake libso triSurface
 wmake libso edgeMesh
 wmake libso surfMesh
-wmake libso meshTools
-wmake libso finiteVolume
 
 decompositionAgglomeration/Allwmake
 
+wmake libso meshTools
+wmake libso finiteVolume
+
 wmake libso sampling
 
 wmake libso dynamicMesh
diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C
index c3479810d47e0c7061dbde9b69c2abf54dc6be41..9378a21c7caacf345d715be1a1cdc20b6e33a9d1 100644
--- a/src/OSspecific/Unix/Unix.C
+++ b/src/OSspecific/Unix/Unix.C
@@ -23,7 +23,7 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Description
-    UNIX versions of the functions declared in OSspecific.H.
+    UNIX versions of the functions declared in OSspecific.H
 
 \*---------------------------------------------------------------------------*/
 
@@ -218,7 +218,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
     // Search user files:
     // ~~~~~~~~~~~~~~~~~~
     fileName searchDir = home()/".OpenFOAM";
-    if (dir(searchDir))
+    if (isDir(searchDir))
     {
         // Check for user file in ~/.OpenFOAM/VERSION
         fileName fullName = searchDir/FOAMversion/name;
@@ -239,7 +239,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
     // Search site files:
     // ~~~~~~~~~~~~~~~~~~
     searchDir = getEnv("WM_PROJECT_INST_DIR");
-    if (dir(searchDir))
+    if (isDir(searchDir))
     {
         // Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
         fileName fullName = searchDir/"site"/FOAMversion/name;
@@ -259,7 +259,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
     // Search installation files:
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~
     searchDir = getEnv("WM_PROJECT_DIR");
-    if (dir(searchDir))
+    if (isDir(searchDir))
     {
         // Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
         fileName fullName = searchDir/"etc"/name;
@@ -432,7 +432,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
 
 
 // Set the file mode
-bool Foam::chmod(const fileName& name, const mode_t m)
+bool Foam::chMod(const fileName& name, const mode_t m)
 {
     return ::chmod(name.c_str(), m) == 0;
 }
@@ -476,21 +476,21 @@ Foam::fileName::Type Foam::type(const fileName& name)
 // Does the name exist in the filing system?
 bool Foam::exists(const fileName& name)
 {
-    return mode(name) || file(name);
+    return mode(name) || isFile(name);
 }
 
 
-// Does the file exist
-bool Foam::file(const fileName& name)
+// Does the directory exist
+bool Foam::isDir(const fileName& name)
 {
-    return S_ISREG(mode(name)) || S_ISREG(mode(name + ".gz"));
+    return S_ISDIR(mode(name));
 }
 
 
-// Does the directory exist
-bool Foam::dir(const fileName& name)
+// Does the file exist
+bool Foam::isFile(const fileName& name, const bool checkGzip)
 {
-    return S_ISDIR(mode(name));
+    return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz")));
 }
 
 
@@ -641,7 +641,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
         }
 
         // Make sure the destination directory exists.
-        if (!dir(destFile.path()) && !mkDir(destFile.path()))
+        if (!isDir(destFile.path()) && !mkDir(destFile.path()))
         {
             return false;
         }
@@ -681,7 +681,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
         }
 
         // Make sure the destination directory exists.
-        if (!dir(destFile) && !mkDir(destFile))
+        if (!isDir(destFile) && !mkDir(destFile))
         {
             return false;
         }
@@ -719,19 +719,19 @@ bool Foam::cp(const fileName& src, const fileName& dest)
 }
 
 
-// Create a softlink. destFile should not exist. Returns true if successful.
-bool Foam::ln(const fileName& src, const fileName& dest)
+// Create a softlink. dst should not exist. Returns true if successful.
+bool Foam::ln(const fileName& src, const fileName& dst)
 {
     if (Unix::debug)
     {
-        Info<< "Create softlink from : " << src << " to " << dest
+        Info<< "Create softlink from : " << src << " to " << dst
             << endl;
     }
 
-    if (exists(dest))
+    if (exists(dst))
     {
         WarningIn("ln(const fileName&, const fileName&)")
-            << "destination " << dest << " already exists. Not linking."
+            << "destination " << dst << " already exists. Not linking."
             << endl;
         return false;
     }
@@ -743,40 +743,40 @@ bool Foam::ln(const fileName& src, const fileName& dest)
         return false;
     }
 
-    if (symlink(src.c_str(), dest.c_str()) == 0)
+    if (symlink(src.c_str(), dst.c_str()) == 0)
     {
         return true;
     }
     else
     {
         WarningIn("ln(const fileName&, const fileName&)")
-            << "symlink from " << src << " to " << dest << " failed." << endl;
+            << "symlink from " << src << " to " << dst << " failed." << endl;
         return false;
     }
 }
 
 
-// Rename srcFile destFile
-bool Foam::mv(const fileName& srcFile, const fileName& destFile)
+// Rename srcFile dstFile
+bool Foam::mv(const fileName& srcFile, const fileName& dstFile)
 {
     if (Unix::debug)
     {
-        Info<< "Move : " << srcFile << " to " << destFile << endl;
+        Info<< "Move : " << srcFile << " to " << dstFile << endl;
     }
 
     if
     (
-        (destFile.type() == fileName::DIRECTORY)
-     && (srcFile.type() != fileName::DIRECTORY)
+        dstFile.type() == fileName::DIRECTORY
+     && srcFile.type() != fileName::DIRECTORY
     )
     {
-        const fileName destName(destFile/srcFile.name());
+        const fileName dstName(dstFile/srcFile.name());
 
-        return rename(srcFile.c_str(), destName.c_str()) == 0;
+        return rename(srcFile.c_str(), dstName.c_str()) == 0;
     }
     else
     {
-        return rename(srcFile.c_str(), destFile.c_str()) == 0;
+        return rename(srcFile.c_str(), dstFile.c_str()) == 0;
     }
 }
 
@@ -806,7 +806,7 @@ bool Foam::rmDir(const fileName& directory)
 {
     if (Unix::debug)
     {
-        Info<< "rmdir(const fileName&) : "
+        Info<< "rmDir(const fileName&) : "
             << "removing directory " << directory << endl;
     }
 
@@ -817,7 +817,7 @@ bool Foam::rmDir(const fileName& directory)
     // Attempt to open directory and set the structure pointer
     if ((source = opendir(directory.c_str())) == NULL)
     {
-        WarningIn("rmdir(const fileName&)")
+        WarningIn("rmDir(const fileName&)")
             << "cannot open directory " << directory << endl;
 
         return false;
@@ -837,7 +837,7 @@ bool Foam::rmDir(const fileName& directory)
                 {
                     if (!rmDir(path))
                     {
-                        WarningIn("rmdir(const fileName&)")
+                        WarningIn("rmDir(const fileName&)")
                             << "failed to remove directory " << fName
                             << " while removing directory " << directory
                             << endl;
@@ -851,7 +851,7 @@ bool Foam::rmDir(const fileName& directory)
                 {
                     if (!rm(path))
                     {
-                        WarningIn("rmdir(const fileName&)")
+                        WarningIn("rmDir(const fileName&)")
                             << "failed to remove file " << fName
                             << " while removing directory " << directory
                             << endl;
@@ -867,7 +867,7 @@ bool Foam::rmDir(const fileName& directory)
 
         if (!rm(directory))
         {
-            WarningIn("rmdir(const fileName&)")
+            WarningIn("rmDir(const fileName&)")
                 << "failed to remove directory " << directory << endl;
 
             closedir(source);
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 2c4bfce8d7e03e04ec054014785255989ee50d7f..92c81085ab93aad0624f2bd3ba873d54dcd9dd9d 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -45,6 +45,10 @@ $(strings)/fileName/fileNameIO.C
 $(strings)/keyType/keyTypeIO.C
 $(strings)/wordRe/wordReIO.C
 
+sha1 = primitives/hashes/SHA1
+$(sha1)/SHA1.C
+$(sha1)/SHA1Digest.C
+
 primitives/random/Random.C
 
 containers/HashTables/HashTable/HashTableName.C
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
index ae9bcc2718776adca0557f7515d1c4d24042ae3f..3ed474b32db9ecfb9a518be93971fa2e1c35a063 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
@@ -226,7 +226,7 @@ bool Foam::HashTable<T, Key, Hash>::set
     const bool protect
 )
 {
-    if (tableSize_ == 0)
+    if (!tableSize_)
     {
         resize(2);
     }
@@ -556,7 +556,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
     }
 
     // could be zero-sized from a previous transfer()
-    if (tableSize_ == 0)
+    if (!tableSize_)
     {
         resize(rhs.tableSize_);
     }
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
index 79ff3741453e3863093e73492307da9a636294bd..aea5f3043ad8dd6ed258c83df3a3a72bd49a6021 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
@@ -54,7 +54,7 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::size() const
 template<class T, class Key, class Hash>
 inline bool Foam::HashTable<T, Key, Hash>::empty() const
 {
-    return (nElmts_ == 0);
+    return !nElmts_;
 }
 
 
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H
index 329437a07a40d774545c36cbb23a80b5db65a383..5cd380357a7c890c5e70c706f69abcc40a9b2c91 100644
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H
+++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H
@@ -41,7 +41,7 @@ inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const
 template<class T, class Key, class Hash>
 inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const
 {
-    return (nElmts_ == 0);
+    return !nElmts_;
 }
 
 
diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H
index 9b80941bf9abaa9679b0df74c29769f15879bea1..bcc20289ca39662ff82a24c2461d03264de9f715 100644
--- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H
+++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H
@@ -83,7 +83,7 @@ inline Foam::label Foam::DLListBase::size() const
 
 inline bool Foam::DLListBase::empty() const
 {
-    return (nElmts_ == 0);
+    return !nElmts_;
 }
 
 
diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H
index de34257d342f82751ebce088b4edd349744d684d..339963da5e5bf16cc3fe8abaa86508fb19006b91 100644
--- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H
+++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H
@@ -73,7 +73,7 @@ inline Foam::label Foam::SLListBase::size() const
 
 inline bool Foam::SLListBase::empty() const
 {
-    return (nElmts_ == 0);
+    return !nElmts_;
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
index 2e3ddf408bd474e74a46f3f51e5bf3387d96051f..0079f13a0290e09eeac0ec998d64242ff9c770a6 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
@@ -135,10 +135,21 @@ public:
             inline label fcIndex(const label i) const;
 
             //- Return the reverse circular index, i.e. the previous index
-            //  which returns to the last at the begining of the list
+            //  which returns to the last at the beginning of the list
             inline label rcIndex(const label i) const;
 
 
+            //- Return a const pointer to the first data element,
+            //  similar to the STL front() method and the string::data() method
+            //  This can be used (with caution) when interfacing with C code.
+            inline const T* cdata() const;
+
+            //- Return a pointer to the first data element,
+            //  similar to the STL front() method and the string::data() method
+            //  This can be used (with caution) when interfacing with C code.
+            inline T* data();
+
+
         // Check
 
             //- Check start is within valid range (0 ... size-1).
@@ -174,10 +185,10 @@ public:
 
     // Member operators
 
-        //- Return subscript-checked element of FixedList.
+        //- Return element of FixedList.
         inline T& operator[](const label);
 
-        //- Return subscript-checked element of constant FixedList.
+        //- Return element of constant FixedList.
         inline const T& operator[](const label) const;
 
         //- Assignment from array operator. Takes linear time.
@@ -282,7 +293,7 @@ public:
         //- Return size of the largest possible FixedList.
         inline label max_size() const;
 
-        //- Return true if the FixedList is empty (i.e., if size() == 0).
+        //- Return true if the FixedList is empty (ie, size() is zero).
         inline bool empty() const;
 
         //- Swap two FixedLists of the same type in constant time.
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
index d618cb6e386751b804e433228c8633b5a4914e5d..a800b04b1d19d8527984215478763b6d14e333a4 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
@@ -121,7 +121,7 @@ inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
 template<class T, Foam::label Size>
 inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
 {
-    return (i == 0 ? Size-1 : i-1);
+    return (i ? i-1 : Size-1);
 }
 
 
@@ -195,9 +195,26 @@ inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst)
     }
 }
 
+
+template<class T, Foam::label Size>
+inline const T*
+Foam::FixedList<T, Size>::cdata() const
+{
+    return v_;
+}
+
+
+template<class T, Foam::label Size>
+inline T*
+Foam::FixedList<T, Size>::data()
+{
+    return v_;
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-// Return subscript-checked element access
+// element access
 template<class T, Foam::label Size>
 inline T& Foam::FixedList<T, Size>::operator[](const label i)
 {
@@ -208,7 +225,7 @@ inline T& Foam::FixedList<T, Size>::operator[](const label i)
 }
 
 
-// Return subscript-checked const element access
+// const element access
 template<class T, Foam::label Size>
 inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
 {
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
index b76bf3be242f3485f5ee6dd9d77aa0c5b305f263..49caad2a0adb439149b658609604157257f80a2a 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
@@ -119,7 +119,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
     }
     else
     {
-        is.read(reinterpret_cast<char*>(L.begin()), Size*sizeof(T));
+        is.read(reinterpret_cast<char*>(L.data()), Size*sizeof(T));
 
         is.fatalCheck
         (
@@ -231,7 +231,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
     }
     else
     {
-        os.write(reinterpret_cast<const char*>(L.v_), Size*sizeof(T));
+        os.write(reinterpret_cast<const char*>(L.cdata()), Size*sizeof(T));
     }
 
     // Check state of IOstream
diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C
index b7cb86c4ee785e39886390f058b68049f00c4015..7cfdfb0397f99049cf79076bdf70265189170686 100644
--- a/src/OpenFOAM/containers/Lists/List/ListIO.C
+++ b/src/OpenFOAM/containers/Lists/List/ListIO.C
@@ -117,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
         {
             if (s)
             {
-                is.read(reinterpret_cast<char*>(L.begin()), s*sizeof(T));
+                is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
 
                 is.fatalCheck
                 (
diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
index b7e90d53d13c7bed9567d4947838ebc5d9d31089..7de9239d04deed112a68f7ddf745c5d1d933133c 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
@@ -90,17 +90,31 @@ void duplicateOrder(const UList<T>&, labelList& order);
 template<class T>
 void uniqueOrder(const UList<T>&, labelList& order);
 
-//- Extract elements of List whose region is certain value.
-//  Use e.g. to extract all selected elements:
-//    subset<boolList, labelList>(selectedElems, true, lst);
+//- Extract elements of List when select is a certain value.
+//  eg, to extract all selected elements:
+//    subset<bool, labelList>(selectedElems, true, lst);
 template<class T, class ListType>
-ListType subset(const UList<T>& regions, const T& region, const ListType&);
+ListType subset(const UList<T>& select, const T& value, const ListType&);
 
-//- Inplace extract elements of List whose region is certain value. Use e.g.
-//  to extract all selected elements:
-//  inplaceSubset<boolList, labelList>(selectedElems, true, lst);
+//- Inplace extract elements of List when select is a certain value.
+//  eg, to extract all selected elements:
+//    inplaceSubset<bool, labelList>(selectedElems, true, lst);
 template<class T, class ListType>
-void inplaceSubset(const UList<T>& regions, const T& region, ListType&);
+void inplaceSubset(const UList<T>& select, const T& value, ListType&);
+
+//- Extract elements of List when select is true
+//  eg, to extract all selected elements:
+//    subset<boolList, labelList>(selectedElems, lst);
+//  Note a labelHashSet could also be used for the bool-list
+template<class BoolListType, class ListType>
+ListType subset(const BoolListType& select, const ListType&);
+
+//- Inplace extract elements of List when select is true
+//  eg, to extract all selected elements:
+//    inplaceSubset<boolList, labelList>(selectedElems, lst);
+//  Note a labelHashSet could also be used for the bool-list
+template<class BoolListType, class ListType>
+void inplaceSubset(const BoolListType& select, ListType&);
 
 //- Invert one-to-one map. Unmapped elements will be -1.
 labelList invert(const label len, const UList<label>&);
@@ -108,8 +122,9 @@ labelList invert(const label len, const UList<label>&);
 //- Invert one-to-many map. Unmapped elements will be size 0.
 labelListList invertOneToMany(const label len, const UList<label>&);
 
-//- Invert many-to-many. Input and output types need to be inherited
-//  from List. E.g. faces to pointFaces.
+//- Invert many-to-many.
+//  Input and output types need to be inherited from List.
+//  eg, faces to pointFaces.
 template<class InList, class OutList>
 void invertManyToMany(const label len, const UList<InList>&, List<OutList>&);
 
diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
index f12b5efd5542e5b7ec52303936b8d861bc7bd3d6..f2178ee38df53e583476328496325f068ef8fc34 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
@@ -243,16 +243,17 @@ void Foam::uniqueOrder
 template<class T, class ListType>
 ListType Foam::subset
 (
-    const UList<T>& regions,
-    const T& region,
+    const UList<T>& select,
+    const T& value,
     const ListType& lst
 )
 {
-    if (regions.size() < lst.size())
+    // select must at least cover the list range
+    if (select.size() < lst.size())
     {
         FatalErrorIn("subset(const UList<T>&, const T&, const ListType&)")
-            << "Regions is of size " << regions.size()
-            << "; list it is supposed to index is of size " << lst.size()
+            << "select is of size " << select.size()
+            << "; but it must index a list of size " << lst.size()
             << abort(FatalError);
     }
 
@@ -261,7 +262,7 @@ ListType Foam::subset
     label nElem = 0;
     forAll(lst, elemI)
     {
-        if (regions[elemI] == region)
+        if (select[elemI] == value)
         {
             newLst[nElem++] = lst[elemI];
         }
@@ -275,23 +276,77 @@ ListType Foam::subset
 template<class T, class ListType>
 void Foam::inplaceSubset
 (
-    const UList<T>& regions,
-    const T& region,
+    const UList<T>& select,
+    const T& value,
     ListType& lst
 )
 {
-    if (regions.size() < lst.size())
+    // select must at least cover the list range
+    if (select.size() < lst.size())
     {
         FatalErrorIn("inplaceSubset(const UList<T>&, const T&, ListType&)")
-            << "Regions is of size " << regions.size()
-            << "; list it is supposed to index is of size " << lst.size()
+            << "select is of size " << select.size()
+            << "; but it must index a list of size " << lst.size()
             << abort(FatalError);
     }
 
     label nElem = 0;
     forAll(lst, elemI)
     {
-        if (regions[elemI] == region)
+        if (select[elemI] == value)
+        {
+            if (nElem != elemI)
+            {
+                lst[nElem] = lst[elemI];
+            }
+            ++nElem;
+        }
+    }
+
+    lst.setSize(nElem);
+}
+
+
+template<class BoolListType, class ListType>
+ListType Foam::subset
+(
+    const BoolListType& select,
+    const ListType& lst
+)
+{
+    // select can have a different size
+    // eg, when it is a PackedBoolList or a labelHashSet
+
+    ListType newLst(lst.size());
+
+    label nElem = 0;
+    forAll(lst, elemI)
+    {
+        if (select[elemI])
+        {
+            newLst[nElem++] = lst[elemI];
+        }
+    }
+    newLst.setSize(nElem);
+
+    return newLst;
+}
+
+
+template<class BoolListType, class ListType>
+void Foam::inplaceSubset
+(
+    const BoolListType& select,
+    ListType& lst
+)
+{
+    // select can have a different size
+    // eg, when it is a PackedBoolList or a labelHashSet
+
+    label nElem = 0;
+    forAll(lst, elemI)
+    {
+        if (select[elemI])
         {
             if (nElem != elemI)
             {
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
index 8667ad47ba5e8c6698a226cb00eb2c9af6d451e8..87ced9504f8bbc7ec4bc708f23c673b051339759 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
@@ -83,25 +83,25 @@ unsigned int Foam::PackedList<nBits>::count() const
 
     if (size_)
     {
-        // mask value for complete chunks
+        // mask value for complete segments
         unsigned int mask = maskLower(packing());
 
-        unsigned int endIdx = size_ / packing();
-        unsigned int endOff = size_ % packing();
+        const unsigned int endSeg = size_ / packing();
+        const unsigned int endOff = size_ % packing();
 
-        // count bits in complete elements
-        for (unsigned i = 0; i < endIdx; ++i)
+        // count bits in complete segments
+        for (unsigned i = 0; i < endSeg; ++i)
         {
             register unsigned int bits = StorageList::operator[](i) & mask;
             COUNT_PACKEDBITS(c, bits);
         }
 
-        // count bits in partial chunk
+        // count bits in partial segment
         if (endOff)
         {
             mask = maskLower(endOff);
 
-            register unsigned int bits = StorageList::operator[](endIdx) & mask;
+            register unsigned int bits = StorageList::operator[](endSeg) & mask;
             COUNT_PACKEDBITS(c, bits);
         }
     }
@@ -118,7 +118,7 @@ bool Foam::PackedList<nBits>::trim()
         return false;
     }
 
-    // mask value for complete chunks
+    // mask value for complete segments
     unsigned int mask = maskLower(packing());
 
     label currElem = packedLength(size_) - 1;
@@ -130,7 +130,7 @@ bool Foam::PackedList<nBits>::trim()
         StorageList::operator[](currElem) &= maskLower(endOff);
     }
 
-    // test entire chunk
+    // test entire segment
     while (currElem > 0 && !(StorageList::operator[](currElem) &= mask))
     {
         currElem--;
@@ -162,10 +162,22 @@ bool Foam::PackedList<nBits>::trim()
 }
 
 
+template<unsigned nBits>
+void Foam::PackedList<nBits>::flip()
+{
+    label packLen = packedLength(size_);
+
+    for (label i=0; i < packLen; i++)
+    {
+        StorageList::operator[](i) = ~StorageList::operator[](i);
+    }
+}
+
+
 template<unsigned nBits>
 Foam::labelList Foam::PackedList<nBits>::values() const
 {
-    labelList elems(size());
+    labelList elems(size_);
 
     forAll(*this, i)
     {
@@ -178,10 +190,11 @@ Foam::labelList Foam::PackedList<nBits>::values() const
 template<unsigned nBits>
 Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
 {
-    os  << "iterator<" << label(nBits) << "> ["
-        << (index_ * packing() + offset_) << "]"
-        << " index:" << index_ << " offset:" << offset_
-        << " value:" << unsigned(*this)
+    os  << "iterator<"  << label(nBits) << "> ["
+        << this->index_ << "]"
+        << " segment:"  << label(this->index_ / packing())
+        << " offset:"   << label(this->index_ % packing())
+        << " value:"    << this->get()
         << nl;
 
     return os;
@@ -194,7 +207,7 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
     os  << "PackedList<" << label(nBits) << ">"
         << " max_value:" << max_value()
         << " packing:"   << packing() << nl
-        << "values: " << size() << "/" << capacity() << "( ";
+        << "values: " << size_ << "/" << capacity() << "( ";
     forAll(*this, i)
     {
         os << get(i) << ' ';
@@ -205,17 +218,17 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
     os  << ")\n"
         << "storage: " << packLen << "/" << StorageList::size() << "( ";
 
-    // mask value for complete chunks
+    // mask value for complete segments
     unsigned int mask = maskLower(packing());
 
     for (label i=0; i < packLen; i++)
     {
         const StorageType& rawBits = StorageList::operator[](i);
 
-        // the final storage may not be full, modify mask accordingly
+        // the final segment may not be full, modify mask accordingly
         if (i+1 == packLen)
         {
-            unsigned endOff = size_ % packing();
+            unsigned int endOff = size_ % packing();
 
             if (endOff)
             {
@@ -229,7 +242,7 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
 
         for (unsigned int testBit = (1 << max_bits()); testBit; testBit >>= 1)
         {
-            if (testBit & mask)
+            if (mask & testBit)
             {
                 if (rawBits & testBit)
                 {
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
index b65a658e3a343176672a3af3b8476d2f471df47a..5f71976aa9d09c1730265fc7f21eb87136ddf8a1 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
@@ -44,9 +44,9 @@ Note
     Using the iteratorBase as a proxy allows assignment of values
     between list elements. Thus the following bit of code works as expected:
     @code
-        blist[1] = blist[5];     // value assignment, not iterator position
-        blist[2] = blist[5] = 4; // propagates value
-        blist[1] = blist[5] = blist[6];  // propagates value
+        list[1] = list[5];      // value assignment, not iterator position
+        list[2] = list[5] = 4;  // propagates value
+        list[1] = list[5] = list[6];  // propagates value
     @endcode
 
     Using get() or the '[]' operator are similarly fast. Looping and reading
@@ -58,11 +58,21 @@ Note
     useful for branching on changed values.
 
     @code
-        blist[5] = 4;
-        changed = blist.set(5, 8);
+        list[5] = 4;
+        changed = list.set(5, 8);
         if (changed) ...
     @endcode
 
+    The lazy evaluation used means that reading an out-of-range element
+    returns zero, but does not affect the list size.  Even in a non-const
+    context, only the assigment causes the element to be created.
+    For example,
+    @code
+        list.resize(4);
+        Info<< list[10] << "\n";  // print zero, but doesn't adjust list
+        list[8] = 1;
+    @endcode
+
 SeeAlso
     Foam::DynamicList
 
@@ -120,9 +130,6 @@ class PackedList
         //- Calculate the list length when packed
         inline static label packedLength(const label);
 
-        //- Check index I is within valid range [ 0 .. max_value() ]
-        inline void checkIndex(const label) const;
-
 public:
 
     // Public data
@@ -172,22 +179,23 @@ public:
 
         // Access
 
-        //- The number of elements that can be stored before resizing
+        //- The number of elements that can be stored before reallocating
         inline label capacity() const;
 
         //- Number of entries.
         inline label size() const;
 
-        //- Return true if the list is empty (i.e., if size() == 0).
+        //- Return true if the list is empty (ie, size() is zero).
         inline bool empty() const;
 
         //- Get value at index I.
-        //  Does not auto-vivify entries.
+        //  Never auto-vivify entries.
         inline unsigned int get(const label) const;
 
         //- Set value at index I. Return true if value changed.
-        //  Does not auto-vivify entries.
-        inline bool set(const label, const unsigned int val);
+        //  Does auto-vivify for non-existent entries.
+        //  Default value set is the max_value.
+        inline bool set(const label, const unsigned int val = ~0u);
 
         //- Return the underlying packed storage
         inline List<unsigned int>& storage();
@@ -200,9 +208,6 @@ public:
         //  http://en.wikipedia.org/wiki/Hamming_weight
         unsigned int count() const;
 
-        //- Trim any trailing zero elements
-        bool trim();
-
         //- Return the values as a labelList
         labelList values() const;
 
@@ -211,6 +216,12 @@ public:
 
         // Edit
 
+        //- Trim any trailing zero elements
+        bool trim();
+
+        //- Invert the bits in the addressable region.
+        void flip();
+
         //- Alter the size of the underlying storage.
         //  The addressed size will be truncated if needed to fit, but will
         //  remain otherwise untouched.
@@ -255,12 +266,12 @@ public:
         inline unsigned int remove();
 
         //- Get value at index I
-        //  Does not auto-vivify entries.
+        //  Never auto-vivify entries.
         inline unsigned int operator[](const label) const;
 
         //- Set value at index I.
         //  Returns iterator to perform the actual operation.
-        //  Does not auto-vivify entries.
+        //  Does not auto-vivify entries, but will when assigned to.
         inline iteratorBase operator[](const label);
 
         //- Assignment of all entries to the given value. Takes linear time.
@@ -294,52 +305,27 @@ public:
                 //  This also lets us use the default bitwise copy/assignment
                 PackedList* list_;
 
-                //- Element index within storage
-                unsigned index_;
-
-                //- Offset within storage element
-                unsigned offset_;
+                //- Element index
+                label index_;
 
             // Protected Member Functions
 
-                //- Get value as unsigned
+                //- Get value as unsigned, no range-checking
                 inline unsigned int get() const;
 
-                //- Set value, returning true if changed
+                //- Set value, returning true if changed, no range-checking
                 inline bool set(unsigned int);
 
-                //- Increment to new position
-                inline void incr();
-
-                //- Decrement to new position
-                inline void decr();
-
-                //- Move to new position, but not beyond end()
-                inline void seek(const iteratorBase&);
-
-
             // Constructors
 
                 //- Construct null
                 inline iteratorBase();
 
-                //- Copy construct
-                inline iteratorBase(const iteratorBase&);
-
                 //- Construct from base list and position index
                 inline iteratorBase(const PackedList*, const label);
 
         public:
 
-            // Member Functions
-
-                //- Return true if the element is within addressable range
-                inline bool valid() const;
-
-                //- Move iterator to end() if it would otherwise be out-of-range
-                //  Returns true if the element was already ok
-                inline bool validate();
-
             // Member Operators
 
                 //- Compare positions
@@ -350,10 +336,12 @@ public:
                 //  This allows packed[0] = packed[3] for assigning values
                 inline unsigned int operator=(const iteratorBase&);
 
-                //- Assign value
+                //- Assign value.
+                //  A non-existent entry will be auto-vivified.
                 inline unsigned int operator=(const unsigned int val);
 
                 //- Conversion operator
+                //  Never auto-vivify entries.
                 inline operator unsigned int () const;
 
             //- Print value and information
@@ -378,6 +366,8 @@ public:
                 inline iterator();
 
                 //- Construct from iterator base, eg iter(packedlist[i])
+                //  but also  "iterator iter = packedlist[i];"
+                //  An out-of-range iterator is assigned end()
                 inline iterator(const iteratorBase&);
 
                 //- Construct from base list and position index
@@ -386,6 +376,7 @@ public:
             // Member Operators
 
                 //- Assign from iteratorBase, eg iter = packedlist[i]
+                //  An out-of-range iterator is assigned end()
                 inline iterator& operator=(const iteratorBase&);
 
                 //- Return value
@@ -427,7 +418,9 @@ public:
                 //- Construct null
                 inline const_iterator();
 
-                //- Construct from iterator base
+                //- Construct from iterator base, eg iter(packedlist[i])
+                //  but also  "const_iterator iter = packedlist[i];"
+                //  An out-of-range iterator is assigned end()
                 inline const_iterator(const iteratorBase&);
 
                 //- Construct from base list and position index
@@ -439,7 +432,7 @@ public:
             // Member operators
 
                 //- Assign from iteratorBase or derived
-                //  eg, iter = packedlist[i] or iter = [non-const]list.begin()
+                //  eg, iter = packedlist[i] or even iter = list.begin()
                 inline const_iterator& operator=(const iteratorBase&);
 
                 //- Return referenced value directly
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
index 07e6d06208388a6dc3774fbf042fef214d0b431b..929688ef242ef97ab7be59c17d3dc205a91a5c8e 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
@@ -65,24 +65,6 @@ inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem)
 }
 
 
-template<unsigned nBits>
-inline void Foam::PackedList<nBits>::checkIndex(const label i) const
-{
-    if (!size_)
-    {
-        FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
-            << "attempt to access element from zero-sized list"
-            << abort(FatalError);
-    }
-    else if (i < 0 || i >= size_)
-    {
-        FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
-            << "index " << i << " out of range 0 ... " << size_-1
-            << abort(FatalError);
-    }
-}
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<unsigned nBits>
@@ -105,7 +87,7 @@ template<unsigned nBits>
 inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
 :
     StorageList(lst),
-    size_(lst.size())
+    size_(lst.size_)
 {}
 
 
@@ -132,20 +114,7 @@ template<unsigned nBits>
 inline Foam::PackedList<nBits>::iteratorBase::iteratorBase()
 :
     list_(0),
-    index_(0),
-    offset_(0)
-{}
-
-
-template<unsigned nBits>
-inline Foam::PackedList<nBits>::iteratorBase::iteratorBase
-(
-    const iteratorBase& iter
-)
-:
-    list_(iter.list_),
-    index_(iter.index_),
-    offset_(iter.offset_)
+    index_(0)
 {}
 
 
@@ -157,8 +126,7 @@ inline Foam::PackedList<nBits>::iteratorBase::iteratorBase
 )
 :
     list_(const_cast<PackedList<nBits>*>(lst)),
-    index_(i / packing()),
-    offset_(i % packing())
+    index_(i)
 {}
 
 
@@ -166,8 +134,11 @@ template<unsigned nBits>
 inline unsigned int
 Foam::PackedList<nBits>::iteratorBase::get() const
 {
-    const unsigned int& stored = list_->StorageList::operator[](index_);
-    return (stored >> (nBits * offset_)) & max_value();
+    const unsigned int seg = index_ / packing();
+    const unsigned int off = index_ % packing();
+
+    const unsigned int& stored = list_->StorageList::operator[](seg);
+    return (stored >> (nBits * off)) & max_value();
 }
 
 
@@ -175,114 +146,37 @@ template<unsigned nBits>
 inline bool
 Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val)
 {
-    unsigned int& stored = list_->StorageList::operator[](index_);
+    const unsigned int seg = index_ / packing();
+    const unsigned int off = index_ % packing();
+
+    unsigned int& stored = list_->StorageList::operator[](seg);
     const unsigned int prev = stored;
 
-    const unsigned int startBit = nBits * offset_;
+    const unsigned int startBit = nBits * off;
     const unsigned int maskNew  = max_value() << startBit;
 
     if (val & ~max_value())
     {
-#       ifdef DEBUGList
-        FatalErrorIn("PackedList<T>::iteratorBase::set(const unsigned int)")
-            << "value " << label(val)
-w            << " out-of-range 0 ... " << label(max_value())
-            << " representable by " << nBits << " bits"
-            << abort(FatalError);
-#       endif
-
-        // treat overflow as max_value
+        // overflow is max_value, fill everything
         stored |= maskNew;
     }
     else
     {
-        stored = (stored & ~maskNew) | (maskNew & (val << startBit));
+        stored &= ~maskNew;
+        stored |= maskNew & (val << startBit);
     }
 
     return prev != stored;
 }
 
 
-
-template<unsigned nBits>
-inline void
-Foam::PackedList<nBits>::iteratorBase::incr()
-{
-    offset_++;
-    if (offset_ >= packing())
-    {
-        offset_ = 0;
-        index_++;
-    }
-}
-
-
-template<unsigned nBits>
-inline void
-Foam::PackedList<nBits>::iteratorBase::decr()
-{
-    if (!offset_)
-    {
-        offset_ = packing();
-        index_--;
-    }
-    offset_--;
-}
-
-
-template<unsigned nBits>
-inline void
-Foam::PackedList<nBits>::iteratorBase::seek
-(
-    const iteratorBase& iter
-)
-{
-    list_   = iter.list_;
-    index_  = iter.index_;
-    offset_ = iter.offset_;
-
-    this->validate();
-}
-
-
-template<unsigned nBits>
-inline bool
-Foam::PackedList<nBits>::iteratorBase::valid() const
-{
-    label elemI = offset_ + index_ * packing();
-    return (elemI < list_->size_);
-}
-
-
-template<unsigned nBits>
-inline bool
-Foam::PackedList<nBits>::iteratorBase::validate()
-{
-    // avoid going past end()
-    unsigned endIdx = list_->size_ / packing();
-    unsigned endOff = list_->size_ % packing();
-
-    if (index_ > endIdx || (index_ == endIdx && offset_ > endOff))
-    {
-        index_  = endIdx;
-        offset_ = endOff;
-
-        return false;
-    }
-    else
-    {
-        return true;
-    }
-}
-
-
 template<unsigned nBits>
 inline bool Foam::PackedList<nBits>::iteratorBase::operator==
 (
     const iteratorBase& iter
 ) const
 {
-    return this->index_ == iter.index_ && this->offset_ == iter.offset_;
+    return this->index_ == iter.index_;
 }
 
 
@@ -292,7 +186,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator!=
     const iteratorBase& iter
 ) const
 {
-    return this->index_ != iter.index_ || this->offset_ != iter.offset_;
+    return this->index_ != iter.index_;
 }
 
 
@@ -310,14 +204,11 @@ template<unsigned nBits>
 inline unsigned int
 Foam::PackedList<nBits>::iteratorBase::operator=(const unsigned int val)
 {
-#   ifdef DEBUGList
-    // lazy evaluation would be nice to keep, but really slows things down
-    label minsize = 1 + offset_ + index_ * packing();
-    if (minsize > list_->size_)
+    // lazy evaluation - increase size on assigment
+    if (index_ >= list_->size_)
     {
-        list_->resize(minsize);
+        list_->resize(index_ + 1);
     }
-#endif
 
     this->set(val);
     return val;
@@ -328,14 +219,11 @@ template<unsigned nBits>
 inline Foam::PackedList<nBits>::iteratorBase::operator
 unsigned int () const
 {
-#   ifdef DEBUGList
-    // lazy evaluation would be nice to keep, but really slows things down
-    label minsize = 1 + offset_ + index_ * packing();
-    if (minsize > list_->size_)
+    // lazy evaluation - return 0 for out-of-range
+    if (index_ >= list_->size_)
     {
         return 0;
     }
-#endif
 
     return this->get();
 }
@@ -365,7 +253,12 @@ inline Foam::PackedList<nBits>::iterator::iterator
 :
     iteratorBase(iter)
 {
-    this->validate();
+    // avoid going past end()
+    // eg, iter = iterator(list, Inf)
+    if (this->index_ > this->list_->size_)
+    {
+        this->index_ = this->list_->size_;
+    }
 }
 
 
@@ -377,7 +270,12 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
 :
     iteratorBase(iter)
 {
-    this->validate();
+    // avoid going past end()
+    // eg, iter = iterator(list, Inf)
+    if (this->index_ > this->list_->size_)
+    {
+        this->index_ = this->list_->size_;
+    }
 }
 
 
@@ -417,7 +315,16 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::iterator&
 Foam::PackedList<nBits>::iterator::operator=(const iteratorBase& iter)
 {
-    this->seek(iter);
+    this->list_  = iter.list_;
+    this->index_ = iter.index_;
+
+    // avoid going past end()
+    // eg, iter = iterator(list, Inf)
+    if (this->index_ > this->list_->size_)
+    {
+        this->index_ = this->list_->size_;
+    }
+
     return *this;
 }
 
@@ -426,7 +333,16 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::const_iterator&
 Foam::PackedList<nBits>::const_iterator::operator=(const iteratorBase& iter)
 {
-    this->seek(iter);
+    this->list_  = iter.list_;
+    this->index_ = iter.index_;
+
+    // avoid going past end()
+    // eg, iter = iterator(list, Inf)
+    if (this->index_ > this->list_->size_)
+    {
+        this->index_ = this->list_->size_;
+    }
+
     return *this;
 }
 
@@ -435,7 +351,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::iterator&
 Foam::PackedList<nBits>::iterator::operator++()
 {
-    this->incr();
+    ++this->index_;
     return *this;
 }
 
@@ -444,7 +360,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::const_iterator&
 Foam::PackedList<nBits>::const_iterator::operator++()
 {
-    this->incr();
+    ++this->index_;
     return *this;
 }
 
@@ -454,7 +370,7 @@ inline typename Foam::PackedList<nBits>::iterator
 Foam::PackedList<nBits>::iterator::operator++(int)
 {
     iterator old = *this;
-    this->incr();
+    ++this->index_;
     return old;
 }
 
@@ -464,7 +380,7 @@ inline typename Foam::PackedList<nBits>::const_iterator
 Foam::PackedList<nBits>::const_iterator::operator++(int)
 {
     const_iterator old = *this;
-    this->incr();
+    ++this->index_;
     return old;
 }
 
@@ -473,7 +389,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::iterator&
 Foam::PackedList<nBits>::iterator::operator--()
 {
-    this->decr();
+    --this->index_;
     return *this;
 }
 
@@ -482,7 +398,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::const_iterator&
 Foam::PackedList<nBits>::const_iterator::operator--()
 {
-    this->decr();
+    --this->index_;
     return *this;
 }
 
@@ -492,7 +408,7 @@ inline typename Foam::PackedList<nBits>::iterator
 Foam::PackedList<nBits>::iterator::operator--(int)
 {
     iterator old = *this;
-    this->decr();
+    --this->index_;
     return old;
 }
 
@@ -502,7 +418,7 @@ inline typename Foam::PackedList<nBits>::const_iterator
 Foam::PackedList<nBits>::const_iterator::operator--(int)
 {
     const_iterator old = *this;
-    this->decr();
+    --this->index_;
     return old;
 }
 
@@ -567,7 +483,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::iterator
 Foam::PackedList<nBits>::end()
 {
-    return iterator(this, this->size());
+    return iterator(this, size_);
 }
 
 
@@ -575,7 +491,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::const_iterator
 Foam::PackedList<nBits>::end() const
 {
-    return const_iterator(this, this->size());
+    return const_iterator(this, size_);
 }
 
 
@@ -583,7 +499,7 @@ template<unsigned nBits>
 inline typename Foam::PackedList<nBits>::const_iterator
 Foam::PackedList<nBits>::cend() const
 {
-    return const_iterator(this, this->size());
+    return const_iterator(this, size_);
 }
 
 
@@ -617,20 +533,12 @@ inline void Foam::PackedList<nBits>::resize
         // fill new elements or newly exposed elements
         if (size_)
         {
-            // fill value for complete chunks
+            // fill value for complete segments
             unsigned int fill = val;
 
             if (fill & ~max_value())
             {
-#               ifdef DEBUGList
-                FatalErrorIn("PackedList<T>::resize(label, const unsigned int)")
-                    << "value " << label(val)
-                    << " out-of-range 0 ... " << label(max_value())
-                    << " representable by " << nBits << " bits"
-                    << abort(FatalError);
-#               endif
-
-                // treat overflow as max_value, fill everything
+                // overflow is max_value, fill everything
                 fill = ~0;
             }
             else
@@ -641,26 +549,26 @@ inline void Foam::PackedList<nBits>::resize
                 }
             }
 
-            unsigned begIdx = size_ / packing();
-            unsigned begOff = size_ % packing();
-            unsigned endIdx = nElem / packing();
+            unsigned int seg = size_ / packing();
+            unsigned int off = size_ % packing();
 
-            // partial chunk, preserve existing value
-            if (begOff)
+            // partial segment, preserve existing value
+            if (off)
             {
-                unsigned int maskOld = maskLower(begOff);
+                unsigned int maskOld = maskLower(off);
 
-                StorageList::operator[](begIdx) &= maskOld;
-                StorageList::operator[](begIdx) |= ~maskOld & fill;
+                StorageList::operator[](seg) &= maskOld;
+                StorageList::operator[](seg) |= ~maskOld & fill;
 
-                // continue with the next chunk
-                begIdx++;
+                // continue with the next segment
+                seg++;
             }
 
+            unsigned int endSeg = nElem / packing();
             // fill in complete elements
-            while (begIdx < endIdx)
+            while (seg < endSeg)
             {
-                StorageList::operator[](begIdx++) = fill;
+                StorageList::operator[](seg++) = fill;
             }
         }
         else
@@ -786,17 +694,31 @@ Foam::PackedList<nBits>::xfer()
 template<unsigned nBits>
 inline unsigned int Foam::PackedList<nBits>::get(const label i) const
 {
-#   ifdef DEBUGList
-    checkIndex(i);
+#   ifdef FULLDEBUG
+    if (i < 0)
+    {
+        FatalErrorIn("PackedList<nBits>::get(const label)")
+            << "negative index " << i << " max=" << size_-1
+            << abort(FatalError);
+    }
 #   endif
 
-    return iteratorBase(this, i).get();
+    // lazy evaluation - return 0 for out-of-range
+    if (i < size_)
+    {
+        return iteratorBase(this, i).get();
+    }
+    else
+    {
+        return 0;
+    }
 }
 
 
 template<unsigned nBits>
 inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
 {
+    // lazy evaluation - return 0 for out-of-range
     if (i < size_)
     {
         return iteratorBase(this, i).get();
@@ -815,18 +737,21 @@ inline bool Foam::PackedList<nBits>::set
     const unsigned int val
 )
 {
-#   ifdef DEBUGList
-    checkIndex(i);
-
-    if (val & ~max_value())
+#   ifdef FULLDEBUG
+    if (i < 0)
     {
-        FatalErrorIn("PackedList<T>::set(const label, const unsigned int)")
-            << "value " << label(val)
-            << " out-of-range 0 ... " << label(max_value())
-            << " representable by " << nBits << " bits"
+        FatalErrorIn("PackedList<nBits>::set(const label)")
+            << "negative index " << i << " max=" << size_-1
             << abort(FatalError);
     }
-#   endif
+#endif
+
+    // lazy evaluation - increase size on assigment
+    if (i >= size_)
+    {
+        resize(i + 1);
+    }
+
     return iteratorBase(this, i).set(val);
 }
 
@@ -879,14 +804,6 @@ inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
 
         if (fill & ~max_value())
         {
-#           ifdef DEBUGList
-            FatalErrorIn("PackedList<T>::operator=(const unsigned int)")
-                << "value " << label(val)
-                << " out-of-range 0 ... " << label(max_value())
-                << " representable by " << nBits << " bits"
-                << abort(FatalError);
-#           endif
-
             // treat overflow as max_value
             fill = ~0;
         }
diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
index 5de1345f10d6069e0534f4f9aa0811858590b667..b5167e5ef8977f02334642c9d31f32ed91ac16e3 100644
--- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
+++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
@@ -158,7 +158,7 @@ public:
             //- Return the number of elements in the PtrList
             inline label size() const;
 
-            //- Return true if the PtrList is empty (i.e., if size() == 0).
+            //- Return true if the PtrList is empty (ie, size() is zero).
             inline bool empty() const;
 
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H
index 83c0913a5fee09a44c548ab396a24d512b641314..80bf066e19c7b6e2ba3211712e038ce3f3f4fdd1 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.H
+++ b/src/OpenFOAM/containers/Lists/UList/UList.H
@@ -27,7 +27,7 @@ Class
 
 Description
     A 1D vector of objects of type \<T\>, where the size of the vector is
-    known and used for subscript bounds checking, etc.
+    known and can be used for subscript bounds checking, etc.
 
     Storage is not allocated during construction or use but is supplied to
     the constructor as an argument.  This type of list is particularly useful
@@ -140,6 +140,17 @@ public:
             label byteSize() const;
 
 
+            //- Return a const pointer to the first data element,
+            //  similar to the STL front() method and the string::data() method
+            //  This can be used (with caution) when interfacing with C code.
+            inline const T* cdata() const;
+
+            //- Return a pointer to the first data element,
+            //  similar to the STL front() method and the string::data() method
+            //  This can be used (with caution) when interfacing with C code.
+            inline T* data();
+
+
         // Check
 
             //- Check start is within valid range (0 ... size-1).
@@ -164,10 +175,12 @@ public:
 
     // Member operators
 
-        //- Return subscript-checked element of UList.
+        //- Return element of UList.
         inline T& operator[](const label);
 
-        //- Return subscript-checked element of constant UList.
+        //- Return element of constant UList.
+        //  Note that the bool specialization adds lazy evaluation so reading
+        //  an out-of-range element returns false without any ill-effects
         inline const T& operator[](const label) const;
 
         //- Allow cast to a const List<T>&
@@ -266,7 +279,7 @@ public:
         //- Return size of the largest possible UList.
         inline label max_size() const;
 
-        //- Return true if the UList is empty (i.e., if size() == 0).
+        //- Return true if the UList is empty (ie, size() is zero).
         inline bool empty() const;
 
         //- Swap two ULists of the same type in constant time.
diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H
index 7d8d87006c8420fe6b7f5b79554c2590fee69f19..5c1df4be15c318df142cb195940dd5643b7db0d7 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListI.H
+++ b/src/OpenFOAM/containers/Lists/UList/UListI.H
@@ -25,6 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "error.H"
+#include "pTraits.H"
 #include "Swap.H"
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -64,7 +65,7 @@ inline Foam::label Foam::UList<T>::fcIndex(const label i) const
 template<class T>
 inline Foam::label Foam::UList<T>::rcIndex(const label i) const
 {
-    return (i == 0 ? size()-1 : i-1);
+    return (i ? i-1 : size()-1);
 }
 
 
@@ -113,9 +114,24 @@ inline void Foam::UList<T>::checkIndex(const label i) const
 }
 
 
+template<class T>
+inline const T* Foam::UList<T>::cdata() const
+{
+    return v_;
+}
+
+
+template<class T>
+inline T* Foam::UList<T>::data()
+{
+    return v_;
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-// Return subscript-checked element access
+
+// element access
 template<class T>
 inline T& Foam::UList<T>::operator[](const label i)
 {
@@ -126,7 +142,28 @@ inline T& Foam::UList<T>::operator[](const label i)
 }
 
 
-// Return subscript-checked const element access
+namespace Foam
+{
+
+    // Template specialization for bool
+    template<>
+    inline const bool& Foam::UList<bool>::operator[](const label i) const
+    {
+        // lazy evaluation - return false for out-of-range
+        if (i < size_)
+        {
+            return v_[i];
+        }
+        else
+        {
+            return Foam::pTraits<bool>::zero;
+        }
+    }
+
+} // end of namespace Foam
+
+
+// const element access
 template<class T>
 inline const T& Foam::UList<T>::operator[](const label i) const
 {
@@ -248,7 +285,7 @@ inline Foam::label Foam::UList<T>::max_size() const
 template<class T>
 inline bool Foam::UList<T>::empty() const
 {
-    return (size_ == 0);
+    return !size_;
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
index cfcae367184a3b656c83e7d4d425d4e184e19781..a334e812543688364dbbde8b6754e4fff2542286 100644
--- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
+++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
@@ -124,7 +124,7 @@ public:
             //- Return the number of elements in the UPtrList
             inline label size() const;
 
-            //- Return true if the UPtrList is empty (i.e., if size() == 0).
+            //- Return true if the UPtrList is empty (ie, size() is zero).
             inline bool empty() const;
 
 
diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C
index fc1c023874829c4d397c0933df993f21d014ea24..0a54089b99c56c9411f1d2aa6894bdafb3e5a1ee 100644
--- a/src/OpenFOAM/db/IOobject/IOobject.C
+++ b/src/OpenFOAM/db/IOobject/IOobject.C
@@ -35,6 +35,85 @@ namespace Foam
     defineTypeNameAndDebug(IOobject, 0);
 }
 
+// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
+
+// Return components following the IOobject requirements
+//
+//  behaviour
+//    input               IOobject(instance, local, name)
+//    -----               ------
+//    "foo"               ("", "", "foo")
+//    "foo/bar"           ("foo", "", "bar")
+//    "/XXX"              ERROR - no absolute path
+//    "foo/bar/"          ERROR - no name
+//    "foo/xxx/bar"       ("foo", "xxx", "bar")
+//    "foo/xxx/yyy/bar"   ("foo", "xxx/yyy", "bar")
+bool Foam::IOobject::IOobject::fileNameComponents
+(
+    const fileName& path,
+    fileName& instance,
+    fileName& local,
+    word& name
+)
+{
+    instance.clear();
+    local.clear();
+    name.clear();
+
+    // called with directory
+    if (!isDir(path))
+    {
+        WarningIn("IOobject::fileNameComponents(const fileName&, ...)")
+            << " called with directory: " << path << "\n";
+        return false;
+    }
+
+    string::size_type first = path.find('/');
+
+    if (first == 0)
+    {
+        // called with absolute path
+        WarningIn("IOobject::fileNameComponents(const fileName&, ...)")
+            << "called with absolute path: " << path << "\n";
+        return false;
+    }
+
+    if (first == string::npos)
+    {
+        // no '/' found - no instance or local
+
+        // check afterwards
+        name.string::operator=(path);
+    }
+    else
+    {
+        instance = path.substr(0, first);
+
+        string::size_type last = path.rfind('/');
+        if (last > first)
+        {
+            // with local
+            local = path.substr(first+1, last-first-1);
+        }
+
+        // check afterwards
+        name.string::operator=(path.substr(last+1));
+    }
+
+
+    // check for valid (and stripped) name, regardless of the debug level
+    if (name.empty() || string::stripInvalid<word>(name))
+    {
+        WarningIn("IOobject::fileNameComponents(const fileName&, ...)")
+            << "has invalid word for name: \"" << name
+            << "\"\nwhile processing path: " << path << "\n";
+        return false;
+    }
+
+    return true;
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::IOobject::IOobject
@@ -118,7 +197,15 @@ Foam::IOobject::IOobject
     registerObject_(registerObject),
     objState_(GOOD)
 {
-    path.IOobjectComponents(instance_, local_, name_);
+    if (!fileNameComponents(path, instance_, local_, name_))
+    {
+        FatalErrorIn
+        (
+            "IOobject::IOobject" "(const fileName&, const objectRegistry&, ...)"
+        )
+            << " invalid path specification\n"
+            << exit(FatalError);
+    }
 
     if (objectRegistry::debug)
     {
@@ -182,7 +269,7 @@ Foam::fileName Foam::IOobject::filePath() const
     fileName path = this->path();
     fileName objectPath = path/name();
 
-    if (file(objectPath))
+    if (isFile(objectPath))
     {
         return objectPath;
     }
@@ -201,13 +288,13 @@ Foam::fileName Foam::IOobject::filePath() const
                 rootPath()/caseName()
                /".."/instance()/db_.dbDir()/local()/name();
 
-            if (file(parentObjectPath))
+            if (isFile(parentObjectPath))
             {
                 return parentObjectPath;
             }
         }
 
-        if (!dir(path))
+        if (!isDir(path))
         {
             word newInstancePath = time().findInstancePath(instant(instance()));
 
@@ -219,7 +306,7 @@ Foam::fileName Foam::IOobject::filePath() const
                    /newInstancePath/db_.dbDir()/local()/name()
                 );
 
-                if (file(fName))
+                if (isFile(fName))
                 {
                     return fName;
                 }
@@ -235,7 +322,7 @@ Foam::Istream* Foam::IOobject::objectStream()
 {
     fileName fName = filePath();
 
-    if (fName != fileName::null)
+    if (fName.size())
     {
         IFstream* isPtr = new IFstream(fName);
 
diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H
index 6ee171423a01e5be97f88a731113dc4d8ebeb067..5559a2295a6afb2e860dffd8017c0a78c653bf90 100644
--- a/src/OpenFOAM/db/IOobject/IOobject.H
+++ b/src/OpenFOAM/db/IOobject/IOobject.H
@@ -149,7 +149,6 @@ private:
         //- IOobject state
         objectState objState_;
 
-
 protected:
 
     // Protected member functions
@@ -168,6 +167,18 @@ public:
     TypeName("IOobject");
 
 
+    // Static Member Functions
+
+        //- Split path into instance, local, name components
+        static bool fileNameComponents
+        (
+            const fileName& path,
+            fileName& instance,
+            fileName& local,
+            word& name
+        );
+
+
     // Constructors
 
         //- Construct from name, instance, registry, io options
@@ -194,6 +205,7 @@ public:
         );
 
         //- Construct from path, registry, io options
+        //  Uses fileNameComponents() to split path into components.
         IOobject
         (
             const fileName& path,
@@ -215,7 +227,7 @@ public:
         virtual ~IOobject();
 
 
-    // Member functions
+    // Member Functions
 
         // General access
 
diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.C b/src/OpenFOAM/db/IOobjectList/IOobjectList.C
index 9f923d8fceaea82f8c7288c83ffe7068b61500b0..a55f68a42518df908f7cfd1ec746027b92188e39 100644
--- a/src/OpenFOAM/db/IOobjectList/IOobjectList.C
+++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.C
@@ -48,7 +48,7 @@ Foam::IOobjectList::IOobjectList
 {
     word newInstance = instance;
 
-    if (!dir(db.path(instance)))
+    if (!isDir(db.path(instance)))
     {
         newInstance = db.time().findInstancePath(instant(instance));
 
@@ -59,7 +59,7 @@ Foam::IOobjectList::IOobjectList
     }
 
     // Create list file names in directory
-    fileNameList ObjectNames = 
+    fileNameList ObjectNames =
         readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
 
     forAll(ObjectNames, i)
diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
index b4be5d37fe8f28b001877fd52fad71051ae27878..83951b38711880c0d530479ac030fb78faeb40ea 100644
--- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
+++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
@@ -54,7 +54,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
     ifPtr_ = new ifstream(pathname.c_str());
 
     // If the file is compressed, decompress it before reading.
-    if (!ifPtr_->good() && file(pathname + ".gz"))
+    if (!ifPtr_->good() && isFile(pathname + ".gz", false))
     {
         if (IFstream::debug)
         {
@@ -120,8 +120,8 @@ Foam::IFstream::IFstream
         if (debug)
         {
             Info<< "IFstream::IFstream(const fileName&,"
-                   "streamFormat format=ASCII,"
-                   "versionNumber version=currentVersion) : "
+                   "streamFormat=ASCII,"
+                   "versionNumber=currentVersion) : "
                    "could not open file for input"
                 << endl << info() << endl;
         }
@@ -159,16 +159,17 @@ Foam::IFstream& Foam::IFstream::operator()() const
 {
     if (!good())
     {
-        if (!file(pathname_) && !file(pathname_ + ".gz"))
+        // also checks .gz file
+        if (isFile(pathname_, true))
         {
-            FatalIOErrorIn("IFstream::operator()", *this)
-                << "file " << pathname_ << " does not exist"
-                << exit(FatalIOError);
+            check("IFstream::operator()");
+            FatalIOError.exit();
         }
         else
         {
-            check("IFstream::operator()");
-            FatalIOError.exit();
+            FatalIOErrorIn("IFstream::operator()", *this)
+                << "file " << pathname_ << " does not exist"
+                << exit(FatalIOError);
         }
     }
 
diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C
index bc6c2a03cc3bf085ecfd060bf485e417b1709dbb..f65f0eb636a0081061491e592777256f3789e7b0 100644
--- a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C
+++ b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C
@@ -57,7 +57,8 @@ Foam::OFstreamAllocator::OFstreamAllocator
 
     if (compression == IOstream::COMPRESSED)
     {
-        if (file(pathname))
+        // get identically named uncompressed version out of the way
+        if (isFile(pathname, false))
         {
             rm(pathname);
         }
@@ -66,7 +67,8 @@ Foam::OFstreamAllocator::OFstreamAllocator
     }
     else
     {
-        if (file(pathname + ".gz"))
+        // get identically named compressed version out of the way
+        if (isFile(pathname + ".gz", false))
         {
             rm(pathname + ".gz");
         }
diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H
new file mode 100644
index 0000000000000000000000000000000000000000..00b72fd7bfb8ab31af5b44ba5ae7a8b66aa70919
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H
@@ -0,0 +1,212 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::OSHA1stream
+
+Description
+    An output stream for calculating SHA1 digests.
+
+SourceFiles
+    OSHA1stream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef OSHA1stream_H
+#define OSHA1stream_H
+
+#include "OSstream.H"
+#include "SHA1.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class osha1stream;
+class OSHA1stream;
+
+/*---------------------------------------------------------------------------*\
+                        Class sha1streambuf Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A streambuf class for calculating SHA1 digests
+class sha1streambuf
+:
+    public std::streambuf
+{
+    // Private data
+
+    //- This does all the work and has its own buffering
+    SHA1 sha1_;
+
+    friend class osha1stream;
+
+public:
+
+    // Constructors
+
+        //- Construct null
+        sha1streambuf()
+        {}
+
+    // Member Functions
+
+    // Write
+
+        //- Process unbuffered
+        virtual std::streamsize xsputn(const char* str, std::streamsize n)
+        {
+            sha1_.append(str, n);
+            return n;
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class osha1stream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A basic output stream for calculating SHA1 digests
+class osha1stream
+:
+    virtual public std::ios,
+    public std::ostream
+{
+    // Private data
+
+    sha1streambuf sbuf_;
+
+public:
+
+    // Constructors
+
+        //- Construct null
+        osha1stream()
+        :
+            std::ostream(&sbuf_)
+        {}
+
+    // Member Functions
+
+    // Access
+
+        //- This hides both signatures of std::basic_ios::rdbuf()
+        sha1streambuf* rdbuf()
+        {
+            return &sbuf_;
+        }
+
+        //- Full access to the sha1
+        SHA1& sha1()
+        {
+            return sbuf_.sha1_;
+        }
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class OSHA1stream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- The output stream for calculating SHA1 digests
+class OSHA1stream
+:
+    public OSstream
+{
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        OSHA1stream(const OSHA1stream&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const OSHA1stream&);
+
+public:
+
+    // Constructors
+
+        //- Construct and set stream status
+        OSHA1stream
+        (
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OSstream
+            (
+                *(new osha1stream),
+                "OSHA1stream.sinkFile_",
+                format,
+                version
+            )
+        {}
+
+
+    // Destructor
+
+        ~OSHA1stream()
+        {
+            delete &dynamic_cast<osha1stream&>(stream());
+        }
+
+
+    // Member functions
+
+    // Access
+
+        //- Full access to the sha1
+        Foam::SHA1& sha1()
+        {
+            return dynamic_cast<osha1stream&>(stream()).sha1();
+        }
+
+        //- Return SHA1::Digest for the data processed until now
+        Foam::SHA1Digest digest()
+        {
+            return sha1().digest();
+        }
+
+    // Edit
+
+        //- Clear the SHA1 calculation
+        void rewind()
+        {
+            sha1().clear();
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C
index f20055509e8645ce32c2f0366819556927e6569b..f2096b7968827712150b6d89bdf431ca0d196f9b 100644
--- a/src/OpenFOAM/db/Time/Time.C
+++ b/src/OpenFOAM/db/Time/Time.C
@@ -31,11 +31,7 @@ License
 
 // * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-    defineTypeNameAndDebug(Time, 0);
-}
-
+defineTypeNameAndDebug(Foam::Time, 0);
 
 template<>
 const char* Foam::NamedEnum<Foam::Time::stopAtControls, 4>::names[] =
@@ -100,9 +96,11 @@ void Foam::Time::adjustDeltaT()
 void Foam::Time::setControls()
 {
     // default is to resume calculation from "latestTime"
-    word startFrom("latestTime");
-
-    controlDict_.readIfPresent("startFrom", startFrom);
+    word startFrom = controlDict_.lookupOrDefault<word>
+    (
+        "startFrom",
+        "latestTime"
+    );
 
     if (startFrom == "startTime")
     {
@@ -421,7 +419,7 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
     label nearestIndex = -1;
     scalar deltaT = GREAT;
 
-    for (label i=1; i<times.size(); i++)
+    for (label i=1; i < times.size(); i++)
     {
         scalar diff = mag(times[i].value() - t);
         if (diff < deltaT)
diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H
index 4d3268423de30a2f30dd6cf09c458c22b514bf94..f69f11b581f87ba334c0af3e20b1e3fe2799d938 100644
--- a/src/OpenFOAM/db/Time/Time.H
+++ b/src/OpenFOAM/db/Time/Time.H
@@ -283,7 +283,7 @@ public:
 
             //- Return the location of "dir" containing the file "name".
             //  (Used in reading mesh data)
-            //  If name is null search for a directory "dir"
+            //  If name is null search for the directory "dir" only
             word findInstance
             (
                 const fileName& dir,
diff --git a/src/OpenFOAM/db/Time/findInstance.C b/src/OpenFOAM/db/Time/findInstance.C
index 7b8bddd12029c38396f43e26ee4c3e3545725b25..f21a524c80919f0a395e36b479c8a30390f9ce75 100644
--- a/src/OpenFOAM/db/Time/findInstance.C
+++ b/src/OpenFOAM/db/Time/findInstance.C
@@ -42,78 +42,74 @@ Foam::word Foam::Time::findInstance
     const IOobject::readOption rOpt
 ) const
 {
-    // Is the mesh data in the current time directory ?
+    // Note: if name is empty, just check the directory itself
+
+    // check the current time directory
     if
     (
-        (name.empty() && Foam::dir(path()/timeName()/dir))
-     ||
+        name.empty()
+      ? isDir(path()/timeName()/dir)
+      :
         (
-           !name.empty()
-         && file(path()/timeName()/dir/name)
+            isFile(path()/timeName()/dir/name)
          && IOobject(name, timeName(), dir, *this).headerOk()
         )
     )
     {
         if (debug)
         {
-            Info<< "Time::findInstance(const word&, const word&) : "
-                << "found " << name
-                << " in " << timeName()/dir
+            Info<< "Time::findInstance(const fileName&, const word&) : "
+                << "found \"" << name
+                << "\" in " << timeName()/dir
                 << endl;
         }
 
         return timeName();
     }
 
-    // Search back through the time directories list to find the time
+    // Search back through the time directories to find the time
     // closest to and lower than current time
 
     instantList ts = times();
-    label i;
+    label instanceI;
 
-    for (i=ts.size()-1; i>=0; i--)
+    for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
     {
-        if (ts[i].value() <= timeOutputValue())
+        if (ts[instanceI].value() <= timeOutputValue())
         {
             break;
         }
     }
 
-    // Noting that the current directory has already been searched
-    // for mesh data, start searching from the previously stored time directory
-
-    if (i>=0)
+    // continue searching from here
+    for (; instanceI >= 0; --instanceI)
     {
-        for (label j=i; j>=0; j--)
-        {
-            if
+        if
+        (
+            name.empty()
+          ? isDir(path()/ts[instanceI].name()/dir)
+          :
             (
-                (name.empty() && Foam::dir(path()/ts[j].name()/dir))
-             ||
-                (
-                   !name.empty()
-                 && file(path()/ts[j].name()/dir/name)
-                 && IOobject(name, ts[j].name(), dir, *this).headerOk()
-                )
+                isFile(path()/ts[instanceI].name()/dir/name)
+             && IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
             )
+        )
+        {
+            if (debug)
             {
-                if (debug)
-                {
-                    Info<< "Time::findInstance(const word&, "
-                        << "const word&) : "
-                        << "found " << name
-                        << " in " << ts[j].name()/dir
-                        << endl;
-                }
-
-                return ts[j].name();
+                Info<< "Time::findInstance"
+                    "(const fileName&,const word&) : "
+                    << "found \"" << name
+                    << "\" in " << ts[instanceI].name()/dir
+                    << endl;
             }
+
+            return ts[instanceI].name();
         }
     }
 
 
-    // If the mesh data is not in any of the time directories
-    // Try in constant
+    // not in any of the time directories, try constant
 
     // Note. This needs to be a hard-coded constant, rather than the
     // constant function of the time, because the latter points to
@@ -121,20 +117,21 @@ Foam::word Foam::Time::findInstance
 
     if
     (
-        (name.empty() && Foam::dir(path()/constant()/dir))
-     || (
-            !name.empty()
-         && file(path()/constant()/dir/name)
+        name.empty()
+      ? isDir(path()/constant()/dir)
+      :
+        (
+            isFile(path()/constant()/dir/name)
          && IOobject(name, constant(), dir, *this).headerOk()
         )
     )
     {
         if (debug)
         {
-            Info<< "Time::findInstance(const word&, "
-                << "const word&) : "
-                << "found " << name
-                << " in " << constant()/dir
+            Info<< "Time::findInstance"
+                   "(const fileName&,const word&) : "
+                << "found \"" << name
+                << "\" in " << constant()/dir
                 << endl;
         }
 
@@ -143,7 +140,10 @@ Foam::word Foam::Time::findInstance
 
     if (rOpt == IOobject::MUST_READ)
     {
-        FatalErrorIn("Time::findInstance(const word&, const word&)")
+        FatalErrorIn
+            (
+                "Time::findInstance(const fileName&,const word&)"
+            )
             << "Cannot find file \"" << name << "\" in directory "
             << constant()/dir
             << exit(FatalError);
diff --git a/src/OpenFOAM/db/Time/timeSelector.C b/src/OpenFOAM/db/Time/timeSelector.C
index 8b91422fac4a57d8aab97864f757a55ae3fe3e54..8cd7940ccff7884a15a245fabed7d3a0c0f14e15 100644
--- a/src/OpenFOAM/db/Time/timeSelector.C
+++ b/src/OpenFOAM/db/Time/timeSelector.C
@@ -103,7 +103,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
     const List<instant>& Times
 ) const
 {
-    return subset(selected(Times), true, Times);
+    return subset(selected(Times), Times);
 }
 
 
@@ -112,7 +112,7 @@ void Foam::timeSelector::inplaceSelect
     List<instant>& Times
 ) const
 {
-    inplaceSubset(selected(Times), true, Times);
+    inplaceSubset(selected(Times), Times);
 }
 
 
@@ -219,7 +219,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
             }
         }
 
-        return subset(selectTimes, true, timeDirs);
+        return subset(selectTimes, timeDirs);
     }
     else
     {
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index 8acc6e71ff89e5692286a0d0076d960852abd905..a757caebcc9729ffbe51019c3cc2e3c35abe9543 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -28,6 +28,7 @@ License
 #include "primitiveEntry.H"
 #include "dictionaryEntry.H"
 #include "regExp.H"
+#include "OSHA1stream.H"
 
 /* * * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * */
 
@@ -232,6 +233,25 @@ Foam::label Foam::dictionary::endLineNumber() const
 }
 
 
+Foam::SHA1Digest Foam::dictionary::digest() const
+{
+    OSHA1stream os;
+
+    // process entries
+    for
+    (
+        IDLList<entry>::const_iterator iter = begin();
+        iter != end();
+        ++iter
+    )
+    {
+        os << *iter;
+    }
+
+    return os.digest();
+}
+
+
 bool Foam::dictionary::found(const word& keyword, bool recursive) const
 {
     if (hashedEntries_.found(keyword))
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index 5316f053653781dd85b6fb27f4f42c6bba80df84..68fe20004cfd188790af07316df5625916ae682b 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -69,6 +69,8 @@ namespace Foam
 // Forward declaration of friend functions and operators
 class regExp;
 class dictionary;
+class SHA1Digest;
+
 Istream& operator>>(Istream&, dictionary&);
 Ostream& operator<<(Ostream&, const dictionary&);
 
@@ -210,6 +212,9 @@ public:
         //- Return line number of last token in dictionary
         label endLineNumber() const;
 
+        //- Return the SHA1 digest of the dictionary contents
+        SHA1Digest digest() const;
+
 
         // Search and lookup
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
index 46fd58242e11b425284ae5281baa7e165234b49c..4ed38340530820d2d88a4852c4c1e15e96abbc80 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
@@ -45,7 +45,7 @@ Foam::dictionaryEntry::dictionaryEntry
     is.fatalCheck
     (
         "dictionaryEntry::dictionaryEntry"
-        "(const dictionary& parentDict, Istream& is)"
+        "(const dictionary& parentDict, Istream&)"
     );
 }
 
@@ -65,7 +65,7 @@ Foam::dictionaryEntry::dictionaryEntry
     is.fatalCheck
     (
         "dictionaryEntry::dictionaryEntry"
-        "(const keyType& keyword, const dictionary& parentDict, Istream& is)"
+        "(const keyType&, const dictionary& parentDict, Istream&)"
     );
 }
 
@@ -74,7 +74,9 @@ Foam::dictionaryEntry::dictionaryEntry
 
 void Foam::dictionaryEntry::write(Ostream& os) const
 {
-    os.writeKeyword(keyword());
+    // write keyword with indent but without trailing spaces
+    os.indent();
+    os.write(keyword());
     dictionary::write(os);
 }
 
diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C
index f553589d474211b4eaf07e968236ecdc8a2818c2..6da2cac619c02a35fa3810ec968d0034e3a0e3d8 100644
--- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C
+++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C
@@ -29,14 +29,10 @@ License
 #include "Time.H"
 #include "PstreamReduceOps.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-Istream& regIOobject::readStream()
+Foam::Istream& Foam::regIOobject::readStream()
 {
     if (IFstream::debug)
     {
@@ -48,7 +44,7 @@ Istream& regIOobject::readStream()
 
     if (readOpt() == NO_READ)
     {
-        FatalErrorIn("regIOobject::readStream(const word&)")
+        FatalErrorIn("regIOobject::readStream()")
             << "NO_READ specified for read-constructor of object " << name()
             << " of class " << headerClassName()
             << abort(FatalError);
@@ -61,7 +57,7 @@ Istream& regIOobject::readStream()
         {
             FatalIOError
             (
-                "regIOobject::readStream(const word&)",
+                "regIOobject::readStream()",
                 __FILE__,
                 __LINE__,
                 objectPath(),
@@ -71,7 +67,7 @@ Istream& regIOobject::readStream()
         }
         else if (!readHeader(*isPtr_))
         {
-            FatalIOErrorIn("regIOobject::readStream(const word&)", *isPtr_)
+            FatalIOErrorIn("regIOobject::readStream()", *isPtr_)
                 << "problem while reading header for object " << name()
                 << exit(FatalIOError);
         }
@@ -86,7 +82,7 @@ Istream& regIOobject::readStream()
 }
 
 
-Istream& regIOobject::readStream(const word& aType)
+Foam::Istream& Foam::regIOobject::readStream(const word& expectName)
 {
     if (IFstream::debug)
     {
@@ -106,14 +102,14 @@ Istream& regIOobject::readStream(const word& aType)
         // instantiated is a dictionary
         if
         (
-            aType != word::null
-         && headerClassName() != aType
+            expectName.size()
+         && headerClassName() != expectName
          && headerClassName() != "dictionary"
         )
         {
             FatalIOErrorIn("regIOobject::readStream(const word&)", *isPtr_)
                 << "unexpected class name " << headerClassName()
-                << " expected " << aType << endl
+                << " expected " << expectName << endl
                 << "    while reading object " << name()
                 << exit(FatalIOError);
         }
@@ -123,7 +119,7 @@ Istream& regIOobject::readStream(const word& aType)
 }
 
 
-void regIOobject::close()
+void Foam::regIOobject::close()
 {
     if (IFstream::debug)
     {
@@ -140,13 +136,13 @@ void regIOobject::close()
 }
 
 
-bool regIOobject::readData(Istream&)
+bool Foam::regIOobject::readData(Istream&)
 {
     return false;
 }
 
 
-bool regIOobject::read()
+bool Foam::regIOobject::read()
 {
     bool ok = readData(readStream(type()));
     close();
@@ -154,7 +150,7 @@ bool regIOobject::read()
 }
 
 
-bool regIOobject::modified() const
+bool Foam::regIOobject::modified() const
 {
     return
     (
@@ -164,7 +160,7 @@ bool regIOobject::modified() const
 }
 
 
-bool regIOobject::readIfModified()
+bool Foam::regIOobject::readIfModified()
 {
     if (lastModified_)
     {
@@ -213,8 +209,4 @@ bool regIOobject::readIfModified()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/scalarRange/scalarRanges.C b/src/OpenFOAM/db/scalarRange/scalarRanges.C
index c7c7f4848670ebd8b7a2a421d7ce3bfd847e2207..c59e2b5a9d615e49c05bfa8432e51eaa9261c10d 100644
--- a/src/OpenFOAM/db/scalarRange/scalarRanges.C
+++ b/src/OpenFOAM/db/scalarRange/scalarRanges.C
@@ -123,7 +123,7 @@ Foam::List<Foam::scalar> Foam::scalarRanges::select
     const List<scalar>& values
 ) const
 {
-    return subset(selected(values), true, values);
+    return subset(selected(values), values);
 }
 
 
@@ -132,7 +132,7 @@ void Foam::scalarRanges::inplaceSelect
     List<scalar>& values
 ) const
 {
-    inplaceSubset(selected(values), true, values);
+    inplaceSubset(selected(values), values);
 }
 
 
diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.H b/src/OpenFOAM/dimensionSet/dimensionSet.H
index 50b78f4547c07d5f1ae01f9c4f5e0cde77741efb..e61d3ec4df03d416bec6e57905516119aae3caba 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSet.H
+++ b/src/OpenFOAM/dimensionSet/dimensionSet.H
@@ -123,7 +123,7 @@ public:
         enum dimensionType
         {
             MASS,               // kilogram   kg
-            LENGTH,             // meter      m
+            LENGTH,             // metre      m
             TIME,               // second     s
             TEMPERATURE,        // Kelvin     K
             MOLES,              // mole       mol
diff --git a/src/OpenFOAM/dimensionSet/dimensionSets.C b/src/OpenFOAM/dimensionSet/dimensionSets.C
index dfbb5e7ad57892560fe660b0d895ab1b51de4d16..e89f3c944fc8c82dac5144d781d4ff73be709646 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSets.C
+++ b/src/OpenFOAM/dimensionSet/dimensionSets.C
@@ -44,6 +44,7 @@ const Foam::dimensionSet Foam::dimVol(0, 3, 0, 0, 0, 0, 0);
 
 const Foam::dimensionSet Foam::dimDensity(1, -3, 0, 0, 0, 0, 0);
 const Foam::dimensionSet Foam::dimForce(1, 1, -2, 0, 0, 0, 0);
+const Foam::dimensionSet Foam::dimEnergy(1, 2, -2, 0, 0, 0, 0);
 
 const Foam::dimensionSet Foam::dimVelocity(0, 1, -1, 0, 0, 0, 0);
 const Foam::dimensionSet Foam::dimAcceleration(0, 1, -2, 0, 0, 0, 0);
diff --git a/src/OpenFOAM/dimensionSet/dimensionSets.H b/src/OpenFOAM/dimensionSet/dimensionSets.H
index 7836883ceb57c32f58dc204ded84b50e06fcc742..93d9c1aadcaace278fa89833fa93d56f558306e0 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSets.H
+++ b/src/OpenFOAM/dimensionSet/dimensionSets.H
@@ -60,6 +60,7 @@ extern const dimensionSet dimVol;
 
 extern const dimensionSet dimDensity;
 extern const dimensionSet dimForce;
+extern const dimensionSet dimEnergy;
 
 extern const dimensionSet dimVelocity;
 extern const dimensionSet dimAcceleration;
diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
index 8d9aed1546be5b35aa53644db2e5ade5a909a292..e697ccc20b44d9391f2d47528c4e27866481f6ee 100644
--- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
+++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
@@ -105,7 +105,7 @@ void pointPatchField<Type>::write(Ostream& os) const
 {
     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
 
-    if (patchType_ != word::null)
+    if (patchType_.size())
     {
         os.writeKeyword("patchType") << patchType_
             << token::END_STATEMENT << nl;
diff --git a/src/OpenFOAM/global/JobInfo/JobInfo.C b/src/OpenFOAM/global/JobInfo/JobInfo.C
index f1e802160361c5b4d8a58d1423bba8138557f486..e07b6ab2717d08a1dbc4123f4259174044eac81f 100644
--- a/src/OpenFOAM/global/JobInfo/JobInfo.C
+++ b/src/OpenFOAM/global/JobInfo/JobInfo.C
@@ -65,14 +65,14 @@ Foam::JobInfo::JobInfo()
                 << Foam::exit(FatalError);
         }
 
-        if (!dir(runningDir) && !mkDir(runningDir))
+        if (!isDir(runningDir) && !mkDir(runningDir))
         {
             FatalErrorIn("JobInfo::JobInfo()")
                 << "Cannot make JobInfo directory " << runningDir
                 << Foam::exit(FatalError);
         }
 
-        if (!dir(finishedDir) && !mkDir(finishedDir))
+        if (!isDir(finishedDir) && !mkDir(finishedDir))
         {
             FatalErrorIn("JobInfo::JobInfo()")
                 << "Cannot make JobInfo directory " << finishedDir
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index a237c0256c2d00e80a065fa8d8f89f0003964e31..47d9ce48301eaaf354eb5cc3029d95bfbfd1920b 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -409,7 +409,7 @@ Foam::argList::argList
                     label nProcDirs = 0;
                     while
                     (
-                        dir
+                        isDir
                         (
                             rootPath_/globalCase_/"processor"
                           + name(++nProcDirs)
@@ -624,7 +624,7 @@ void Foam::argList::displayDoc(bool source) const
             docFile = docDirs[dirI]/executable_ + docExts[extI];
             docFile.expand();
 
-            if (exists(docFile))
+            if (isFile(docFile))
             {
                 found = true;
                 break;
@@ -697,7 +697,7 @@ bool Foam::argList::check(bool checkArgs, bool checkOpts) const
 
 bool Foam::argList::checkRootCase() const
 {
-    if (!dir(rootPath()))
+    if (!isDir(rootPath()))
     {
         FatalError
             << executable_
@@ -707,7 +707,7 @@ bool Foam::argList::checkRootCase() const
         return false;
     }
 
-    if (!dir(path()) && Pstream::master())
+    if (!isDir(path()) && Pstream::master())
     {
         // Allow slaves on non-existing processor directories, created later
         FatalError
diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H
index 4594f6eff879fdb2ad699da1acf2673e7d69496e..e4227879a6a55f17fc35c8464885cade7c554f69 100644
--- a/src/OpenFOAM/include/OSspecific.H
+++ b/src/OpenFOAM/include/OSspecific.H
@@ -63,7 +63,7 @@ bool env(const word&);
 
 //- Return environment variable of given name
 //  Return string() if the environment is undefined
-string getEnv(const word& name);
+string getEnv(const word&);
 
 //- Set an environment variable
 bool setEnv(const word& name, const string& value, const bool overwrite);
@@ -103,29 +103,30 @@ bool chDir(const fileName& dir);
 //
 //  @return the full path name or fileName() if the name cannot be found
 //  Optionally abort if the file cannot be found
-fileName findEtcFile(const fileName& name, bool mandatory=false);
+fileName findEtcFile(const fileName&, bool mandatory=false);
 
 //- Make a directory and return an error if it could not be created
 //  and does not already exist
 bool mkDir(const fileName&, mode_t=0777);
 
 //- Set the file mode
-bool chmod(const fileName&, const mode_t);
+bool chMod(const fileName&, const mode_t);
 
 //- Return the file mode
 mode_t mode(const fileName&);
 
-//- Return the file type: FILE or DIRECTORY
+//- Return the file type: DIRECTORY or FILE
 fileName::Type type(const fileName&);
 
-//- Does the name exist in the file system?
-bool exists(const fileName& name);
+//- Does the name exist (as DIRECTORY or FILE) in the file system?
+bool exists(const fileName&);
 
-//- Does the file exist?
-bool file(const fileName&);
+//- Does the name exist as a DIRECTORY in the file system?
+bool isDir(const fileName&);
 
-//- Does the directory exist?
-bool dir(const fileName&);
+//- Does the name exist as a FILE in the file system?
+//  Optionally enable/disable check for gzip file.
+bool isFile(const fileName&, const bool checkGzip=true);
 
 //- Return size of file
 off_t fileSize(const fileName&);
@@ -165,10 +166,10 @@ void fdClose(const int);
 //- Check if machine is up by pinging given port
 bool ping(const word&, const label port, const label timeOut);
 
-//- Check if machine is up by ping port 22 = ssh and 222 = rsh
+//- Check if machine is up by pinging port 22 (ssh) and 222 (rsh)
 bool ping(const word&, const label timeOut=10);
 
-//- Executes a command specified in command
+//- Execute the specified command
 int system(const string& command);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
index 345aed54cc7f4ba7ac00438c0e659297db79fb31..aa6d0d750fe14abf03ddff76ca5ca31d070cd7b3 100644
--- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
+++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
@@ -44,7 +44,7 @@ void Foam::interpolationTable<Type>::readTable()
     // Check that the data are okay
     check();
 
-    if (this->size() == 0)
+    if (this->empty())
     {
         FatalErrorIn
         (
diff --git a/src/OpenFOAM/memory/tmp/refCount.H b/src/OpenFOAM/memory/tmp/refCount.H
index d297997cb43ab5c1da5a845010f4c9b86bf48e83..6af7317cedc4179bf27a4bee3c2d71d6b7d4ad73 100644
--- a/src/OpenFOAM/memory/tmp/refCount.H
+++ b/src/OpenFOAM/memory/tmp/refCount.H
@@ -82,7 +82,7 @@ public:
         //- Return true if the reference count is zero
         bool okToDelete() const
         {
-            return (count_ == 0);
+            return !count_;
         }
 
 
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
index 500798e532a14f9e6683d3292efc353bb308bb1c..57f5eeaf99ab4ffc1a6087a785723d693b48f89f 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
@@ -36,7 +36,7 @@ inline Foam::label Foam::face::right(const label i) const
 // Edge to the left of face vertex i
 inline Foam::label Foam::face::left(const label i) const
 {
-    return i == 0 ? size() - 1 : (i - 1);
+    return i ? i-1 : size()-1;
 }
 
 
diff --git a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C
index abf4b64c7174969e3c7e8543f07ec0b74eb7d2cb..c6ea597721c7f2e28604dc7bbe90ec106ce480b8 100644
--- a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C
+++ b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C
@@ -37,7 +37,7 @@ Foam::patchIdentifier::patchIdentifier
 )
 :
     name_(name),
-    boundaryIndex_(index),
+    index_(index),
     physicalType_(physicalType)
 {}
 
@@ -50,7 +50,7 @@ Foam::patchIdentifier::patchIdentifier
 )
 :
     name_(name),
-    boundaryIndex_(index)
+    index_(index)
 {
     dict.readIfPresent("physicalType", physicalType_);
 }
@@ -63,7 +63,7 @@ Foam::patchIdentifier::patchIdentifier
 )
 :
     name_(p.name_),
-    boundaryIndex_(index),
+    index_(index),
     physicalType_(p.physicalType_)
 {}
 
diff --git a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.H b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.H
index b862dbd0ee5a30c0535c0ccf952ca42103697555..bea45cc2b168d92534f30240fc25712bcdfb3bd5 100644
--- a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.H
+++ b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.H
@@ -64,7 +64,7 @@ class patchIdentifier
         word name_;
 
         //- Index of patch in boundary
-        label boundaryIndex_;
+        label index_;
 
         //- Optional physical type
         mutable word physicalType_;
@@ -86,14 +86,14 @@ public:
         patchIdentifier
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index
         );
 
         //- Construct from geometric patch, resetting the index
         patchIdentifier
         (
-            const patchIdentifier& p,
+            const patchIdentifier&,
             const label index
         );
 
@@ -132,13 +132,13 @@ public:
         //- Return the index of this patch in the boundaryMesh
         label index() const
         {
-            return boundaryIndex_;
+            return index_;
         }
 
         //- Return the index of this patch in the boundaryMesh for modification
         label& index()
         {
-            return boundaryIndex_;
+            return index_;
         }
 
         //- Write patchIdentifier as a dictionary
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.C
index 8ad3e1d95d3200653418c1c8e5f23bb362db9bac..53ac14e268d61931bdb0f335e2485351b0634db6 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.C
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.C
@@ -25,35 +25,28 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "globalPointPatch.H"
-#include "globalMeshData.H"
-#include "triFace.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-defineTypeNameAndDebug(globalPointPatch, 0);
+defineTypeNameAndDebug(Foam::globalPointPatch, 0);
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-globalPointPatch::globalPointPatch
+Foam::globalPointPatch::globalPointPatch
 (
     const pointBoundaryMesh& bm,
-    const label bi
+    const label index
 )
 :
     pointPatch(bm),
     coupledPointPatch(bm),
-    boundaryIndex_(bi)
+    index_(index)
 {}
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-globalPointPatch::~globalPointPatch()
+Foam::globalPointPatch::~globalPointPatch()
 {}
 
 
@@ -62,6 +55,4 @@ globalPointPatch::~globalPointPatch()
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H
index 9701381efbbc3f3fbe8939af6808db2feb775fc2..990ab0de9a45c5356c2a6316c7eaec7c5884bd2b 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/global/globalPointPatch.H
@@ -47,7 +47,7 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-             Class globalPointPatch Declaration
+                      Class globalPointPatch Declaration
 \*---------------------------------------------------------------------------*/
 
 class globalPointPatch
@@ -57,11 +57,11 @@ class globalPointPatch
 {
     // Private data
 
-        ////- Reference to the basic globalMeshData
-        //const globalMeshData& globalMeshData_;
+        // //- Reference to the basic globalMeshData
+        // const globalMeshData& globalMeshData_;
 
         //- Index in the boundary mesh
-        label boundaryIndex_;
+        label index_;
 
 
     // Protected Member Functions
@@ -113,7 +113,7 @@ public:
         //- Construct from components
         globalPointPatch
         (
-            const pointBoundaryMesh& bm,
+            const pointBoundaryMesh&,
             const label index
         );
 
@@ -129,7 +129,7 @@ public:
         virtual const word& name() const
         {
             // There can only be a single patch of this type - therefore
-            // its name is hard-coded.  
+            // its name is hard-coded.
             return type();
         }
 
@@ -161,7 +161,7 @@ public:
         //- Return the index of this patch in the pointBoundaryMesh
         virtual label index() const
         {
-            return boundaryIndex_;
+            return index_;
         }
 
         //- Return mesh points
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
index c3a789e54dc091536f74bc351d7180ae239e7c3f..0428b252d7d173713c13b79510a4d5244e64dd39 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
@@ -1103,7 +1103,7 @@ void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
     rm(meshFilesPath/"parallelData");
 
     // remove subdirectories
-    if (dir(meshFilesPath/"sets"))
+    if (isDir(meshFilesPath/"sets"))
     {
         rmDir(meshFilesPath/"sets");
     }
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
index 8938faf69bcea9d710ed2cb749322802f84b6ad4..e73d1d078d2b41b6ccdf005bcf24823c7ff79774 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
@@ -867,7 +867,7 @@ bool primitiveMesh::checkFaceAngles
         forAll(f, fp0)
         {
             // Get vertex after fp
-            label fp1 = (fp0 + 1) % f.size();
+            label fp1 = f.fcIndex(fp0);
 
             // Normalized vector between two consecutive points
             vector e10(p[f[fp1]] - p[f[fp0]]);
@@ -1636,12 +1636,12 @@ bool primitiveMesh::checkCommonOrder
 
 
                     // Vertices before and after on curFace
-                    label fpPlus1 = (fp+1) % curFace.size();
-                    label fpMin1 = (fp == 0 ? curFace.size()-1 : fp-1);
+                    label fpPlus1 = curFace.fcIndex(fp);
+                    label fpMin1  = curFace.rcIndex(fp);
 
                     // Vertices before and after on nbFace
-                    label nbPlus1 = (nb+1) % nbFace.size();
-                    label nbMin1 = (nb == 0 ? nbFace.size()-1 : nb-1);
+                    label nbPlus1 = nbFace.fcIndex(nb);
+                    label nbMin1  = nbFace.rcIndex(nb);
 
                     // Find order of walking by comparing next points on both
                     // faces.
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
index f49c8beca8baef9edc740b22808a8333bdeccc74..022cf60ab2eda992f268437c557c4497ce6b5bc0 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
@@ -155,20 +155,10 @@ void Foam::walkPatch::faceToFace
 
             indexInFace_.append(fp);
 
-
             // Visit neighbouring faces in order, starting at fp.
             for (label i = 0; i < f.size(); i++)
             {
-                label fp1;
-                if (reverse_)
-                {
-                    fp1 = (fp == 0 ? f.size()-1 : fp-1);
-                }
-                else
-                {
-                    fp1 = (fp + 1) % f.size();
-                }
-
+                label fp1 = reverse_ ? f.rcIndex(fp) : f.fcIndex(fp);
                 label nbr = getNeighbour(faceI, fp, f[fp], f[fp1]);
 
                 if
diff --git a/src/OpenFOAM/primitives/Hash/Hash.H b/src/OpenFOAM/primitives/hashes/Hash/Hash.H
similarity index 100%
rename from src/OpenFOAM/primitives/Hash/Hash.H
rename to src/OpenFOAM/primitives/hashes/Hash/Hash.H
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
new file mode 100644
index 0000000000000000000000000000000000000000..7bf07845e2f87f1200bfb6c3b8380f03e945a2ef
--- /dev/null
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
@@ -0,0 +1,455 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+Description
+    Functions to compute SHA1 message digest of files or memory blocks
+    according to the NIST specification FIPS-180-1.
+
+    Adapted from the gnulib implementation written by Scott G. Miller with
+    credits to Robert Klep <robert@ilse.nl> -- Expansion function fix
+
+    Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free Software
+    Foundation, Inc.
+
+\*---------------------------------------------------------------------------*/
+
+#include "SHA1.H"
+#include "IOstreams.H"
+
+#include <cstring>
+
+#if defined (__GLIBC__)
+#  include <endian.h>
+#endif
+
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+//! @cond fileScope
+//  The bytes used to pad buffer to the next 64-byte boundary.
+//  (RFC 1321, 3.1: Step 1)
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
+//! @endcond fileScope
+
+
+// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
+
+inline uint32_t Foam::SHA1::swapBytes(uint32_t n)
+{
+#ifdef __BYTE_ORDER
+# if (__BYTE_ORDER == __BIG_ENDIAN)
+    return n;
+# else
+    return (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24));
+# endif
+
+#else
+
+    const short x = 0x0100;
+
+    // yields 0x01 for big endian
+    if (*(reinterpret_cast<const char *>(&x)))
+    {
+        return n;
+    }
+    else
+    {
+        return (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24));
+    }
+#endif
+}
+
+
+inline void
+Foam::SHA1::set_uint32(unsigned char *cp, uint32_t v)
+{
+    memcpy(cp, &v, sizeof(uint32_t));
+}
+
+
+// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+
+
+void Foam::SHA1::processBytes(const void *data, size_t len)
+{
+    // already finalized, thus need to restart from nothing
+    if (finalized_)
+    {
+        clear();
+    }
+
+    // complete filling of internal buffer
+    if (bufLen_)
+    {
+        size_t remaining = bufLen_;
+        size_t add =
+        (
+            sizeof(buffer_) - remaining > len
+          ? len
+          : sizeof(buffer_) - remaining
+        );
+
+        unsigned char* bufp = reinterpret_cast<unsigned char*>(buffer_);
+
+        memcpy(&bufp[remaining], data, add);
+        bufLen_ += add;
+
+        if (bufLen_ > 64)
+        {
+            processBlock(buffer_, bufLen_ & ~63);
+
+            bufLen_ &= 63;
+            // The regions in the following copy operation do not (cannot) overlap
+            memcpy(buffer_, &bufp[(remaining + add) & ~63], bufLen_);
+        }
+
+        data = reinterpret_cast<const unsigned char*>(data) + add;
+        len -= add;
+    }
+
+    // Process available complete blocks
+    if (len >= 64)
+    {
+#if !_STRING_ARCH_unaligned
+# define alignof(type) offsetof (struct { char c; type x; }, x)
+# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
+        if (UNALIGNED_P (data))
+        {
+            while (len > 64)
+            {
+                processBlock(memcpy (buffer_, data, 64), 64);
+                data = reinterpret_cast<const unsigned char*>(data) + 64;
+                len -= 64;
+            }
+        }
+        else
+#endif
+        {
+            processBlock(data, len & ~63);
+            data = reinterpret_cast<const unsigned char*>(data) + (len & ~63);
+            len &= 63;
+        }
+    }
+
+    // Move remaining bytes in internal buffer.
+    if (len > 0)
+    {
+        unsigned char* bufp = reinterpret_cast<unsigned char*>(buffer_);
+        size_t remaining = bufLen_;
+
+        memcpy (&bufp[remaining], data, len);
+        remaining += len;
+        if (remaining >= 64)
+        {
+            processBlock(buffer_, 64);
+            remaining -= 64;
+            memcpy (buffer_, &buffer_[16], remaining);
+        }
+        bufLen_ = remaining;
+    }
+}
+
+
+// SHA1 round constants
+#define K1 0x5a827999
+#define K2 0x6ed9eba1
+#define K3 0x8f1bbcdc
+#define K4 0xca62c1d6
+
+// Round functions.  Note that F2 is the same as F4.
+#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
+#define F2(B,C,D) (B ^ C ^ D)
+#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
+#define F4(B,C,D) (B ^ C ^ D)
+
+// Process LEN bytes of BUFFER, it is assumed that LEN % 64 == 0.
+// Most of this code comes from GnuPG's cipher/sha1.c
+
+void
+Foam::SHA1::processBlock(const void *data, size_t len)
+{
+    const uint32_t *words = reinterpret_cast<const uint32_t*>(data);
+    size_t nwords = len / sizeof(uint32_t);
+    const uint32_t *endp = words + nwords;
+
+    // calculate with sixteen words of 32-bits
+    uint32_t x[16];
+    uint32_t a = hashsumA_;
+    uint32_t b = hashsumB_;
+    uint32_t c = hashsumC_;
+    uint32_t d = hashsumD_;
+    uint32_t e = hashsumE_;
+
+    // First increment the byte count.
+    // RFC 1321 specifies the possible length of the file up to 2^64 bits.
+    // Here we only compute the number of bytes.  Do a double word increment.
+    bufTotal_[0] += len;
+    if (bufTotal_[0] < len)
+    {
+        ++bufTotal_[1];
+    }
+
+    // rotate left uint32_t by n bits
+#define rol_uint32(x, nbits)  (((x) << (nbits)) | ((x) >> (32 - (nbits))))
+
+#define M(I) ( tm = x[I & 0x0F] ^ x[(I-14) & 0x0F]                            \
+               ^ x[(I-8) & 0x0F] ^ x[(I-3) & 0x0F]                            \
+               , (x[I & 0x0F] = rol_uint32(tm, 1)) )
+
+
+#define R(A,B,C,D,E,F,K,M)                                                    \
+    do                                                                        \
+    {                                                                         \
+        E += rol_uint32(A, 5) + F(B, C, D) + K + M;                           \
+        B = rol_uint32(B, 30);                                                \
+    } while(0)
+
+    while (words < endp)
+    {
+        uint32_t tm;
+        for (int t = 0; t < 16; t++)
+        {
+            x[t] = swapBytes (*words);
+            words++;
+        }
+
+        R( a, b, c, d, e, F1, K1, x[ 0] );
+        R( e, a, b, c, d, F1, K1, x[ 1] );
+        R( d, e, a, b, c, F1, K1, x[ 2] );
+        R( c, d, e, a, b, F1, K1, x[ 3] );
+        R( b, c, d, e, a, F1, K1, x[ 4] );
+        R( a, b, c, d, e, F1, K1, x[ 5] );
+        R( e, a, b, c, d, F1, K1, x[ 6] );
+        R( d, e, a, b, c, F1, K1, x[ 7] );
+        R( c, d, e, a, b, F1, K1, x[ 8] );
+        R( b, c, d, e, a, F1, K1, x[ 9] );
+        R( a, b, c, d, e, F1, K1, x[10] );
+        R( e, a, b, c, d, F1, K1, x[11] );
+        R( d, e, a, b, c, F1, K1, x[12] );
+        R( c, d, e, a, b, F1, K1, x[13] );
+        R( b, c, d, e, a, F1, K1, x[14] );
+        R( a, b, c, d, e, F1, K1, x[15] );
+        R( e, a, b, c, d, F1, K1, M(16) );
+        R( d, e, a, b, c, F1, K1, M(17) );
+        R( c, d, e, a, b, F1, K1, M(18) );
+        R( b, c, d, e, a, F1, K1, M(19) );
+        R( a, b, c, d, e, F2, K2, M(20) );
+        R( e, a, b, c, d, F2, K2, M(21) );
+        R( d, e, a, b, c, F2, K2, M(22) );
+        R( c, d, e, a, b, F2, K2, M(23) );
+        R( b, c, d, e, a, F2, K2, M(24) );
+        R( a, b, c, d, e, F2, K2, M(25) );
+        R( e, a, b, c, d, F2, K2, M(26) );
+        R( d, e, a, b, c, F2, K2, M(27) );
+        R( c, d, e, a, b, F2, K2, M(28) );
+        R( b, c, d, e, a, F2, K2, M(29) );
+        R( a, b, c, d, e, F2, K2, M(30) );
+        R( e, a, b, c, d, F2, K2, M(31) );
+        R( d, e, a, b, c, F2, K2, M(32) );
+        R( c, d, e, a, b, F2, K2, M(33) );
+        R( b, c, d, e, a, F2, K2, M(34) );
+        R( a, b, c, d, e, F2, K2, M(35) );
+        R( e, a, b, c, d, F2, K2, M(36) );
+        R( d, e, a, b, c, F2, K2, M(37) );
+        R( c, d, e, a, b, F2, K2, M(38) );
+        R( b, c, d, e, a, F2, K2, M(39) );
+        R( a, b, c, d, e, F3, K3, M(40) );
+        R( e, a, b, c, d, F3, K3, M(41) );
+        R( d, e, a, b, c, F3, K3, M(42) );
+        R( c, d, e, a, b, F3, K3, M(43) );
+        R( b, c, d, e, a, F3, K3, M(44) );
+        R( a, b, c, d, e, F3, K3, M(45) );
+        R( e, a, b, c, d, F3, K3, M(46) );
+        R( d, e, a, b, c, F3, K3, M(47) );
+        R( c, d, e, a, b, F3, K3, M(48) );
+        R( b, c, d, e, a, F3, K3, M(49) );
+        R( a, b, c, d, e, F3, K3, M(50) );
+        R( e, a, b, c, d, F3, K3, M(51) );
+        R( d, e, a, b, c, F3, K3, M(52) );
+        R( c, d, e, a, b, F3, K3, M(53) );
+        R( b, c, d, e, a, F3, K3, M(54) );
+        R( a, b, c, d, e, F3, K3, M(55) );
+        R( e, a, b, c, d, F3, K3, M(56) );
+        R( d, e, a, b, c, F3, K3, M(57) );
+        R( c, d, e, a, b, F3, K3, M(58) );
+        R( b, c, d, e, a, F3, K3, M(59) );
+        R( a, b, c, d, e, F4, K4, M(60) );
+        R( e, a, b, c, d, F4, K4, M(61) );
+        R( d, e, a, b, c, F4, K4, M(62) );
+        R( c, d, e, a, b, F4, K4, M(63) );
+        R( b, c, d, e, a, F4, K4, M(64) );
+        R( a, b, c, d, e, F4, K4, M(65) );
+        R( e, a, b, c, d, F4, K4, M(66) );
+        R( d, e, a, b, c, F4, K4, M(67) );
+        R( c, d, e, a, b, F4, K4, M(68) );
+        R( b, c, d, e, a, F4, K4, M(69) );
+        R( a, b, c, d, e, F4, K4, M(70) );
+        R( e, a, b, c, d, F4, K4, M(71) );
+        R( d, e, a, b, c, F4, K4, M(72) );
+        R( c, d, e, a, b, F4, K4, M(73) );
+        R( b, c, d, e, a, F4, K4, M(74) );
+        R( a, b, c, d, e, F4, K4, M(75) );
+        R( e, a, b, c, d, F4, K4, M(76) );
+        R( d, e, a, b, c, F4, K4, M(77) );
+        R( c, d, e, a, b, F4, K4, M(78) );
+        R( b, c, d, e, a, F4, K4, M(79) );
+
+        a = hashsumA_ += a;
+        b = hashsumB_ += b;
+        c = hashsumC_ += c;
+        d = hashsumD_ += d;
+        e = hashsumE_ += e;
+    }
+}
+
+
+void Foam::SHA1::calcDigest(SHA1Digest& dig) const
+{
+    if (bufTotal_[0] || bufTotal_[1])
+    {
+        unsigned char *r = dig.v_;
+
+        set_uint32 (r + 0 * sizeof(uint32_t), swapBytes(hashsumA_));
+        set_uint32 (r + 1 * sizeof(uint32_t), swapBytes(hashsumB_));
+        set_uint32 (r + 2 * sizeof(uint32_t), swapBytes(hashsumC_));
+        set_uint32 (r + 3 * sizeof(uint32_t), swapBytes(hashsumD_));
+        set_uint32 (r + 4 * sizeof(uint32_t), swapBytes(hashsumE_));
+    }
+    else
+    {
+        // no data!
+        dig.clear();
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
+
+
+void Foam::SHA1::clear()
+{
+    hashsumA_ = 0x67452301;
+    hashsumB_ = 0xefcdab89;
+    hashsumC_ = 0x98badcfe;
+    hashsumD_ = 0x10325476;
+    hashsumE_ = 0xc3d2e1f0;
+
+    bufTotal_[0] = bufTotal_[1] = 0;
+    bufLen_ = 0;
+
+    finalized_ = false;
+}
+
+
+bool Foam::SHA1::finalize()
+{
+    if (!finalized_)
+    {
+        finalized_ = true;
+
+        // account for unprocessed bytes
+        uint32_t bytes = bufLen_;
+        size_t size = (bytes < 56 ? 64 : 128) / sizeof(uint32_t);
+
+        // count remaining bytes.
+        bufTotal_[0] += bytes;
+        if (bufTotal_[0] < bytes)
+        {
+            ++bufTotal_[1];
+        }
+
+        // finalized, but no data!
+        if (!bufTotal_[0] && !bufTotal_[1])
+        {
+            return false;
+        }
+
+        // place the 64-bit file length in *bits* at the end of the buffer.
+        buffer_[size-2] = swapBytes((bufTotal_[1] << 3) | (bufTotal_[0] >> 29));
+        buffer_[size-1] = swapBytes(bufTotal_[0] << 3);
+
+        unsigned char* bufp = reinterpret_cast<unsigned char *>(buffer_);
+
+        memcpy(&bufp[bytes], fillbuf, (size-2) * sizeof(uint32_t) - bytes);
+
+        // Process remaining bytes
+        processBlock(buffer_, size * sizeof(uint32_t));
+    }
+
+    return true;
+}
+
+
+Foam::SHA1Digest Foam::SHA1::digest() const
+{
+    SHA1Digest dig;
+
+    if (finalized_)
+    {
+        calcDigest(dig);
+    }
+    else
+    {
+        // avoid disturbing our data - use a copy
+        SHA1 sha(*this);
+        if (sha.finalize())
+        {
+            sha.calcDigest(dig);
+        }
+    }
+
+    return dig;
+}
+
+
+// * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * * //
+
+// void Foam::SHA1::operator=(const SHA1& rhs)
+// {
+//     // Check for assignment to self
+//     if (this == &rhs)
+//     {
+//         FatalErrorIn("Foam::SHA1::operator=(const Foam::SHA1&)")
+//             << "Attempted assignment to self"
+//             << abort(FatalError);
+//     }
+// }
+
+// * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H
new file mode 100644
index 0000000000000000000000000000000000000000..e2be6300a87e6c3943f932f2b1bbab9160bd8fa7
--- /dev/null
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.H
@@ -0,0 +1,185 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::SHA1
+
+Description
+    Functions to compute SHA1 message digest according to the NIST
+    specification FIPS-180-1.
+
+    Adapted from the gnulib implementation.
+
+SeeAlso
+    Foam::SHA1Digest
+
+SourceFiles
+    SHA1I.H
+    SHA1.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef SHA1_H
+#define SHA1_H
+
+#include <string>
+#include <cstddef>
+#include <stdint.h>    // C++0x uses <cstdint>
+
+#include "SHA1Digest.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class Ostream;
+
+// Forward declaration of friend functions and operators
+class SHA1;
+class SHA1Digest;
+Ostream& operator<<(Ostream&, const SHA1&);
+
+
+/*---------------------------------------------------------------------------*\
+                            Class SHA1 Declaration
+\*---------------------------------------------------------------------------*/
+
+class SHA1
+{
+    // Private data
+
+        //- Track if the hashsum has been finalized (added count, etc)
+        bool finalized_;
+
+        //- The hash sums
+        uint32_t hashsumA_;
+        uint32_t hashsumB_;
+        uint32_t hashsumC_;
+        uint32_t hashsumD_;
+        uint32_t hashsumE_;
+
+        //- The total number processed, saved as 64-bit
+        uint32_t bufTotal_[2];
+
+        //- The number of elements pending in the buffer
+        uint32_t bufLen_;
+
+        //- The input processing buffer
+        uint32_t buffer_[32];
+
+    // Private Member Functions
+
+        //- Swap bytes from internal to network (big-endian) order
+        static inline uint32_t swapBytes(uint32_t);
+
+        //- Copy the 4-byte value into the memory location pointed to by *dst.
+        //  If the architecture allows unaligned access this is equivalent to
+        //  *(uint32_t *) cp = val
+        static inline void set_uint32(unsigned char *cp, uint32_t);
+
+        //- Process data block-wise, LEN must be a multiple of 64!
+        void processBlock(const void *data, size_t len);
+
+        //- Process for the next LEN bytes, LEN need not be a multiple of 64.
+        void processBytes(const void *data, size_t len);
+
+        //- Calculate current digest from appended data.
+        void calcDigest(SHA1Digest&) const;
+
+public:
+
+    // Constructors
+
+        //- Construct null
+	inline SHA1();
+
+        //- Construct and append initial std::string
+        explicit inline SHA1(const std::string&);
+
+        //- Construct and append initial string
+        explicit inline SHA1(const char*);
+
+    // Member Functions
+
+	//- Reset the hashed data before appending more
+	void clear();
+
+	//- Append data for processing
+	inline SHA1& append(const char* data, size_t len);
+
+	//- Append string for processing
+        inline SHA1& append(const std::string&);
+
+	//- Append string for processing
+	inline SHA1& append(const char* str);
+
+	//- Finalized the calculations (normally not needed directly).
+        //  Returns false if no bytes were passed for processing
+	bool finalize();
+
+        //- Calculate current digest from appended data.
+	SHA1Digest digest() const;
+
+
+    // Member Operators
+
+        //- Equality operator
+        inline bool operator==(const SHA1Digest&) const;
+
+        //- Inequality operator
+        inline bool operator!=(const SHA1Digest&) const;
+
+        //- Equality operator
+        inline bool operator==(const SHA1&) const;
+
+        //- Inequality operator
+        inline bool operator!=(const SHA1&) const;
+
+        //- Convert to a digest, calculate current digest from appended data.
+        inline operator SHA1Digest() const;
+
+    // Friend Functions
+
+    // Friend Operators
+
+        inline friend Ostream& operator<<(Ostream&, const SHA1&);
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "SHA1I.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
new file mode 100644
index 0000000000000000000000000000000000000000..b9df2d3cefb391a063822a49c6aa4f4fc40909a3
--- /dev/null
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
@@ -0,0 +1,94 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "SHA1Digest.H"
+#include "IOstreams.H"
+
+#include <cstring>
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+//! @cond fileScope
+const char hexChars[] = "0123456789abcdef";
+//! @endcond fileScope
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::SHA1Digest::SHA1Digest()
+{
+    clear();
+}
+
+
+// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
+
+void Foam::SHA1Digest::clear()
+{
+    memset(v_, 0, length);
+}
+
+
+// * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * * //
+
+bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const
+{
+    for (unsigned i = 0; i < length; ++i)
+    {
+        if (v_[i] != rhs.v_[i])
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+
+bool Foam::SHA1Digest::operator!=(const SHA1Digest& rhs) const
+{
+    return !operator==(rhs);
+}
+
+
+// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
+
+Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1Digest& dig)
+{
+    const unsigned char *v = dig.v_;
+
+    for (unsigned i = 0; i < dig.length; ++i)
+    {
+        os.write(hexChars[((v[i] >> 4) & 0xF)]);
+        os.write(hexChars[(v[i] & 0xF)]);
+    }
+
+    os.check("Ostream& operator<<(Ostream&, const SHA1Digest&)");
+    return os;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H
new file mode 100644
index 0000000000000000000000000000000000000000..27c9e8510fcd5c11476341c07bbc91c0833b9f97
--- /dev/null
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H
@@ -0,0 +1,97 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::SHA1Digest
+
+Description
+    The SHA1 message digest.
+
+SeeAlso
+    Foam::SHA1
+
+SourceFiles
+    SHA1Digest.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef SHA1Digest_H
+#define SHA1Digest_H
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class Ostream;
+
+// Forward declaration of friend functions and operators
+class SHA1;
+class SHA1Digest;
+Ostream& operator<<(Ostream&, const SHA1Digest&);
+
+
+/*---------------------------------------------------------------------------*\
+                        Class SHA1Digest Declaration
+\*---------------------------------------------------------------------------*/
+
+class SHA1Digest
+{
+public:
+    friend class SHA1;
+
+    //- The length of the digest contents
+    static const unsigned length = 20;
+
+    //- Construct a zero digest
+    SHA1Digest();
+
+    //- Reset the digest to zero
+    void clear();
+
+    //- Equality operator
+    bool operator==(const SHA1Digest&) const;
+
+    //- Inequality operator
+    bool operator!=(const SHA1Digest&) const;
+
+    friend Ostream& operator<<(Ostream&, const SHA1Digest&);
+
+private:
+
+    //- The digest contents
+    unsigned char v_[length];
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H
new file mode 100644
index 0000000000000000000000000000000000000000..19ab5bedbd95cdd65331946e831673c6671e7cea
--- /dev/null
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1I.H
@@ -0,0 +1,134 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "SHA1.H"
+#include <cstring>
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+inline Foam::SHA1::SHA1()
+{
+    clear();
+}
+
+
+inline Foam::SHA1::SHA1(const std::string& str)
+{
+    clear();
+    append(str);
+}
+
+
+inline Foam::SHA1::SHA1(const char* str)
+{
+    clear();
+    append(str);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline Foam::SHA1& Foam::SHA1::append(const char* data, size_t len)
+{
+    processBytes(data, len);
+    return *this;
+}
+
+
+inline Foam::SHA1& Foam::SHA1::append(const std::string& str)
+{
+    processBytes(str.data(), str.size());
+    return *this;
+}
+
+
+inline Foam::SHA1& Foam::SHA1::append(const char* str)
+{
+    if (str)
+    {
+        processBytes(str, strlen(str));
+    }
+    return *this;
+}
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+inline bool Foam::SHA1::operator==(const SHA1Digest& rhs) const
+{
+    return this->digest() == rhs;
+}
+
+
+inline bool Foam::SHA1::operator!=(const SHA1Digest& rhs) const
+{
+    return this->digest() != rhs;
+}
+
+
+inline bool Foam::SHA1::operator==(const SHA1& rhs) const
+{
+    return digest() == rhs.digest();
+}
+
+
+inline bool Foam::SHA1::operator!=(const SHA1& rhs) const
+{
+    return digest() != rhs.digest();
+}
+
+
+inline Foam::SHA1::operator
+Foam::SHA1Digest () const
+{
+    return digest();
+}
+
+
+// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
+
+inline Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1& sha)
+{
+    return os << sha.digest();
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C
index 3f41e9e692698f4833bd0d946a53ef410a0d3484..c6faa26073643fadf0281c180a1a7e511504cba4 100644
--- a/src/OpenFOAM/primitives/strings/fileName/fileName.C
+++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C
@@ -55,24 +55,6 @@ Foam::fileName::Type Foam::fileName::type() const
 }
 
 
-bool Foam::fileName::exists() const
-{
-    return ::Foam::exists(*this);
-}
-
-
-bool Foam::fileName::isDir() const
-{
-    return ::Foam::dir(*this);
-}
-
-
-bool Foam::fileName::isFile() const
-{
-    return ::Foam::file(*this);
-}
-
-
 //  Return file name (part beyond last /)
 //
 //  behaviour compared to /usr/bin/basename:
@@ -212,94 +194,6 @@ Foam::word Foam::fileName::component
 }
 
 
-
-// Return components following the IOobject requirements
-//
-//  behaviour
-//    input               IOobject(instance, local, name)
-//    -----               ------
-//    "foo"               ("", "", "foo")
-//    "foo/bar"           ("foo", "", "bar")
-//    "/XXX"              ERROR - no absolute path
-//    "foo/bar/"          ERROR - no name
-//    "foo/xxx/bar"       ("foo", "xxx", "bar")
-//    "foo/xxx/yyy/bar"   ("foo", "xxx/yyy", "bar")
-bool Foam::fileName::IOobjectComponents
-(
-    fileName& instance,
-    fileName& local,
-    word& name
-)
-const
-{
-    instance.clear();
-    local.clear();
-    name.clear();
-
-    // called with directory
-    if (::Foam::dir(*this))
-    {
-        std::cerr
-            << "fileName::IOobjectComponents() called with directory: "
-            << this->c_str() << std::endl;
-        std::abort();
-
-        return false;
-    }
-
-    size_type first = find('/');
-
-    if (first == 0)
-    {
-        // called with absolute path
-        std::cerr
-            << "fileName::IOobjectComponents() called with absolute path: "
-            << this->c_str() << std::endl;
-        std::abort();
-
-        return false;
-    }
-
-    if (first == npos)
-    {
-        // no '/' found - no instance or local
-
-        // check afterwards
-        name.string::operator=(*this);
-    }
-    else
-    {
-        instance = substr(0, first);
-
-        size_type last = rfind('/');
-        if (last > first)
-        {
-            // with local
-            local = substr(first+1, last-first-1);
-        }
-
-        // check afterwards
-        name.string::operator=(substr(last+1));
-    }
-
-
-    // check for valid (and stripped) name, regardless of the debug level
-    if (name.empty() || string::stripInvalid<word>(name))
-    {
-        std::cerr
-            << "fileName::IOobjectComponents() has invalid word for name: "
-            << name.c_str() << "\nwhile processing  "
-            << this->c_str() << std::endl;
-        std::abort();
-
-        return false;
-    }
-
-    return true;
-}
-
-
-
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 void Foam::fileName::operator=(const fileName& str)
diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H
index 0eeb89312e19af4cb672e0b39ab772b3d0834c64..ccb2d3caa440ccbb0500f6122c2358d60f9db008 100644
--- a/src/OpenFOAM/primitives/strings/fileName/fileName.H
+++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H
@@ -134,15 +134,6 @@ public:
             //- Return the file type: FILE, DIRECTORY or UNDEFINED
             Type type() const;
 
-            //- Does it exist (as FILE or DIRECTORY) in the file system?
-            bool exists() const;
-
-            //- Does it exist as DIRECTORY in the file system?
-            bool isDir() const;
-
-            //- Does it exist as FILE in the file system?
-            bool isFile() const;
-
         // Decomposition
 
             //- Return file name (part beyond last /)
@@ -163,15 +154,6 @@ public:
             //- Return a single component of the path
             word component(const size_type, const char delimiter='/') const;
 
-            //- Return path as instance, local, name components for IOobject
-            bool IOobjectComponents
-            (
-                fileName& instance,
-                fileName& local,
-                word& name
-            ) const;
-
-
     // Member operators
 
         // Assignment
diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake
index cb2c43e843246ec3b50afc715b2492a8a4228db8..a24dd16a5db6d9e5af462c67d9fd014c668852e9 100755
--- a/src/Pstream/Allwmake
+++ b/src/Pstream/Allwmake
@@ -5,18 +5,18 @@ set -x
 wmake libso dummy
 
 case "$WM_MPLIB" in
-GAMMA)
-    wmake libso gamma
-    ;;
-
 LAM | *MPI* )
-    WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB
     set +x
     echo
     echo "Note: ignore spurious warnings about missing mpicxx.h headers"
     set -x
-    wmake libso mpi
+    (WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB; wmake libso mpi)
     ;;
+
+#GAMMA)
+#    wmake libso gamma
+#    ;;
 esac
 
+
 # ----------------------------------------------------------------- end-of-file
diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C
index 0438fa276d330d60e92368e907f317adc2e59947..5bb4a0ee2d03b8b5a24ec8bbdfb59b2a5ed2c153 100644
--- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C
+++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C
@@ -317,25 +317,18 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
 
             Info<< surfaces().names()[surfI] << ':' << nl << nl;
 
-            //const triSurfaceMesh& s = surfaces()[surfI];
-            //const geometricSurfacePatchList& regions = s.patches();
-            //labelList nTrisPerRegion(surfaces().countRegions(s));
-
             forAll(regNames, i)
             {
-                //if (nTrisPerRegion[i] > 0)
-                //{
-                    label patchI = meshRefinement::addPatch
-                    (
-                        mesh,
-                        regNames[i],
-                        wallPolyPatch::typeName
-                    );
-
-                    Info<< patchI << '\t' << regNames[i] << nl;
-
-                    globalToPatch_[surfaces().globalRegion(surfI, i)] = patchI;
-                //}
+                label patchI = meshRefinement::addPatch
+                (
+                    mesh,
+                    regNames[i],
+                    wallPolyPatch::typeName
+                );
+
+                Info<< patchI << '\t' << regNames[i] << nl;
+
+                globalToPatch_[surfaces().globalRegion(surfI, i)] = patchI;
             }
 
             Info<< nl;
diff --git a/src/decompositionAgglomeration/Allwmake b/src/decompositionAgglomeration/Allwmake
index 144244776fe0ba056d03216495084e4542068531..3294fe48c349607d3862d65dffa0d74af840a46d 100755
--- a/src/decompositionAgglomeration/Allwmake
+++ b/src/decompositionAgglomeration/Allwmake
@@ -6,7 +6,7 @@ wmake libso decompositionMethods
 
 if [ -d "$FOAM_MPI_LIBBIN" ]
 then
-    wmake libso parMetisDecomp
+    (WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB; wmake libso parMetisDecomp)
 fi
 
 wmake libso MGridGenGamgAgglomeration
diff --git a/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C b/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C
index 575a0a0ef4f49298e48632ca267fa91681067168..c44c455c74f1cdc7a2fe56d6660cb60c5842cd7e 100644
--- a/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C
+++ b/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C
@@ -340,8 +340,8 @@ Foam::label Foam::octreeDataFaceList::getSampleType
             // Face intersection point lies on edge between two face triangles
 
             // Calculate edge normal as average of the two triangle normals
-            label fpPrev = (fp == 0 ? f.size()-1 : fp-1);
-            label fpNext = (fp + 1) % f.size();
+            label fpPrev = f.rcIndex(fp);
+            label fpNext = f.fcIndex(fp);
 
             vector e = points[f[fp]] - ctr;
             vector ePrev = points[f[fpPrev]] - ctr;
@@ -434,7 +434,7 @@ bool Foam::octreeDataFaceList::intersects
     // Disable picking up intersections behind us.
     scalar oldTol = intersection::setPlanarTol(0.0);
 
-    pointHit inter = 
+    pointHit inter =
         f.ray
         (
             start,
@@ -486,7 +486,7 @@ bool Foam::octreeDataFaceList::findTightest
     else
     {
         // Construct bb around sample and myFar
-        const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z())); 
+        const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
 
         tightest.min() = sample - dist2;
         tightest.max() = sample + dist2;
@@ -558,7 +558,7 @@ Foam::scalar Foam::octreeDataFaceList::calcNearest
     }
     return nearHit.distance();
 }
-    
+
 
 void Foam::octreeDataFaceList::write
 (
diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
index 7e0e1fbb8d072ddf4fb0d74f672d6133d3d3709f..78bae37eb60efe41258d55495b4265ff2c819e6c 100644
--- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
+++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
@@ -374,7 +374,7 @@ void Foam::cellCuts::calcFaceCuts() const
         label cutI = 0;
 
         // Do point-edge-point walk over face and collect all cuts.
-        // Problem is that we want to start from one of the endpoints of a 
+        // Problem is that we want to start from one of the endpoints of a
         // string of connected cuts; we don't want to start somewhere in the
         // middle.
 
@@ -387,17 +387,16 @@ void Foam::cellCuts::calcFaceCuts() const
 
             if (pointIsCut_[v0])
             {
-                label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
-                label vMin1 = f[fpMin1];
+                label vMin1 = f[f.rcIndex(fp)];
 
-                if 
+                if
                 (
                     !pointIsCut_[vMin1]
                  && !edgeIsCut_[findEdge(faceI, v0, vMin1)]
                 )
                 {
                     cuts[cutI++] = vertToEVert(v0);
-                    startFp = (fp+1) % f.size();
+                    startFp = f.fcIndex(fp);
                     break;
                 }
             }
@@ -408,7 +407,7 @@ void Foam::cellCuts::calcFaceCuts() const
         {
             forAll(f, fp)
             {
-                label fp1 = (fp+1) % f.size();
+                label fp1 = f.fcIndex(fp);
 
                 label v0 = f[fp];
                 label v1 = f[fp1];
@@ -438,7 +437,7 @@ void Foam::cellCuts::calcFaceCuts() const
 
         forAll(f, i)
         {
-            label fp1 = (fp+1) % f.size();
+            label fp1 = f.fcIndex(fp);
 
             // Get the three items: current vertex, next vertex and edge
             // inbetween
@@ -659,7 +658,7 @@ bool Foam::cellCuts::crossEdge
         return true;
     }
     else
-    {    
+    {
         // No success. Restore state (i.e. backtrack)
         nVisited = oldNVisited;
 
@@ -794,7 +793,7 @@ bool Foam::cellCuts::walkFace
 
 
 
-// Walk across cuts (cut edges or cut vertices) of cell. Stops when hit cut 
+// Walk across cuts (cut edges or cut vertices) of cell. Stops when hit cut
 // already visited. Returns true when loop of 3 or more vertices found.
 bool Foam::cellCuts::walkCell
 (
@@ -1202,7 +1201,7 @@ Foam::labelList Foam::cellCuts::nonAnchorPoints
 
         if
         (
-            findIndex(anchorPoints, pointI) == -1 
+            findIndex(anchorPoints, pointI) == -1
          && findIndex(loop, vertToEVert(pointI)) == -1
         )
         {
@@ -1556,7 +1555,7 @@ bool Foam::cellCuts::calcAnchors
                 }
                 prevStat = eStat;
             }
-        }        
+        }
     }
 
 
@@ -2135,7 +2134,7 @@ bool Foam::cellCuts::setFromCellLoop
         // Storage for points on one side of cell
         labelList anchorPoints;
 
-        okLoop = 
+        okLoop =
             validLoop(cellI, loop, loopWeights, faceSplitCuts, anchorPoints);
 
         if (okLoop)
@@ -3007,7 +3006,7 @@ void Foam::cellCuts::flip(const label cellI)
             mesh().cellPoints()[cellI],
             cellAnchorPoints_[cellI],
             loop
-        );  
+        );
 }
 
 
diff --git a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
index 2576ff9867374721913fb4c4651b3c5e74a77840..1cca5d6111e78e5abceeaa4c48d78b29cc358820 100644
--- a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
+++ b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
@@ -53,7 +53,6 @@ namespace Foam
 {
 
 defineTypeNameAndDebug(geomCellLooper, 0);
-
 addToRunTimeSelectionTable(cellLooper, geomCellLooper, word);
 
 }
@@ -187,8 +186,8 @@ bool Foam::geomCellLooper::edgeEndsCut
 
     const edge& e = mesh().edges()[edgeI];
 
-    label prevCut = loop[(index == 0 ? loop.size()-1 : index-1)];
-    label nextCut = loop[(index == loop.size()-1 ? 0 : index+1)];
+    const label prevCut = loop[loop.rcIndex(index)];
+    const label nextCut = loop[loop.fcIndex(index)];
 
     if (!isEdge(prevCut) && !isEdge(nextCut))
     {
@@ -360,7 +359,7 @@ bool Foam::geomCellLooper::cut
                 }
                 else
                 {
-                    // Cut through edge end point. Might be duplicate 
+                    // Cut through edge end point. Might be duplicate
                     // since connected edge might also be snapped to same
                     // endpoint so only insert if unique.
                     label cut = vertToEVert(cutVertI);
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
index 6cbf8ecfc0d3da07da0cd78f7549540081383e22..a8dfe9ffcae5f4094ae254ec0e12382120de8057 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
@@ -76,24 +76,11 @@ bool Foam::meshCutAndRemove::isIn
         return false;
     }
 
-    label nextIndex = (index + 1) % cuts.size();
-
-    if (cuts[nextIndex] == twoCuts[1])
-    {
-        return true;
-    }
-
-
-    label prevIndex = (index == 0 ? cuts.size()-1 : index - 1);
-
-    if (cuts[prevIndex] == twoCuts[1])
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
+    return
+    (
+        cuts[cuts.fcIndex(index)] == twoCuts[1]
+     || cuts[cuts.rcIndex(index)] == twoCuts[1]
+    );
 }
 
 
@@ -502,11 +489,11 @@ Foam::face Foam::meshCutAndRemove::addEdgeCutsToFace(const label faceI) const
 
     forAll(f, fp)
     {
-        // Duplicate face vertex .
+        // Duplicate face vertex.
         newFace[newFp++] = f[fp];
 
         // Check if edge has been cut.
-        label fp1 = (fp + 1) % f.size();
+        label fp1 = f.fcIndex(fp);
 
         HashTable<label, edge, Hash<edge> >::const_iterator fnd =
             addedPoints_.find(edge(f[fp], f[fp1]));
@@ -558,7 +545,7 @@ Foam::face Foam::meshCutAndRemove::loopToFace
 
             newFace[newFaceI++] = vertI;
 
-            label nextCut = loop[(fp+1) % loop.size()];
+            label nextCut = loop[loop.fcIndex(fp)];
 
             if (!isEdge(nextCut))
             {
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
index 6a97db625685b39f31f1c7f7cc6a764e5ec77289..80e18af319a12c1504cda9ec4eaf23842d063f7a 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
@@ -72,24 +72,11 @@ bool Foam::meshCutter::isIn
         return false;
     }
 
-    label nextIndex = (index + 1) % cuts.size();
-
-    if (cuts[nextIndex] == twoCuts[1])
-    {
-        return true;
-    }
-
-
-    label prevIndex = (index == 0 ? cuts.size()-1 : index - 1);
-
-    if (cuts[prevIndex] == twoCuts[1])
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
+    return
+    (
+        cuts[cuts.fcIndex(index)] == twoCuts[1]
+     || cuts[cuts.rcIndex(index)] == twoCuts[1]
+    );
 }
 
 
@@ -459,7 +446,7 @@ Foam::face Foam::meshCutter::addEdgeCutsToFace(const label faceI) const
         newFace[newFp++] = f[fp];
 
         // Check if edge has been cut.
-        label fp1 = (fp + 1) % f.size();
+        label fp1 = f.fcIndex(fp);
 
         HashTable<label, edge, Hash<edge> >::const_iterator fnd =
             addedPoints_.find(edge(f[fp], f[fp1]));
@@ -511,7 +498,7 @@ Foam::face Foam::meshCutter::loopToFace
 
             newFace[newFaceI++] = vertI;
 
-            label nextCut = loop[(fp+1) % loop.size()];
+            label nextCut = loop[loop.fcIndex(fp)];
 
             if (!isEdge(nextCut))
             {
diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
index 851c8cdec422c558924297b59715dc53a0e8efac..f2f7ec17bee2590ad940f864d3823d1307174323 100644
--- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
+++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
@@ -1284,7 +1284,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles
         forAll(f, fp0)
         {
             // Get vertex after fp
-            label fp1 = (fp0 + 1) % f.size();
+            label fp1 = f.fcIndex(fp0);
 
             // Normalized vector between two consecutive points
             vector e10(p[f[fp1]] - p[f[fp0]]);
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
index caa3642f5c9d1d4e78404a565c4d3e2db30fb6fd..e0fae6f9712208aec54fee1a9014d160a518276a 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
@@ -69,7 +69,7 @@ bool Foam::combineFaces::convexFace
     forAll(f, fp0)
     {
         // Get vertex after fp
-        label fp1 = (fp0 + 1) % f.size();
+        label fp1 = f.fcIndex(fp0);
 
         // Normalized vector between two consecutive points
         vector e10(points[f[fp1]] - points[f[fp0]]);
@@ -730,7 +730,7 @@ void Foam::combineFaces::setRefinement
     }
     else
     {
-        // Count removed points 
+        // Count removed points
         label n = 0;
         forAll(nPointFaces, pointI)
         {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C
index 3bb5c345d3d7ec1e2ae83dada361e3376a8e811b..da303ca404ded83cef9d40cf3046dab7d467e2b2 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C
@@ -71,7 +71,7 @@ Foam::label Foam::faceCollapser::findEdge
         label edgeI = edgeLabels[i];
 
         const edge& e = edges[edgeI];
-    
+
         if
         (
             (e[0] == v0 && e[1] == v1)
@@ -113,7 +113,7 @@ void Foam::faceCollapser::filterFace
         newFace.append(v0);
 
         // Look ahead one to get edge.
-        label fp1 = (fp + 1) % f.size();
+        label fp1 = f.fcIndex(fp);
 
         label v1 = f[fp1];
 
@@ -410,7 +410,7 @@ void Foam::faceCollapser::setRefinement
 
         forAll(f, fp)
         {
-            label fp1 = (fp + 1) % f.size();
+            label fp1 = f.fcIndex(fp);
 
             // Get index in sorted list
             label sorted0 = sortedFp[fp];
diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C
index 2ce70cf68d33cfaed265cb36f708f0b2e111f4cc..48de23bfe239d49755f674995ac405fb20409362 100644
--- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C
+++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C
@@ -27,15 +27,55 @@ License
 #include "timeActivatedExplicitSource.H"
 #include "volFields.H"
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+template<>
+const char* Foam::NamedEnum
+<
+    Foam::timeActivatedExplicitSource::volumeType,
+    2
+>::names[] =
+{
+    "specific",
+    "absolute"
+};
+
+const Foam::NamedEnum<Foam::timeActivatedExplicitSource::volumeType, 2>
+Foam::timeActivatedExplicitSource::volumeTypeNames_;
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::timeActivatedExplicitSource::updateCellSet()
+{
+    cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_);
+
+    Info<< "    " << sourceName_ << ": selected "
+        << returnReduce(selectedCellSet_.size(), sumOp<label>())
+        << " cells" << nl << endl;
+
+    V_ = scalarField(selectedCellSet_.size(), 1.0);
+    if (volumeType_ == vtAbsolute)
+    {
+        label i = 0;
+        forAllConstIter(cellSet, selectedCellSet_, iter)
+        {
+            V_[i++] = mesh_.V()[iter.key()];
+        }
+    }
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::timeActivatedExplicitSource::timeActivatedExplicitSource
 (
     const word& sourceName,
-    const fvMesh& mesh
+    const fvMesh& mesh,
+    const dimensionSet& dims
 )
 :
-    dict_
+    IOdictionary
     (
         IOobject
         (
@@ -46,52 +86,36 @@ Foam::timeActivatedExplicitSource::timeActivatedExplicitSource
             IOobject::NO_WRITE
         )
     ),
+    sourceName_(sourceName),
     mesh_(mesh),
     runTime_(mesh.time()),
-    cellSource_(dict_.lookup("cellSource")),
-    timeStart_(dimensionedScalar(dict_.lookup("timeStart")).value()),
-    duration_(dimensionedScalar(dict_.lookup("duration")).value()),
-    onValue_(dict_.lookup("onValue")),
-    offValue_(dict_.lookup("offValue")),
-    currentValue_(dimensionedScalar("zero", onValue_.dimensions(), 0.0)),
+    dimensions_(dims),
+    volumeType_(volumeTypeNames_.read(lookup("volumeType"))),
+    timeStart_(readScalar(lookup("timeStart"))),
+    duration_(readScalar(lookup("duration"))),
+    onValue_(readScalar(lookup("onValue"))),
+    offValue_(readScalar(lookup("offValue"))),
+    currentValue_(0.0),
+    V_(0),
+    cellSource_(lookup("cellSource")),
     cellSelector_
     (
         topoSetSource::New
         (
             cellSource_,
             mesh,
-            dict_.subDict(cellSource_ + "Coeffs")
+            subDict(cellSource_ + "Coeffs")
         )
     ),
     selectedCellSet_
     (
         mesh,
-        "timeActivatedExplicitSourceCellSet",
+        sourceName + "SourceCellSet",
         mesh.nCells()/10 + 1  // Reasonable size estimate.
     )
 {
-    // Check dimensions of on/off values are consistent
-    if (onValue_.dimensions() != offValue_.dimensions())
-    {
-        FatalErrorIn
-        (
-            "Foam::timeActivatedExplicitSource::timeActivatedExplicitSource"
-        )<< "Dimensions of on and off values must be equal" << nl
-         << "onValue = " << onValue_ << nl
-         << "offValue = " << offValue_ << exit(FatalError);
-    }
-
     // Create the cell set
-    cellSelector_->applyToSet
-    (
-        topoSetSource::NEW,
-        selectedCellSet_
-    );
-
-    // Give some feedback
-    Info<< "timeVaryingExplitSource(" << sourceName << ")" << nl
-        << "Selected " << returnReduce(selectedCellSet_.size(), sumOp<label>())
-        << " cells." << endl;
+    updateCellSet();
 
     // Initialise the value
     update();
@@ -112,10 +136,15 @@ Foam::scalar Foam::timeActivatedExplicitSource::duration() const
 }
 
 
-const Foam::dimensionedScalar&
+const Foam::dimensionedScalar
 Foam::timeActivatedExplicitSource::currentValue() const
 {
-    return currentValue_;
+    return dimensionedScalar
+    (
+        sourceName_,
+        dimensions_,
+        currentValue_
+    );
 }
 
 
@@ -128,30 +157,60 @@ Foam::timeActivatedExplicitSource::Su() const
         (
             IOobject
             (
-                "timeActivatedExplicitSource",
+                sourceName_ + "Su",
                 runTime_.timeName(),
                 mesh_,
                 IOobject::NO_READ,
                 IOobject::NO_WRITE
             ),
             mesh_,
-            dimensionedScalar("zero", onValue_.dimensions(), 0.0)
+            dimensionedScalar("zero", dimensions_, 0.0)
         )
     );
 
     DimensionedField<scalar, volMesh>& sourceField = tSource();
 
+    label i = 0;
     forAllConstIter(cellSet, selectedCellSet_, iter)
     {
-        sourceField[iter.key()] = currentValue_.value();
+        sourceField[iter.key()] = currentValue_/V_[i++];
     }
 
     return tSource;
 }
 
 
+bool Foam::timeActivatedExplicitSource::read()
+{
+    if (regIOobject::read())
+    {
+        volumeType_ = volumeTypeNames_.read(lookup("volumeType"));
+        lookup("timeStart") >> duration_;
+        lookup("duration") >> duration_;
+        lookup("onValue") >> onValue_;
+        lookup("offValue") >> offValue_;
+        lookup("cellSource") >> cellSource_;
+        cellSelector_ =
+            topoSetSource::New
+            (
+                cellSource_,
+                mesh_,
+                subDict(cellSource_ + "Coeffs")
+            );
+        updateCellSet();
+
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
 void Foam::timeActivatedExplicitSource::update()
 {
+    // Set the source value
     if
     (
         (runTime_.time().value() >= timeStart_)
@@ -164,6 +223,12 @@ void Foam::timeActivatedExplicitSource::update()
     {
         currentValue_ = offValue_;
     }
+
+    // Update the cell set if the mesh is changing
+    if (mesh_.changing())
+    {
+        updateCellSet();
+    }
 }
 
 
diff --git a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H
index 3085b6ee8a8d65ee378c899c638a9575db319079..f258bc1f7fce14d91ea23891c74604ceb19dd041 100644
--- a/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H
+++ b/src/finiteVolume/cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.H
@@ -23,24 +23,28 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::timeActivatedExplicitSource
+    Foam::timeActivatedExplicitSourceNew
 
 Description
-    Creates a cell set source that is activated at timeStart_ for duration_
+    Creates a cell set source that is activated at a given time, and remains
+    active for a specified duration. The source value is either in specific
+    (XX/m3) or absolute (XX) units.
 
 SourceFiles
-    timeActivatedExplicitSource.C
+    timeActivatedExplicitSourceNew.C
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef timeActivatedExplicitSource_H
 #define timeActivatedExplicitSource_H
 
+#include "IOdictionary.H"
 #include "autoPtr.H"
 #include "topoSetSource.H"
 #include "cellSet.H"
 #include "fvMesh.H"
 #include "Time.H"
+#include "NamedEnum.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -48,15 +52,38 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class timeActivatedExplicitSource Declaration
+                Class timeActivatedExplicitSource Declaration
 \*---------------------------------------------------------------------------*/
 
 class timeActivatedExplicitSource
+:
+    public IOdictionary
 {
-    // Private data
+public:
+
+    enum volumeType
+    {
+        vtSpecific,
+        vtAbsolute
+    };
+
+    static const NamedEnum<volumeType, 2> volumeTypeNames_;
+
+
+private:
+
+    // Private member functions
+
+        //- Update the cell set that the source is acting on
+        void updateCellSet();
+
+
+protected:
 
-        //- Properties dictionary
-        IOdictionary dict_;
+    // Protected data
+
+        //- Name of the source
+        word sourceName_;
 
         //- Reference to the mesh
         const fvMesh& mesh_;
@@ -64,32 +91,47 @@ class timeActivatedExplicitSource
         //- Reference to time database
         const Time& runTime_;
 
-        //- Name of cell source
-        word cellSource_;
 
-        //- Time start [s]
-        scalar timeStart_;
+        // Source properties
+
+            //- Dimensions
+            const dimensionSet dimensions_;
+
+            //- Volume type
+            volumeType volumeType_;
+
+            //- Time start [s]
+            scalar timeStart_;
+
+            //- Duration [s]
+            scalar duration_;
 
-        //- Duration [s]
-        scalar duration_;
+            //- Value when "on"
+            scalar onValue_;
 
-        //- Value when "on"
-        dimensionedScalar onValue_;
+            //- Value when "off"
+            scalar offValue_;
 
-        //- Value when "off"
-        dimensionedScalar offValue_;
+            //- Current source value
+            scalar currentValue_;
 
-        //- Current source value
-        dimensionedScalar currentValue_;
 
-        //- The method by which the cells will be selecetd
-        autoPtr<topoSetSource> cellSelector_;
+        // Cell set
 
-        //- The set of selected cells
-        cellSet selectedCellSet_;
+            //- Cell volumes
+            scalarList V_;
 
+            //- Name of cell source (XXXToCell)
+            word cellSource_;
 
-    // Private Member Functions
+            //- Method by which the cells will be selected
+            autoPtr<topoSetSource> cellSelector_;
+
+            //- Set of selected cells
+            cellSet selectedCellSet_;
+
+
+    // Protected Member Functions
 
         //- Disallow default bitwise copy construct
         timeActivatedExplicitSource(const timeActivatedExplicitSource&);
@@ -103,7 +145,12 @@ public:
     // Constructors
 
         //- Construct from explicit source name and mesh
-        timeActivatedExplicitSource(const word&, const fvMesh&);
+        timeActivatedExplicitSource
+        (
+            const word&,
+            const fvMesh&,
+            const dimensionSet&
+        );
 
 
     // Member Functions
@@ -117,14 +164,17 @@ public:
             scalar duration() const;
 
             //- Return the current value of the source
-            const dimensionedScalar& currentValue() const;
+            const dimensionedScalar currentValue() const;
 
             //- Return a tmp field of the source
-            tmp<DimensionedField<scalar, volMesh> > Su() const;
+            virtual tmp<DimensionedField<scalar, volMesh> > Su() const;
+
 
+        //- Read properties dictionary
+        virtual bool read();
 
         //- Update
-        void update();
+        virtual void update();
 };
 
 
diff --git a/src/finiteVolume/cfdTools/general/findRefCell/findRefCell.C b/src/finiteVolume/cfdTools/general/findRefCell/findRefCell.C
index 3572bcb6d05ee7b797ab22e3b2b14fe9e5426bc2..192688995530847e59e1c2084eae7405dd200b15 100644
--- a/src/finiteVolume/cfdTools/general/findRefCell/findRefCell.C
+++ b/src/finiteVolume/cfdTools/general/findRefCell/findRefCell.C
@@ -52,18 +52,19 @@ void Foam::setRefCell
 
                 if (refCelli < 0 || refCelli >= field.mesh().nCells())
                 {
-                    FatalErrorIn
+                    FatalIOErrorIn
                     (
-                        "void Foam::setRefCell"
-                         "("
-                         "    const volScalarField&,"
-                         "    const dictionary&,"
-                         "    label& scalar&,"
-                         "    bool"
-                         ")"
+                        "void Foam::setRefCell\n"
+                         "(\n"
+                         "    const volScalarField&,\n"
+                         "    const dictionary&,\n"
+                         "    label& scalar&,\n"
+                         "    bool\n"
+                         ")",
+                        dict
                     )   << "Illegal master cellID " << refCelli
                         << ". Should be 0.." << field.mesh().nCells()
-                        << exit(FatalError);
+                        << exit(FatalIOError);
                 }
             }
             else
@@ -79,36 +80,38 @@ void Foam::setRefCell
             label sumHasRef = returnReduce<label>(hasRef, sumOp<label>());
             if (sumHasRef != 1)
             {
-                FatalErrorIn
+                FatalIOErrorIn
                 (
-                    "void Foam::setRefCell"
-                     "("
-                     "    const volScalarField&,"
-                     "    const dictionary&,"
-                     "    label& scalar&,"
-                     "    bool"
-                     ")"
+                    "void Foam::setRefCell\n"
+                     "(\n"
+                     "    const volScalarField&,\n"
+                     "    const dictionary&,\n"
+                     "    label& scalar&,\n"
+                     "    bool\n"
+                     ")",
+                    dict
                 )
                   << "Unable to set reference cell for field " << field.name()
                   << nl << "    Reference point " << refPointName
-                  << " found on multiple domains" << nl << exit(FatalError);
+                  << " found on multiple domains" << nl << exit(FatalIOError);
             }
         }
         else
         {
-            FatalErrorIn
+            FatalIOErrorIn
             (
-                "void Foam::setRefCell"
-                 "("
-                 "    const volScalarField&,"
-                 "    const dictionary&,"
-                 "    label& scalar&,"
-                 "    bool"
-                 ")"
+                "void Foam::setRefCell\n"
+                 "(\n"
+                 "    const volScalarField&,\n"
+                 "    const dictionary&,\n"
+                 "    label& scalar&,\n"
+                 "    bool\n"
+                 ")",
+                dict
             )
               << "Unable to set reference cell for field" << field.name() << nl
               << "    Please supply either " << refCellName
-              << " or " << refPointName << nl << exit(FatalError);
+              << " or " << refPointName << nl << exit(FatalIOError);
         }
 
         refValue = readScalar(dict.lookup(refValueName));
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
index 637cf8037af8bd4fb679032c8cc4e490ef6dac42..3dd71eae5b41f5a1f97a659bcffc8f2154fb7634 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
@@ -236,7 +236,7 @@ void Foam::fvPatchField<Type>::write(Ostream& os) const
 {
     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
 
-    if (patchType_ != word::null)
+    if (patchType_.size())
     {
         os.writeKeyword("patchType") << patchType_
             << token::END_STATEMENT << nl;
diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C
index d9c775a68ba3b93062e2bfb9fc301f3703fc35e4..aebecfefe9e22cf44914f8ff7b5a196a6b8f8207 100644
--- a/src/finiteVolume/fvMesh/fvMesh.C
+++ b/src/finiteVolume/fvMesh/fvMesh.C
@@ -162,7 +162,7 @@ Foam::fvMesh::fvMesh(const IOobject& io)
 
     // Check the existance of the cell volumes and read if present
     // and set the storage of V00
-    if (file(time().timePath()/"V0"))
+    if (isFile(time().timePath()/"V0"))
     {
         V0Ptr_ = new DimensionedField<scalar, volMesh>
         (
@@ -182,7 +182,7 @@ Foam::fvMesh::fvMesh(const IOobject& io)
 
     // Check the existance of the mesh fluxes, read if present and set the
     // mesh to be moving
-    if (file(time().timePath()/"meshPhi"))
+    if (isFile(time().timePath()/"meshPhi"))
     {
         phiPtr_ = new surfaceScalarField
         (
diff --git a/src/meshTools/cellFeatures/cellFeatures.C b/src/meshTools/cellFeatures/cellFeatures.C
index 605624473b5ab3e343a4e86196c287093b6990cf..8d3170dca39c7a620a51b47f3446c06df3551ab6 100644
--- a/src/meshTools/cellFeatures/cellFeatures.C
+++ b/src/meshTools/cellFeatures/cellFeatures.C
@@ -50,7 +50,7 @@ bool Foam::cellFeatures::faceAlignedEdge(const label faceI, const label edgeI)
     {
         if (f[fp] == e.start())
         {
-            label fp1 = (fp + 1) % f.size();
+            label fp1 = f.fcIndex(fp);
 
             return f[fp1] == e.end();
         }
@@ -112,7 +112,7 @@ Foam::label Foam::cellFeatures::nextEdge
         << thisEdgeI << " at vertex " << thisVertI << endl
         << "This might mean that the externalEdges do not form a closed loop"
         << abort(FatalError);
-    
+
     return -1;
 }
 
@@ -146,12 +146,12 @@ bool Foam::cellFeatures::isCellFeatureEdge
     const face& f0 = mesh_.faces()[face0];
 
     label face0Start = findIndex(f0, e.start());
-    label face0End = (face0Start + 1) % f0.size();
+    label face0End   = f0.fcIndex(face0Start);
 
     const face& f1 = mesh_.faces()[face1];
 
     label face1Start = findIndex(f1, e.start());
-    label face1End = (face1Start + 1) % f1.size();
+    label face1End   = f1.fcIndex(face1Start);
 
     if
     (
@@ -268,7 +268,7 @@ void Foam::cellFeatures::calcSuperFaces() const
     {
         faceMap_[superI].shrink();
     }
-        
+
 
     // Construct superFaces
 
diff --git a/src/meshTools/octree/octreeDataFace.C b/src/meshTools/octree/octreeDataFace.C
index c8b9e7943c6e0f088e5fa5113313b2bbb69d6759..d93234f05c9871a8f1af971f102d1385857d336e 100644
--- a/src/meshTools/octree/octreeDataFace.C
+++ b/src/meshTools/octree/octreeDataFace.C
@@ -440,8 +440,8 @@ Foam::label Foam::octreeDataFace::getSampleType
             // Face intersection point lies on edge between two face triangles
 
             // Calculate edge normal as average of the two triangle normals
-            label fpPrev = (fp == 0 ? f.size()-1 : fp-1);
-            label fpNext = (fp + 1) % f.size();
+            const label fpPrev = f.rcIndex(fp);
+            const label fpNext = f.fcIndex(fp);
 
             vector e = points[f[fp]] - mesh_.faceCentres()[faceI];
             vector ePrev = points[f[fpPrev]] - mesh_.faceCentres()[faceI];
@@ -530,7 +530,7 @@ bool Foam::octreeDataFace::overlaps
 
     forAll(f, fp)
     {
-        label fp1 = (fp == f.size()-1 ? 0 : fp+1);
+        const label fp1 = f.fcIndex(fp);
 
         bool triIntersects = triangleFuncs::intersectBb
         (
diff --git a/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C b/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C
index a0a237b8f1ade8d17365374ed978c000396e22e3..0b226e3e0241d100ad05e63f60eb5176831dd039 100644
--- a/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C
+++ b/src/meshTools/primitiveMeshGeometry/primitiveMeshGeometry.C
@@ -808,7 +808,7 @@ bool Foam::primitiveMeshGeometry::checkFaceAngles
         forAll(f, fp0)
         {
             // Get vertex after fp
-            label fp1 = (fp0 + 1) % f.size();
+            label fp1 = f.fcIndex(fp0);
 
             // Normalized vector between two consecutive points
             vector e10(p[f[fp1]] - p[f[fp0]]);
diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C
index ad8ffc5927326f3c68171421bc171755f08fbc0a..7b9abc1aec6664b9efa541cbb128a7a9e27a5528 100644
--- a/src/meshTools/searchableSurface/triSurfaceMesh.C
+++ b/src/meshTools/searchableSurface/triSurfaceMesh.C
@@ -50,7 +50,7 @@ const Foam::fileName& Foam::triSurfaceMesh::checkFile
     const fileName& objectName
 )
 {
-    if (fName == fileName::null)
+    if (fName.empty())
     {
         FatalErrorIn
         (
@@ -562,7 +562,7 @@ bool Foam::triSurfaceMesh::writeObject
 
     triSurface::write(fullPath);
 
-    if (!file(fullPath))
+    if (!isFile(fullPath))
     {
         return false;
     }
diff --git a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C
index ba61f6cb41cc4947eb83cba519e34dad39cc0246..3e007c880e8d80680ba91e338ff0d2ecb1c9aa93 100644
--- a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C
+++ b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C
@@ -241,14 +241,14 @@ void Foam::booleanSurface::propagateEdgeSide
     {
         // Edge (and hence eFaces) in same order as prevVert0.
         // Take next face from sorted list
-        nextInd = (ind + 1) % eFaces.size();
-        prevInd = (ind > 0 ? ind - 1 : eFaces.size()-1);
+        nextInd = eFaces.fcIndex(ind);
+        prevInd = eFaces.rcIndex(ind);
     }
     else
     {
         // Take previous face from sorted neighbours
-        nextInd = (ind > 0 ? ind - 1 : eFaces.size()-1);
-        prevInd = (ind + 1) % eFaces.size();
+        nextInd = eFaces.rcIndex(ind);
+        prevInd = eFaces.fcIndex(ind);
     }
 
 
diff --git a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
index eadfeb7c4b664bc2debb273e897b1c25b0007831..9450865081106b2747a9be30c70e358fc711e147 100644
--- a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
+++ b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
@@ -222,11 +222,11 @@ bool Foam::intersectedSurface::sameEdgeOrder
         {
             // Get prev/next vertex on fA
             label vA1 = fA[(fpA + 1) % 3];
-            label vAMin1 = fA[fpA == 0 ? 2 : fpA-1];
+            label vAMin1 = fA[fpA ? fpA-1 : 2];
 
             // Get prev/next vertex on fB
             label vB1 = fB[(fpB + 1) % 3];
-            label vBMin1 = fB[fpB == 0 ? 2 : fpB-1];
+            label vBMin1 = fB[fpB ? fpB-1 : 2];
 
             if (vA1 == vB1 || vAMin1 == vBMin1)
             {
@@ -1308,14 +1308,14 @@ Foam::intersectedSurface::intersectedSurface
     // Construct mapping back into original surface
     faceMap_.setSize(size());
 
-    for(label faceI = 0; faceI < surf.size()-1; faceI++)
+    for (label faceI = 0; faceI < surf.size()-1; faceI++)
     {
-        for(label triI = startTriI[faceI]; triI < startTriI[faceI+1]; triI++)
+        for (label triI = startTriI[faceI]; triI < startTriI[faceI+1]; triI++)
         {
             faceMap_[triI] = faceI;
         }
     }
-    for(label triI = startTriI[surf.size()-1]; triI < size(); triI++)
+    for (label triI = startTriI[surf.size()-1]; triI < size(); triI++)
     {
         faceMap_[triI] = surf.size()-1;
     }
diff --git a/src/postProcessing/foamCalcFunctions/Make/files b/src/postProcessing/foamCalcFunctions/Make/files
index 4f4a0ccf6ff4906926916c1ef1e7a3c39d737a50..55297ca8c8025e958bb8303612eaa0234b7ceb7c 100644
--- a/src/postProcessing/foamCalcFunctions/Make/files
+++ b/src/postProcessing/foamCalcFunctions/Make/files
@@ -9,6 +9,6 @@ field/div/div.C
 field/randomise/randomise.C
 field/interpolate/interpolate.C
 
-basic/add/add.C
+basic/addSubtract/addSubtract.C
 
 LIB = $(FOAM_LIBBIN)/libfoamCalcFunctions
diff --git a/src/postProcessing/foamCalcFunctions/basic/add/add.C b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C
similarity index 63%
rename from src/postProcessing/foamCalcFunctions/basic/add/add.C
rename to src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C
index 84ec8db834afa52ace5a2506b40727420d7ebf2c..b64f5f8adbbc4a68d2d5f5c114e1ba7662e93700 100644
--- a/src/postProcessing/foamCalcFunctions/basic/add/add.C
+++ b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "add.H"
+#include "addSubtract.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -33,15 +33,15 @@ namespace Foam
 {
     namespace calcTypes
     {
-        defineTypeNameAndDebug(add, 0);
-        addToRunTimeSelectionTable(calcType, add, dictionary);
+        defineTypeNameAndDebug(addSubtract, 0);
+        addToRunTimeSelectionTable(calcType, addSubtract, dictionary);
     }
 }
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-void Foam::calcTypes::add::writeAddFields
+void Foam::calcTypes::addSubtract::writeAddSubtractFields
 (
     const Time& runTime,
     const fvMesh& mesh,
@@ -50,48 +50,48 @@ void Foam::calcTypes::add::writeAddFields
 {
     bool processed = false;
 
-    IOobject addFieldHeader
+    IOobject addSubtractFieldHeader
     (
-        addFieldName_,
+        addSubtractFieldName_,
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ
     );
 
-    if (addFieldHeader.headerOk())
+    if (addSubtractFieldHeader.headerOk())
     {
-        writeAddField<scalar>
+        writeAddSubtractField<scalar>
         (
             baseFieldHeader,
-            addFieldHeader,
+            addSubtractFieldHeader,
             mesh,
             processed
         );
-        writeAddField<vector>
+        writeAddSubtractField<vector>
         (
             baseFieldHeader,
-            addFieldHeader,
+            addSubtractFieldHeader,
             mesh,
             processed
         );
-        writeAddField<sphericalTensor>
+        writeAddSubtractField<sphericalTensor>
         (
             baseFieldHeader,
-            addFieldHeader,
+            addSubtractFieldHeader,
             mesh,
             processed
         );
-        writeAddField<symmTensor>
+        writeAddSubtractField<symmTensor>
         (
             baseFieldHeader,
-            addFieldHeader,
+            addSubtractFieldHeader,
             mesh,
             processed
         );
-        writeAddField<tensor>
+        writeAddSubtractField<tensor>
         (
             baseFieldHeader,
-            addFieldHeader,
+            addSubtractFieldHeader,
             mesh,
             processed
         );
@@ -100,23 +100,23 @@ void Foam::calcTypes::add::writeAddFields
         {
             FatalError
                 << "Unable to process " << baseFieldName_
-                << " + " << addFieldName_ << nl
-                << "No call to add for fields of type "
+                << " + " << addSubtractFieldName_ << nl
+                << "No call to addSubtract for fields of type "
                 << baseFieldHeader.headerClassName() << " + "
-                << addFieldHeader.headerClassName() << nl << nl
+                << addSubtractFieldHeader.headerClassName() << nl << nl
                 << exit(FatalError);
         }
     }
     else
     {
-        FatalErrorIn("calcTypes::add::writeAddFields()")
-            << "Unable to read add field: " << addFieldName_
+        FatalErrorIn("calcTypes::addSubtract::writeAddSubtractFields()")
+            << "Unable to read addSubtract field: " << addSubtractFieldName_
             << nl << exit(FatalError);
     }
 }
 
 
-void Foam::calcTypes::add::writeAddValues
+void Foam::calcTypes::addSubtract::writeAddSubtractValues
 (
     const Time& runTime,
     const fvMesh& mesh,
@@ -125,48 +125,48 @@ void Foam::calcTypes::add::writeAddValues
 {
     bool processed = false;
 
-    writeAddValue<scalar>
+    writeAddSubtractValue<scalar>
     (
         baseFieldHeader,
-        addValueStr_,
+        addSubtractValueStr_,
         mesh,
         processed
     );
-    writeAddValue<vector>
+    writeAddSubtractValue<vector>
     (
         baseFieldHeader,
-        addValueStr_,
+        addSubtractValueStr_,
         mesh,
         processed
     );
-    writeAddValue<sphericalTensor>
+    writeAddSubtractValue<sphericalTensor>
     (
         baseFieldHeader,
-        addValueStr_,
+        addSubtractValueStr_,
         mesh,
         processed
     );
-    writeAddValue<symmTensor>
+    writeAddSubtractValue<symmTensor>
     (
         baseFieldHeader,
-        addValueStr_,
+        addSubtractValueStr_,
         mesh,
         processed
     );
-    writeAddValue<tensor>
+    writeAddSubtractValue<tensor>
     (
         baseFieldHeader,
-        addValueStr_,
+        addSubtractValueStr_,
         mesh,
         processed
     );
 
     if (!processed)
     {
-        FatalErrorIn("calcTypes::add::writeAddValues()")
+        FatalErrorIn("calcTypes::addSubtract::writeAddSubtractValue()")
             << "Unable to process " << baseFieldName_
-            << " + " << addValueStr_ << nl
-            << "No call to add for fields of type "
+            << " + " << addSubtractValueStr_ << nl
+            << "No call to addSubtract for fields of type "
             << baseFieldHeader.headerClassName() << nl << nl
             << exit(FatalError);
     }
@@ -175,36 +175,38 @@ void Foam::calcTypes::add::writeAddValues
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::calcTypes::add::add()
+Foam::calcTypes::addSubtract::addSubtract()
 :
     calcType(),
     baseFieldName_(""),
     calcType_(FIELD),
-    addFieldName_(""),
-    addValueStr_(""),
-    resultName_("")
+    addSubtractFieldName_(""),
+    addSubtractValueStr_(""),
+    resultName_(""),
+    calcMode_(ADD)
 {}
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-Foam::calcTypes::add::~add()
+Foam::calcTypes::addSubtract::~addSubtract()
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void Foam::calcTypes::add::init()
+void Foam::calcTypes::addSubtract::init()
 {
     argList::validArgs.append("add");
     argList::validArgs.append("baseField");
+    argList::validArgs.append("calcMode");
     argList::validOptions.insert("field", "fieldName");
     argList::validOptions.insert("value", "valueString");
     argList::validOptions.insert("resultName", "fieldName");
 }
 
 
-void Foam::calcTypes::add::preCalc
+void Foam::calcTypes::addSubtract::preCalc
 (
     const argList& args,
     const Time& runTime,
@@ -212,21 +214,38 @@ void Foam::calcTypes::add::preCalc
 )
 {
     baseFieldName_ = args.additionalArgs()[1];
+    word calcModeName = args.additionalArgs()[2];
+
+    if (calcModeName == "add")
+    {
+        calcMode_ = ADD;
+    }
+    else if (calcModeName == "subtract")
+    {
+        calcMode_ = SUBTRACT;
+    }
+    else
+    {
+        FatalErrorIn("calcTypes::addSubtract::preCalc")
+            << "Invalid calcMode: " << calcModeName << nl
+            << "    Valid calcModes are add and subtract" << nl
+            << exit(FatalError);
+    }
 
     if (args.options().found("field"))
     {
-        addFieldName_ = args.options()["field"];
+        addSubtractFieldName_ = args.options()["field"];
         calcType_ = FIELD;
     }
     else if (args.options().found("value"))
     {
-        addValueStr_ = args.options()["value"];
+        addSubtractValueStr_ = args.options()["value"];
         calcType_ = VALUE;
     }
     else
     {
-        FatalErrorIn("calcTypes::add::preCalc")
-            << "add requires either -field or -value option"
+        FatalErrorIn("calcTypes::addSubtract::preCalc")
+            << "addSubtract requires either -field or -value option"
             << nl << exit(FatalError);
     }
 
@@ -237,7 +256,7 @@ void Foam::calcTypes::add::preCalc
 }
 
 
-void Foam::calcTypes::add::calc
+void Foam::calcTypes::addSubtract::calc
 (
     const argList& args,
     const Time& runTime,
@@ -258,17 +277,17 @@ void Foam::calcTypes::add::calc
         {
             case FIELD:
             {
-                writeAddFields(runTime, mesh, baseFieldHeader);
+                writeAddSubtractFields(runTime, mesh, baseFieldHeader);
                 break;
             }
             case VALUE:
             {
-                writeAddValues(runTime, mesh, baseFieldHeader);
+                writeAddSubtractValues(runTime, mesh, baseFieldHeader);
                 break;
             }
             default:
             {
-                FatalErrorIn("calcTypes::add::calc")
+                FatalErrorIn("calcTypes::addSubtract::calc")
                     << "unknown calcType " << calcType_ << nl
                     << abort(FatalError);
             }
@@ -276,7 +295,7 @@ void Foam::calcTypes::add::calc
     }
     else
     {
-        FatalErrorIn("calcTypes::add::calc")
+        FatalErrorIn("calcTypes::addSubtract::calc")
             << "Unable to read base field: " << baseFieldName_
             << nl << exit(FatalError);
     }
diff --git a/src/postProcessing/foamCalcFunctions/basic/add/add.H b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.H
similarity index 71%
rename from src/postProcessing/foamCalcFunctions/basic/add/add.H
rename to src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.H
index f365ca50d4ef490c4f65c0170b22f8a862a8cba8..bc04b45b7c13d2daa2012d9346c256f4e0f10e3e 100644
--- a/src/postProcessing/foamCalcFunctions/basic/add/add.H
+++ b/src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.H
@@ -23,28 +23,30 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::calcTypes::add
+    Foam::calcTypes::addSubtract
 
 Description
-    Adds and field or value to base field.
+    adds/subtracts a field or value to/from a base field.
 
     New field name specified by -resultName option, or automatically as:
-        <baseFieldName>_plus_<addFieldName>
-        <baseFieldName>_plus_value
+        <baseFieldName>_add_<addSubtractFieldName>
+        <baseFieldName>_add_value
+        <baseFieldName>_subtract_<addSubtractFieldName>
+        <baseFieldName>_subtract_value
 
     Example usage:
-        add p -value 100000 -resultName pAbs
-        add U -field U0
+        addSubtract p add -value 100000 -resultName pAbs
+        addSubtract U subtract -field U0
 
 SourceFiles
-    add.C
-    writeAddField.C
-    writeAddValue.C
+    addSubtract.C
+    writeaddSubtractField.C
+    writeaddSubtractValue.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef add_H
-#define add_H
+#ifndef addSubtract_H
+#define addSubtract_H
 
 #include "calcType.H"
 
@@ -57,10 +59,10 @@ namespace calcTypes
 {
 
 /*---------------------------------------------------------------------------*\
-                          Class add Declaration
+                          Class addSubtract Declaration
 \*---------------------------------------------------------------------------*/
 
-class add
+class addSubtract
 :
     public calcType
 {
@@ -72,41 +74,50 @@ public:
         VALUE
     };
 
+    enum calcModes
+    {
+        ADD,
+        SUBTRACT
+    };
+
 
 private:
 
     // Private data
 
-        //- Name of base field (to add to)
+        //- Name of base field (to addSubtract to)
         word baseFieldName_;
 
         //- Calc type as given by enumerations above
         calcTypes calcType_;
 
-        //- Name of field to add
-        word addFieldName_;
+        //- Name of field to add/subtract
+        word addSubtractFieldName_;
 
-        //- String representation of value to add
-        string addValueStr_;
+        //- String representation of value to add/subtract
+        string addSubtractValueStr_;
 
         //- Name of result field
         word resultName_;
 
+        //- Mode - addSubtract/subtract
+        calcModes calcMode_;
+
 
     // Private Member Functions
 
         // Output
 
-            //- Calc and output field additions
-            void writeAddFields
+            //- Calc and output field addSubtractitions
+            void writeAddSubtractFields
             (
                 const Time& runTime,
                 const fvMesh& mesh,
                 const IOobject& baseFieldHeader
             );
 
-            //- Calc and output field and value additions
-            void writeAddValues
+            //- Calc and output field and value addSubtractitions
+            void writeAddSubtractValues
             (
                 const Time& runTime,
                 const fvMesh& mesh,
@@ -115,10 +126,10 @@ private:
 
 
         //- Disallow default bitwise copy construct
-        add(const add&);
+        addSubtract(const addSubtract&);
 
         //- Disallow default bitwise assignment
-        void operator=(const add&);
+        void operator=(const addSubtract&);
 
 
 protected:
@@ -150,19 +161,19 @@ protected:
 
         // I-O
 
-            //- Write add field
+            //- Write addSubtract field
             template<class Type>
-            void writeAddField
+            void writeAddSubtractField
             (
                 const IOobject& baseHeader,
-                const IOobject& addHeader,
+                const IOobject& addSubtractHeader,
                 const fvMesh& mesh,
                 bool& processed
             );
 
-            //- Write add value
+            //- Write addSubtract value
             template<class Type>
-            void writeAddValue
+            void writeAddSubtractValue
             (
                 const IOobject& baseHeader,
                 const string& valueStr,
@@ -174,18 +185,18 @@ protected:
 public:
 
     //- Runtime type information
-    TypeName("add");
+    TypeName("addSubtract");
 
 
     // Constructors
 
         //- Construct null
-        add();
+        addSubtract();
 
 
     // Destructor
 
-        virtual ~add();
+        virtual ~addSubtract();
 };
 
 
@@ -197,8 +208,8 @@ public:
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 #ifdef NoRepository
-#   include "writeAddField.C"
-#   include "writeAddValue.C"
+#   include "writeAddSubtractField.C"
+#   include "writeAddSubtractValue.C"
 #endif
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/postProcessing/foamCalcFunctions/basic/add/writeAddField.C b/src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractField.C
similarity index 84%
rename from src/postProcessing/foamCalcFunctions/basic/add/writeAddField.C
rename to src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractField.C
index 3701a0d429f591b7159b2cc6f0dee42fe3b1e871..79cd9a7cf81cacba17902687acb634fa5656f61d 100644
--- a/src/postProcessing/foamCalcFunctions/basic/add/writeAddField.C
+++ b/src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractField.C
@@ -25,7 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 template<class Type>
-void Foam::calcTypes::add::writeAddField
+void Foam::calcTypes::addSubtract::writeAddSubtractField
 (
     const IOobject& baseHeader,
     const IOobject& addHeader,
@@ -33,11 +33,6 @@ void Foam::calcTypes::add::writeAddField
     bool& processed
 )
 {
-    if (resultName_ == "")
-    {
-        resultName_ = baseHeader.name() + "_plus_" + addHeader.name();
-    }
-
     typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
 
     if
@@ -46,6 +41,19 @@ void Foam::calcTypes::add::writeAddField
      && baseHeader.headerClassName() == addHeader.headerClassName()
     )
     {
+        if (resultName_ == "")
+        {
+            if (calcMode_ == ADD)
+            {
+                resultName_ = baseHeader.name() + "_add_" + addHeader.name();
+            }
+            else
+            {
+                resultName_ = baseHeader.name() + "_subtract_"
+                    + addHeader.name();
+            }
+        }
+
         Info<< "    Reading " << baseHeader.name() << endl;
         fieldType baseField(baseHeader, mesh);
 
@@ -65,7 +73,7 @@ void Foam::calcTypes::add::writeAddField
                     mesh,
                     IOobject::NO_READ
                 ),
-                baseField + addField
+                calcMode_ == ADD ? baseField + addField : baseField - addField
             );
             newField.write();
         }
diff --git a/src/postProcessing/foamCalcFunctions/basic/add/writeAddValue.C b/src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractValue.C
similarity index 76%
rename from src/postProcessing/foamCalcFunctions/basic/add/writeAddValue.C
rename to src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractValue.C
index 3a5abaf188c5b6812e3bd6250da0e39877333954..2f8872b54a853908196d269db5aafa210bce8e26 100644
--- a/src/postProcessing/foamCalcFunctions/basic/add/writeAddValue.C
+++ b/src/postProcessing/foamCalcFunctions/basic/addSubtract/writeAddSubtractValue.C
@@ -25,7 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 template<class Type>
-void Foam::calcTypes::add::writeAddValue
+void Foam::calcTypes::addSubtract::writeAddSubtractValue
 (
     const IOobject& baseHeader,
     const string& valueStr,
@@ -39,14 +39,21 @@ void Foam::calcTypes::add::writeAddValue
     {
         if (resultName_ == "")
         {
-            resultName_ = baseHeader.name() + "_plus_value";
+            if (calcMode_ == ADD)
+            {
+                resultName_ = baseHeader.name() + "_add_value";
+            }
+            else
+            {
+                resultName_ = baseHeader.name() + "_subtract_value";
+            }
         }
 
         Type value;
         IStringStream(valueStr)() >> value;
 
         Info<< "    Reading " << baseHeader.name() << endl;
-            fieldType baseField(baseHeader, mesh);
+        fieldType baseField(baseHeader, mesh);
 
         fieldType newField
         (
@@ -61,8 +68,17 @@ void Foam::calcTypes::add::writeAddValue
         );
 
         Info<< "    Calculating " << resultName_ << endl;
-        newField == baseField
-            + dimensioned<Type>("value", baseField.dimensions(), value);
+        if (calcMode_ == ADD)
+        {
+            newField == baseField
+                + dimensioned<Type>("value", baseField.dimensions(), value);
+        }
+        else
+        {
+            newField == baseField
+                - dimensioned<Type>("value", baseField.dimensions(), value);
+        }
+
         newField.write();
 
         processed = true;
diff --git a/src/postProcessing/foamCalcFunctions/field/components/components.C b/src/postProcessing/foamCalcFunctions/field/components/components.C
index 8b5c54e8bfcaac1ad13cd7e85f568beb059903fd..35254bbca26c5d8befc4eb48a15a7163eb1dacd5 100644
--- a/src/postProcessing/foamCalcFunctions/field/components/components.C
+++ b/src/postProcessing/foamCalcFunctions/field/components/components.C
@@ -57,8 +57,8 @@ Foam::calcTypes::components::~components()
 
 void Foam::calcTypes::components::init()
 {
-    Foam::argList::validArgs.append("components");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("components");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::components::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::components::calc
@@ -85,49 +78,39 @@ void Foam::calcTypes::components::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeComponentFields<vector>(fieldHeader, mesh, processed);
-            writeComponentFields<sphericalTensor>
-            (
-                fieldHeader,
-                mesh,
-                processed
-            );
-            writeComponentFields<symmTensor>(fieldHeader, mesh, processed);
-            writeComponentFields<tensor>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                FatalError
-                    << "Unable to process " << fieldName << nl
-                    << "No call to components for fields of type "
-                    << fieldHeader.headerClassName() << nl << nl
-                    << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeComponentFields<vector>(fieldHeader, mesh, processed);
+        writeComponentFields<sphericalTensor>(fieldHeader, mesh, processed);
+        writeComponentFields<symmTensor>(fieldHeader, mesh, processed);
+        writeComponentFields<tensor>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to components for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+                << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/postProcessing/foamCalcFunctions/field/div/div.C b/src/postProcessing/foamCalcFunctions/field/div/div.C
index e99182f061f53b81a2889e24d65beea1e7bb1a9a..0b1492dc39aacda9e7635f9f8d8f95c14737a48b 100644
--- a/src/postProcessing/foamCalcFunctions/field/div/div.C
+++ b/src/postProcessing/foamCalcFunctions/field/div/div.C
@@ -57,8 +57,8 @@ Foam::calcTypes::div::~div()
 
 void Foam::calcTypes::div::init()
 {
-    Foam::argList::validArgs.append("div");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("div");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::div::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::div::calc
@@ -85,42 +78,37 @@ void Foam::calcTypes::div::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeDivField<surfaceScalarField>(fieldHeader, mesh, processed);
-            writeDivField<volVectorField>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                 FatalError
-                     << "Unable to process " << fieldName << nl
-                     << "No call to div for fields of type "
-                     << fieldHeader.headerClassName() << nl << nl
-                     << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeDivField<surfaceScalarField>(fieldHeader, mesh, processed);
+        writeDivField<volVectorField>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+                FatalError
+                    << "Unable to process " << fieldName << nl
+                    << "No call to div for fields of type "
+                    << fieldHeader.headerClassName() << nl << nl
+                    << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/postProcessing/foamCalcFunctions/field/interpolate/interpolate.C b/src/postProcessing/foamCalcFunctions/field/interpolate/interpolate.C
index d9126c6c03910f9acf2efa1c3cc032c42a8c321e..aa319343ae2792c4dfffff9a5f96f16f8ef375a0 100644
--- a/src/postProcessing/foamCalcFunctions/field/interpolate/interpolate.C
+++ b/src/postProcessing/foamCalcFunctions/field/interpolate/interpolate.C
@@ -58,7 +58,7 @@ Foam::calcTypes::interpolate::~interpolate()
 void Foam::calcTypes::interpolate::init()
 {
     Foam::argList::validArgs.append("interpolate");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::interpolate::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::interpolate::calc
@@ -85,50 +78,40 @@ void Foam::calcTypes::interpolate::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeInterpolateField<scalar>(fieldHeader, mesh, processed);
-            writeInterpolateField<vector>(fieldHeader, mesh, processed);
-            writeInterpolateField<sphericalTensor>
-            (
-                fieldHeader,
-                mesh,
-                processed
-            );
-            writeInterpolateField<symmTensor>(fieldHeader, mesh, processed);
-            writeInterpolateField<tensor>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                 FatalError
-                     << "Unable to process " << fieldName << nl
-                     << "No call to interpolate for fields of type "
-                     << fieldHeader.headerClassName() << nl << nl
-                     << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeInterpolateField<scalar>(fieldHeader, mesh, processed);
+        writeInterpolateField<vector>(fieldHeader, mesh, processed);
+        writeInterpolateField<sphericalTensor>(fieldHeader, mesh, processed);
+        writeInterpolateField<symmTensor>(fieldHeader, mesh, processed);
+        writeInterpolateField<tensor>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to interpolate for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+                << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/postProcessing/foamCalcFunctions/field/mag/mag.C b/src/postProcessing/foamCalcFunctions/field/mag/mag.C
index 0f2a19eb05b6755efb3d99d5f9325454d203076b..cc86e8fa89ecda6e8e0862312e5ef62467ecb5c0 100644
--- a/src/postProcessing/foamCalcFunctions/field/mag/mag.C
+++ b/src/postProcessing/foamCalcFunctions/field/mag/mag.C
@@ -57,8 +57,8 @@ Foam::calcTypes::mag::~mag()
 
 void Foam::calcTypes::mag::init()
 {
-    Foam::argList::validArgs.append("mag");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("mag");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::mag::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::mag::calc
@@ -85,45 +78,40 @@ void Foam::calcTypes::mag::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeMagField<scalar>(fieldHeader, mesh, processed);
-            writeMagField<vector>(fieldHeader, mesh, processed);
-            writeMagField<sphericalTensor>(fieldHeader, mesh, processed);
-            writeMagField<symmTensor>(fieldHeader, mesh, processed);
-            writeMagField<tensor>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                 FatalError
-                     << "Unable to process " << fieldName << nl
-                     << "No call to mag for fields of type "
-                     << fieldHeader.headerClassName() << nl << nl
-                     << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeMagField<scalar>(fieldHeader, mesh, processed);
+        writeMagField<vector>(fieldHeader, mesh, processed);
+        writeMagField<sphericalTensor>(fieldHeader, mesh, processed);
+        writeMagField<symmTensor>(fieldHeader, mesh, processed);
+        writeMagField<tensor>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to mag for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+                << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C b/src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C
index 33b767c39636bac229e72aed21887afde271cc33..92722d917cb3712aed884d5d0d03d02f39f5e310 100644
--- a/src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C
+++ b/src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C
@@ -57,8 +57,8 @@ Foam::calcTypes::magGrad::~magGrad()
 
 void Foam::calcTypes::magGrad::init()
 {
-    Foam::argList::validArgs.append("magGrad");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("magGrad");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::magGrad::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::magGrad::calc
@@ -85,42 +78,37 @@ void Foam::calcTypes::magGrad::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeMagGradField<scalar>(fieldHeader, mesh, processed);
-            writeMagGradField<vector>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                 FatalError
-                     << "Unable to process " << fieldName << nl
-                     << "No call to magGrad for fields of type "
-                     << fieldHeader.headerClassName() << nl << nl
-                     << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeMagGradField<scalar>(fieldHeader, mesh, processed);
+        writeMagGradField<vector>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to magGrad for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+                << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C b/src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C
index 872fbf1f806ae596966c04e15a7f08b5bb24659e..5bce397e0796bf9ffc02815bcf3267b0000e0d2d 100644
--- a/src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C
+++ b/src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C
@@ -58,7 +58,7 @@ Foam::calcTypes::magSqr::~magSqr()
 void Foam::calcTypes::magSqr::init()
 {
     Foam::argList::validArgs.append("magSqr");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -68,14 +68,7 @@ void Foam::calcTypes::magSqr::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 2)
-    {
-        Info<< nl << "must specify one or more fields" << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::magSqr::calc
@@ -85,47 +78,43 @@ void Foam::calcTypes::magSqr::calc
     const fvMesh& mesh
 )
 {
-    const stringList& params = args.additionalArgs();
-
-    for (label fieldi=1; fieldi<params.size(); fieldi++)
+    const word& fieldName = args.additionalArgs()[1];
+
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
-
-        IOobject fieldHeader
-        (
-            fieldName,
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ
-        );
-
-        // Check field exists
-        if (fieldHeader.headerOk())
-        {
-            bool processed = false;
-
-            writeMagSqrField<scalar>(fieldHeader, mesh, processed);
-            writeMagSqrField<vector>(fieldHeader, mesh, processed);
-            writeMagSqrField<sphericalTensor>(fieldHeader, mesh, processed);
-            writeMagSqrField<symmTensor>(fieldHeader, mesh, processed);
-            writeMagSqrField<tensor>(fieldHeader, mesh, processed);
-
-            if (!processed)
-            {
-                 FatalError
-                     << "Unable to process " << fieldName << nl
-                     << "No call to magSqr for fields of type "
-                     << fieldHeader.headerClassName() << nl << nl
-                     << exit(FatalError);
-            }
-        }
-        else
+        bool processed = false;
+
+        writeMagSqrField<scalar>(fieldHeader, mesh, processed);
+        writeMagSqrField<vector>(fieldHeader, mesh, processed);
+        writeMagSqrField<sphericalTensor>(fieldHeader, mesh, processed);
+        writeMagSqrField<symmTensor>(fieldHeader, mesh, processed);
+        writeMagSqrField<tensor>(fieldHeader, mesh, processed);
+
+        if (!processed)
         {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to magSqr for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+               << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
+
 // ************************************************************************* //
 
diff --git a/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C
index f8f7ef68ec1407905abb4cf7cc330608b00828ab..7c218e1b77a859660e2e4145f6f823723783914f 100644
--- a/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C
+++ b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C
@@ -59,7 +59,7 @@ void Foam::calcTypes::randomise::init()
 {
     argList::validArgs.append("randomise");
     argList::validArgs.append("perturbation");
-    argList::validArgs.append("fieldName1 .. fieldNameN");
+    argList::validArgs.append("fieldName");
 }
 
 
@@ -69,17 +69,7 @@ void Foam::calcTypes::randomise::preCalc
     const Time& runTime,
     const fvMesh& mesh
 )
-{
-    if (args.additionalArgs().size() < 3)
-    {
-        Info<< nl
-            << "must specify perturbation magnitude and one"
-            << "or more fields"
-            << nl;
-        args.printUsage();
-        FatalError.exit();
-    }
-}
+{}
 
 
 void Foam::calcTypes::randomise::calc
@@ -91,73 +81,69 @@ void Foam::calcTypes::randomise::calc
 {
     const stringList& params = args.additionalArgs();
     const scalar pertMag = readScalar(IStringStream(params[1])());
+    const word& fieldName = params[2];
 
     Random rand(1234567);
 
-    for (label fieldi=2; fieldi<params.size(); fieldi++)
+    IOobject fieldHeader
+    (
+        fieldName,
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    // Check field exists
+    if (fieldHeader.headerOk())
     {
-        const word fieldName(params[fieldi]);
+        bool processed = false;
 
-        IOobject fieldHeader
+        writeRandomField<vector>
         (
-            fieldName,
-            runTime.timeName(),
+            fieldHeader,
+            pertMag,
+            rand,
             mesh,
-            IOobject::MUST_READ
+            processed
+        );
+        writeRandomField<sphericalTensor>
+        (
+            fieldHeader,
+            pertMag,
+            rand,
+            mesh,
+            processed
+        );
+        writeRandomField<symmTensor>
+        (
+            fieldHeader,
+            pertMag,
+            rand,
+            mesh,
+            processed
+        );
+        writeRandomField<tensor>
+        (
+            fieldHeader,
+            pertMag,
+            rand,
+            mesh,
+            processed
         );
 
-        // Check field exists
-        if (fieldHeader.headerOk())
+        if (!processed)
         {
-            bool processed = false;
-
-            writeRandomField<vector>
-            (
-                fieldHeader,
-                pertMag,
-                rand,
-                mesh,
-                processed
-            );
-            writeRandomField<sphericalTensor>
-            (
-                fieldHeader,
-                pertMag,
-                rand,
-                mesh,
-                processed
-            );
-            writeRandomField<symmTensor>
-            (
-                fieldHeader,
-                pertMag,
-                rand,
-                mesh,
-                processed
-            );
-            writeRandomField<tensor>
-            (
-                fieldHeader,
-                pertMag,
-                rand,
-                mesh,
-                processed
-            );
-
-            if (!processed)
-            {
-                FatalError
-                    << "Unable to process " << fieldName << nl
-                    << "No call to randomise for fields of type "
-                    << fieldHeader.headerClassName() << nl << nl
-                    << exit(FatalError);
-            }
-        }
-        else
-        {
-            Info<< "    No " << fieldName << endl;
+            FatalError
+                << "Unable to process " << fieldName << nl
+                << "No call to randomise for fields of type "
+                << fieldHeader.headerClassName() << nl << nl
+                << exit(FatalError);
         }
     }
+    else
+    {
+        Info<< "    No " << fieldName << endl;
+    }
 }
 
 
diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C
index 50888ee31d2d660cfe2b3d1acf9c1037c53d4cca..20249528645314d4f50ac06b8b42a4bdcc0595b2 100644
--- a/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C
+++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C
@@ -369,7 +369,7 @@ void Foam::isoSurface::generateTriPoints
     {
         const polyPatch& pp = patches[patchI];
 
-        if (pp.coupled())
+        if (isA<processorPolyPatch>(pp))
         {
             if (refCast<const processorPolyPatch>(pp).owner())
             {
diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C
index 9511f6dabe7f0572d3d3f1327c19fa10a306122b..2cbe93c40abd1c863bdb73de74f7fc9f54079f1b 100644
--- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C
+++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C
@@ -466,12 +466,13 @@ Foam::sampledIsoSurface::sampledIsoSurface
 {
     if (!sampledSurface::interpolate())
     {
-        FatalErrorIn
+        FatalIOErrorIn
         (
             "sampledIsoSurface::sampledIsoSurface"
-            "(const word&, const polyMesh&, const dictionary&)"
+            "(const word&, const polyMesh&, const dictionary&)",
+            dict
         )   << "Non-interpolated iso surface not supported since triangles"
-            << " span across cells." << exit(FatalError);
+            << " span across cells." << exit(FatalIOError);
     }
 
     if (zoneID_.index() != -1)
@@ -480,14 +481,15 @@ Foam::sampledIsoSurface::sampledIsoSurface
 
         if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1)
         {
-            FatalErrorIn
+            FatalIOErrorIn
             (
                 "sampledIsoSurface::sampledIsoSurface"
-                "(const word&, const polyMesh&, const dictionary&)"
+                "(const word&, const polyMesh&, const dictionary&)",
+                dict
             )   << "Cannot find patch " << exposedPatchName_
                 << " in which to put exposed faces." << endl
                 << "Valid patches are " << mesh.boundaryMesh().names()
-                << exit(FatalError);
+                << exit(FatalIOError);
         }
 
         if (debug && zoneID_.index() != -1)
diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C
index f48c15bb582b4528c26dd340838838ee3cfa40d2..592382ddf05dc9bcc6fa8325a2d4b53bd1630358 100644
--- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C
+++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C
@@ -302,7 +302,7 @@ void Foam::dxSurfaceWriter<Type>::write
 {
     fileName surfaceDir(samplePath/timeDir);
 
-    if (!exists(surfaceDir))
+    if (!isDir(surfaceDir))
     {
         mkDir(surfaceDir);
     }
diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C
index e5962d8a0ca6c3fa6ff3f401812844485de95b9a..38ad998cc5628c0a9b5818afebbd946ab2698dee 100644
--- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C
+++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C
@@ -63,7 +63,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
 {
     fileName surfaceDir(samplePath/timeDir/surfaceName);
 
-    if (!exists(surfaceDir))
+    if (!isDir(surfaceDir))
     {
         mkDir(surfaceDir);
     }
@@ -84,7 +84,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
     fileName foamName(pTraits<Type>::typeName);
     fileName valuesDir(surfaceDir  / (foamName + Field<Type>::typeName));
 
-    if (!exists(valuesDir))
+    if (!isDir(valuesDir))
     {
         mkDir(valuesDir);
     }
diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C
index c71cc140bbe022ce5ef87765dec842d4798efd19..301f8e69dbc554d66af8b30119fa702d6af793ab 100644
--- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C
+++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C
@@ -342,7 +342,7 @@ void Foam::rawSurfaceWriter<Type>::write
 {
     fileName surfaceDir(samplePath/timeDir);
 
-    if (!exists(surfaceDir))
+    if (!isDir(surfaceDir))
     {
         mkDir(surfaceDir);
     }
diff --git a/src/sampling/sampledSurface/writers/stl/stlSurfaceWriter.C b/src/sampling/sampledSurface/writers/stl/stlSurfaceWriter.C
index cdf0927f19f33e874bdf3b38b6c57e23d10cb0ab..c3ef53df858bd3b92b61745c04c32b64bb559c3a 100644
--- a/src/sampling/sampledSurface/writers/stl/stlSurfaceWriter.C
+++ b/src/sampling/sampledSurface/writers/stl/stlSurfaceWriter.C
@@ -64,7 +64,7 @@ void Foam::stlSurfaceWriter<Type>::write
 {
     fileName surfaceDir(samplePath/timeDir);
 
-    if (!exists(surfaceDir))
+    if (!isDir(surfaceDir))
     {
         mkDir(surfaceDir);
     }
diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C
index 79e9ffe10be3ae584f95d1ecf74b013d401d73cc..d2f529588c5180fdef433f5253982430099d9d64 100644
--- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C
+++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C
@@ -309,7 +309,7 @@ void Foam::vtkSurfaceWriter<Type>::write
 {
     fileName surfaceDir(samplePath/timeDir);
 
-    if (!exists(surfaceDir))
+    if (!isDir(surfaceDir))
     {
         mkDir(surfaceDir);
     }
diff --git a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C b/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C
index c495cb4afd581194b73a7db3cb2131d743d0c680..41295b44b610453809db3818f56ac15cbcfa21db 100644
--- a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C
+++ b/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C
@@ -49,8 +49,8 @@ Foam::BasicMeshedSurface<Face>::BasicMeshedSurface()
 template<class Face>
 Foam::BasicMeshedSurface<Face>::BasicMeshedSurface
 (
-    const Xfer<pointField>& pointLst,
-    const Xfer<List<Face> >& faceLst
+    const Xfer< pointField >& pointLst,
+    const Xfer< List<Face> >& faceLst
 )
 :
     ParentType(List<Face>(), pointField())
@@ -112,8 +112,8 @@ void Foam::BasicMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
 template<class Face>
 void Foam::BasicMeshedSurface<Face>::reset
 (
-    const Xfer<pointField>& pointLst,
-    const Xfer<List<Face> >& faceLst
+    const Xfer< pointField >& pointLst,
+    const Xfer< List<Face> >& faceLst
 )
 {
     ParentType::clearOut();
@@ -135,8 +135,8 @@ void Foam::BasicMeshedSurface<Face>::reset
 template<class Face>
 void Foam::BasicMeshedSurface<Face>::reset
 (
-    const Xfer<List<point> >& pointLst,
-    const Xfer<List<Face> >& faceLst
+    const Xfer< List<point> >& pointLst,
+    const Xfer< List<Face> >& faceLst
 )
 {
     ParentType::clearOut();
@@ -473,7 +473,7 @@ Foam::label Foam::BasicMeshedSurface<Face>::triangulate
 
             for (label fp = 1; fp < f.size() - 1; ++fp)
             {
-                label fp1 = (fp + 1) % f.size();
+                label fp1 = f.fcIndex(fp);
 
                 newFaces[newFaceI] = triFace(f[0], f[fp], f[fp1]);
                 faceMap[newFaceI] = faceI;
@@ -532,10 +532,35 @@ void Foam::BasicMeshedSurface<Face>::remapFaces(const UList<label>&)
 template<class Face>
 void Foam::BasicMeshedSurface<Face>::writeStats(Ostream& os) const
 {
-    os  << "points      : " << this->points().size() << nl
-        << (this->isTri() ? "triangles   : " : "faces       : ")
-        << this->size() << nl
-        << "boundingBox : " << boundBox(this->points()) << endl;
+    os  << "points      : " << this->points().size() << nl;
+    if (this->isTri())
+    {
+        os << "triangles   : " << this->size() << nl;
+    }
+    else
+    {
+        label nTri = 0;
+        label nQuad = 0;
+        forAll(*this, i)
+        {
+            const label n = this->operator[](i).size();
+
+            if (n == 3)
+            {
+                nTri++;
+            }
+            else if (n == 4)
+            {
+                nQuad++;
+            }
+        }
+
+        os  << "faces       : " << this->size()
+            << "  (tri:" << nTri << " quad:" << nQuad
+            << " poly:" << (this->size() - nTri - nQuad ) << ")" << nl;
+    }
+
+    os  << "boundingBox : " << boundBox(this->points()) << endl;
 }
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
diff --git a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.H b/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.H
index 89120b255e232619a6c7174081a07a2197301265..ab60baf93de8ab5bacd94958bb5931df297fec34 100644
--- a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.H
+++ b/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.H
@@ -59,7 +59,8 @@ class BasicMeshedSurface
     public PrimitivePatch<Face, ::Foam::List, pointField, point>
 {
 
-    //- Typedefs for convenience
+    // Private typedefs
+
         typedef PrimitivePatch
         <
             Face,
@@ -70,6 +71,7 @@ class BasicMeshedSurface
         ParentType;
 
 protected:
+
     // Protected Member Functions
 
         //- Non-const access to global points
@@ -84,7 +86,7 @@ protected:
             return static_cast<List<Face> &>(*this);
         }
 
-        //- Set new regions from faceMap
+        //- Set new zones from faceMap
         virtual void remapFaces(const UList<label>& faceMap);
 
 public:
@@ -103,8 +105,8 @@ public:
         //- Construct by transferring components (points, faces).
         BasicMeshedSurface
         (
-            const Xfer<pointField>&,
-            const Xfer<List<Face> >&
+            const Xfer< pointField >&,
+            const Xfer< List<Face> >&
         );
 
     // Destructor
@@ -135,15 +137,15 @@ public:
         //- Transfer components (points, faces).
         virtual void reset
         (
-            const Xfer<pointField>&,
-            const Xfer<List<Face> >&
+            const Xfer< pointField >&,
+            const Xfer< List<Face> >&
         );
 
         //- Transfer components (points, faces).
         virtual void reset
         (
-            const Xfer<List<point> >&,
-            const Xfer<List<Face> >&
+            const Xfer< List<point> >&,
+            const Xfer< List<Face> >&
         );
 
         //- Remove invalid faces
@@ -160,14 +162,12 @@ public:
             const bool verbose=false
         );
 
-        //- Triangulate in-place
-        //  Returning the number of triangles added
-        //  Optionally returning a map of original face Ids (zero-sized when
-        //  no triangulation was done)
+        //- Triangulate in-place, returning the number of triangles added
         virtual label triangulate();
 
-        //- Triangulate in-place, setting a map of original face Ids
-        //  faceMap is zero-sized when no triangulation was done
+        //- Triangulate in-place, returning the number of triangles added
+        //  and setting a map of original face Ids.
+        //  The faceMap is zero-sized when no triangulation was done.
         virtual label triangulate(List<label>& faceMap);
 
 
diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files
index 21733262f0049cfe0374d468986c59954f6c2844..2a51d95fbf77bdff3098c3b67e2c1403c3a972fe 100644
--- a/src/surfMesh/Make/files
+++ b/src/surfMesh/Make/files
@@ -1,10 +1,18 @@
-surfRegion/surfRegion/surfRegion.C
-surfRegion/surfRegion/surfRegionIOList.C
-surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
+surfZone/surfZone/surfZone.C
+surfZone/surfZone/surfZoneIOList.C
+surfZone/surfZoneIdentifier/surfZoneIdentifier.C
 
+MeshedSurface/MeshedSurfaceCore.C
 MeshedSurface/MeshedSurfaces.C
 UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
 
+surfaceRegistry/surfaceRegistry.C
+surfFields/surfFields.C
+surfPointFields/surfPointFields.C
+surfMesh/surfMesh.C
+surfMesh/surfMeshClear.C
+surfMesh/surfMeshIO.C
+
 surfaceFormats = surfaceFormats
 $(surfaceFormats)/surfaceFormatsCore.C
 
diff --git a/src/surfMesh/Make/options b/src/surfMesh/Make/options
index 45765759c16acadd0d907685d44e79783df5cc54..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/surfMesh/Make/options
+++ b/src/surfMesh/Make/options
@@ -1,5 +0,0 @@
-EXE_INC = \
-    -I$(LIB_SRC)/triSurface/lnInclude
-
-LIB_LIBS = \
-    -ltriSurface
diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C
index 99f54c3a6d5e9fbf376173dd390ef59f7b977733..b446f3c0efbf94bbce9a919e6beaef512c37050e 100644
--- a/src/surfMesh/MeshedSurface/MeshedSurface.C
+++ b/src/surfMesh/MeshedSurface/MeshedSurface.C
@@ -32,7 +32,7 @@ License
 #include "ListOps.H"
 #include "polyBoundaryMesh.H"
 #include "polyMesh.H"
-// #include "surfMesh.H"
+#include "surfMesh.H"
 #include "primitivePatch.H"
 #include "addToRunTimeSelectionTable.H"
 
@@ -166,11 +166,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
 (
     const Xfer<pointField>& pointLst,
     const Xfer<List<Face> >& faceLst,
-    const Xfer<surfRegionList>& regionLst
+    const Xfer<surfZoneList>& zoneLst
 )
 :
     ParentType(pointLst, faceLst),
-    regions_(regionLst)
+    zones_(zoneLst)
 {}
 
 
@@ -179,26 +179,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
 (
     const Xfer<pointField>& pointLst,
     const Xfer<List<Face> >& faceLst,
-    const UList<label>& regionSizes,
-    const UList<word>& regionNames
+    const UList<label>& zoneSizes,
+    const UList<word>& zoneNames
 )
 :
     ParentType(pointLst, faceLst)
 {
-    if (&regionSizes)
+    if (&zoneSizes)
     {
-        if (&regionNames)
+        if (&zoneNames)
         {
-            addRegions(regionSizes, regionNames);
+            addZones(zoneSizes, zoneNames);
         }
         else
         {
-            addRegions(regionSizes);
+            addZones(zoneSizes);
         }
     }
     else
     {
-        oneRegion();
+        oneZone();
     }
 }
 
@@ -225,108 +225,70 @@ Foam::MeshedSurface<Face>::MeshedSurface
         mesh.points()
     );
 
-    // use global/local points
+    // use global/local points:
     const pointField& bPoints =
     (
         useGlobalPoints ? mesh.points() : allBoundary.localPoints()
     );
 
-    // global or local face addressing
+    // global/local face addressing:
     const List<Face>& bFaces =
     (
         useGlobalPoints ? allBoundary : allBoundary.localFaces()
     );
 
 
-    // create region list
-    surfRegionList newRegions(bPatches.size());
+    // create zone list
+    surfZoneList newZones(bPatches.size());
 
     label startFaceI = 0;
+    label nZone = 0;
     forAll(bPatches, patchI)
     {
         const polyPatch& p = bPatches[patchI];
 
-        newRegions[patchI] = surfRegion
-        (
-            p.name(),
-            p.size(),
-            startFaceI,
-            patchI
-        );
+        if (p.size())
+        {
+            newZones[nZone] = surfZone
+            (
+                p.name(),
+                p.size(),
+                startFaceI,
+                nZone
+            );
 
-        startFaceI += p.size();
+            nZone++;
+            startFaceI += p.size();
+        }
     }
 
-    // must create with the same face type as the polyBoundaryMesh
+    newZones.setSize(nZone);
+
+    // same face type as the polyBoundaryMesh
     MeshedSurface<face> surf
     (
         xferCopy(bPoints),
         xferCopy(bFaces),
-        xferMove(newRegions)
+        xferMove(newZones)
     );
 
-
-    // must triangulate?
-    if (this->isTri())
-    {
-        surf.triangulate();
-        this->storedPoints().transfer(surf.storedPoints());
-
-        // transcribe from face -> triFace
-        List<face>&    origFaces = surf.storedFaces();
-        List<triFace>  newFaces(origFaces.size());
-        forAll(origFaces, faceI)
-        {
-            newFaces[faceI] = Face
-            (
-                static_cast<const UList<label>&>(origFaces[faceI])
-            );
-        }
-        origFaces.clear();
-
-        this->storedFaces().transfer(newFaces);
-        regions_.transfer(surf.regions_);
-    }
-    else
-    {
-        this->transfer(surf);
-    }
+    this->transcribe(surf);
 }
 
 
-#if 0
-// in preparation
-Foam::MeshedSurface<Face>::MeshedSurface
-(
-    const surfMesh& sMesh
-)
-:
-    ParentType(xferCopy(sMesh.points()), xferCopy(sMesh.faces()))
+template<class Face>
+Foam::MeshedSurface<Face>::MeshedSurface(const surfMesh& mesh)
 {
-    const surfPatchList& sPatches = sMesh.boundaryMesh();
-
-    // create regions list
-    List<surfRegion> newRegions(sPatches.size());
-
-    label startFaceI = 0;
-    forAll(sPatches, patchI)
-    {
-        const surfPatch& p = sPatches[patchI];
-
-        newRegions[patchI] = surfRegion
-        (
-            p.name(),
-            p.size(),
-            startFaceI,
-            patchI
-        );
-
-        startFaceI += p.size();
-    }
+    // same face type as surfMesh
+    MeshedSurface<face> surf
+    (
+        xferCopy(mesh.points()),
+        xferCopy(mesh.faces()),
+        xferCopy(mesh.surfZones())
+    );
 
-    regions_.transfer(newRegions);
+    this->transcribe(surf);
 }
-#endif
 
 
 template<class Face>
@@ -336,8 +298,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
 )
 {
     labelList faceMap;
-    surfRegionList regionLst = surf.sortedRegions(faceMap);
-    regions_.transfer(regionLst);
+    surfZoneList zoneLst = surf.sortedZones(faceMap);
+    zones_.transfer(zoneLst);
 
     const List<Face>& origFaces = surf.faces();
     List<Face> newFaces(origFaces.size());
@@ -378,9 +340,9 @@ Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
 
 
 template<class Face>
-Foam::MeshedSurface<Face>::MeshedSurface(const Time& d)
+Foam::MeshedSurface<Face>::MeshedSurface(const Time& d, const word& surfName)
 {
-    read(IFstream(findMeshName(d))());
+    read(IFstream(findMeshFile(d, surfName))());
 }
 
 
@@ -388,7 +350,7 @@ template<class Face>
 Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
 :
     ParentType(surf),
-    regions_(surf.regions_)
+    zones_(surf.zones_)
 {}
 
 
@@ -419,71 +381,74 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
 template<class Face>
-void Foam::MeshedSurface<Face>::oneRegion(const word& name)
+void Foam::MeshedSurface<Face>::oneZone(const word& name)
 {
-    word regionName(name);
-    if (regionName.empty())
+    word zoneName(name);
+    if (zoneName.empty())
     {
-        if (regions_.size())
+        if (zones_.size())
         {
-            regionName = regions_[0].name();
+            zoneName = zones_[0].name();
         }
-        if (regionName.empty())
+        if (zoneName.empty())
         {
-            regionName = "region0";
+            zoneName = "zone0";
         }
     }
 
-    // set single default region
-    regions_.setSize(1);
-    regions_[0] = surfRegion
+    // set single default zone
+    zones_.setSize(1);
+    zones_[0] = surfZone
     (
-        regionName,
-        size(),         // region size
-        0,              // region start
-        0               // region index
+        zoneName,
+        this->size(),   // zone size
+        0,              // zone start
+        0               // zone index
     );
 }
 
 
 template<class Face>
-void Foam::MeshedSurface<Face>::checkRegions()
+void Foam::MeshedSurface<Face>::checkZones()
 {
-    // extra safety, ensure we have at some regions
+    // extra safety, ensure we have at some zones
     // and they cover all the faces - fix start silently
-    if (regions_.size() <= 1)
+    if (zones_.size() <= 1)
     {
-        oneRegion();
+        oneZone();
     }
     else
     {
         label count = 0;
-        forAll(regions_, regionI)
+        forAll(zones_, zoneI)
         {
-            regions_[regionI].start() = count;
-            count += regions_[regionI].size();
+            zones_[zoneI].start() = count;
+            count += zones_[zoneI].size();
         }
 
         if (count < size())
         {
             WarningIn
             (
-                "MeshedSurface::checkRegions()\n"
+                "MeshedSurface::checkZones()\n"
             )
-                << "more face " << size() << " than regions " << count
-                << " ... extending final region"
+                << "more faces " << size() << " than zones " << count
+                << " ... extending final zone"
                 << endl;
 
-            regions_[regions_.size()-1].size() += count - size();
+            zones_[zones_.size()-1].size() += count - size();
         }
         else if (count > size())
         {
             FatalErrorIn
             (
-                "MeshedSurface::checkRegions()\n"
+                "MeshedSurface::checkZones()\n"
             )
-                << "more regions " << count << " than faces " << size()
+                << "more zones " << count << " than faces " << size()
                 << exit(FatalError);
         }
     }
@@ -494,12 +459,12 @@ template<class Face>
 void Foam::MeshedSurface<Face>::sortFacesAndStore
 (
     const Xfer<List<Face> >& unsortedFaces,
-    const Xfer<List<label> >& regionIds,
+    const Xfer<List<label> >& zoneIds,
     const bool sorted
 )
 {
     List<Face>  oldFaces(unsortedFaces);
-    List<label> regions(regionIds);
+    List<label> zones(zoneIds);
 
     if (sorted)
     {
@@ -511,8 +476,8 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
         // unsorted - determine the sorted order:
         // avoid SortableList since we discard the main list anyhow
         List<label> faceMap;
-        sortedOrder(regions, faceMap);
-        regions.clear();
+        sortedOrder(zones, faceMap);
+        zones.clear();
 
         // sorted faces
         List<Face> newFaces(faceMap.size());
@@ -524,7 +489,7 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
         this->storedFaces().transfer(newFaces);
 
     }
-    regions.clear();
+    zones.clear();
 }
 
 
@@ -534,29 +499,29 @@ void Foam::MeshedSurface<Face>::remapFaces
     const UList<label>& faceMap
 )
 {
-    // recalculate the region start/size
+    // recalculate the zone start/size
     if (&faceMap && faceMap.size())
     {
-        if (regions_.empty())
+        if (zones_.empty())
         {
-            oneRegion();
+            oneZone();
         }
-        else if (regions_.size() == 1)
+        else if (zones_.size() == 1)
         {
-            // optimized for single region case
-            regions_[0].size() = faceMap.size();
+            // optimized for single zone case
+            zones_[0].size() = faceMap.size();
         }
         else
         {
             label newFaceI = 0;
             label origEndI = 0;
-            forAll(regions_, regionI)
+            forAll(zones_, zoneI)
             {
-                surfRegion& reg = regions_[regionI];
+                surfZone& zone = zones_[zoneI];
 
-                // adjust region start
-                reg.start() = newFaceI;
-                origEndI += reg.size();
+                // adjust zone start
+                zone.start() = newFaceI;
+                origEndI += zone.size();
 
                 for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
                 {
@@ -570,15 +535,13 @@ void Foam::MeshedSurface<Face>::remapFaces
                     }
                 }
 
-                // adjust region size
-                reg.size() = newFaceI - reg.start();
+                // adjust zone size
+                zone.size() = newFaceI - zone.start();
             }
         }
     }
 }
 
-// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
-
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
@@ -586,7 +549,7 @@ template<class Face>
 void Foam::MeshedSurface<Face>::clear()
 {
     ParentType::clear();
-    regions_.clear();
+    zones_.clear();
 }
 
 
@@ -614,11 +577,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
         oldToNew[pointMap[pointI]] = pointI;
     }
 
-    // create/copy a new region list, each region with zero size
-    surfRegionList newRegions(regions_);
-    forAll(newRegions, regionI)
+    // create/copy a new zones list, each zone with zero size
+    surfZoneList newZones(zones_);
+    forAll(newZones, zoneI)
     {
-        newRegions[regionI].size() = 0;
+        newZones[zoneI].size() = 0;
     }
 
     // Renumber face node labels
@@ -637,18 +600,18 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
     }
     oldToNew.clear();
 
-    // recalculate the region start/size
+    // recalculate the zones start/size
     label newFaceI = 0;
     label origEndI = 0;
 
-    // adjust region sizes
-    forAll(newRegions, regionI)
+    // adjust zone sizes
+    forAll(newZones, zoneI)
     {
-        surfRegion& reg = newRegions[regionI];
+        surfZone& zone = newZones[zoneI];
 
-        // adjust region start
-        reg.start() = newFaceI;
-        origEndI += reg.size();
+        // adjust zone start
+        zone.start() = newFaceI;
+        origEndI += zone.size();
 
         for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
         {
@@ -662,8 +625,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
             }
         }
 
-        // adjust region size
-        reg.size() = newFaceI - reg.start();
+        // adjust zone size
+        zone.size() = newFaceI - zone.start();
     }
 
 
@@ -672,7 +635,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
     (
         xferMove(newPoints),
         xferMove(newFaces),
-        xferMove(newRegions)
+        xferMove(newZones)
     );
 }
 
@@ -690,29 +653,29 @@ Foam::MeshedSurface<Face>::subsetMesh
 
 
 template<class Face>
-void Foam::MeshedSurface<Face>::addRegions
+void Foam::MeshedSurface<Face>::addZones
 (
-    const UList<surfRegion>& regions,
+    const UList<surfZone>& zones,
     const bool cullEmpty
 )
 {
-    label nRegion = 0;
+    label nZone = 0;
 
-    regions_.setSize(regions.size());
-    forAll(regions_, regionI)
+    zones_.setSize(zones.size());
+    forAll(zones_, zoneI)
     {
-        if (regions[regionI].size() || !cullEmpty)
+        if (zones[zoneI].size() || !cullEmpty)
         {
-            regions_[nRegion] = surfRegion(regions[regionI], nRegion);
-            nRegion++;
+            zones_[nZone] = surfZone(zones[zoneI], nZone);
+            nZone++;
         }
     }
-    regions_.setSize(nRegion);
+    zones_.setSize(nZone);
 }
 
 
 template<class Face>
-void Foam::MeshedSurface<Face>::addRegions
+void Foam::MeshedSurface<Face>::addZones
 (
     const UList<label>& sizes,
     const UList<word>& names,
@@ -720,55 +683,55 @@ void Foam::MeshedSurface<Face>::addRegions
 )
 {
     label start   = 0;
-    label nRegion = 0;
+    label nZone = 0;
 
-    regions_.setSize(sizes.size());
-    forAll(regions_, regionI)
+    zones_.setSize(sizes.size());
+    forAll(zones_, zoneI)
     {
-        if (sizes[regionI] || !cullEmpty)
+        if (sizes[zoneI] || !cullEmpty)
         {
-            regions_[nRegion] = surfRegion
+            zones_[nZone] = surfZone
             (
-                names[regionI],
-                sizes[regionI],
+                names[zoneI],
+                sizes[zoneI],
                 start,
-                nRegion
+                nZone
             );
-            start += sizes[regionI];
-            nRegion++;
+            start += sizes[zoneI];
+            nZone++;
         }
     }
-    regions_.setSize(nRegion);
+    zones_.setSize(nZone);
 }
 
 
 template<class Face>
-void Foam::MeshedSurface<Face>::addRegions
+void Foam::MeshedSurface<Face>::addZones
 (
     const UList<label>& sizes,
     const bool cullEmpty
 )
 {
     label start   = 0;
-    label nRegion = 0;
+    label nZone = 0;
 
-    regions_.setSize(sizes.size());
-    forAll(regions_, regionI)
+    zones_.setSize(sizes.size());
+    forAll(zones_, zoneI)
     {
-        if (sizes[regionI] || !cullEmpty)
+        if (sizes[zoneI] || !cullEmpty)
         {
-            regions_[nRegion] = surfRegion
+            zones_[nZone] = surfZone
             (
-                word("region") + ::Foam::name(nRegion),
-                sizes[regionI],
+                word("zone") + ::Foam::name(nZone),
+                sizes[zoneI],
                 start,
-                nRegion
+                nZone
             );
-            start += sizes[regionI];
-            nRegion++;
+            start += sizes[zoneI];
+            nZone++;
         }
     }
-    regions_.setSize(nRegion);
+    zones_.setSize(nZone);
 }
 
 
@@ -779,7 +742,7 @@ void Foam::MeshedSurface<Face>::transfer
 )
 {
     reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
-    regions_.transfer(surf.regions_);
+    zones_.transfer(surf.zones_);
 
     surf.clear();
 }
@@ -794,7 +757,7 @@ void Foam::MeshedSurface<Face>::transfer
     clear();
 
     labelList faceMap;
-    surfRegionList regionLst = surf.sortedRegions(faceMap);
+    surfZoneList zoneLst = surf.sortedZones(faceMap);
     List<Face>& oldFaces = surf.storedFaces();
 
     List<Face> newFaces(faceMap.size());
@@ -805,12 +768,20 @@ void Foam::MeshedSurface<Face>::transfer
     faceMap.clear();
 
     reset(xferMove(surf.storedPoints()), xferMove(newFaces));
-    regions_.transfer(regionLst);
+    zones_.transfer(zoneLst);
 
     surf.clear();
 }
 
 
+template<class Face>
+Foam::Xfer< Foam::MeshedSurface<Face> >
+Foam::MeshedSurface<Face>::xfer()
+{
+    return xferMove(*this);
+}
+
+
 // Read from file, determine format from extension
 template<class Face>
 bool Foam::MeshedSurface<Face>::read(const fileName& name)
@@ -851,9 +822,9 @@ bool Foam::MeshedSurface<Face>::read
 
 
 template<class Face>
-void Foam::MeshedSurface<Face>::write(const Time& d) const
+void Foam::MeshedSurface<Face>::write(const Time& d, const word& surfName) const
 {
-    write(OFstream(findMeshName(d))());
+    write(OFstream(findMeshFile(d, surfName))());
 }
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
@@ -865,7 +836,7 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
 
     this->storedPoints() = surf.points();
     this->storedFaces()  = surf.faces();
-    regions_ = surf.regions_;
+    zones_ = surf.zones_;
 }
 
 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.H b/src/surfMesh/MeshedSurface/MeshedSurface.H
index 493a7ffece1743afc145cb728db6b74af48b79e1..a3e8ed5758839f5ad69952dac5fc1e061d5b1b1f 100644
--- a/src/surfMesh/MeshedSurface/MeshedSurface.H
+++ b/src/surfMesh/MeshedSurface/MeshedSurface.H
@@ -26,13 +26,13 @@ Class
     Foam::MeshedSurface
 
 Description
-    A surface geometry mesh with region information, not to be confused
+    A surface geometry mesh with zone information, not to be confused
     with a similarily named surfaceMesh, which actually refers to
     the cell faces of a volume mesh.
 
-   The MeshedSurface is intended to surfaces from a variety of sources.
-   - A set of points and faces without any region information.
-   - A set of points and faces with randomly sorted region information.
+   The MeshedSurface is intended for surfaces from a variety of sources.
+   - A set of points and faces without any surface zone information.
+   - A set of points and faces with randomly ordered zone information.
      This could arise, for example, from reading external file formats
      such as STL, etc.
 
@@ -45,7 +45,7 @@ SourceFiles
 #define MeshedSurface_H
 
 #include "BasicMeshedSurface.H"
-#include "surfRegionList.H"
+#include "surfZoneList.H"
 #include "surfaceFormatsCore.H"
 #include "runTimeSelectionTables.H"
 #include "memberFunctionSelectionTables.H"
@@ -59,6 +59,7 @@ namespace Foam
 // Forward declaration of friend functions and operators
 
 class Time;
+class surfMesh;
 template<class Face> class MeshedSurface;
 template<class Face> class UnsortedMeshedSurface;
 
@@ -66,7 +67,7 @@ class polyBoundaryMesh;
 class surfMesh;
 
 template<class Face>
-    Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
+Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
 
 /*---------------------------------------------------------------------------*\
                       Class MeshedSurface Declaration
@@ -78,7 +79,15 @@ class MeshedSurface
     public BasicMeshedSurface<Face>,
     public fileFormats::surfaceFormatsCore
 {
-    friend class UnsortedMeshedSurface<Face>;
+    // friends despite different faces
+    template<class Face2>
+    friend class MeshedSurface;
+
+    // friends despite different faces
+    template<class Face2>
+    friend class UnsortedMeshedSurface;
+
+    friend class surfMesh;
 
 private:
 
@@ -88,31 +97,40 @@ private:
 
     // Private Member Data
 
-        //- Region information
+        //- Zone information
         // (face ordering nFaces/startFace only used during reading/writing)
-        List<surfRegion> regions_;
+        List<surfZone> zones_;
 
     // Private member functions
 
         //- Read OpenFOAM Surface format
         bool read(Istream&);
 
+        //- Transfer points/zones and transcribe face -> triFace
+        void transcribe(MeshedSurface<face>&);
+
 protected:
 
     // Protected Member functions
 
-        //- basic sanity check on regions
-        void checkRegions();
+        //- basic sanity check on zones
+        void checkZones();
+
+        //- Non-const access to the zones
+        surfZoneList& storedZones()
+        {
+            return zones_;
+        }
 
-        //- sort faces by regions and store sorted faces
+        //- sort faces by zones and store sorted faces
         void sortFacesAndStore
         (
             const Xfer<List<Face> >& unsortedFaces,
-            const Xfer<List<label> >& regionIds,
+            const Xfer<List<label> >& zoneIds,
             const bool sorted
         );
 
-        //- Set new regions from faceMap
+        //- Set new zones from faceMap
         virtual void remapFaces(const UList<label>& faceMap);
 
 public:
@@ -139,22 +157,22 @@ public:
         //- Construct null
         MeshedSurface();
 
-        //- Construct by transferring components (points, faces, regions).
+        //- Construct by transferring components (points, faces, zones).
         MeshedSurface
         (
             const Xfer<pointField>&,
             const Xfer<List<Face> >&,
-            const Xfer<surfRegionList>&
+            const Xfer<surfZoneList>&
         );
 
         //- Construct by transferring points, faces.
-        //  Use region information, or set single default region.
+        //  Use zone information, or set single default zone.
         MeshedSurface
         (
             const Xfer<pointField>&,
             const Xfer<List<Face> >&,
-            const UList<label>& regionSizes = UList<label>::null(),
-            const UList<word>& regionNames = UList<word>::null()
+            const UList<label>& zoneSizes = UList<label>::null(),
+            const UList<word>& zoneNames = UList<word>::null()
         );
 
         //- Construct from a boundary mesh with local points/faces
@@ -186,7 +204,7 @@ public:
         MeshedSurface(Istream&);
 
         //- Construct from objectRegistry
-        MeshedSurface(const Time&);
+        MeshedSurface(const Time&, const word& surfName="");
 
         //- Construct as copy
         MeshedSurface(const MeshedSurface&);
@@ -250,31 +268,31 @@ public:
             return ParentType::size();
         }
 
-        const List<surfRegion>& regions() const
+        const List<surfZone>& zones() const
         {
-            return regions_;
+            return zones_;
         }
 
-        //- set a single region, optionally with a specific name
-        void oneRegion(const word& name = word::null);
+        //- set a single zone, optionally with a specific name
+        void oneZone(const word& name = word::null);
 
-        //- Add regions
-        void addRegions
+        //- Add zones
+        void addZones
         (
-            const UList<surfRegion>&,
+            const UList<surfZone>&,
             const bool cullEmpty=false
         );
 
-        //- Add regions
-        void addRegions
+        //- Add zones
+        void addZones
         (
             const UList<label>& sizes,
             const UList<word>& names,
             const bool cullEmpty=false
         );
 
-        //- Add regions
-        void addRegions
+        //- Add zones
+        void addZones
         (
             const UList<label>& sizes,
             const bool cullEmpty=false
@@ -306,6 +324,8 @@ public:
         //- Transfer the contents of the argument and annull the argument
         void transfer(UnsortedMeshedSurface<Face>&);
 
+        //- Transfer contents to the Xfer container
+        Xfer< MeshedSurface<Face> > xfer();
 
     // Read
 
@@ -328,7 +348,7 @@ public:
         }
 
         //- Write to database
-        void write(const Time&) const;
+        void write(const Time&, const word& surfName="") const;
 
 
     // Member operators
diff --git a/src/surfMesh/MeshedSurface/MeshedSurfaceCore.C b/src/surfMesh/MeshedSurface/MeshedSurfaceCore.C
new file mode 100644
index 0000000000000000000000000000000000000000..6a95b18b4ab483be1cb8c7f10f588d3e6f0366da
--- /dev/null
+++ b/src/surfMesh/MeshedSurface/MeshedSurfaceCore.C
@@ -0,0 +1,78 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "MeshedSurface.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+namespace Foam
+{
+
+    // specialization: from face -> triFace
+    template<>
+    void Foam::MeshedSurface<triFace>::transcribe(MeshedSurface<face>& surf)
+    {
+        // first triangulate
+        surf.triangulate();
+        this->storedPoints().transfer(surf.storedPoints());
+        zones_.transfer(surf.zones_);
+
+        // transcribe from face -> triFace
+        List<face>&    origFaces = surf.storedFaces();
+        List<triFace>  newFaces(origFaces.size());
+        forAll(origFaces, faceI)
+        {
+            newFaces[faceI] = triFace
+            (
+                static_cast<const UList<label>&>(origFaces[faceI])
+            );
+        }
+        surf.clear();
+
+        this->storedFaces().transfer(newFaces);
+    }
+
+
+    // specialization: from face -> face
+    template<>
+    void Foam::MeshedSurface<face>::transcribe(MeshedSurface<face>& surf)
+    {
+        this->transfer(surf);
+    }
+
+
+}  // end of namespace Foam
+
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// ************************************************************************* //
diff --git a/src/surfMesh/MeshedSurface/MeshedSurfaceIO.C b/src/surfMesh/MeshedSurface/MeshedSurfaceIO.C
index 76e3a23f60e2ed72dae20bb14e6357b4b2f9ce21..5beb33b0458dae663c82ff582275e4b2dc872a84 100644
--- a/src/surfMesh/MeshedSurface/MeshedSurfaceIO.C
+++ b/src/surfMesh/MeshedSurface/MeshedSurfaceIO.C
@@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
 {
     clear();
 
-    List<surfRegion> regionLst(is);
+    List<surfZone> newZones(is);
 
     // copy and set the indices
-    regions_.setSize(regionLst.size());
-    forAll(regionLst, regionI)
+    zones_.setSize(newZones.size());
+    forAll(newZones, zoneI)
     {
-        regions_[regionI] = surfRegion
+        zones_[zoneI] = surfZone
         (
-            regionLst[regionI],
-            regionI
+            newZones[zoneI],
+            zoneI
         );
     }
 
@@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
             Xfer<pointField>::null(),
             faceLst.xfer()
         );
-        surf.addRegions(regions_);
+        surf.addZones(zones_);
 
         // this will break if the triangulation needed points
         surf.triangulate();
-        regions_ = surf.regions();
+        zones_ = surf.zones();
 
         // transcribe from face -> triFace (Face)
         const List<face>& origFaces = surf.faces();
@@ -101,12 +101,12 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
     IOobject::writeBanner(os);
     os  << "// OpenFOAM Surface Format" << nl
         << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
-        << "// regions:" << nl
-        << regions_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
+        << "// zones:" << nl
+        << zones_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
 
-    forAll(regions_, regionI)
+    forAll(zones_, zoneI)
     {
-        regions_[regionI].writeDict(os);
+        zones_[zoneI].writeDict(os);
     }
     os  << decrIndent << token::END_LIST << nl;
 
diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C
index 7387b64cfa0ac2c31a90c224ec8526edf203a7dd..f74ccdae0bc62f684f8668fa692fbbb26f478590 100644
--- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C
+++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C
@@ -163,13 +163,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
 (
     const Xfer<pointField>& pointLst,
     const Xfer<List<Face> >& faceLst,
-    const Xfer<List<label> >& regionIds,
-    const Xfer<surfRegionIdentifierList>& regionTofc
+    const Xfer<List<label> >& zoneIds,
+    const Xfer<surfZoneIdentifierList>& zoneTofc
 )
 :
     ParentType(pointLst, faceLst),
-    regionIds_(regionIds),
-    regionToc_(regionTofc)
+    zoneIds_(zoneIds),
+    zoneToc_(zoneTofc)
 {}
 
 
@@ -178,26 +178,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
 (
     const Xfer<pointField>& pointLst,
     const Xfer<List<Face> >& faceLst,
-    const UList<label>& regionSizes,
-    const UList<word>& regionNames
+    const UList<label>& zoneSizes,
+    const UList<word>& zoneNames
 )
 :
     ParentType(pointLst, faceLst)
 {
-    if (&regionSizes)
+    if (&zoneSizes)
     {
-        if (&regionNames)
+        if (&zoneNames)
         {
-            setRegions(regionSizes, regionNames);
+            setZones(zoneSizes, zoneNames);
         }
         else
         {
-            setRegions(regionSizes);
+            setZones(zoneSizes);
         }
     }
     else
     {
-        oneRegion();
+        oneZone();
     }
 }
 
@@ -223,7 +223,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
 :
     ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
 {
-    setRegions(surf.regions());
+    setZones(surf.zones());
 }
 
 
@@ -253,9 +253,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
 
 
 template<class Face>
-Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d)
+Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
+(
+    const Time& d,
+    const word& surfName
+)
 {
-    read(IFstream(findMeshName(d))());
+    read(IFstream(findMeshFile(d, surfName))());
 }
 
 
@@ -266,8 +270,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
 )
 :
     ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
-    regionIds_(surf.regionIds_),
-    regionToc_(surf.regionToc_)
+    zoneIds_(surf.zoneIds_),
+    zoneToc_(surf.zoneToc_)
 {}
 
 
@@ -299,102 +303,104 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
+
+
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
 template<class Face>
-void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
+void Foam::UnsortedMeshedSurface<Face>::oneZone(const word& name)
 {
-    regionIds_.setSize(size());
-    regionIds_ = 0;
+    zoneIds_.setSize(size());
+    zoneIds_ = 0;
 
-    word regionName(name);
-    if (regionName.empty())
+    word zoneName(name);
+    if (zoneName.empty())
     {
-        if (regionToc_.size())
+        if (zoneToc_.size())
         {
-            regionName = regionToc_[0].name();
+            zoneName = zoneToc_[0].name();
         }
-        if (regionName.empty())
+        if (zoneName.empty())
         {
-            regionName = "region0";
+            zoneName = "zone0";
         }
     }
 
-    // set single default region
-    regionToc_.setSize(1);
-    regionToc_[0] = surfRegionIdentifier(regionName, 0);
+    // set single default zone
+    zoneToc_.setSize(1);
+    zoneToc_[0] = surfZoneIdentifier(zoneName, 0);
 }
 
 
 template<class Face>
-void Foam::UnsortedMeshedSurface<Face>::setRegions
+void Foam::UnsortedMeshedSurface<Face>::setZones
 (
-    const surfRegionList& regionLst
+    const surfZoneList& zoneLst
 )
 {
-    regionIds_.setSize(size());
-    regionToc_.setSize(regionLst.size());
+    zoneIds_.setSize(size());
+    zoneToc_.setSize(zoneLst.size());
 
-    forAll(regionToc_, regionI)
+    forAll(zoneToc_, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
-        regionToc_[regionI] = reg;
+        zoneToc_[zoneI] = zone;
 
-        // assign sub-region Ids
-        SubList<label> subRegion(regionIds_, reg.size(), reg.start());
-        subRegion = regionI;
+        // assign sub-zone Ids
+        SubList<label> subZone(zoneIds_, zone.size(), zone.start());
+        subZone = zoneI;
     }
 }
 
 
 template<class Face>
-void Foam::UnsortedMeshedSurface<Face>::setRegions
+void Foam::UnsortedMeshedSurface<Face>::setZones
 (
     const UList<label>& sizes,
     const UList<word>& names
 )
 {
-    regionIds_.setSize(size());
-    regionToc_.setSize(sizes.size());
+    zoneIds_.setSize(size());
+    zoneToc_.setSize(sizes.size());
 
     label start = 0;
-    forAll(regionToc_, regionI)
+    forAll(zoneToc_, zoneI)
     {
-        regionToc_[regionI] = surfRegionIdentifier(names[regionI], regionI);
+        zoneToc_[zoneI] = surfZoneIdentifier(names[zoneI], zoneI);
 
-        // assign sub-region Ids
-        SubList<label> subRegion(regionIds_, sizes[regionI], start);
-        subRegion = regionI;
+        // assign sub-zone Ids
+        SubList<label> subZone(zoneIds_, sizes[zoneI], start);
+        subZone = zoneI;
 
-        start += sizes[regionI];
+        start += sizes[zoneI];
     }
 }
 
 
 template<class Face>
-void Foam::UnsortedMeshedSurface<Face>::setRegions
+void Foam::UnsortedMeshedSurface<Face>::setZones
 (
     const UList<label>& sizes
 )
 {
-    regionIds_.setSize(size());
-    regionToc_.setSize(sizes.size());
+    zoneIds_.setSize(size());
+    zoneToc_.setSize(sizes.size());
 
     label start = 0;
-    forAll(regionToc_, regionI)
+    forAll(zoneToc_, zoneI)
     {
-        regionToc_[regionI] = surfRegionIdentifier
+        zoneToc_[zoneI] = surfZoneIdentifier
         (
-            word("region") + ::Foam::name(regionI),
-            regionI
+            word("zone") + ::Foam::name(zoneI),
+            zoneI
         );
 
-        // assign sub-region Ids
-        SubList<label> subRegion(regionIds_, sizes[regionI], start);
-        subRegion = regionI;
+        // assign sub-zone Ids
+        SubList<label> subZone(zoneIds_, sizes[zoneI], start);
+        subZone = zoneI;
 
-        start += sizes[regionI];
+        start += sizes[zoneI];
     }
 }
 
@@ -405,27 +411,27 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
     const UList<label>& faceMap
 )
 {
-    // re-assign the region Ids
+    // re-assign the zone Ids
     if (&faceMap && faceMap.size())
     {
-        if (regionToc_.empty())
+        if (zoneToc_.empty())
         {
-            oneRegion();
+            oneZone();
         }
-        else if (regionToc_.size() == 1)
+        else if (zoneToc_.size() == 1)
         {
-            // optimized for single-region case
-            regionIds_ = 0;
+            // optimized for single-zone case
+            zoneIds_ = 0;
         }
         else
         {
-            List<label> newRegions(faceMap.size());
+            List<label> newZones(faceMap.size());
 
             forAll(faceMap, faceI)
             {
-                newRegions[faceI] = regionIds_[faceMap[faceI]];
+                newZones[faceI] = zoneIds_[faceMap[faceI]];
             }
-            regionIds_.transfer(newRegions);
+            zoneIds_.transfer(newZones);
         }
     }
 }
@@ -437,8 +443,8 @@ template<class Face>
 void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
 {
     ParentType::setSize(s);
-    // if regions extend: set with last regionId
-    regionIds_.setSize(s, regionToc_.size() - 1);
+    // if zones extend: set with last zoneId
+    zoneIds_.setSize(s, zoneToc_.size() - 1);
 }
 
 
@@ -446,25 +452,25 @@ template<class Face>
 void Foam::UnsortedMeshedSurface<Face>::clear()
 {
     ParentType::clear();
-    regionIds_.clear();
-    regionToc_.clear();
+    zoneIds_.clear();
+    zoneToc_.clear();
 }
 
 
 template<class Face>
-Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
+Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
 (
     labelList& faceMap
 ) const
 {
-    // supply some region names
-    Map<word> regionNames;
-    forAll(regionToc_, regionI)
+    // supply some zone names
+    Map<word> zoneNames;
+    forAll(zoneToc_, zoneI)
     {
-        regionNames.insert(regionI, regionToc_[regionI].name());
+        zoneNames.insert(zoneI, zoneToc_[zoneI].name());
     }
 
-    return sortedRegionsById(regionIds_, regionNames, faceMap);
+    return sortedZonesById(zoneIds_, zoneNames, faceMap);
 }
 
 
@@ -493,7 +499,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
 
     // Renumber face node labels and compact
     List<Face>  newFaces(faceMap.size());
-    List<label> newRegions(faceMap.size());
+    List<label> newZones(faceMap.size());
 
     forAll(faceMap, faceI)
     {
@@ -507,7 +513,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
             f[fp] = oldToNew[f[fp]];
         }
 
-        newRegions[faceI] = regionIds_[origFaceI];
+        newZones[faceI] = zoneIds_[origFaceI];
     }
     oldToNew.clear();
 
@@ -516,8 +522,8 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
     (
         xferMove(newPoints),
         xferMove(newFaces),
-        xferMove(newRegions),
-        xferCopy(regionToc_)
+        xferMove(newZones),
+        xferCopy(zoneToc_)
     );
 }
 
@@ -538,14 +544,14 @@ void Foam::UnsortedMeshedSurface<Face>::reset
 (
     const Xfer<pointField>& pointLst,
     const Xfer<List<Face> >& faceLst,
-    const Xfer<List<label> >& regionIds
+    const Xfer<List<label> >& zoneIds
 )
 {
     ParentType::reset(pointLst, faceLst);
 
-    if (&regionIds)
+    if (&zoneIds)
     {
-        regionIds_.transfer(regionIds());
+        zoneIds_.transfer(zoneIds());
     }
 }
 
@@ -560,9 +566,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
     (
         xferMove(surf.storedPoints()),
         xferMove(surf.storedFaces()),
-        xferMove(surf.regionIds_)
+        xferMove(surf.zoneIds_)
     );
-    regionToc_.transfer(surf.regionToc_);
+    zoneToc_.transfer(surf.zoneToc_);
 
     surf.clear();
 }
@@ -575,11 +581,20 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
 )
 {
     reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
-    setRegions(surf.regions());
+    setZones(surf.zones());
     surf.clear();
 }
 
 
+template<class Face>
+Foam::Xfer< Foam::UnsortedMeshedSurface<Face> >
+Foam::UnsortedMeshedSurface<Face>::xfer()
+{
+    return xferMove(*this);
+}
+
+
+
 // Read from file, determine format from extension
 template<class Face>
 bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& name)
@@ -620,9 +635,13 @@ bool Foam::UnsortedMeshedSurface<Face>::read
 
 
 template<class Face>
-void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) const
+void Foam::UnsortedMeshedSurface<Face>::write
+(
+    const Time& d,
+    const word& surfName
+) const
 {
-    write(OFstream(findMeshName(d))());
+    write(OFstream(findMeshFile(d, surfName))());
 }
 
 
@@ -638,8 +657,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
 
     this->storedPoints() = surf.points();
     this->storedFaces()  = surf.faces();
-    regionIds_ = surf.regionIds_;
-    regionToc_ = surf.regionToc_;
+    zoneIds_ = surf.zoneIds_;
+    zoneToc_ = surf.zoneToc_;
 }
 
 
diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H
index 8caabb0776ac3fa868eb863741973944f9072c39..efecda798b9a5b9598773c26daf7abdc17556708 100644
--- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H
+++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H
@@ -26,18 +26,18 @@ Class
     Foam::UnsortedMeshedSurface
 
 Description
-    A surface geometry mesh, in which the region information is conveyed by
-    the 'regionId' associated with each face.
+    A surface geometry mesh, in which the surface zone information is
+    conveyed by the 'zoneId' associated with each face.
 
     This form of surface description is particularly useful for reading in
     surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
     can also be particularly useful for situations in which the surface
     many be adjusted in an arbitrary manner without worrying about needed
-    to adjust the region information (eg, surface refinement).
+    to adjust the zone information (eg, surface refinement).
 
 See Also
     The Foam::MeshedSurface - which is organized as a surface mesh, but
-    with independent region information.
+    with independent zone information.
 
 SourceFiles
     UnsortedMeshedSurface.C
@@ -48,8 +48,8 @@ SourceFiles
 #define UnsortedMeshedSurface_H
 
 #include "BasicMeshedSurface.H"
-#include "surfRegionIdentifierList.H"
-#include "surfRegionList.H"
+#include "surfZoneIdentifierList.H"
+#include "surfZoneList.H"
 #include "surfaceFormatsCore.H"
 #include "runTimeSelectionTables.H"
 #include "memberFunctionSelectionTables.H"
@@ -83,6 +83,14 @@ class UnsortedMeshedSurface
     public BasicMeshedSurface<Face>,
     public fileFormats::surfaceFormatsCore
 {
+    // friends despite different faces
+    template<class Face2>
+    friend class MeshedSurface;
+
+    // friends despite different faces
+    template<class Face2>
+    friend class UnsortedMeshedSurface;
+
     friend class MeshedSurface<Face>;
 
 private:
@@ -93,12 +101,12 @@ private:
 
     // Private Member Data
 
-        //- The region Ids associated with the faces
-        labelList regionIds_;
+        //- The zone Id associated with each face
+        labelList zoneIds_;
 
-        //- Region information (face ordering nFaces/startFace only used
+        //- Zone information (face ordering nFaces/startFace only used
         //  during reading and writing)
-        List<surfRegionIdentifier> regionToc_;
+        List<surfZoneIdentifier> zoneToc_;
 
     // Private member functions
 
@@ -115,19 +123,19 @@ protected:
 
     // Protected Member functions
 
-        //- Return non-const access to the region Ids
-        List<label>& storedRegionIds()
+        //- Return non-const access to the zone Ids
+        List<label>& storedZoneIds()
         {
-            return regionIds_;
+            return zoneIds_;
         }
 
-        //- Return non-const access to the region table-of-contents
-        List<surfRegionIdentifier>& storedRegionToc()
+        //- Return non-const access to the zone table-of-contents
+        List<surfZoneIdentifier>& storedZoneToc()
         {
-            return regionToc_;
+            return zoneToc_;
         }
 
-        //- Set new regions from faceMap
+        //- Set new zones from faceMap
         virtual void remapFaces(const UList<label>& faceMap);
 
 public:
@@ -155,23 +163,23 @@ public:
         UnsortedMeshedSurface();
 
         //- Construct by transferring components
-        //  (points, faces, region ids, region info).
+        //  (points, faces, zone ids, zone info).
         UnsortedMeshedSurface
         (
             const Xfer<pointField>&,
             const Xfer<List<Face> >&,
-            const Xfer<List<label> >& regionIds,
-            const Xfer<surfRegionIdentifierList>&
+            const Xfer<List<label> >& zoneIds,
+            const Xfer<surfZoneIdentifierList>&
         );
 
         //- Construct by transferring points, faces.
-        //  Use region information, or set single default region
+        //  Use zone information, or set single default zone
         UnsortedMeshedSurface
         (
             const Xfer<pointField>&,
             const Xfer<List<Face> >&,
-            const UList<label>& regionSizes = UList<label>::null(),
-            const UList<word>& regionNames = UList<word>::null()
+            const UList<label>& zoneSizes = UList<label>::null(),
+            const UList<word>& zoneNames = UList<word>::null()
         );
 
         //- Construct from a boundary mesh with local points/faces
@@ -200,7 +208,7 @@ public:
         UnsortedMeshedSurface(Istream&);
 
         //- Construct from objectRegistry
-        UnsortedMeshedSurface(const Time&);
+        UnsortedMeshedSurface(const Time&, const word& surfName="");
 
         //- Construct as copy
         UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
@@ -264,37 +272,37 @@ public:
             return ParentType::size();
         }
 
-        //- Reset size of face and region list
+        //- Reset size of face and zone list
         void setSize(const label);
 
-        //- Return const access to the regions ids
-        const List<label>& regionIds() const
+        //- Return const access to the zone ids
+        const List<label>& zoneIds() const
         {
-            return regionIds_;
+            return zoneIds_;
         }
 
-        //- Return const access to the region table-of-contents
-        const List<surfRegionIdentifier>& regionToc() const
+        //- Return const access to the zone table-of-contents
+        const List<surfZoneIdentifier>& zoneToc() const
         {
-            return regionToc_;
+            return zoneToc_;
         }
 
-        //- Sort faces according to region.
-        //  Returns a surfRegionList and sets faceMap to index within faces()
-        surfRegionList sortedRegions(labelList& faceMap) const;
+        //- Sort faces according to zone.
+        //  Returns a surfZoneList and sets faceMap to index within faces()
+        surfZoneList sortedZones(labelList& faceMap) const;
 
-        //- Set regions to 0 and set a single region
+        //- Set zones to 0 and set a single zone
         //  Optionally with a specific name
-        void oneRegion(const word& name = word::null);
+        void oneZone(const word& name = word::null);
 
-        //- Set region ids and regions
-        void setRegions(const surfRegionList&);
+        //- Set zone ids and zones
+        void setZones(const surfZoneList&);
 
-        //- Set region ids and regions
-        void setRegions(const UList<label>& sizes, const UList<word>& names);
+        //- Set zone ids and zones
+        void setZones(const UList<label>& sizes, const UList<word>& names);
 
-        //- Set region ids and set regions with default names
-        void setRegions(const UList<label>& sizes);
+        //- Set zone ids and zones with default names
+        void setZones(const UList<label>& sizes);
 
 
     // Edit
@@ -317,12 +325,12 @@ public:
             const labelHashSet& include
         ) const;
 
-        //- Transfer components (points, faces, region ids).
+        //- Transfer components (points, faces, zone ids).
         virtual void reset
         (
             const Xfer<pointField>&,
             const Xfer<List<Face> >&,
-            const Xfer<List<label> >& regionIds = Xfer<List<label> >::null()
+            const Xfer<List<label> >& zoneIds = Xfer<List<label> >::null()
         );
 
         //- Transfer the contents of the argument and annull the argument
@@ -331,6 +339,9 @@ public:
         //- Transfer the contents of the argument and annull the argument
         void transfer(MeshedSurface<Face>&);
 
+        //- Transfer contents to the Xfer container
+        Xfer< UnsortedMeshedSurface<Face> > xfer();
+
 
     // Read
 
@@ -353,7 +364,7 @@ public:
         }
 
         //- Write to database
-        void write(const Time&) const;
+        void write(const Time&, const word& surfName="") const;
 
 
     // Member operators
diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C
index 70049bd020a47332c156b5a500cb5914f5a44ce2..391f0dc83bddf316f8b1487bad13f6f37bf7100a 100644
--- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C
+++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C
@@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
     const List<Face>& faceLst = this->faces();
 
     labelList faceMap;
-    surfRegionList regionLst = sortedRegions(faceMap);
+    surfZoneList zoneLst = sortedZones(faceMap);
 
     // just emit some information until we get a nice IOobject
     IOobject::writeBanner(os);
     os  << "// OpenFOAM Surface Format" << nl
         << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
-        << "// regions:" << nl
-        << regionLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
+        << "// zones:" << nl
+        << zoneLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        regionLst[regionI].writeDict(os);
+        zoneLst[zoneI].writeDict(os);
     }
     os  << decrIndent << token::END_LIST << nl;
 
@@ -74,12 +74,12 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
     os  << faceLst.size() << nl << token::BEGIN_LIST << nl;
 
     label faceI = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        // Print all faces belonging to this region
-        const surfRegion& reg = regionLst[regionI];
+        // Print all faces belonging to this zone
+        const surfZone& zone = zoneLst[zoneI];
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             os << faceLst[faceMap[faceI++]] << nl;
         }
diff --git a/src/surfMesh/surfFields/surfFields.C b/src/surfMesh/surfFields/surfFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..57c295c397dac1a1eabaa8847938326fc373a371
--- /dev/null
+++ b/src/surfMesh/surfFields/surfFields.C
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+template<>
+const word surfLabelField::typeName("surfLabelField");
+
+template<>
+const word surfScalarField::typeName("surfScalarField");
+
+template<>
+const word surfVectorField::typeName("surfVectorField");
+
+template<>
+const word surfSphericalTensorField::typeName("surfSphericalTensorField");
+
+template<>
+const word surfSymmTensorField::typeName("surfSymmTensorField");
+
+template<>
+const word surfTensorField::typeName("surfTensorField");
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfFields/surfFields.H b/src/surfMesh/surfFields/surfFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..e016bbe04dbc8f2e39eebf0b2e9dee2d811b68fc
--- /dev/null
+++ b/src/surfMesh/surfFields/surfFields.H
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfFields
+
+Description
+    Fields for surfMesh
+
+SourceFiles
+    surfFields.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfFields_H
+#define surfFields_H
+
+#include "DimensionedField.H"
+#include "surfGeoMesh.H"
+#include "surfFieldsFwd.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfFields/surfFieldsFwd.H b/src/surfMesh/surfFields/surfFieldsFwd.H
new file mode 100644
index 0000000000000000000000000000000000000000..e1457d2bd08b0c79249c4d5cf681bee9c2487e04
--- /dev/null
+++ b/src/surfMesh/surfFields/surfFieldsFwd.H
@@ -0,0 +1,59 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfFieldsFwd_H
+#define surfFieldsFwd_H
+
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+class surfGeoMesh;
+
+template<class Type, class GeoMesh>
+class DimensionedField;
+
+typedef DimensionedField<label, surfGeoMesh>  surfLabelField;
+typedef DimensionedField<scalar, surfGeoMesh> surfScalarField;
+typedef DimensionedField<vector, surfGeoMesh> surfVectorField;
+typedef DimensionedField<sphericalTensor, surfGeoMesh> surfSphericalTensorField;
+typedef DimensionedField<symmTensor, surfGeoMesh> surfSymmTensorField;
+typedef DimensionedField<tensor, surfGeoMesh> surfTensorField;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfFields/surfGeoMesh.H b/src/surfMesh/surfFields/surfGeoMesh.H
new file mode 100644
index 0000000000000000000000000000000000000000..8ced148e4fd3d73e16566c5453a39af5a7dceae5
--- /dev/null
+++ b/src/surfMesh/surfFields/surfGeoMesh.H
@@ -0,0 +1,91 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfGeoMesh
+
+Description
+    The surfMesh GeoMesh (for holding fields).
+
+    Similar to the volGeoMesh used for the Finite Volume discretization.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfGeoMesh_H
+#define surfGeoMesh_H
+
+#include "GeoMesh.H"
+#include "surfMesh.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                         Class surfGeoMesh Declaration
+\*---------------------------------------------------------------------------*/
+
+class surfGeoMesh
+:
+    public GeoMesh<surfMesh>
+{
+
+public:
+
+    // Constructors
+
+        //- Construct from surfMesh reference
+        explicit surfGeoMesh(const surfMesh& mesh)
+        :
+            GeoMesh<surfMesh>(mesh)
+        {}
+
+
+    // Member Functions
+
+        //- Return size
+        static label size(const surfMesh& mesh)
+        {
+            return mesh.nFaces();
+        }
+
+        //- Return size
+        label size() const
+        {
+            return size(mesh_);
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfMesh/surfMesh.C b/src/surfMesh/surfMesh/surfMesh.C
new file mode 100644
index 0000000000000000000000000000000000000000..c6166345da5b69bf32179e404f4df298bc27bdf6
--- /dev/null
+++ b/src/surfMesh/surfMesh/surfMesh.C
@@ -0,0 +1,415 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfMesh.H"
+#include "Time.H"
+#include "cellIOList.H"
+#include "SubList.H"
+#include "OSspecific.H"
+#include "MeshedSurface.H"
+#include "demandDrivenData.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+defineTypeNameAndDebug(Foam::surfMesh, 0);
+
+Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::surfMesh::oneZone()
+{
+    word zoneName;
+
+    if (surfZones_.size())
+    {
+        zoneName = surfZones_[0].name();
+    }
+    if (zoneName.empty())
+    {
+        zoneName = "zone0";
+    }
+
+    // set single default zone
+    surfZones_.setSize(1);
+    surfZones_[0] = surfZone
+    (
+        zoneName,
+        nFaces(),       // zone size
+        0,              // zone start
+        0               // zone index
+    );
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+
+Foam::surfMesh::surfMesh(const IOobject& io, const word& surfName)
+:
+    surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
+    surfMeshAllocator
+    (
+        IOobject
+        (
+            "points",
+            time().findInstance(meshDir(), "points"),
+            meshSubDir,
+            *this,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        ),
+        IOobject
+        (
+            "faces",
+            time().findInstance(meshDir(), "faces"),
+            meshSubDir,
+            *this,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        )
+    ),
+    MeshReference(storedFaces_, storedPoints_),
+    surfZones_
+    (
+        IOobject
+        (
+            "surfZones",
+            time().findInstance(meshDir(), "surfZones"),
+            meshSubDir,
+            *this,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        )
+    )
+{}
+
+
+Foam::surfMesh::surfMesh
+(
+    const IOobject& io,
+    const Xfer<pointField>& pointLst,
+    const Xfer<faceList>& faceLst,
+    const word& surfName
+)
+:
+    surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
+    surfMeshAllocator
+    (
+        IOobject
+        (
+            "points",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        pointLst,
+        IOobject
+        (
+            "faces",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        faceLst
+    ),
+    MeshReference(storedFaces_, storedPoints_),
+    surfZones_
+    (
+        IOobject
+        (
+            "surfZones",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        )
+    )
+{}
+
+
+Foam::surfMesh::surfMesh
+(
+    const IOobject& io,
+    const Xfer< MeshedSurface<face> >& surf,
+    const word& surfName
+)
+:
+    surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
+    surfMeshAllocator
+    (
+        IOobject
+        (
+            "points",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        pointField(),
+        IOobject
+        (
+            "faces",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        faceList()
+    ),
+    MeshReference(storedFaces_, storedPoints_),
+    surfZones_
+    (
+        IOobject
+        (
+            "surfZones",
+            instance(),
+            meshSubDir,
+            *this,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        surfZoneList()
+    )
+{
+    // We can also send Xfer<..>::null just to force initialization
+    if (&surf)
+    {
+        transfer(surf());
+    }
+}
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::surfMesh::~surfMesh()
+{
+    //    clearOut();
+    //    resetMotion();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::surfMesh::resetPrimitives
+(
+    const Xfer<pointField>& points,
+    const Xfer<faceList>& faces,
+    const Xfer<surfZoneList>& zones,
+    const bool validate
+)
+{
+    // Clear addressing.
+    MeshReference::clearGeom();
+
+    // Take over new primitive data.
+    // Optimized to avoid overwriting data at all
+    if (&points)
+    {
+        storedPoints_.transfer(points());
+    }
+
+    if (&faces)
+    {
+        storedFaces_.transfer(faces());
+    }
+
+    if (&zones)
+    {
+        surfZones_.transfer(zones());
+    }
+
+    if (validate)
+    {
+        checkZones();
+    }
+}
+
+
+void Foam::surfMesh::transfer
+(
+    MeshedSurface<face>& surf
+)
+{
+    // Clear addressing.
+    MeshReference::clearGeom();
+
+    storedPoints_.transfer(surf.storedPoints());
+    storedFaces_.transfer(surf.storedFaces());
+    surfZones_.transfer(surf.storedZones());
+}
+
+
+Foam::Xfer< Foam::MeshedSurface<Foam::face> >
+Foam::surfMesh::xfer()
+{
+    Xfer< MeshedSurface<face> > xf;
+
+    xf().storedPoints().transfer(storedPoints_);
+    xf().storedFaces().transfer(storedFaces_);
+    xf().storedZones().transfer(surfZones_);
+
+    // Clear addressing.
+    MeshReference::clearGeom();
+
+    return xf;
+}
+
+
+void Foam::surfMesh::rename(const word& newName)
+{
+    FatalErrorIn
+    (
+        "surfMesh::rename(const word&)\n"
+    )
+        << "rename does not work correctly\n";
+}
+
+
+
+Foam::fileName Foam::surfMesh::meshDir() const
+{
+    return dbDir()/meshSubDir;
+}
+
+
+const Foam::fileName& Foam::surfMesh::pointsInstance() const
+{
+    return storedPoints_.instance();
+}
+
+
+const Foam::fileName& Foam::surfMesh::facesInstance() const
+{
+    return storedFaces_.instance();
+}
+
+
+Foam::label Foam::surfMesh::nPoints() const
+{
+    return storedPoints_.size();
+}
+
+Foam::label Foam::surfMesh::nFaces() const
+{
+    return storedFaces_.size();
+}
+
+const Foam::pointField& Foam::surfMesh::points() const
+{
+    return storedPoints_;
+}
+
+const Foam::faceList& Foam::surfMesh::faces() const
+{
+    return storedFaces_;
+}
+
+void Foam::surfMesh::checkZones()
+{
+    // extra safety, ensure we have at some zones
+    // and they cover all the faces - fix start silently
+    if (surfZones_.size() <= 1)
+    {
+        oneZone();
+    }
+    else
+    {
+        label count = 0;
+        forAll(surfZones_, zoneI)
+        {
+            surfZones_[zoneI].start() = count;
+            count += surfZones_[zoneI].size();
+        }
+
+        if (count < nFaces())
+        {
+            WarningIn
+            (
+                "surfMesh::checkZones()\n"
+            )
+                << "more faces " << nFaces() << " than zones " << count
+                << " ... extending final zone"
+                << endl;
+
+            surfZones_[surfZones_.size()-1].size() += count - nFaces();
+        }
+        else if (count > size())
+        {
+            FatalErrorIn
+            (
+                "surfMesh::checkZones()\n"
+            )
+                << "more zones " << count << " than faces " << nFaces()
+                << exit(FatalError);
+        }
+    }
+}
+
+
+// Add boundary patches. Constructor helper
+void Foam::surfMesh::addZones
+(
+    const surfZoneList& zones,
+    const bool validate
+)
+{
+    surfZones_.setSize(zones.size());
+
+    forAll(surfZones_, zoneI)
+    {
+        surfZones_[zoneI] = surfZone(zones[zoneI], zoneI);
+    }
+
+    if (validate)
+    {
+        checkZones();
+    }
+}
+
+
+// Remove all files and some subdirs (eg, sets)
+void Foam::surfMesh::removeFiles(const fileName& instanceDir) const
+{
+    fileName meshFilesPath = db().path()/instanceDir/meshSubDir;
+
+    rm(meshFilesPath/"points");
+    rm(meshFilesPath/"faces");
+    rm(meshFilesPath/"surfZones");
+}
+
+void Foam::surfMesh::removeFiles() const
+{
+    removeFiles(instance());
+}
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfMesh/surfMesh.H b/src/surfMesh/surfMesh/surfMesh.H
new file mode 100644
index 0000000000000000000000000000000000000000..358620fd61783225cec6bcbf1c36270087c88684
--- /dev/null
+++ b/src/surfMesh/surfMesh/surfMesh.H
@@ -0,0 +1,348 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfMesh
+
+Description
+    A surface mesh consisting of general polygon faces.
+
+SourceFiles
+    surfMesh.C
+    surfMeshClear.C
+    surfMeshIO.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfMesh_H
+#define surfMesh_H
+
+#include "surfaceRegistry.H"
+#include "PrimitivePatch.H"
+#include "pointField.H"
+#include "faceList.H"
+#include "pointIOField.H"
+#include "faceIOList.H"
+#include "labelIOList.H"
+#include "surfZoneIOList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+template<class Face>
+class MeshedSurface;
+
+/*---------------------------------------------------------------------------*\
+                      Class surfMeshAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A helper class for storing points and faces
+class surfMeshAllocator
+{
+protected:
+    pointIOField storedPoints_;
+    faceIOList   storedFaces_;
+
+    surfMeshAllocator(const IOobject& ioPoints, const IOobject& ioFaces)
+    :
+        storedPoints_(ioPoints),
+        storedFaces_(ioFaces)
+    {}
+
+    surfMeshAllocator
+    (
+        const IOobject& ioPoints,
+        const pointField& points,
+        const IOobject& ioFaces,
+        const faceList& faces
+    )
+    :
+        storedPoints_(ioPoints, points),
+        storedFaces_(ioFaces, faces)
+    {}
+
+    surfMeshAllocator
+    (
+        const IOobject& ioPoints,
+        const Xfer<pointField>& points,
+        const IOobject& ioFaces,
+        const Xfer<faceList>& faces
+    )
+    :
+        storedPoints_(ioPoints, points),
+        storedFaces_(ioFaces, faces)
+    {}
+
+};
+
+
+
+/*---------------------------------------------------------------------------*\
+                          Class surfMesh Declaration
+\*---------------------------------------------------------------------------*/
+
+class surfMesh
+:
+    public surfaceRegistry,
+    public surfMeshAllocator,
+    public PrimitivePatch<face, ::Foam::UList, const pointField&, point>
+{
+
+public:
+
+    // Public data types
+
+        //- Enumeration defining the state of the mesh after a read update.
+        //  Used for post-processing applications, where the mesh
+        //  needs to update based on the files written in time
+        //  directores
+        enum readUpdateState
+        {
+            UNCHANGED,
+            POINTS_MOVED,
+            TOPO_CHANGE,
+            TOPO_PATCH_CHANGE
+        };
+
+
+private:
+
+    // Private typedefs
+
+        typedef PrimitivePatch
+        <
+            face,
+            ::Foam::UList,
+            const pointField&,
+            point
+        >
+        MeshReference;
+
+    // Permanent data
+
+        // Zoning information
+
+           //- Face zones
+           surfZoneIOList surfZones_;
+
+
+    // Private member functions
+
+        //- Set a single zone
+        void oneZone();
+
+        //- Disallow construct as copy
+        surfMesh(const surfMesh&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const surfMesh&);
+
+protected:
+
+    // Protected Member Functions
+
+        //- Non-const access to global points
+        pointIOField& storedPoints()
+        {
+            return surfMeshAllocator::storedPoints_;
+        }
+
+        //- Non-const access to the faces
+        faceIOList& storedFaces()
+        {
+            return surfMeshAllocator::storedFaces_;
+        }
+
+        //- Non-const access to the zones
+        surfZoneIOList& storedZones()
+        {
+            return surfZones_;
+        }
+
+public:
+
+    // Public typedefs
+
+    typedef surfMesh Mesh;
+
+    //- Placeholder only, but do not remove - it is needed for GeoMesh
+    typedef bool BoundaryMesh;
+
+
+    //- Runtime type information
+    TypeName("surfMesh");
+
+    //- Return the mesh sub-directory name (normally "surfMesh")
+    static word meshSubDir;
+
+    // Constructors
+
+        //- Construct from IOobject, with alternative surface name
+        explicit surfMesh(const IOobject&, const word& surfName="");
+
+        //- Construct by transferring components (points, faces) without zones.
+        //  surfZones are added using addZones() member function
+        surfMesh
+        (
+            const IOobject&,
+            const Xfer<pointField>&,
+            const Xfer<faceList>&,
+            const word& surfName=""
+        );
+
+        //- Construct copy/move from MeshedSurface
+        surfMesh
+        (
+            const IOobject&,
+            const Xfer< MeshedSurface<face> >& surf,
+            const word& surfName=""
+        );
+
+    // Destructor
+
+        virtual ~surfMesh();
+
+
+    // Member Functions
+
+        // Database
+
+            //- Return the local mesh directory (dbDir()/meshSubDir)
+            fileName meshDir() const;
+
+            //- Return the current instance directory for points
+            //  Used in the consruction of geometric mesh data dependent
+            //  on points
+            const fileName& pointsInstance() const;
+
+            //- Return the current instance directory for faces
+            const fileName& facesInstance() const;
+
+            //- Set the instance for mesh files
+            void setInstance(const fileName&);
+
+
+        // Access
+
+            //- Return raw points
+            virtual label nPoints() const;
+
+            //- Return raw faces
+            virtual label nFaces() const;
+
+            //- Return number of faces
+            virtual label size() const
+            {
+                return nFaces();
+            }
+
+
+            //- Return raw points
+            virtual const pointField& points() const;
+
+            //- Return raw faces
+            virtual const faceList& faces() const;
+
+            //- Return surface zones
+            const surfZoneList& surfZones() const
+            {
+                return surfZones_;
+            }
+
+            //- Return non-const access to the zones
+            surfZoneList& surfZones()
+            {
+                return surfZones_;
+            }
+
+            //- Check the surface zone definitions
+            void checkZones();
+
+            //- Add surface zones patches
+            void addZones
+            (
+                const List<surfZone>&,
+                const bool validate = true
+            );
+
+            //- Update the mesh based on the mesh files saved in
+            //  time directories
+            virtual readUpdateState readUpdate();
+
+            //- Update the mesh corresponding to given map
+
+            //- Remove surface zones
+            void removeZones();
+
+            //- Rename surface
+            virtual void rename(const word&);
+
+            //- Reset mesh primitive data.
+            void resetPrimitives
+            (
+                const Xfer<pointField>& points,
+                const Xfer<faceList>& faces,
+                const Xfer<surfZoneList>& zones,
+                const bool validate = true
+            );
+
+
+            //- Transfer the contents of the argument and annull the argument
+            void transfer(MeshedSurface<face>&);
+
+        //  Storage management
+
+            //- Transfer contents to the Xfer container as a MeshedSurface
+            Xfer< MeshedSurface<face> > xfer();
+
+            //- Clear geometry
+            void clearGeom();
+
+            //- Clear addressing
+            void clearAddressing();
+
+            //- Clear all geometry and addressing unnecessary for CFD
+            void clearOut();
+
+            //- Clear primitive data (points, faces and cells)
+            void clearPrimitives();
+
+            //- Remove all files from mesh instance
+            void removeFiles(const fileName& instanceDir) const;
+
+            //- Remove all files from mesh instance()
+            void removeFiles() const;
+};
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfMesh/surfMeshClear.C b/src/surfMesh/surfMesh/surfMeshClear.C
new file mode 100644
index 0000000000000000000000000000000000000000..92611ef150e0e6089446c99807c169cd4dbfd780
--- /dev/null
+++ b/src/surfMesh/surfMesh/surfMeshClear.C
@@ -0,0 +1,84 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfMesh.H"
+#include "globalMeshData.H"
+#include "demandDrivenData.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::surfMesh::removeZones()
+{
+    if (debug)
+    {
+        Info<< "void surfMesh::removeZones(): "
+            << "Removing surface zones."
+            << endl;
+    }
+
+    // Remove the surface zones
+    surfZones_.clear();
+
+    clearOut();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::surfMesh::clearGeom()
+{
+    if (debug)
+    {
+        Info<< "void surfMesh::clearGeom() : "
+            << "clearing geometric data"
+            << endl;
+    }
+
+    MeshReference::clearGeom();
+}
+
+
+void Foam::surfMesh::clearAddressing()
+{
+    if (debug)
+    {
+        Info<< "void surfMesh::clearAddressing() : "
+            << "clearing topology"
+            << endl;
+    }
+
+    MeshReference::clearPatchMeshAddr();
+}
+
+
+void Foam::surfMesh::clearOut()
+{
+    clearGeom();
+    clearAddressing();
+}
+
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfMesh/surfMeshIO.C b/src/surfMesh/surfMesh/surfMeshIO.C
new file mode 100644
index 0000000000000000000000000000000000000000..9665b4e20cd715bb052426c54f63faafd5231be1
--- /dev/null
+++ b/src/surfMesh/surfMesh/surfMeshIO.C
@@ -0,0 +1,207 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfMesh.H"
+#include "Time.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::surfMesh::setInstance(const fileName& inst)
+{
+    if (debug)
+    {
+        Info<< "void surfMesh::setInstance(const fileName& inst) : "
+            << "Resetting file instance to " << inst << endl;
+    }
+
+    storedPoints_.writeOpt() = IOobject::AUTO_WRITE;
+    storedPoints_.instance() = inst;
+
+    storedFaces_.writeOpt() = IOobject::AUTO_WRITE;
+    storedFaces_.instance() = inst;
+
+    surfZones_.writeOpt() = IOobject::AUTO_WRITE;
+    surfZones_.instance() = inst;
+}
+
+
+Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
+{
+    if (debug)
+    {
+        Info<< "surfMesh::readUpdateState surfMesh::readUpdate() : "
+            << "Updating mesh based on saved data." << endl;
+    }
+
+    // Find point and face instances
+    fileName pointsInst(time().findInstance(meshDir(), "points"));
+    fileName facesInst(time().findInstance(meshDir(), "faces"));
+
+    if (debug)
+    {
+        Info<< "Points instance: old = " << pointsInstance()
+            << " new = " << pointsInst << nl
+            << "Faces instance: old = " << facesInstance()
+            << " new = " << facesInst << endl;
+    }
+
+    if (facesInst != facesInstance())
+    {
+        // Topological change
+        if (debug)
+        {
+            Info << "Topological change" << endl;
+        }
+
+        clearOut();
+
+        // Set instance to new instance.
+        // Note points instance can differ from faces instance.
+        setInstance(facesInst);
+        storedPoints_.instance() = pointsInst;
+
+        storedPoints_ = pointIOField
+        (
+            IOobject
+            (
+                "points",
+                pointsInst,
+                meshSubDir,
+                *this,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        storedFaces_ = faceIOList
+        (
+            IOobject
+            (
+                "faces",
+                facesInst,
+                meshSubDir,
+                *this,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        // synchronize sizes and references?
+//        MeshReference::operator=(MeshReference(storedFaces_, storedPoints_));
+
+        // Reset the surface zones
+        surfZoneIOList newZones
+        (
+            IOobject
+            (
+                "surfZones",
+                facesInst,
+                meshSubDir,
+                *this,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        // Check that zone types and names are unchanged
+        bool zonesChanged = false;
+
+        if (surfZones_.size() != newZones.size())
+        {
+            zonesChanged = true;
+        }
+        else
+        {
+            forAll (surfZones_, zoneI)
+            {
+                if (surfZones_[zoneI].name() != newZones[zoneI].name())
+                {
+                    zonesChanged = true;
+                    break;
+                }
+            }
+        }
+
+        surfZones_.transfer(newZones);
+
+        if (zonesChanged)
+        {
+            WarningIn("surfMesh::readUpdateState surfMesh::readUpdate()")
+                << "Number of zones has changed.  This may have "
+                << "unexpected consequences.  Proceed with care." << endl;
+
+            return surfMesh::TOPO_PATCH_CHANGE;
+        }
+        else
+        {
+            return surfMesh::TOPO_CHANGE;
+        }
+
+    }
+    else if (pointsInst != pointsInstance())
+    {
+        // Points moved
+        if (debug)
+        {
+            Info << "Point motion" << endl;
+        }
+
+        clearGeom();
+
+        storedPoints_.instance() = pointsInst;
+
+        storedPoints_ = pointIOField
+        (
+            IOobject
+            (
+                "points",
+                pointsInst,
+                meshSubDir,
+                *this,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        return surfMesh::POINTS_MOVED;
+    }
+    else
+    {
+        if (debug)
+        {
+            Info << "No change" << endl;
+        }
+    }
+
+    return surfMesh::UNCHANGED;
+}
+
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfPointFields/surfPointFields.C b/src/surfMesh/surfPointFields/surfPointFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..871ecd1524d82af9d41f0327252fd7d8f36642cb
--- /dev/null
+++ b/src/surfMesh/surfPointFields/surfPointFields.C
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfPointFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+template<>
+const word surfPointLabelField::typeName("surfPointLabelField");
+
+template<>
+const word surfPointScalarField::typeName("surfPointScalarField");
+
+template<>
+const word surfPointVectorField::typeName("surfPointVectorField");
+
+template<>
+const word surfPointSphericalTensorField::typeName("surfPointSphericalTensorField");
+
+template<>
+const word surfPointSymmTensorField::typeName("surfPointSymmTensorField");
+
+template<>
+const word surfPointTensorField::typeName("surfPointTensorField");
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfPointFields/surfPointFields.H b/src/surfMesh/surfPointFields/surfPointFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..855cc4efcaee5d83e46a07631624d99591ebefef
--- /dev/null
+++ b/src/surfMesh/surfPointFields/surfPointFields.H
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfPointFields
+
+Description
+    Point fields for surfMesh
+
+SourceFiles
+    surfPointFields.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfPointFields_H
+#define surfPointFields_H
+
+#include "DimensionedField.H"
+#include "surfPointGeoMesh.H"
+#include "surfPointFieldsFwd.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfPointFields/surfPointFieldsFwd.H b/src/surfMesh/surfPointFields/surfPointFieldsFwd.H
new file mode 100644
index 0000000000000000000000000000000000000000..62cc746df4a9973aedd8a554df688e113f350d0b
--- /dev/null
+++ b/src/surfMesh/surfPointFields/surfPointFieldsFwd.H
@@ -0,0 +1,65 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfPointFieldsFwd_H
+#define surfPointFieldsFwd_H
+
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+class surfPointGeoMesh;
+
+template<class Type, class GeoMesh>
+class DimensionedField;
+
+typedef DimensionedField<label, surfPointGeoMesh>
+    surfPointLabelField;
+typedef DimensionedField<scalar, surfPointGeoMesh>
+    surfPointScalarField;
+typedef DimensionedField<vector, surfPointGeoMesh>
+    surfPointVectorField;
+typedef DimensionedField<sphericalTensor, surfPointGeoMesh>
+    surfPointSphericalTensorField;
+typedef DimensionedField<symmTensor, surfPointGeoMesh>
+    surfPointSymmTensorField;
+typedef DimensionedField<tensor, surfPointGeoMesh>
+    surfPointTensorField;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfPointFields/surfPointGeoMesh.H b/src/surfMesh/surfPointFields/surfPointGeoMesh.H
new file mode 100644
index 0000000000000000000000000000000000000000..188b3dd6bda406d8e4cdce313c2eb2f55706f3f3
--- /dev/null
+++ b/src/surfMesh/surfPointFields/surfPointGeoMesh.H
@@ -0,0 +1,91 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfPointGeoMesh
+
+Description
+    The surfMesh GeoMesh (for holding fields).
+
+    Similar to surfGeoMesh, but refers to the surface points.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfPointGeoMesh_H
+#define surfPointGeoMesh_H
+
+#include "GeoMesh.H"
+#include "surfMesh.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                      Class surfPointGeoMesh Declaration
+\*---------------------------------------------------------------------------*/
+
+class surfPointGeoMesh
+:
+    public GeoMesh<surfMesh>
+{
+
+public:
+
+    // Constructors
+
+        //- Construct from surfMesh reference
+        explicit surfPointGeoMesh(const surfMesh& mesh)
+        :
+            GeoMesh<surfMesh>(mesh)
+        {}
+
+
+    // Member Functions
+
+        //- Return size
+        static label size(const surfMesh& mesh)
+        {
+            return mesh.nPoints();
+        }
+
+        //- Return size
+        label size() const
+        {
+            return size(mesh_);
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfRegion/surfRegion/surfRegion.C b/src/surfMesh/surfZone/surfZone/surfZone.C
similarity index 64%
rename from src/surfMesh/surfRegion/surfRegion/surfRegion.C
rename to src/surfMesh/surfZone/surfZone/surfZone.C
index 8c7e3a23a3189830d8382ba0818f6237d7e4e07f..b10d1737c60ee6510611cac356552ed94be88b10 100644
--- a/src/surfMesh/surfRegion/surfRegion/surfRegion.C
+++ b/src/surfMesh/surfZone/surfZone/surfZone.C
@@ -26,28 +26,27 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#include "surfRegion.H"
+#include "surfZone.H"
 #include "dictionary.H"
 #include "word.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-defineTypeNameAndDebug(Foam::surfRegion, 0);
-
+defineTypeNameAndDebug(Foam::surfZone, 0);
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::surfRegion::surfRegion()
+Foam::surfZone::surfZone()
 :
-    surfRegionIdentifier(),
+    surfZoneIdentifier(),
     size_(0),
     start_(0)
 {}
 
 
 
-Foam::surfRegion::surfRegion
+Foam::surfZone::surfZone
 (
     const word& name,
     const label size,
@@ -56,68 +55,68 @@ Foam::surfRegion::surfRegion
     const word& geometricType
 )
 :
-    surfRegionIdentifier(name, index, geometricType),
+    surfZoneIdentifier(name, index, geometricType),
     size_(size),
     start_(start)
 {}
 
 
-Foam::surfRegion::surfRegion(Istream& is, const label index)
+Foam::surfZone::surfZone(Istream& is, const label index)
 :
-    surfRegionIdentifier(),
+    surfZoneIdentifier(),
     size_(0),
     start_(0)
 {
     word name(is);
     dictionary dict(is);
 
-    operator=(surfRegion(name, dict, index));
+    operator=(surfZone(name, dict, index));
 }
 
 
-Foam::surfRegion::surfRegion
+Foam::surfZone::surfZone
 (
     const word& name,
     const dictionary& dict,
     const label index
 )
 :
-    surfRegionIdentifier(name, dict, index),
+    surfZoneIdentifier(name, dict, index),
     size_(readLabel(dict.lookup("nFaces"))),
     start_(readLabel(dict.lookup("startFace")))
 {}
 
 
-Foam::surfRegion::surfRegion(const surfRegion& reg)
+Foam::surfZone::surfZone(const surfZone& zone)
 :
-    surfRegionIdentifier(reg, reg.index()),
-    size_(reg.size()),
-    start_(reg.start())
+    surfZoneIdentifier(zone, zone.index()),
+    size_(zone.size()),
+    start_(zone.start())
 {}
 
 
-Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
+Foam::surfZone::surfZone(const surfZone& zone, const label index)
 :
-    surfRegionIdentifier(reg, index),
-    size_(reg.size()),
-    start_(reg.start())
+    surfZoneIdentifier(zone, index),
+    size_(zone.size()),
+    start_(zone.start())
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void Foam::surfRegion::write(Ostream& os) const
+void Foam::surfZone::write(Ostream& os) const
 {
     writeDict(os);
 }
 
 
-void Foam::surfRegion::writeDict(Ostream& os) const
+void Foam::surfZone::writeDict(Ostream& os) const
 {
     os  << indent << name() << nl
         << indent << token::BEGIN_BLOCK << incrIndent << nl;
 
-    surfRegionIdentifier::write(os);
+    surfZoneIdentifier::write(os);
     os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
     os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
 
@@ -127,38 +126,38 @@ void Foam::surfRegion::writeDict(Ostream& os) const
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-bool Foam::surfRegion::operator!=(const surfRegion& reg) const
+bool Foam::surfZone::operator!=(const surfZone& rhs) const
 {
-    return !(*this == reg);
+    return !(*this == rhs);
 }
 
 
-bool Foam::surfRegion::operator==(const surfRegion& reg) const
+bool Foam::surfZone::operator==(const surfZone& rhs) const
 {
     return
     (
-        (geometricType() == reg.geometricType())
-     && (size() == reg.size())
-     && (start() == reg.start())
+        size() == rhs.size()
+     && start() == rhs.start()
+     && geometricType() == rhs.geometricType()
     );
 }
 
 
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
-Foam::Istream& Foam::operator>>(Istream& is, surfRegion& reg)
+Foam::Istream& Foam::operator>>(Istream& is, surfZone& zone)
 {
-    reg = surfRegion(is, 0);
+    zone = surfZone(is, 0);
 
-    is.check("Istream& operator>>(Istream&, surfRegion&)");
+    is.check("Istream& operator>>(Istream&, surfZone&)");
     return is;
 }
 
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
+Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone)
 {
-    reg.write(os);
-    os.check("Ostream& operator<<(Ostream&, const surfRegion&");
+    zone.write(os);
+    os.check("Ostream& operator<<(Ostream&, const surfZone&");
     return os;
 }
 
diff --git a/src/surfMesh/surfRegion/surfRegion/surfRegion.H b/src/surfMesh/surfZone/surfZone/surfZone.H
similarity index 69%
rename from src/surfMesh/surfRegion/surfRegion/surfRegion.H
rename to src/surfMesh/surfZone/surfZone/surfZone.H
index 4a5bf629510614f62cb98b67b7c79ccdba2f47e5..f5ea6ec1fa329e4114787ad15a08210d949b2305 100644
--- a/src/surfMesh/surfRegion/surfRegion/surfRegion.H
+++ b/src/surfMesh/surfZone/surfZone/surfZone.H
@@ -23,24 +23,25 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::surfRegion
+    Foam::surfZone
 
 Description
-    A region on a meshed surface.
-    Similar in concept to a faceZone on the surface.
+    A surface zone on a MeshedSurface.
+
+    Similar in concept to a faceZone, but the face list is contiguous.
 
 SourceFiles
-    surfRegion.C
+    surfZone.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef surfRegion_H
-#define surfRegion_H
+#ifndef surfZone_H
+#define surfZone_H
 
 #include "word.H"
 #include "label.H"
 #include "className.H"
-#include "surfRegionIdentifier.H"
+#include "surfZoneIdentifier.H"
 #include "autoPtr.H"
 #include "dictionary.H"
 
@@ -51,18 +52,18 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 
-class surfRegion;
+class surfZone;
 
-Istream& operator>>(Istream&, surfRegion&);
-Ostream& operator<<(Ostream&, const surfRegion&);
+Istream& operator>>(Istream&, surfZone&);
+Ostream& operator<<(Ostream&, const surfZone&);
 
 /*---------------------------------------------------------------------------*\
-                           Class surfRegion Declaration
+                          Class surfZone Declaration
 \*---------------------------------------------------------------------------*/
 
-class surfRegion
+class surfZone
 :
-    public surfRegionIdentifier
+    public surfZoneIdentifier
 {
     // Private data
 
@@ -75,16 +76,16 @@ class surfRegion
 public:
 
     //- Runtime type information
-    ClassName("surfRegion");
+    ClassName("surfZone");
 
 
     // Constructors
 
         //- Construct null
-        surfRegion();
+        surfZone();
 
         //- Construct from components
-        surfRegion
+        surfZone
         (
             const word& name,
             const label size,
@@ -94,10 +95,10 @@ public:
         );
 
         //- Construct from Istream
-        surfRegion(Istream& is, const label index);
+        surfZone(Istream& is, const label index);
 
         //- Construct from dictionary
-        surfRegion
+        surfZone
         (
             const word& name,
             const dictionary& dict,
@@ -105,48 +106,48 @@ public:
         );
 
         //- Construct as copy
-        surfRegion(const surfRegion&);
+        surfZone(const surfZone&);
 
-        //- Construct from another region, resetting the index
-        surfRegion(const surfRegion&, const label index);
+        //- Construct from another zone, resetting the index
+        surfZone(const surfZone&, const label index);
 
         //- Return clone
-        autoPtr<surfRegion> clone() const
+        autoPtr<surfZone> clone() const
         {
-            notImplemented("autoPtr<surfRegion> clone() const");
-            return autoPtr<surfRegion>(NULL);
+            notImplemented("autoPtr<surfZone> clone() const");
+            return autoPtr<surfZone>(NULL);
         }
 
-        static autoPtr<surfRegion> New(Istream& is)
+        static autoPtr<surfZone> New(Istream& is)
         {
             word name(is);
             dictionary dict(is);
 
-            return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
+            return autoPtr<surfZone>(new surfZone(name, dict, 0));
         }
 
 
     // Member Functions
 
-        //- Return start label of this region in the face list
+        //- Return start label of this zone in the face list
         label start() const
         {
             return start_;
         }
 
-        //- Return start label of this region in the face list
+        //- Return start label of this zone in the face list
         label& start()
         {
             return start_;
         }
 
-        //- Return size of this region in the face list
+        //- Return size of this zone in the face list
         label size() const
         {
             return size_;
         }
 
-        //- Return size of this region in the face list
+        //- Return size of this zone in the face list
         label& size()
         {
             return size_;
@@ -161,15 +162,15 @@ public:
 
     // Member Operators
 
-        bool operator!=(const surfRegion&) const;
+        bool operator!=(const surfZone&) const;
 
         //- compare.
-        bool operator==(const surfRegion&) const;
+        bool operator==(const surfZone&) const;
 
     // IOstream Operators
 
-        friend Istream& operator>>(Istream&, surfRegion&);
-        friend Ostream& operator<<(Ostream&, const surfRegion&);
+        friend Istream& operator>>(Istream&, surfZone&);
+        friend Ostream& operator<<(Ostream&, const surfZone&);
 };
 
 
diff --git a/src/surfMesh/surfRegion/surfRegion/surfRegionIOList.C b/src/surfMesh/surfZone/surfZone/surfZoneIOList.C
similarity index 69%
rename from src/surfMesh/surfRegion/surfRegion/surfRegionIOList.C
rename to src/surfMesh/surfZone/surfZone/surfZoneIOList.C
index 731664ae0875ee4e182c01afc10296d06cbeb0bb..0cda4e3069024e713e5d044aaac24e19df824d3c 100644
--- a/src/surfMesh/surfRegion/surfRegion/surfRegionIOList.C
+++ b/src/surfMesh/surfZone/surfZone/surfZoneIOList.C
@@ -24,71 +24,69 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "surfRegionIOList.H"
+#include "surfZoneIOList.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
+defineTypeNameAndDebug(Foam::surfZoneIOList, 0);
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::surfRegionIOList::surfRegionIOList
+Foam::surfZoneIOList::surfZoneIOList
 (
     const IOobject& io
 )
 :
-    surfRegionList(),
+    surfZoneList(),
     regIOobject(io)
 {
     Foam::string functionName =
-        "surfRegionIOList::surfRegionIOList"
+        "surfZoneIOList::surfZoneIOList"
         "(const IOobject& io)";
 
 
     if (readOpt() == IOobject::MUST_READ)
     {
-        surfRegionList& regions = *this;
+        surfZoneList& zones = *this;
 
-        // read polyPatchList
         Istream& is = readStream(typeName);
 
         PtrList<entry> dictEntries(is);
-        regions.setSize(dictEntries.size());
+        zones.setSize(dictEntries.size());
 
         label faceI = 0;
-        forAll(regions, regionI)
+        forAll(zones, zoneI)
         {
-            const dictionary& dict = dictEntries[regionI].dict();
+            const dictionary& dict = dictEntries[zoneI].dict();
 
-            label regionSize = readLabel(dict.lookup("nFaces"));
+            label zoneSize = readLabel(dict.lookup("nFaces"));
             label startFaceI = readLabel(dict.lookup("startFace"));
 
-            regions[regionI] = surfRegion
+            zones[zoneI] = surfZone
             (
-                dictEntries[regionI].keyword(),
-                regionSize,
+                dictEntries[zoneI].keyword(),
+                zoneSize,
                 startFaceI,
-                regionI
+                zoneI
             );
 
             word geoType;
             if (dict.readIfPresent("geometricType", geoType))
             {
-                regions[regionI].geometricType() = geoType;
+                zones[zoneI].geometricType() = geoType;
             }
 
             if (startFaceI != faceI)
             {
                 FatalErrorIn(functionName)
-                    << "Regions are not ordered. Start of region " << regionI
-                    << " does not correspond to sum of preceding regions."
-                    << endl
-                    << "while reading " << io.objectPath()
+                    << "surfZones are not ordered. Start of zone " << zoneI
+                    << " does not correspond to sum of preceding zones." << nl
+                    << "while reading " << io.objectPath() << endl
                     << exit(FatalError);
             }
 
-            faceI += regionSize;
+            faceI += zoneSize;
         }
 
         // Check state of IOstream
@@ -98,21 +96,32 @@ Foam::surfRegionIOList::surfRegionIOList
     }
 }
 
-// Construct from IOObject
-Foam::surfRegionIOList::surfRegionIOList
+
+Foam::surfZoneIOList::surfZoneIOList
+(
+    const IOobject& io,
+    const surfZoneList& zones
+)
+:
+    surfZoneList(zones),
+    regIOobject(io)
+{}
+
+
+Foam::surfZoneIOList::surfZoneIOList
 (
     const IOobject& io,
-    const surfRegionList& regions
+    const Xfer<surfZoneList>& zones
 )
 :
-    surfRegionList(regions),
+    surfZoneList(zones),
     regIOobject(io)
 {}
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-Foam::surfRegionIOList::~surfRegionIOList()
+Foam::surfZoneIOList::~surfZoneIOList()
 {}
 
 
@@ -120,25 +129,25 @@ Foam::surfRegionIOList::~surfRegionIOList()
 
 
 // writeData member function required by regIOobject
-bool Foam::surfRegionIOList::writeData(Ostream& os) const
+bool Foam::surfZoneIOList::writeData(Ostream& os) const
 {
-    os << *this;
+    os  << *this;
     return os.good();
 }
 
 
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIOList& L)
+Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& L)
 {
-    os  << L.size() << nl << token::BEGIN_LIST;
+    os  << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
 
     forAll(L, i)
     {
         L[i].writeDict(os);
     }
 
-    os  << token::END_LIST;
+    os  << decrIndent << token::END_LIST;
 
     return os;
 }
diff --git a/src/surfMesh/surfRegion/surfRegion/surfRegionIOList.H b/src/surfMesh/surfZone/surfZone/surfZoneIOList.H
similarity index 76%
rename from src/surfMesh/surfRegion/surfRegion/surfRegionIOList.H
rename to src/surfMesh/surfZone/surfZone/surfZoneIOList.H
index 0e1abb2785a001a1431e4272679f8d4299f07d79..a386f65fabe03f15e2501b62b80a7506f65bb436 100644
--- a/src/surfMesh/surfRegion/surfRegion/surfRegionIOList.H
+++ b/src/surfMesh/surfZone/surfZone/surfZoneIOList.H
@@ -23,20 +23,20 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::surfRegionIOList
+    Foam::surfZoneIOList
 
 Description
-    IOobject for a surfRegionList
+    IOobject for a surfZoneList
 
 SourceFiles
-    surfRegionIOList.C
+    surfZoneIOList.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef surfRegionIOList_H
-#define surfRegionIOList_H
+#ifndef surfZoneIOList_H
+#define surfZoneIOList_H
 
-#include "surfRegionList.H"
+#include "surfZoneList.H"
 #include "regIOobject.H"
 #include "faceList.H"
 #include "className.H"
@@ -49,12 +49,12 @@ namespace Foam
 // Forward declaration of classes
 
 /*---------------------------------------------------------------------------*\
-                      Class surfRegionIOList Declaration
+                      Class surfZoneIOList Declaration
 \*---------------------------------------------------------------------------*/
 
-class surfRegionIOList
+class surfZoneIOList
 :
-    public surfRegionList,
+    public surfZoneList,
     public regIOobject
 {
     // Private data
@@ -63,29 +63,32 @@ class surfRegionIOList
     // Private Member Functions
 
         //- Disallow default bitwise copy construct
-        surfRegionIOList(const surfRegionIOList&);
+        surfZoneIOList(const surfZoneIOList&);
 
         //- Disallow default bitwise assignment
-        void operator=(const surfRegionIOList&);
+        void operator=(const surfZoneIOList&);
 
 
 public:
 
     //- Runtime type information
-    TypeName("surfRegionIOList");
+    TypeName("surfZoneList");
 
 
     // Constructors
 
         //- Construct from IOobject
-        explicit surfRegionIOList(const IOobject&);
+        explicit surfZoneIOList(const IOobject&);
 
-        //- Construct from IOobject
-        surfRegionIOList(const IOobject&, const surfRegionList&);
+        //- Construct from IOobject and surfZoneList
+        surfZoneIOList(const IOobject&, const surfZoneList&);
+
+        //- Construct from IOobject and surfZoneList
+        surfZoneIOList(const IOobject&, const Xfer<surfZoneList>&);
 
     // Destructor
 
-        ~surfRegionIOList();
+        ~surfZoneIOList();
 
 
     // Member Functions
@@ -102,7 +105,7 @@ public:
 
     // IOstream Operators
 
-        friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
+        friend Ostream& operator<<(Ostream&, const surfZoneIOList&);
 };
 
 
diff --git a/src/surfMesh/surfRegion/surfRegion/surfRegionList.H b/src/surfMesh/surfZone/surfZone/surfZoneList.H
similarity index 90%
rename from src/surfMesh/surfRegion/surfRegion/surfRegionList.H
rename to src/surfMesh/surfZone/surfZone/surfZoneList.H
index a6dd1b0703b1d8e10fa2f6a73acad8444451e4bb..32999524cd091fb5b345a210a661210cd3c7e41d 100644
--- a/src/surfMesh/surfRegion/surfRegion/surfRegionList.H
+++ b/src/surfMesh/surfZone/surfZone/surfZoneList.H
@@ -23,18 +23,18 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Typedef
-    Foam::surfRegionList
+    Foam::surfZoneList
 
 Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef surfRegionList_H
-#define surfRegionList_H
+#ifndef surfZoneList_H
+#define surfZoneList_H
 
-#include "surfRegion.H"
+#include "surfZone.H"
 #include "List.H"
-#include "surfRegionIdentifierList.H"
+#include "surfZoneIdentifierList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -43,7 +43,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-typedef List<surfRegion>  surfRegionList;
+typedef List<surfZone>  surfZoneList;
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.C b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C
similarity index 75%
rename from src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
rename to src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C
index 12ea17658f45485ae334d109c64e6ccd59c9505f..1149bfded33e13c4273119e36374a68cb796a92b 100644
--- a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
+++ b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C
@@ -24,22 +24,22 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "surfRegionIdentifier.H"
+#include "surfZoneIdentifier.H"
 #include "dictionary.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::surfRegionIdentifier::surfRegionIdentifier()
+Foam::surfZoneIdentifier::surfZoneIdentifier()
 :
     name_(word::null),
-    boundaryIndex_(0),
+    index_(0),
     geometricType_(word::null)
 {}
 
 
-Foam::surfRegionIdentifier::surfRegionIdentifier
+Foam::surfZoneIdentifier::surfZoneIdentifier
 (
     const word& name,
     const label index,
@@ -47,12 +47,12 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
 )
 :
     name_(name),
-    boundaryIndex_(index),
+    index_(index),
     geometricType_(geometricType)
 {}
 
 
-Foam::surfRegionIdentifier::surfRegionIdentifier
+Foam::surfZoneIdentifier::surfZoneIdentifier
 (
     const word& name,
     const dictionary& dict,
@@ -60,33 +60,33 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
 )
 :
     name_(name),
-    boundaryIndex_(index)
+    index_(index)
 {
     dict.readIfPresent("geometricType", geometricType_);
 }
 
 
-Foam::surfRegionIdentifier::surfRegionIdentifier
+Foam::surfZoneIdentifier::surfZoneIdentifier
 (
-    const surfRegionIdentifier& p,
+    const surfZoneIdentifier& p,
     const label index
 )
 :
     name_(p.name()),
-    boundaryIndex_(index),
+    index_(index),
     geometricType_(p.geometricType())
 {}
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-Foam::surfRegionIdentifier::~surfRegionIdentifier()
+Foam::surfZoneIdentifier::~surfZoneIdentifier()
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 
-void Foam::surfRegionIdentifier::write(Ostream& os) const
+void Foam::surfZoneIdentifier::write(Ostream& os) const
 {
     if (geometricType_.size())
     {
@@ -98,18 +98,18 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-// bool Foam::surfRegionIdentifier::operator!=
+// bool Foam::surfZoneIdentifier::operator!=
 // (
-//     const surfRegionIdentifier& p
+//     const surfZoneIdentifier& p
 // ) const
 // {
 //     return !(*this == p);
 // }
 //
 //
-// bool Foam::surfRegionIdentifier::operator==
+// bool Foam::surfZoneIdentifier::operator==
 // (
-//     const surfRegionIdentifier& p
+//     const surfZoneIdentifier& p
 // ) const
 // {
 //     return geometricType() == p.geometricType() && name() == p.name();
@@ -118,7 +118,7 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
 
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
-// Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
+// Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& p)
 // {
 //     is >> p.name_ >> p.geometricType_;
 //
@@ -126,12 +126,12 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
 // }
 
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIdentifier& p)
+Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& p)
 {
     p.write(os);
     os.check
     (
-        "Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
+        "Ostream& operator<<(Ostream&, const surfZoneIdentifier&)"
     );
     return os;
 }
diff --git a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.H b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H
similarity index 67%
rename from src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.H
rename to src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H
index a4f0609665397a9e019c1ff7d9f76c87e535f7d4..7b87c3dd30b06434e575884c2b5415606b672846 100644
--- a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifier.H
+++ b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H
@@ -23,23 +23,21 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::surfRegionIdentifier
+    Foam::surfZoneIdentifier
 
 Description
-    An identifier for a region on a meshed surface.
+    An identifier for a surface zone on a meshed surface.
 
     Similar in concept to a faceZone on the surface, but can also have a
-    "geometricType" rather.  Despite the similarity to a 'patch' for
-    volume meshes (with a "physicalType"), the region does not have any
-    patch information per se.
+    "geometricType" as well.
 
 SourceFiles
-    surfRegionIdentifier.C
+    surfZoneIdentifier.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef surfRegionIdentifier_H
-#define surfRegionIdentifier_H
+#ifndef surfZoneIdentifier_H
+#define surfZoneIdentifier_H
 
 #include "word.H"
 #include "label.H"
@@ -54,24 +52,24 @@ class dictionary;
 
 // Forward declaration of friend functions and operators
 
-class surfRegionIdentifier;
-Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
+class surfZoneIdentifier;
+Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
 
 /*---------------------------------------------------------------------------*\
-                    Class surfRegionIdentifier Declaration
+                    Class surfZoneIdentifier Declaration
 \*---------------------------------------------------------------------------*/
 
-class surfRegionIdentifier
+class surfZoneIdentifier
 {
     // Private data
 
-        //- Name of region
+        //- Name of zone
         word name_;
 
-        //- Index of region in surface mesh
-        label boundaryIndex_;
+        //- Index of zone in surface mesh
+        label index_;
 
-        //- Type name of region
+        //- Type name of zone
         mutable word geometricType_;
 
 public:
@@ -79,10 +77,10 @@ public:
     // Constructors
 
         //- Construct null
-        surfRegionIdentifier();
+        surfZoneIdentifier();
 
         //- Construct from components
-        surfRegionIdentifier
+        surfZoneIdentifier
         (
             const word& name,
             const label index,
@@ -91,24 +89,24 @@ public:
         );
 
         //- Construct from dictionary
-        surfRegionIdentifier
+        surfZoneIdentifier
         (
             const word& name,
             const dictionary&,
             const label index
         );
 
-        //- Construct from another region identifier, resetting the index
-        surfRegionIdentifier
+        //- Construct from another zone identifier, resetting the index
+        surfZoneIdentifier
         (
-            const surfRegionIdentifier&,
+            const surfZoneIdentifier&,
             const label index
         );
 
 
     // Destructor
 
-        virtual ~surfRegionIdentifier();
+        virtual ~surfZoneIdentifier();
 
 
     // Member Functions
@@ -125,42 +123,42 @@ public:
             return name_;
         }
 
-        //- Return the geometric type of the region
+        //- Return the geometric type of the zone
         const word& geometricType() const
         {
             return geometricType_;
         }
 
-        //- Return the geometric type of the region for modification
+        //- Return the geometric type of the zone for modification
         word& geometricType()
         {
             return geometricType_;
         }
 
-        //- Return the index of this region in the surface mesh
+        //- Return the index of this zone in the surface mesh
         label index() const
         {
-            return boundaryIndex_;
+            return index_;
         }
 
-        //- Write surfRegionIdentifier as a dictionary
+        //- Write surfZoneIdentifier as a dictionary
         void write(Ostream&) const;
 
-        //- Write surfRegionIdentifier as a dictionary
+        //- Write surfZoneIdentifier as a dictionary
 //        void writeDict(Ostream&) const;
 
 
     // Member Operators
 
-//        bool operator!=(const surfRegionIdentifier&) const;
+//        bool operator!=(const surfZoneIdentifier&) const;
 //
 //        //- compare.
-//        bool operator==(const surfRegionIdentifier&) const;
+//        bool operator==(const surfZoneIdentifier&) const;
 
     // Ostream Operator
 
-        friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
-//        friend Istream& operator>>(Istream&, surfRegionIdentifier&);
+        friend Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
+//        friend Istream& operator>>(Istream&, surfZoneIdentifier&);
 };
 
 
diff --git a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifierList.H b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifierList.H
similarity index 89%
rename from src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifierList.H
rename to src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifierList.H
index 2a8efb0086a19df84ea8c8171d2e58e2eec64c72..7a26d74b9df9034be9d99b094b4487edb61b13af 100644
--- a/src/surfMesh/surfRegion/surfRegionIdentifier/surfRegionIdentifierList.H
+++ b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifierList.H
@@ -23,16 +23,16 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Typedef
-    Foam::surfRegionIdentifierList
+    Foam::surfZoneIdentifierList
 
 Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef surfRegionIdentifierList_H
-#define surfRegionIdentifierList_H
+#ifndef surfZoneIdentifierList_H
+#define surfZoneIdentifierList_H
 
-#include "surfRegionIdentifier.H"
+#include "surfZoneIdentifier.H"
 #include "List.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -42,7 +42,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-typedef List<surfRegionIdentifier>  surfRegionIdentifierList;
+typedef List<surfZoneIdentifier>  surfZoneIdentifierList;
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C
index 1cc11e6c7a0c9a8100278d78d227b2cd075b110b..8347bdeee8f508040163ccd3a7df827868a7765e 100644
--- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C
@@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
             << exit(FatalError);
     }
 
-    // # of kids is the # of regions
+    // # of kids is the # of zones
     args = cueToOrDie(is, "kids");
-    label nRegions = parse<int>(args);
+    label nZones = parse<int>(args);
 
-    // Start of vertices for object/region
+    // Start of vertices for object/zones
     label vertexOffset = 0;
 
     DynamicList<point> dynPoints;
     DynamicList<Face>  dynFaces;
-    List<word>         names(nRegions);
-    List<label>        sizes(nRegions, 0);
+    List<word>         names(nZones);
+    List<label>        sizes(nZones, 0);
 
-    for (label regionI = 0; regionI < nRegions; ++regionI)
+    for (label zoneI = 0; zoneI < nZones; ++zoneI)
     {
-        names[regionI] = word("region") + Foam::name(regionI);
+        names[zoneI] = word("zone") + Foam::name(zoneI);
 
-        args = cueToOrDie(is, "OBJECT", "while reading " + names[regionI]);
+        args = cueToOrDie(is, "OBJECT", "while reading " + names[zoneI]);
 
-        // number of vertices for this region
-        label  nRegionPoints = 0;
+        // number of vertices for this zone
+        label  nZonePoints = 0;
         vector location(pTraits<vector>::zero);
         // tensor rotation(I);
 
-        // Read all info for current region
+        // Read all info for current zone
         while (is.good())
         {
             // Read line and get first word. If end of file break since
-            // region should always end with 'kids' command ?not sure.
+            // zone should always end with 'kids' command ?not sure.
             if (!readCmd(is, cmd, args))
             {
                 FatalErrorIn
                 (
                     "fileFormats::AC3DsurfaceFormat::read(const fileName&)"
                 )
-                    << "Did not read up to \"kids 0\" while reading region "
-                    << regionI << " from file " << filename
+                    << "Did not read up to \"kids 0\" while reading zone "
+                    << zoneI << " from file " << filename
                     << exit(FatalError);
             }
 
@@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
                 string str = parse<string>(args);
                 string::stripInvalid<word>(str);
 
-                names[regionI] = str;
+                names[zoneI] = str;
             }
             else if (cmd == "rot")
             {
@@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
                 )
                     << "rot (rotation tensor) command not implemented"
                     << "Line:" << cmd << ' ' << args << endl
-                    << "while reading region " << regionI << endl;
+                    << "while reading zone " << zoneI << endl;
             }
             else if (cmd == "loc")
             {
@@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
             else if (cmd == "numvert")
             {
                 // numvert  %d
-                nRegionPoints = parse<int>(args);
+                nZonePoints = parse<int>(args);
 
-                for (label vertI = 0; vertI < nRegionPoints; ++vertI)
+                for (label vertI = 0; vertI < nZonePoints; ++vertI)
                 {
                     is.getLine(line);
                     IStringStream lineStream(line);
@@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
                 {
                     static string errorMsg =
                         string(" while reading face ")
-                            + Foam::name(faceI) + " on region "
-                            + Foam::name(regionI)
+                            + Foam::name(faceI) + " on zone "
+                            + Foam::name(zoneI)
                             + " from file " + filename;
 
                     cueToOrDie(is, "SURF", errorMsg);
@@ -227,26 +227,26 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
                         // points may be incomplete
                         for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
                         {
-                            label fp2 = (fp1 + 1) % f.size();
+                            label fp2 = f.fcIndex(fp1);
 
                             dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
-                            sizes[regionI]++;
+                            sizes[zoneI]++;
                         }
                     }
                     else
                     {
                         dynFaces.append(Face(f));
-                        sizes[regionI]++;
+                        sizes[zoneI]++;
                     }
                 }
 
-                // Done the current region.
+                // Done the current zone.
                 // Increment the offset vertices are stored at
-                vertexOffset += nRegionPoints;
+                vertexOffset += nZonePoints;
             }
             else if (cmd == "kids")
             {
-                // 'kids' denotes the end of the current region.
+                // 'kids' denotes the end of the current zone.
                 label nKids = parse<int>(args);
 
                 if (nKids != 0)
@@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
                     )
                         << "Can only read objects without kids."
                         << " Encountered " << nKids << " kids when"
-                        << " reading region " << regionI
+                        << " reading zone " << zoneI
                         << exit(FatalError);
                 }
 
-                // Done reading current region
+                // Done reading current zone
                 break;
             }
         }
@@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
     this->storedPoints().transfer(dynPoints);
     this->storedFaces().transfer(dynFaces);
 
-    // add regions, culling empty ones
-    this->addRegions(sizes, names, true);
+    // add zones, culling empty ones
+    this->addZones(sizes, names, true);
     this->stitchFaces(SMALL);
     return true;
 }
@@ -282,21 +282,19 @@ template<class Face>
 void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const pointField& pointLst = surf.points();
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
-    writeHeader(os, regionLst);
+    writeHeader(os, zoneLst);
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
         os  << "OBJECT poly" << nl
-            << "name \"" << reg.name() << '"' << endl;
+            << "name \"" << zone.name() << '"' << endl;
 
         // Temporary PrimitivePatch to calculate compact points & faces
         // use 'UList' to avoid allocations!
@@ -322,7 +320,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
             const Face& f = patch.localFaces()[localFaceI];
 
             os  << "SURF 0x20" << nl          // polygon
-                << "mat " << regionI << nl
+                << "mat " << zoneI << nl
                 << "refs " << f.size() << nl;
 
             forAll(f, fp)
@@ -336,6 +334,17 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
 }
 
 
+template<class Face>
+void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
+}
+
+
 template<class Face>
 void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
 (
@@ -344,22 +353,22 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
 )
 {
     labelList faceMap;
-    List<surfRegion> regionLst = surf.sortedRegions(faceMap);
+    List<surfZone> zoneLst = surf.sortedZones(faceMap);
 
-    writeHeader(os, regionLst);
+    writeHeader(os, zoneLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
         os  << "OBJECT poly" << nl
-            << "name \"" << reg.name() << '"' << endl;
+            << "name \"" << zone.name() << '"' << endl;
 
-        // Create region with only region faces included for ease of addressing
+        // Create zone with only zone faces included for ease of addressing
         labelHashSet include(surf.size());
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const label faceI = faceMap[faceIndex++];
             include.insert(faceI);
@@ -384,7 +393,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
             const Face& f = subm.localFaces()[localFaceI];
 
             os  << "SURF 0x20" << nl          // polygon
-                << "mat " << regionI << nl
+                << "mat " << zoneI << nl
                 << "refs " << f.size() << nl;
 
             forAll(f, fp)
diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H
index 3ccfeeda23565863dcc679350edd4cf20d1a2cef..24aa25df181a5bb90e39942c470dd8728c3900c2 100644
--- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H
@@ -31,8 +31,8 @@ Description
     http://www.inivis.com/ac3d/man/ac3dfileformat.html
 
 Note
-   The faces are already organized as regions.
-   The output is always sorted by regions.
+   The faces are already organized as zones.
+   The output is always sorted by zones.
 
 SourceFiles
     AC3DsurfaceFormat.C
@@ -56,7 +56,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                      Class AC3DfileFormat Declaration
+                      Class AC3DsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -102,6 +102,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -120,7 +129,7 @@ public:
         }
 
         //- Write UnsortedMeshedSurface
-        //  The output is always sorted by regions.
+        //  The output is always sorted by zones.
         static void write
         (
             Ostream&,
@@ -128,7 +137,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  The output is always sorted by regions.
+        //  The output is always sorted by zones.
         static void write
         (
             const fileName& name,
diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.C
index e31c59f796f3085fd514bd3e772cbb633b0c5778..ef2860cd3cc8bbb8bf50b35c1a7ba40bd19bed69 100644
--- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.C
@@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
 void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
 (
     Ostream& os,
-    const UList<surfRegion>& regionLst
+    const UList<surfZone>& zoneLst
 )
 {
-    // Write with regions as separate objects under "world" object.
+    // Write with zones as separate objects under "world" object.
     // Header is taken over from sample file.
-    // Defines separate materials for all regions. Recycle colours.
+    // Defines separate materials for all zones. Recycle colours.
 
     // Define 8 standard colours as r,g,b components
     static scalar colourMap[] =
@@ -139,12 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
     // Write header. Define materials.
     os  << "AC3Db" << nl;
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        label colourI = regionI % 8;
+        label colourI = zoneI % 8;
         label colourCompI = 3 * colourI;
 
-        os  << "MATERIAL \"" << regionLst[regionI].name() << "Mat\" rgb "
+        os  << "MATERIAL \"" << zoneLst[zoneI].name() << "Mat\" rgb "
             << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
             << ' ' << colourMap[colourCompI+2]
             << "  amb 0.2 0.2 0.2  emis 0 0 0  spec 0.5 0.5 0.5  shi 10"
@@ -153,7 +153,7 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
     }
 
     os  << "OBJECT world" << nl
-        << "kids " << regionLst.size() << endl;
+        << "kids " << zoneLst.size() << endl;
 }
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H
index 574f7da1f5d920f36dcb4cc5979b45ef9095d934..93619e5a9b9039e2dc07b331225ebbe09ef3b4fe 100644
--- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H
@@ -49,7 +49,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                       Class AC3DfileFormat Declaration
+                    Class AC3DsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class AC3DsurfaceFormatCore
@@ -77,7 +77,7 @@ protected:
     );
 
     //- Write header with materials
-    static void writeHeader(Ostream&, const UList<surfRegion>&);
+    static void writeHeader(Ostream&, const UList<surfZone>&);
 
 };
 
diff --git a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C
index 3840bfaea711ce25a7ec72c02aece3d96323d75e..372427f4ad2ded54b02ae7e97f2d4da5a0f4a9d1 100644
--- a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C
@@ -65,38 +65,39 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
 
     List<ftrPatch> ftrPatches(is);
 
-    // read points directly
+    // points read directly
     is >> this->storedPoints();
 
-    // faces read with keys
-    List<Keyed<triFace> > facesRead(is);
+    // triFaces read with attached keys
+    List< Keyed<triFace> > facesRead(is);
 
     List<Face>  faceLst(facesRead.size());
-    List<label> regionIds(facesRead.size());
+    List<label> zoneIds(facesRead.size());
 
     // disentangle faces/keys - already triangulated
     forAll(facesRead, faceI)
     {
         // unfortunately cannot transfer to save memory
-        faceLst[faceI]   = facesRead[faceI];
-        regionIds[faceI] = facesRead[faceI].key();
+        faceLst[faceI] = facesRead[faceI];
+        zoneIds[faceI] = facesRead[faceI].key();
     }
 
     this->storedFaces().transfer(faceLst);
-    this->storedRegionIds().transfer(regionIds);
+    this->storedZoneIds().transfer(zoneIds);
+    facesRead.clear();
 
-    // change ftrPatch into surfRegionIdentifier
-    List<surfRegionIdentifier> newRegions(ftrPatches.size());
-    forAll(newRegions, regionI)
+    // change ftrPatch into surfZoneIdentifier
+    List<surfZoneIdentifier> newZones(ftrPatches.size());
+    forAll(newZones, zoneI)
     {
-        newRegions[regionI] = surfRegionIdentifier
+        newZones[zoneI] = surfZoneIdentifier
         (
-            ftrPatches[regionI].name(),
-            regionI
+            ftrPatches[zoneI].name(),
+            zoneI
         );
     }
 
-    this->storedRegionToc().transfer(newRegions);
+    this->storedZoneToc().transfer(newZones);
     return true;
 }
 
diff --git a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.H b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.H
index a99d4756e033f25eb9057bebfa0a48463002475e..fa7401890f084d955e0308d0a81944ab66eddd6f 100644
--- a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.H
@@ -26,7 +26,7 @@ Class
     Foam::fileFormats::FTRsurfaceFormat
 
 Description
-    Reading of the (now deprecated) Foam Trisurface Format.
+    Reading of the (now deprecated and barely used) Foam Trisurface Format.
 
 SourceFiles
     FTRsurfaceFormat.C
@@ -48,7 +48,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class FTRsurfaceFormat Declaration
+                      Class FTRsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
diff --git a/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.C b/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.C
index ab3cf269f235e90a8fc4ad56fec6ee32c0ce2d19..0ac2f27a3566db5d2d4918e9dc68c08781dc58ae 100644
--- a/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.C
@@ -82,11 +82,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
     // write directly into the lists:
     pointField&  pointLst  = this->storedPoints();
     List<Face>&  faceLst   = this->storedFaces();
-    List<label>& regionIds = this->storedRegionIds();
+    List<label>& zoneIds = this->storedZoneIds();
 
     pointLst.setSize(nPoints);
     faceLst.setSize(nElems);
-    regionIds.setSize(nElems);
+    zoneIds.setSize(nElems);
 
     // Read points
     forAll(pointLst, pointI)
@@ -118,11 +118,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
 
 
     // Read triangles. Convert references to edges into pointlabels
-    label maxRegion = 0;
+    label maxZone = 0;
     forAll(faceLst, faceI)
     {
         label e0Label, e1Label, e2Label;
-        label regionI = 0;
+        label zoneI = 0;
 
         line = this->getLineNoComment(is);
         {
@@ -130,17 +130,17 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
             lineStream
                 >> e0Label >> e1Label >> e2Label;
 
-            // Optional region number: read first, then check state on stream
+            // Optional zone number: read first, then check state on stream
             if (lineStream)
             {
                 label num;
                 lineStream >> num;
                 if (!lineStream.bad())
                 {
-                    regionI = num;
-                    if (maxRegion < regionI)
+                    zoneI = num;
+                    if (maxZone < zoneI)
                     {
-                        maxRegion = regionI;
+                        maxZone = zoneI;
                     }
                 }
             }
@@ -202,21 +202,21 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
         }
 
         faceLst[faceI] = triFace(e0Far, common01, e1Far);
-        regionIds[faceI] = regionI;
+        zoneIds[faceI] = zoneI;
     }
 
 
-    List<surfRegionIdentifier> newRegions(maxRegion+1);
-    forAll(newRegions, regionI)
+    List<surfZoneIdentifier> newZones(maxZone+1);
+    forAll(newZones, zoneI)
     {
-        newRegions[regionI] = surfRegionIdentifier
+        newZones[zoneI] = surfZoneIdentifier
         (
-            "region" + ::Foam::name(regionI),
-            regionI
+            "zone" + ::Foam::name(zoneI),
+            zoneI
         );
     }
 
-    this->storedRegionToc().transfer(newRegions);
+    this->storedZoneToc().transfer(newZones);
     return true;
 }
 
@@ -230,7 +230,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
 {
     const pointField& pointLst = surf.points();
     const List<Face>& faceLst  = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
+    const List<surfZone>& zoneLst = surf.zones();
 
 
     // check if output triangulation would be required
@@ -260,14 +260,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
         }
     }
 
-    // Write header, print region names as comment
+    // Write header, print zone names as comment
     os  << "# GTS file" << nl
-        << "# Regions:" << nl;
+        << "# Zones:" << nl;
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        os  << "#     " << regionI << "    "
-            << regionLst[regionI].name() << nl;
+        os  << "#     " << zoneI << "    "
+            << zoneLst[zoneI].name() << nl;
     }
     os  << "#" << endl;
 
@@ -300,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
     const labelListList& faceEs = surf.faceEdges();
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const labelList& fEdges = faceEs[faceIndex++];
 
             os  << fEdges[0] + 1 << ' '
                 << fEdges[1] + 1 << ' '
                 << fEdges[2] + 1 << ' '
-                << regionI << endl;
+                << zoneI << endl;
         }
     }
 }
@@ -326,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
 {
     const pointField& pointLst   = surf.points();
     const List<Face>& faceLst    = surf.faces();
-    const List<label>& regionIds = surf.regionIds();
-    const List<surfRegionIdentifier>& regionToc = surf.regionToc();
+    const List<label>& zoneIds = surf.zoneIds();
+    const List<surfZoneIdentifier>& zoneToc = surf.zoneToc();
 
     // check if output triangulation would be required
     // It is too annoying to triangulate on-the-fly
@@ -356,14 +356,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
         }
     }
 
-    // Write header, print region names as comment
+    // Write header, print zone names as comment
     os  << "# GTS file" << nl
-        << "# Regions:" << nl;
+        << "# Zones:" << nl;
 
-    forAll(regionToc, regionI)
+    forAll(zoneToc, zoneI)
     {
-        os  << "#     " << regionI << "    "
-            << regionToc[regionI].name() << nl;
+        os  << "#     " << zoneI << "    "
+            << zoneToc[zoneI].name() << nl;
     }
     os  << "#" << endl;
 
@@ -404,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
         os  << fEdges[0] + 1 << ' '
             << fEdges[1] + 1 << ' '
             << fEdges[2] + 1 << ' '
-            << regionIds[faceI] << endl;
+            << zoneIds[faceI] << endl;
     }
 }
 
diff --git a/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.H b/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.H
index 62d218274d5757685198dd10e2cbb2ddbf4d05a0..be4a7411e4e1d68717cffd80bfa7a5105966edd3 100644
--- a/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/gts/GTSsurfaceFormat.H
@@ -27,7 +27,7 @@ Class
 
 Description
     Provide a means of reading/writing GTS format.
-    The output is never sorted by region.
+    The output is never sorted by zone.
 
 SourceFiles
     GTSsurfaceFormat.C
@@ -50,7 +50,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class GTSsurfaceFormat Declaration
+                      Class GTSsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C
index 6a4da1ec8066cda65a28dc714bb2e24ae88f357a..adfa807a62f4b9285dee9d520b69757f562246a5 100644
--- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.C
@@ -71,13 +71,13 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
     DynamicList<label>  pointId;
     DynamicList<point>  dynPoints;
     DynamicList<Face>   dynFaces;
-    DynamicList<label>  dynRegions;
+    DynamicList<label>  dynZones;
     DynamicList<label>  dynSizes;
     Map<label>          lookup;
 
     // assume the types are not intermixed
     bool sorted = true;
-    label regionI = 0;
+    label zoneI = 0;
 
     // Name for face group
     Map<word> nameLookup;
@@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
     // Ansa tags. Denoted by $ANSA_NAME.
     // These will appear just before the first use of a type.
     // We read them and store the PSHELL types which are used to name
-    // the regions.
+    // the zones.
     label ansaId = -1;
     word  ansaType, ansaName;
 
@@ -211,28 +211,28 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
             fTri[1] = readLabel(IStringStream(line.substr(32,8))());
             fTri[2] = readLabel(IStringStream(line.substr(40,8))());
 
-            // Convert groupID into regionId
+            // Convert groupID into zoneId
             Map<label>::const_iterator fnd = lookup.find(groupId);
             if (fnd != lookup.end())
             {
-                if (regionI != fnd())
+                if (zoneI != fnd())
                 {
                     // pshell types are intermixed
                     sorted = false;
                 }
-                regionI = fnd();
+                zoneI = fnd();
             }
             else
             {
-                regionI = dynSizes.size();
-                lookup.insert(groupId, regionI);
+                zoneI = dynSizes.size();
+                lookup.insert(groupId, zoneI);
                 dynSizes.append(0);
-                // Info<< "region" << regionI << " => group " << groupId <<endl;
+                // Info<< "zone" << zoneI << " => group " << groupId <<endl;
             }
 
             dynFaces.append(fTri);
-            dynRegions.append(regionI);
-            dynSizes[regionI]++;
+            dynZones.append(zoneI);
+            dynSizes[zoneI]++;
         }
         else if (cmd == "CQUAD4")
         {
@@ -245,23 +245,23 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
             fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
             fQuad[3] = readLabel(IStringStream(line.substr(48,8))());
 
-            // Convert groupID into regionId
+            // Convert groupID into zoneId
             Map<label>::const_iterator fnd = lookup.find(groupId);
             if (fnd != lookup.end())
             {
-                if (regionI != fnd())
+                if (zoneI != fnd())
                 {
                     // pshell types are intermixed
                     sorted = false;
                 }
-                regionI = fnd();
+                zoneI = fnd();
             }
             else
             {
-                regionI = dynSizes.size();
-                lookup.insert(groupId, regionI);
+                zoneI = dynSizes.size();
+                lookup.insert(groupId, zoneI);
                 dynSizes.append(0);
-                // Info<< "region" << regionI << " => group " << groupId <<endl;
+                // Info<< "zone" << zoneI << " => group " << groupId <<endl;
             }
 
 
@@ -269,15 +269,15 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
             {
                 dynFaces.append(triFace(f[0], f[1], f[2]));
                 dynFaces.append(triFace(f[0], f[2], f[3]));
-                dynRegions.append(regionI);
-                dynRegions.append(regionI);
-                dynSizes[regionI] += 2;
+                dynZones.append(zoneI);
+                dynZones.append(zoneI);
+                dynSizes[zoneI] += 2;
             }
             else
             {
                 dynFaces.append(Face(f));
-                dynRegions.append(regionI);
-                dynSizes[regionI]++;
+                dynZones.append(zoneI);
+                dynSizes[zoneI]++;
             }
         }
         else if (cmd == "GRID")
@@ -322,7 +322,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
         }
         else if (cmd == "PSHELL")
         {
-            // pshell type for region names with the Ansa extension
+            // pshell type for zone names with the Ansa extension
             label groupId = readLabel(IStringStream(line.substr(8,8))());
 
             if (groupId == ansaId && ansaType == "PSHELL")
@@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
     mapPointId.clear();
 
 
-    // create default region names, or from ANSA/Hypermesh information
+    // create default zone names, or from ANSA/Hypermesh information
     List<word> names(dynSizes.size());
     forAllConstIter(Map<label>, lookup, iter)
     {
-        const label regionI = iter();
+        const label zoneI = iter();
         const label groupI  = iter.key();
 
         Map<word>::const_iterator fnd = nameLookup.find(groupI);
         if (fnd != nameLookup.end())
         {
-            names[regionI] = fnd();
+            names[zoneI] = fnd();
         }
         else
         {
-            names[regionI] = word("region") + ::Foam::name(regionI);
+            names[zoneI] = word("zone") + ::Foam::name(zoneI);
         }
     }
 
 
-    sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
+    sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
 
-    // add regions, culling empty ones
-    this->addRegions(dynSizes, names, true);
+    // add zones, culling empty ones
+    this->addZones(dynSizes, names, true);
 
     return true;
 }
diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H
index c4b9c0b2edd37583b5b872c5a90e466fb1044a04..83d735acb3b4800051c2c3fb52c784b6f3025e1d 100644
--- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormat.H
@@ -29,7 +29,7 @@ Description
     Nastran surface reader.
 
     - Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
-      to obtain region names.
+      to obtain zone names.
     - Handles Nastran short and long formats, but not free format.
     - Properly handles the Nastran compact floating point notation: \n
     @verbatim
@@ -58,7 +58,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class NASsurfaceFormat Declaration
+                      Class NASsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
diff --git a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H
index c21b5af510dd7024e5bdd2b67c1027959b234f90..b9a350043271d8bf1f9d406540cf97dfcae989bc 100644
--- a/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/nas/NASsurfaceFormatCore.H
@@ -47,7 +47,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class NASsurfaceFormatCore Declaration
+                    Class NASsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class NASsurfaceFormatCore
diff --git a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.C b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.C
index bdebe7e0d5f7e44474d875404897b077aabe0e46..db4295ce64d5b6f334e96073dd1c9ab4df251824 100644
--- a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.C
@@ -70,15 +70,15 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
 
     DynamicList<point> dynPoints;
     DynamicList<Face>  dynFaces;
-    DynamicList<label> dynRegions;
+    DynamicList<label> dynZones;
     DynamicList<word>  dynNames;
     DynamicList<label> dynSizes;
     HashTable<label>   lookup;
 
-    // place faces without a group in region0
-    label regionI = 0;
-    lookup.insert("region0", regionI);
-    dynNames.append("region0");
+    // place faces without a group in zone0
+    label zoneI = 0;
+    lookup.insert("zone0", zoneI);
+    dynNames.append("zone0");
     dynSizes.append(0);
 
     while (is.good())
@@ -111,17 +111,17 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
             HashTable<label>::const_iterator fnd = lookup.find(name);
             if (fnd != lookup.end())
             {
-                if (regionI != fnd())
+                if (zoneI != fnd())
                 {
                     // group appeared out of order
                     sorted = false;
                 }
-                regionI = fnd();
+                zoneI = fnd();
             }
             else
             {
-                regionI = dynSizes.size();
-                lookup.insert(name, regionI);
+                zoneI = dynSizes.size();
+                lookup.insert(name, zoneI);
                 dynNames.append(name);
                 dynSizes.append(0);
             }
@@ -182,18 +182,18 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
                 // points may be incomplete
                 for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
                 {
-                    label fp2 = (fp1 + 1) % f.size();
+                    label fp2 = f.fcIndex(fp1);
 
                     dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
-                    dynRegions.append(regionI);
-                    dynSizes[regionI]++;
+                    dynZones.append(zoneI);
+                    dynSizes[zoneI]++;
                 }
             }
             else
             {
                 dynFaces.append(Face(f));
-                dynRegions.append(regionI);
-                dynSizes[regionI]++;
+                dynZones.append(zoneI);
+                dynSizes[zoneI]++;
             }
         }
     }
@@ -202,10 +202,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
     // transfer to normal lists
     this->storedPoints().transfer(dynPoints);
 
-    sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
+    sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
 
-    // add regions, culling empty ones
-    this->addRegions(dynSizes, dynNames, true);
+    // add zones, culling empty ones
+    this->addZones(dynSizes, dynNames, true);
     return true;
 }
 
@@ -214,22 +214,21 @@ template<class Face>
 void Foam::fileFormats::OBJsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
-    writeHeader(os, surf.points(), faceLst.size(), regionLst);
+    writeHeader(os, pointLst, faceLst.size(), zoneLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
-        os << "g " << reg.name() << endl;
+        os << "g " << zone.name() << endl;
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const Face& f = faceLst[faceIndex++];
 
@@ -245,6 +244,17 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
 }
 
 
+template<class Face>
+void Foam::fileFormats::OBJsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
+}
+
+
 template<class Face>
 void Foam::fileFormats::OBJsurfaceFormat<Face>::write
 (
@@ -255,19 +265,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
     const List<Face>& faceLst = surf.faces();
 
     labelList faceMap;
-    List<surfRegion> regionLst = surf.sortedRegions(faceMap);
+    List<surfZone> zoneLst = surf.sortedZones(faceMap);
 
-    writeHeader(os, surf.points(), faceLst.size(), regionLst);
+    writeHeader(os, surf.points(), faceLst.size(), zoneLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        // Print all faces belonging to this region
-        const surfRegion& reg = regionLst[regionI];
+        // Print all faces belonging to this zone
+        const surfZone& zone = zoneLst[zoneI];
 
-        os << "g " << reg.name() << endl;
+        os << "g " << zone.name() << endl;
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const Face& f = faceLst[faceMap[faceIndex++]];
 
diff --git a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.H b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.H
index 87d573c1c5e5a126501303e49c6e1f7c928812ef..d9acc483abc1714e144c627395623389d300f1bb 100644
--- a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormat.H
@@ -52,7 +52,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class OBJsurfaceFormat Declaration
+                      Class OBJsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -98,6 +98,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -116,7 +125,7 @@ public:
         }
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by regions
+        //  The output is sorted by zones
         static void write
         (
             Ostream&,
@@ -124,7 +133,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by regions
+        //  The output is sorted by zones
         static void write
         (
             const fileName& name,
diff --git a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C
index 24c538de3ed85684e36fcc16b99054c7f08c4439..c6062d54feeba1ce4caf00eee658a123966182fd 100644
--- a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C
@@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
     Ostream& os,
     const pointField& pointLst,
     const label nFaces,
-    const UList<surfRegion>& regionLst
+    const UList<surfZone>& zoneLst
 )
 {
     os  << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
@@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
         << nl
         << "# points : " << pointLst.size() << nl
         << "# faces  : " << nFaces << nl
-        << "# region : " << regionLst.size() << nl;
+        << "# zones  : " << zoneLst.size() << nl;
 
-    // Print region names as comment
-    forAll(regionLst, regionI)
+    // Print zone names as comment
+    forAll(zoneLst, zoneI)
     {
-        os  << "#   " << regionI << "  " << regionLst[regionI].name()
-            << "  (nFaces: " << regionLst[regionI].size() << ")" << nl;
+        os  << "#   " << zoneI << "  " << zoneLst[zoneI].name()
+            << "  (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
     }
 
     os  << nl
diff --git a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H
index 00869aaaf3bc383a89b9c8dd2a9c96a543a1b5d8..42e48f75f6c1635addafb0456287009223b095ed 100644
--- a/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H
@@ -49,7 +49,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class OBJsurfaceFormatCore Declaration
+                    Class OBJsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class OBJsurfaceFormatCore
@@ -63,7 +63,7 @@ protected:
         Ostream&,
         const pointField&,
         const label nFaces,
-        const UList<surfRegion>&
+        const UList<surfZone>&
     );
 
 };
diff --git a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.C b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.C
index 0d1f6ee5aa63383923b8a5301e39cfcfc3b7076e..7e73affa17d2e97855beac7efb255f97fe9e9a49 100644
--- a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.C
@@ -101,7 +101,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
         pointLst[pointI] = point(x, y, z);
     }
 
-    // Read faces - ignore optional region information
+    // Read faces - ignore optional zone information
     // use a DynamicList for possible on-the-fly triangulation
     DynamicList<Face>  dynFaces(nElems);
 
@@ -130,7 +130,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
                 // cannot use face::triangulation (points may be incomplete)
                 for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
                 {
-                    label fp2 = (fp1 + 1) % f.size();
+                    label fp2 = f.fcIndex(fp1);
 
                     dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
                 }
@@ -145,8 +145,8 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
     // transfer to normal lists
     reset(pointLst.xfer(), dynFaces.xfer());
 
-    // no region information
-    this->oneRegion();
+    // no zone information
+    this->oneZone();
     return true;
 }
 
@@ -155,24 +155,21 @@ template<class Face>
 void Foam::fileFormats::OFFsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const UnsortedMeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const List<Face>& faceLst = surf.faces();
-
-    labelList faceMap;
-    List<surfRegion> regionLst = surf.sortedRegions(faceMap);
-
-    writeHeader(os, surf.points(), faceLst.size(), regionLst);
+    writeHeader(os, pointLst, faceLst.size(), zoneLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
+        os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
 
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
-            const Face& f = faceLst[faceMap[faceIndex++]];
+            const Face& f = faceLst[faceIndex++];
 
             os << f.size();
             forAll(f, fp)
@@ -180,10 +177,10 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
                 os << ' ' << f[fp];
             }
 
-            // add optional region information
-            os << ' ' << regionI << endl;
+            // add optional zone information
+            os << ' ' << zoneI << endl;
         }
-        os << "# </region>" << endl;
+        os << "# </zone>" << endl;
     }
     os << "# </faces>" << endl;
 }
@@ -195,20 +192,33 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
     Ostream& os,
     const MeshedSurface<Face>& surf
 )
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
+}
+
+
+template<class Face>
+void Foam::fileFormats::OFFsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const UnsortedMeshedSurface<Face>& surf
+)
 {
     const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
 
-    writeHeader(os, surf.points(), faceLst.size(), regionLst);
+    labelList faceMap;
+    List<surfZone> zoneLst = surf.sortedZones(faceMap);
+
+    writeHeader(os, surf.points(), faceLst.size(), zoneLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
+        os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
 
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
-            const Face& f = faceLst[faceIndex++];
+            const Face& f = faceLst[faceMap[faceIndex++]];
 
             os << f.size();
             forAll(f, fp)
@@ -216,12 +226,13 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
                 os << ' ' << f[fp];
             }
 
-            // add optional region information
-            os << ' ' << regionI << endl;
+            // add optional zone information
+            os << ' ' << zoneI << endl;
         }
-        os << "# </region>" << endl;
+        os << "# </zone>" << endl;
     }
     os << "# </faces>" << endl;
 }
 
+
 // ************************************************************************* //
diff --git a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.H b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.H
index 89e82aee62d10fda41bf7d6bc01ef638bd0d80d6..669be5a9a5b68fcc4481e461391c87aac8e7e0fe 100644
--- a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormat.H
@@ -36,7 +36,7 @@ See Also
 
 Note
     When reading, the optional @a colorspec is ignored.
-    When writing, it is set to the region number (integer).
+    When writing, it is set to the zone number (integer).
 
 SourceFiles
     OFFsurfaceFormat.C
@@ -60,7 +60,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class OFFsurfaceFormat Declaration
+                      Class OFFsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -104,6 +104,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -122,7 +131,7 @@ public:
         }
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by region.
+        //  The output is sorted by zone.
         static void write
         (
             Ostream&,
@@ -130,7 +139,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by region.
+        //  The output is sorted by zone.
         static void write
         (
             const fileName& name,
diff --git a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C
index b3866bdbc72a3a0f5833e370d46414a344a25e0c..e65476da677f5b9b397ded62db84d02fd6d94463 100644
--- a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C
@@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
     Ostream& os,
     const pointField& pointLst,
     const label nFaces,
-    const UList<surfRegion>& regionLst
+    const UList<surfZone>& zoneLst
 )
 {
     // Write header
@@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
         << nl
         << "# points : " << pointLst.size() << nl
         << "# faces  : " << nFaces << nl
-        << "# regions: " << regionLst.size() << nl;
+        << "# zones  : " << zoneLst.size() << nl;
 
-    // Print region names as comment
-    forAll(regionLst, regionI)
+    // Print zone names as comment
+    forAll(zoneLst, zoneI)
     {
-        os  << "#   " << regionI << "  " << regionLst[regionI].name()
-            << "  (nFaces: " << regionLst[regionI].size() << ")" << nl;
+        os  << "#   " << zoneI << "  " << zoneLst[zoneI].name()
+            << "  (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
     }
 
     os  << nl
diff --git a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H
index 8706d1fb94784424a48760efbefd8810d58b7dda..e72bc82ee7e13e1aa916385eb54a72bb9d246008 100644
--- a/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H
@@ -49,7 +49,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class OFFsurfaceFormatCore Declaration
+                    Class OFFsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class OFFsurfaceFormatCore
@@ -63,7 +63,7 @@ protected:
         Ostream&,
         const pointField&,
         const label nFaces,
-        const UList<surfRegion>&
+        const UList<surfZone>&
     );
 
 };
diff --git a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.C b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.C
index f256d308fc6f96744cdd1e37ccc492a220c40e14..3aba1aa74477362fe92161958a81c061628d3b9d 100644
--- a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.C
@@ -42,18 +42,17 @@ template<class Face>
 void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
-    writeHeader(os, surf.points(), faceLst.size());
+    writeHeader(os, pointLst, faceLst.size());
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             const Face& f = faceLst[faceIndex++];
 
@@ -62,7 +61,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
             {
                 os << ' ' << f[fp];
             }
-            os << ' ' << regionI << endl;
+            os << ' ' << zoneI << endl;
         }
     }
 
@@ -70,6 +69,17 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
 }
 
 
+template<class Face>
+void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
+}
+
+
 template<class Face>
 void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
 (
@@ -82,12 +92,12 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
     writeHeader(os, surf.points(), faceLst.size());
 
     labelList faceMap;
-    List<surfRegion> regionLst = surf.sortedRegions(faceMap);
+    List<surfZone> zoneLst = surf.sortedZones(faceMap);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             const Face& f = faceLst[faceMap[faceIndex++]];
 
@@ -96,7 +106,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
             {
                 os << ' ' << f[fp];
             }
-            os << ' ' << regionI << endl;
+            os << ' ' << zoneI << endl;
         }
     }
 
diff --git a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.H b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.H
index 67dd0951ecf1035884bfc2fc13071cfed8da0b75..4ddc438cbbb64be0cf21b10deed5a6a85ceff35a 100644
--- a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormat.H
@@ -57,7 +57,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                      Class SMESHsurfaceFormat Declaration
+                     Class SMESHsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -91,6 +91,15 @@ public:
 
     // Member Functions
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -109,7 +118,7 @@ public:
         }
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by region.
+        //  The output is sorted by zone.
         static void write
         (
             Ostream&,
@@ -117,7 +126,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by region.
+        //  The output is sorted by zone.
         static void write
         (
             const fileName& name,
diff --git a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C
index 5548ec26683ad3f7a634b5a335c007ce1f73512f..0095dc9279cc93bb972d5086c6bf69904f0f8964 100644
--- a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C
@@ -53,7 +53,7 @@ void Foam::fileFormats::SMESHsurfaceFormatCore::writeHeader
         << nl
         << "# <faces count=\"" << nFaces << "\">" << endl;
 
-    os  << nFaces << " 1" << endl;   // one attribute: region number
+    os  << nFaces << " 1" << endl;   // one attribute: zone number
 }
 
 
diff --git a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H
index 71ba8ca226124df479d06b4e7b2a29fb091781a9..a50f2a50d75d9568c5ec55270b3e50feb419ce67 100644
--- a/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H
@@ -48,7 +48,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                  Class SMESHsurfaceFormatCore Declaration
+                   Class SMESHsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class SMESHsurfaceFormatCore
diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C
index 05b82cd1f42c240f128a41e8487a8d475c274d7c..4fcac468c2198c5c923815838d23b4d3993041ee 100644
--- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C
@@ -122,14 +122,14 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
     readHeader(is, "PROSTAR_CELL");
 
     DynamicList<Face>  dynFaces;
-    DynamicList<label> dynRegions;
+    DynamicList<label> dynZones;
     DynamicList<word>  dynNames;
     DynamicList<label> dynSizes;
     Map<label> lookup;
 
     // assume the cellTableIds are not intermixed
     bool sorted = true;
-    label regionI = 0;
+    label zoneI = 0;
 
     label lineLabel, shapeId, nLabels, cellTableId, typeId;
     DynamicList<label> vertexLabels(64);
@@ -157,22 +157,22 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
 
         if (typeId == starcdShellType_)
         {
-            // Convert groupID into regionID
+            // Convert groupID into zoneID
             Map<label>::const_iterator fnd = lookup.find(cellTableId);
             if (fnd != lookup.end())
             {
-                if (regionI != fnd())
+                if (zoneI != fnd())
                 {
                     // cellTableIds are intermixed
                     sorted = false;
                 }
-                regionI = fnd();
+                zoneI = fnd();
             }
             else
             {
-                regionI = dynSizes.size();
-                lookup.insert(cellTableId, regionI);
-                dynNames.append(word("cellTable_") + ::Foam::name(regionI));
+                zoneI = dynSizes.size();
+                lookup.insert(cellTableId, zoneI);
+                dynNames.append(word("cellTable_") + ::Foam::name(zoneI));
                 dynSizes.append(0);
             }
 
@@ -195,24 +195,24 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
                             static_cast<UList<label>&>(triFaces[faceI])
                         )
                     );
-                    dynRegions.append(regionI);
-                    dynSizes[regionI]++;
+                    dynZones.append(zoneI);
+                    dynSizes[zoneI]++;
                 }
             }
             else
             {
                 dynFaces.append(Face(vertices));
-                dynRegions.append(regionI);
-                dynSizes[regionI]++;
+                dynZones.append(zoneI);
+                dynSizes[zoneI]++;
             }
         }
     }
     mapPointId.clear();
 
-    sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
+    sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
 
-    // add regions, culling empty ones
-    this->addRegions(dynSizes, dynNames, true);
+    // add zones, culling empty ones
+    this->addZones(dynSizes, dynNames, true);
     return true;
 }
 
@@ -221,27 +221,26 @@ template<class Face>
 void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
 (
     const fileName& filename,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
     fileName baseName = filename.lessExt();
 
-    writePoints(OFstream(baseName + ".vrt")(), surf.points());
+    writePoints(OFstream(baseName + ".vrt")(), pointLst);
     OFstream os(baseName + ".cel");
     writeHeader(os, "CELL");
 
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const Face& f = faceLst[faceIndex++];
-            writeShell(os, f, faceIndex, regionI + 1);
+            writeShell(os, f, faceIndex, zoneI + 1);
         }
     }
 
@@ -249,10 +248,22 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
     writeCase
     (
         OFstream(baseName + ".inp")(),
-        surf.points(),
-        surf.size(),
-        regionLst
+        pointLst,
+        faceLst.size(),
+        zoneLst
     );
+
+}
+
+
+template<class Face>
+void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
+(
+    const fileName& filename,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(filename, surf.points(), surf.faces(), surf.zones());
 }
 
 
@@ -266,23 +277,22 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
     fileName baseName = filename.lessExt();
 
     writePoints(OFstream(baseName + ".vrt")(), surf.points());
-
     OFstream os(baseName + ".cel");
     writeHeader(os, "CELL");
 
     const List<Face>& faceLst = surf.faces();
     labelList faceMap;
-    List<surfRegion> regionLst = surf.sortedRegions(faceMap);
+    List<surfZone> zoneLst = surf.sortedZones(faceMap);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        const surfRegion& reg = regionLst[regionI];
+        const surfZone& zone = zoneLst[zoneI];
 
-        forAll(reg, localFaceI)
+        forAll(zone, localFaceI)
         {
             const Face& f = faceLst[faceMap[faceIndex++]];
-            writeShell(os, f, faceIndex, regionI + 1);
+            writeShell(os, f, faceIndex, zoneI + 1);
         }
     }
 
@@ -292,7 +302,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
         OFstream(baseName + ".inp")(),
         surf.points(),
         surf.size(),
-        regionLst
+        zoneLst
     );
 }
 
diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H
index 037f1d960891e33822e40078496eed362675da34..a0e8314c262bec7df7621333c6f4f915a1c57d25 100644
--- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H
@@ -56,7 +56,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class STARCDsurfaceFormat Declaration
+                     Class STARCDsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -66,6 +66,7 @@ class STARCDsurfaceFormat
     public STARCDsurfaceFormatCore
 {
     // Private Data
+
         //- STAR-CD identifier for shell shapes (2d elements)
         static const int starcdShellShape_ = 3;
 
@@ -116,6 +117,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components
+        static void write
+        (
+            const fileName&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -124,7 +134,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  The output is sorted by regions
+        //  The output is sorted by zones
         static void write
         (
             const fileName&,
diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C
index b7691491e21cf4c97f6ac59b9acdc6bbfce9a3bf..0539f41e583e72055dc01469fa28097baca69e8e 100644
--- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C
@@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
     Ostream& os,
     const pointField& pointLst,
     const label nFaces,
-    const UList<surfRegion>& regionLst
+    const UList<surfZone>& zoneLst
 )
 {
     word caseName = os.name().lessExt().name();
@@ -176,11 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
         << "! case " << caseName << nl
         << "! ------------------------------" << nl;
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        os  << "ctable " << regionI + 1 << " shell" << nl
-            << "ctname " << regionI + 1 << " "
-            << regionLst[regionI].name() << nl;
+        os  << "ctable " << zoneI + 1 << " shell" << nl
+            << "ctname " << zoneI + 1 << " "
+            << zoneLst[zoneI].name() << nl;
     }
 
     os  << "! ------------------------------" << nl
diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H
index 481cedd1c2bbe9c4cc8a535bf778520d6fe77d99..0cadd394d28ed25f0fadc3ee5e4719826ad52ce1 100644
--- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H
@@ -49,7 +49,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                  Class STARCDsurfaceFormatCore Declaration
+                   Class STARCDsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class STARCDsurfaceFormatCore
@@ -70,7 +70,7 @@ protected:
         Ostream&,
         const pointField&,
         const label nFaces,
-        const UList<surfRegion>&
+        const UList<surfZone>&
     );
 
 };
diff --git a/src/surfMesh/surfaceFormats/stl/STLpoint.H b/src/surfMesh/surfaceFormats/stl/STLpoint.H
index c85806b3a77eea1fa5241ea26ef7b0a20f0fc5f1..a92c56fc8d36b39d43eab5fb47d7cb5f82e3b639 100644
--- a/src/surfMesh/surfaceFormats/stl/STLpoint.H
+++ b/src/surfMesh/surfaceFormats/stl/STLpoint.H
@@ -38,7 +38,6 @@ SourceFiles
 
 #include "point.H"
 #include "Istream.H"
-#include "Ostream.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -46,7 +45,7 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                         Class STLpoint Declaration
+                          Class STLpoint Declaration
 \*---------------------------------------------------------------------------*/
 
 class STLpoint
@@ -83,7 +82,7 @@ public:
 
     // Member Operators
 
-        //- Return point
+        //- Conversion to point
         inline operator point() const
         {
             return point(x(), y(), z());
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C
index 919f6d98e2fd082c7811394b70463128c631fdaa..bbc1c097303d5975f67acd06099545a1ca2ba86a 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C
@@ -26,6 +26,7 @@ License
 
 #include "STLsurfaceFormat.H"
 #include "ListOps.H"
+#include "triPointRef.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -36,16 +37,24 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
 (
     Ostream& os,
     const pointField& pointLst,
-    const Face& f,
-    const vector& norm
+    const Face& f
 )
 {
+    // calculate the normal ourselves, for flexibility and speed
+    vector norm = triPointRef
+    (
+        pointLst[f[0]],
+        pointLst[f[1]],
+        pointLst[f[2]]
+    ).normal();
+    norm /= mag(norm) + VSMALL;
+
     // simple triangulation about f[0].
     // better triangulation should have been done before
     const point& p0 = pointLst[f[0]];
     for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
     {
-        label fp2 = (fp1 + 1) % f.size();
+        label fp2 = f.fcIndex(fp1);
 
         const point& p1 = pointLst[f[fp1]];
         const point& p2 = pointLst[f[fp2]];
@@ -69,16 +78,24 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
     ostream& os,
     const pointField& pointLst,
     const Face& f,
-    const vector& norm,
-    const label regionI
+    const label zoneI
 )
 {
+    // calculate the normal ourselves, for flexibility and speed
+    vector norm = triPointRef
+    (
+        pointLst[f[0]],
+        pointLst[f[1]],
+        pointLst[f[2]]
+    ).normal();
+    norm /= mag(norm) + VSMALL;
+
     // simple triangulation about f[0].
     // better triangulation should have been done before
     const point& p0 = pointLst[f[0]];
     for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
     {
-        label fp2 = (fp1 + 1) % f.size();
+        label fp2 = f.fcIndex(fp1);
 
         STLtriangle stlTri
         (
@@ -86,7 +103,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
             p0,
             pointLst[f[fp1]],
             pointLst[f[fp2]],
-            regionI
+            zoneI
         );
 
         stlTri.write(os);
@@ -94,96 +111,17 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
 }
 
 
-// write sorted:
-template<class Face>
-void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
-(
-    Ostream& os,
-    const MeshedSurface<Face>& surf
-)
-{
-    const pointField& pointLst = surf.points();
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-    const vectorField& normLst = surf.faceNormals();
-
-    label faceIndex = 0;
-    forAll(regionLst, regionI)
-    {
-        // Print all faces belonging to this region
-        const surfRegion& reg = regionLst[regionI];
-
-        os << "solid " << reg.name() << endl;
-        forAll(reg, localFaceI)
-        {
-            const label faceI = faceIndex++;
-            writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
-        }
-        os << "endsolid " << reg.name() << endl;
-    }
-}
-
-
-// write sorted:
-template<class Face>
-void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
-(
-    Ostream& os,
-    const UnsortedMeshedSurface<Face>& surf
-)
-{
-    const pointField& pointLst = surf.points();
-    const List<Face>& faceLst  = surf.faces();
-    const vectorField& normLst = surf.faceNormals();
-
-    if (surf.regionToc().size() == 1)
-    {
-        // a single region - we can skip sorting
-        os << "solid " << surf.regionToc()[0].name() << endl;
-        forAll(faceLst, faceI)
-        {
-            writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
-        }
-        os << "endsolid " << surf.regionToc()[0].name() << endl;
-    }
-   else
-   {
-        labelList faceMap;
-        List<surfRegion> regionLst = surf.sortedRegions(faceMap);
-
-        label faceIndex = 0;
-        forAll(regionLst, regionI)
-        {
-            // Print all faces belonging to this region
-            const surfRegion& reg = regionLst[regionI];
-
-            os << "solid " << reg.name() << endl;
-            forAll(reg, localFaceI)
-            {
-                const label faceI = faceMap[faceIndex++];
-                writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
-            }
-            os << "endsolid " << reg.name() << endl;
-        }
-   }
-}
-
-
-
 template<class Face>
 void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
 (
     ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const pointField&  pointLst = surf.points();
-    const List<Face>&  faceLst  = surf.faces();
-    const vectorField& normLst = surf.faceNormals();
-    const List<surfRegion>& regionLst = surf.regions();
-
     unsigned int nTris = 0;
-    if (surf.isTri())
+    if (BasicMeshedSurface<Face>::isTri())
     {
         nTris = faceLst.size();
     }
@@ -200,26 +138,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
     STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], regionFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             writeShell
             (
                 os,
                 pointLst,
-                faceLst[faceIndex],
-                normLst[faceIndex],
-                regionI
+                faceLst[faceIndex++],
+                zoneI
             );
-
-            ++faceIndex;
         }
     }
 }
 
 
-// write unsorted:
 template<class Face>
 void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
 (
@@ -229,8 +163,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
 {
     const pointField&  pointLst = surf.points();
     const List<Face>&  faceLst = surf.faces();
-    const List<label>& regionIds = surf.regionIds();
-    const vectorField& normLst = surf.faceNormals();
+    const List<label>& zoneIds = surf.zoneIds();
 
     unsigned int nTris = 0;
     if (surf.isTri())
@@ -257,8 +190,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
             os,
             pointLst,
             faceLst[faceI],
-            normLst[faceI],
-            regionIds[faceI]
+            zoneIds[faceI]
         );
     }
 }
@@ -292,13 +224,13 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
     // transfer points
     this->storedPoints().transfer(reader.points());
 
-    // retrieve the original region information
+    // retrieve the original zone information
     List<word>  names(reader.names().xfer());
     List<label> sizes(reader.sizes().xfer());
-    List<label> regionIds(reader.regionIds().xfer());
+    List<label> zoneIds(reader.zoneIds().xfer());
 
     // generate the (sorted) faces
-    List<Face> faceLst(regionIds.size());
+    List<Face> faceLst(zoneIds.size());
 
     if (reader.sorted())
     {
@@ -314,7 +246,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
         // unsorted - determine the sorted order:
         // avoid SortableList since we discard the main list anyhow
         List<label> faceMap;
-        sortedOrder(regionIds, faceMap);
+        sortedOrder(zoneIds, faceMap);
 
         // generate sorted faces
         forAll(faceMap, faceI)
@@ -323,18 +255,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
             faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
         }
     }
-    regionIds.clear();
+    zoneIds.clear();
 
     // transfer:
     this->storedFaces().transfer(faceLst);
 
     if (names.size())
     {
-        this->addRegions(sizes, names);
+        this->addZones(sizes, names);
     }
     else
     {
-        this->addRegions(sizes);
+        this->addZones(sizes);
     }
 
     this->stitchFaces(SMALL);
@@ -346,10 +278,24 @@ template<class Face>
 void Foam::fileFormats::STLsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const UnsortedMeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    writeASCII(os, surf);
+    label faceIndex = 0;
+    forAll(zoneLst, zoneI)
+    {
+        // Print all faces belonging to this zone
+        const surfZone& zone = zoneLst[zoneI];
+
+        os << "solid " << zone.name() << endl;
+        forAll(zone, localFaceI)
+        {
+            writeShell(os, pointLst, faceLst[faceIndex++]);
+        }
+        os << "endsolid " << zone.name() << endl;
+    }
 }
 
 
@@ -360,18 +306,61 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
     const MeshedSurface<Face>& surf
 )
 {
-    writeASCII(os, surf);
+    write(os, surf.points(), surf.faces(), surf.zones());
 }
 
 
 template<class Face>
 void Foam::fileFormats::STLsurfaceFormat<Face>::write
 (
-    const fileName& filename,
+    Ostream& os,
     const UnsortedMeshedSurface<Face>& surf
 )
 {
-    word ext = filename.ext();
+    const pointField& pointLst = surf.points();
+    const List<Face>& faceLst  = surf.faces();
+
+    if (surf.zoneToc().size() == 1)
+    {
+        // a single zone - we can skip sorting
+        os << "solid " << surf.zoneToc()[0].name() << endl;
+        forAll(faceLst, faceI)
+        {
+            writeShell(os, pointLst, faceLst[faceI]);
+        }
+        os << "endsolid " << surf.zoneToc()[0].name() << endl;
+    }
+   else
+   {
+        labelList faceMap;
+        List<surfZone> zoneLst = surf.sortedZones(faceMap);
+
+        label faceIndex = 0;
+        forAll(zoneLst, zoneI)
+        {
+            // Print all faces belonging to this zone
+            const surfZone& zone = zoneLst[zoneI];
+
+            os << "solid " << zone.name() << endl;
+            forAll(zone, localFaceI)
+            {
+                const label faceI = faceMap[faceIndex++];
+                writeShell(os, pointLst, faceLst[faceI]);
+            }
+            os << "endsolid " << zone.name() << endl;
+        }
+   }
+}
+
+
+template<class Face>
+void Foam::fileFormats::STLsurfaceFormat<Face>::write
+(
+    const fileName& filename,
+    const MeshedSurface<Face>& surf
+)
+{
+    const word ext = filename.ext();
 
     // handle 'stlb' as binary directly
     if (ext == "stlb")
@@ -381,7 +370,13 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
     }
     else
     {
-        writeASCII(OFstream(filename)(), surf);
+        write
+        (
+            OFstream(filename)(),
+            surf.points(),
+            surf.faces(),
+            surf.zones()
+        );
     }
 }
 
@@ -390,10 +385,10 @@ template<class Face>
 void Foam::fileFormats::STLsurfaceFormat<Face>::write
 (
     const fileName& filename,
-    const MeshedSurface<Face>& surf
+    const UnsortedMeshedSurface<Face>& surf
 )
 {
-    const word ext = filename.ext();
+    word ext = filename.ext();
 
     // handle 'stlb' as binary directly
     if (ext == "stlb")
@@ -403,8 +398,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
     }
     else
     {
-        writeASCII(OFstream(filename)(), surf);
+        write(OFstream(filename)(), surf);
     }
 }
 
+
 // ************************************************************************* //
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.H b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.H
index ebeeb7eafe417ee7e414ecd20007a75f6cd2ff34..8fa474455c6e077dc1dcc09349b48743c66496a1 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.H
@@ -29,7 +29,7 @@ Description
     Provide a means of reading/writing STL files (ASCII and binary).
 
 Note
-    For efficiency, the regions are sorted before creating the faces.
+    For efficiency, the zones are sorted before creating the faces.
     The class is thus derived from MeshedSurface.
 
 SourceFiles
@@ -68,8 +68,7 @@ class STLsurfaceFormat
         (
             Ostream&,
             const pointField&,
-            const Face&,
-            const vector& norm
+            const Face&
         );
 
         //- Write Face in BINARY
@@ -78,24 +77,22 @@ class STLsurfaceFormat
             ostream&,
             const pointField&,
             const Face&,
-            const vector&,
-            const label regionI
+            const label zoneI
         );
 
 
-        //- Write UnsortedMeshedSurface
-        static void writeASCII(Ostream&, const UnsortedMeshedSurface<Face>&);
+        //- Write surface mesh components (as BINARY)
+        static void writeBINARY
+        (
+            ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
 
         //- Write UnsortedMeshedSurface
         static void writeBINARY(ostream&, const UnsortedMeshedSurface<Face>&);
 
-        //- Write MeshedSurface
-        static void writeASCII(Ostream&, const MeshedSurface<Face>&);
-
-        //- Write MeshedSurface
-        static void writeBINARY(ostream&, const MeshedSurface<Face>&);
-
-
         //- Disallow default bitwise copy construct
         STLsurfaceFormat(const STLsurfaceFormat<Face>&);
 
@@ -128,6 +125,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components (as ASCII)
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface (as ASCII)
         static void write
         (
@@ -135,14 +141,14 @@ public:
             const MeshedSurface<Face>&
         );
 
-        //- Write MeshedSurface
+        //- Write MeshedSurface (ASCII or BINARY, depending on the extension)
         static void write
         (
             const fileName&,
             const MeshedSurface<Face>&
         );
 
-        //- Write UnsortedMeshedSurface (as ASCII) sorted by region
+        //- Write UnsortedMeshedSurface (as ASCII) sorted by zone
         static void write
         (
             Ostream&,
@@ -150,7 +156,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  ASCII output is sorted by region; binary output is unsorted
+        //  ASCII output is sorted by zone; binary output is unsorted
         static void write
         (
             const fileName&,
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
index 14779d4d6155549eb26dc84bb6b2001bd68a5954..74e9ab2245e043c177167ae6ca14f579ebc73f77 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L
@@ -63,9 +63,8 @@ int yyFlexLexer::yywrap()
 
 
 //- A lexer for parsing STL ASCII files.
-//  Returns DynamicList(s) of points and facets (regionIds).
-//  Since the facets appear within a solid/endsolid grouping,
-//  they are always within a region
+//  Returns DynamicList(s) of points and facets (zoneIds).
+//  The facets are within a solid/endsolid grouping
 class STLASCIILexer
 :
     public yyFlexLexer
@@ -73,7 +72,7 @@ class STLASCIILexer
     // Private data
 
         bool  sorted_;
-        label groupID_;      // current region
+        label groupID_;      // current solid group
         label lineNo_;
         word  startError_;
 
@@ -110,20 +109,20 @@ public:
             return points_;
         }
 
-        //- A list of facet IDs (region IDs)
+        //- A list of facet IDs (group IDs)
         //  corresponds to the number of triangles
         DynamicList<label>& facets()
         {
             return facets_;
         }
 
-        //- region names
+        //- Names
         DynamicList<word>& names()
         {
             return names_;
         }
 
-        //- region sizes
+        //- Sizes
         DynamicList<label>& sizes()
         {
             return sizes_;
@@ -417,7 +416,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
 
     // transfer to normal lists
     points_.transfer(lexer.points());
-    regionIds_.transfer(lexer.facets());
+    zoneIds_.transfer(lexer.facets());
     names_.transfer(lexer.names());
     sizes_.transfer(lexer.sizes());
 
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C
index afe81aebac385ac2796d20eeb9280b2cf9a146b8..6ba5f661e3bd079e90a8a4a3aa28c1b6453f7f62 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C
@@ -25,6 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "STLsurfaceFormatCore.H"
+#include "gzstream.h"
 #include "OSspecific.H"
 #include "Map.H"
 
@@ -138,18 +139,18 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
 
 #ifdef DEBUG_STLBINARY
     Info<< "# " << nTris << " facets" << endl;
-    label prevRegion = -1;
+    label prevZone = -1;
 #endif
 
     points_.setSize(3*nTris);
-    regionIds_.setSize(nTris);
+    zoneIds_.setSize(nTris);
 
     Map<label> lookup;
     DynamicList<label> dynSizes;
 
     label ptI = 0;
-    label regionI = -1;
-    forAll(regionIds_, faceI)
+    label zoneI = -1;
+    forAll(zoneIds_, faceI)
     {
         // Read an STL triangle
         STLtriangle stlTri(is);
@@ -159,39 +160,39 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
         points_[ptI++] = stlTri.b();
         points_[ptI++] = stlTri.c();
 
-        // interprete colour as a region
-        const label stlRegion = stlTri.region();
+        // interprete stl attribute as a zone
+        const label origId = stlTri.attrib();
 
-        Map<label>::const_iterator fnd = lookup.find(stlRegion);
+        Map<label>::const_iterator fnd = lookup.find(origId);
         if (fnd != lookup.end())
         {
-            if (regionI != fnd())
+            if (zoneI != fnd())
             {
                 // group appeared out of order
                 sorted_ = false;
             }
-            regionI = fnd();
+            zoneI = fnd();
         }
         else
         {
-            regionI = dynSizes.size();
-            lookup.insert(stlRegion, regionI);
+            zoneI = dynSizes.size();
+            lookup.insert(origId, zoneI);
             dynSizes.append(0);
         }
 
-        regionIds_[faceI] = regionI;
-        dynSizes[regionI]++;
+        zoneIds_[faceI] = zoneI;
+        dynSizes[zoneI]++;
 
 #ifdef DEBUG_STLBINARY
-        if (prevRegion != regionI)
+        if (prevZone != zoneI)
         {
-            if (prevRegion != -1)
+            if (prevZone != -1)
             {
-                Info<< "endsolid region" << prevRegion << nl;
+                Info<< "endsolid zone" << prevZone << nl;
             }
-            prevRegion = regionI;
+            prevZone = zoneI;
 
-            Info<< "solid region" << prevRegion << nl;
+            Info<< "solid zone" << prevZone << nl;
         }
 
         Info<< " facet normal " << stlTri.normal() << nl
@@ -220,7 +221,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
 :
     sorted_(true),
     points_(0),
-    regionIds_(0),
+    zoneIds_(0),
     names_(0),
     sizes_(0)
 {
diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H
index 56607fa0a04aad991b3e2852ecef46088e28a4e1..f7c28a98f18ee5096b6264a01705b6a79b1cb2a2 100644
--- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H
@@ -39,7 +39,6 @@ SourceFiles
 
 #include "STLtriangle.H"
 #include "triFace.H"
-#include "gzstream.h"
 #include "IFstream.H"
 #include "Ostream.H"
 #include "OFstream.H"
@@ -64,8 +63,8 @@ class STLsurfaceFormatCore
         //- The points supporting the facets
         pointField points_;
 
-        //- The regions associated with the faces
-        List<label> regionIds_;
+        //- The zones associated with the faces
+        List<label> zoneIds_;
 
         //- The solid names, in the order of their first appearance
         List<word> names_;
@@ -124,7 +123,7 @@ public:
         {
             sorted_ = true;
             points_.clear();
-            regionIds_.clear();
+            zoneIds_.clear();
             names_.clear();
             sizes_.clear();
         }
@@ -135,10 +134,10 @@ public:
             return points_;
         }
 
-        //- Return full access to the regionIds
-        List<label>& regionIds()
+        //- Return full access to the zoneIds
+        List<label>& zoneIds()
         {
-            return regionIds_;
+            return zoneIds_;
         }
 
         //- The list of solid names in the order of their first appearance
diff --git a/src/surfMesh/surfaceFormats/stl/STLtriangle.H b/src/surfMesh/surfaceFormats/stl/STLtriangle.H
index 2f5b32a2d091fe4d05afed47ec8583abd836b1ea..924f0bb6b7ef08dc67b508d866d24737db315f74 100644
--- a/src/surfMesh/surfaceFormats/stl/STLtriangle.H
+++ b/src/surfMesh/surfaceFormats/stl/STLtriangle.H
@@ -46,18 +46,24 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                           Class STLtriangle Declaration
+                         Class STLtriangle Declaration
 \*---------------------------------------------------------------------------*/
 
 class STLtriangle
 {
     // Private data
 
-        typedef unsigned short STLregion;
+        //- Attribute is 16-bit
+        typedef unsigned short STLattrib;
 
-        STLpoint normal_, a_, b_, c_;
+        //- The face normal, many programs write zore or other junk
+        STLpoint normal_;
 
-        STLregion region_;
+        //- The three points defining the triangle
+        STLpoint a_, b_, c_;
+
+        //- The attribute information could for colour or solid id, etc
+        STLattrib attrib_;
 
 public:
 
@@ -73,7 +79,7 @@ public:
             const STLpoint& a,
             const STLpoint& b,
             const STLpoint& c,
-            unsigned short region
+            unsigned short attrib
         );
 
         //- Construct from istream (read binary)
@@ -88,7 +94,7 @@ public:
             inline const STLpoint& a() const;
             inline const STLpoint& b() const;
             inline const STLpoint& c() const;
-            inline unsigned short region() const;
+            inline unsigned short attrib() const;
 
         // Read
 
diff --git a/src/surfMesh/surfaceFormats/stl/STLtriangleI.H b/src/surfMesh/surfaceFormats/stl/STLtriangleI.H
index 92561d2cae9a7194b46d1a0d7dbed4e61ff45060..44b2bfe3249f8c9bb89292f696b6c445c4ed137b 100644
--- a/src/surfMesh/surfaceFormats/stl/STLtriangleI.H
+++ b/src/surfMesh/surfaceFormats/stl/STLtriangleI.H
@@ -38,14 +38,14 @@ inline Foam::STLtriangle::STLtriangle
     const STLpoint& a,
     const STLpoint& b,
     const STLpoint& c,
-    unsigned short region
+    unsigned short attrib
 )
 :
     normal_(normal),
     a_(a),
     b_(b),
     c_(c),
-    region_(region)
+    attrib_(attrib)
 {}
 
 
@@ -77,23 +77,23 @@ inline const Foam::STLpoint& Foam::STLtriangle::c() const
     return c_;
 }
 
-inline unsigned short Foam::STLtriangle::region() const
+inline unsigned short Foam::STLtriangle::attrib() const
 {
-    return region_;
+    return attrib_;
 }
 
 
 inline void Foam::STLtriangle::read(istream& is)
 {
     is.read(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
-    is.read(reinterpret_cast<char*>(&region_), sizeof(STLregion));
+    is.read(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
 }
 
 
 inline void Foam::STLtriangle::write(ostream& os)
 {
     os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
-    os.write(reinterpret_cast<char*>(&region_), sizeof(STLregion));
+    os.write(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
 }
 
 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
@@ -104,7 +104,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const STLtriangle& t)
         << t.a_ << token::SPACE
         << t.b_ << token::SPACE
         << t.c_ << token::SPACE
-        << t.region_;
+        << t.attrib_;
 
     return os;
 }
diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C
index 3552d4f4046308955a3833efd017f1f6b5a3b681..81c99e9b0da420023ca63b670bb010bcd9ab47e0 100644
--- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C
+++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C
@@ -29,10 +29,10 @@ License
 #include "OFstream.H"
 #include "Time.H"
 #include "SortableList.H"
+#include "surfMesh.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-Foam::word Foam::fileFormats::surfaceFormatsCore::meshSubDir("meshedSurface");
 Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
 
 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@@ -61,14 +61,29 @@ Foam::fileFormats::surfaceFormatsCore::getLineNoComment
 }
 
 
+Foam::fileName
+Foam::fileFormats::surfaceFormatsCore::localMeshFileName(const word& surfName)
+{
+    const word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
+
+    return fileName
+    (
+        surfaceRegistry::subInstance
+      / name
+      / surfMesh::meshSubDir
+      / name + "." + nativeExt
+    );
+}
+
+
 Foam::fileName
 Foam::fileFormats::surfaceFormatsCore::findMeshInstance
 (
     const Time& d,
-    const word& subdirName
+    const word& surfName
 )
 {
-    fileName foamName(d.caseName() + "." + nativeExt);
+    fileName localName = localMeshFileName(surfName);
 
     // Search back through the time directories list to find the time
     // closest to and lower than current time
@@ -91,7 +106,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
     {
         for (label i = instanceI; i >= 0; --i)
         {
-            if (file(d.path()/ts[i].name()/subdirName/foamName))
+            if (isFile(d.path()/ts[i].name()/localName))
             {
                 return ts[i].name();
             }
@@ -103,13 +118,13 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
 
 
 Foam::fileName
-Foam::fileFormats::surfaceFormatsCore::findMeshName
+Foam::fileFormats::surfaceFormatsCore::findMeshFile
 (
     const Time& d,
-    const word& subdirName
+    const word& surfName
 )
 {
-    fileName foamName(d.caseName() + "." + nativeExt);
+    fileName localName = localMeshFileName(surfName);
 
     // Search back through the time directories list to find the time
     // closest to and lower than current time
@@ -132,122 +147,103 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
     {
         for (label i = instanceI; i >= 0; --i)
         {
-            fileName testName(d.path()/ts[i].name()/subdirName/foamName);
+            fileName testName(d.path()/ts[i].name()/localName);
 
-            if (file(testName))
+            if (isFile(testName))
             {
                 return testName;
             }
         }
     }
 
-    return d.path()/"constant"/subdirName/foamName;
-}
-
-
-Foam::fileName
-Foam::fileFormats::surfaceFormatsCore::findMeshInstance
-(
-    const Time& d
-)
-{
-    return findMeshInstance(d, meshSubDir);
-}
-
-
-Foam::fileName
-Foam::fileFormats::surfaceFormatsCore::findMeshName
-(
-    const Time& d
-)
-{
-    return findMeshName(d, meshSubDir);
+    // fallback to "constant"
+    return d.path()/"constant"/localName;
 }
 
 
-// Returns region info.
-// Sets faceMap to the indexing according to region numbers.
-// Region numbers start at 0.
-Foam::surfRegionList
-Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
+// Returns zone info.
+// Sets faceMap to the indexing according to zone numbers.
+// Zone numbers start at 0.
+Foam::surfZoneList
+Foam::fileFormats::surfaceFormatsCore::sortedZonesById
 (
-    const UList<label>& regionIds,
-    const Map<word>& regionNames,
+    const UList<label>& zoneIds,
+    const Map<word>& zoneNames,
     labelList& faceMap
 )
 {
-    // determine sort order according to region numbers
+    // determine sort order according to zone numbers
 
     // std::sort() really seems to mix up the order.
     // and std::stable_sort() might take too long / too much memory
 
-    // Assuming that we have relatively fewer regions compared to the
+    // Assuming that we have relatively fewer zones compared to the
     // number of items, just do it ourselves
 
-    // step 1: get region sizes and store (regionId => regionI)
+    // step 1: get zone sizes and store (origId => zoneI)
     Map<label> lookup;
-    forAll(regionIds, faceI)
+    forAll(zoneIds, faceI)
     {
-        const label regId = regionIds[faceI];
+        const label origId = zoneIds[faceI];
 
-        Map<label>::iterator fnd = lookup.find(regId);
+        Map<label>::iterator fnd = lookup.find(origId);
         if (fnd != lookup.end())
         {
             fnd()++;
         }
         else
         {
-            lookup.insert(regId, 1);
+            lookup.insert(origId, 1);
         }
     }
 
-    // step 2: assign start/size (and name) to the newRegions
-    // re-use the lookup to map (regionId => regionI)
-    surfRegionList regionLst(lookup.size());
+    // step 2: assign start/size (and name) to the newZones
+    // re-use the lookup to map (zoneId => zoneI)
+    surfZoneList zoneLst(lookup.size());
     label start = 0;
-    label regionI = 0;
+    label zoneI = 0;
     forAllIter(Map<label>, lookup, iter)
     {
-        label regId = iter.key();
+        label origId = iter.key();
 
         word name;
-        Map<word>::const_iterator fnd = regionNames.find(regId);
-        if (fnd != regionNames.end())
+        Map<word>::const_iterator fnd = zoneNames.find(origId);
+        if (fnd != zoneNames.end())
         {
             name = fnd();
         }
         else
         {
-            name = word("region") + ::Foam::name(regionI);
+            name = word("zone") + ::Foam::name(zoneI);
         }
 
-        regionLst[regionI] = surfRegion
+        zoneLst[zoneI] = surfZone
         (
             name,
             0,           // initialize with zero size
             start,
-            regionI
+            zoneI
         );
 
-        // increment the start for the next region
-        // and save the (regionId => regionI) mapping
+        // increment the start for the next zone
+        // and save the (zoneId => zoneI) mapping
         start += iter();
-        iter() = regionI++;
+        iter() = zoneI++;
     }
 
 
     // step 3: build the re-ordering
-    faceMap.setSize(regionIds.size());
+    faceMap.setSize(zoneIds.size());
 
-    forAll(regionIds, faceI)
+    forAll(zoneIds, faceI)
     {
-        label regionI = lookup[regionIds[faceI]];
+        label zoneI = lookup[zoneIds[faceI]];
         faceMap[faceI] =
-            regionLst[regionI].start() + regionLst[regionI].size()++;
+            zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
     }
 
     // with reordered faces registered in faceMap
-    return regionLst;
+    return zoneLst;
 }
 
 
diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H
index 46ee062bdf64936df76d1581cc8068cc55e7a6b6..b8b227902cd00393ebb41f8f1c4daf4435f4dc74 100644
--- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H
+++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H
@@ -39,8 +39,8 @@ SourceFiles
 #include "Map.H"
 #include "HashSet.H"
 #include "labelList.H"
-#include "surfRegionList.H"
-#include "surfRegionIdentifierList.H"
+#include "surfZoneList.H"
+#include "surfZoneIdentifierList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -56,7 +56,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class surfaceFormatsCore Declaration
+                     Class surfaceFormatsCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class surfaceFormatsCore
@@ -65,9 +65,6 @@ public:
 
     // Static Data
 
-    //- Return the mesh sub-directory name (usually "meshedSurface")
-    static word meshSubDir;
-
     //- The file extension corresponding to 'native' surface format
     //  Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
     static word nativeExt;
@@ -80,24 +77,21 @@ public:
         //- Read non-comment line
         static string getLineNoComment(IFstream&);
 
-        //- Name of UnsortedMeshedSurface directory to use.
-        static fileName findMeshInstance(const Time&, const word& subdirName);
-
-        //- Name of UnsortedMeshedSurface directory to use.
-        static fileName findMeshName(const Time&, const word& subdirName);
+        //- Return the local file name (within time directory)
+        static fileName localMeshFileName(const word& surfName="");
 
-        //- Name of UnsortedMeshedSurface directory to use.
-        static fileName findMeshInstance(const Time&);
+        //- Find instance with surfName
+        static fileName findMeshInstance(const Time&, const word& surfName="");
 
-        //- Name of UnsortedMeshedSurface directory to use.
-        static fileName findMeshName(const Time&);
+        //- Find mesh file with surfName
+        static fileName findMeshFile(const Time&, const word& surfName="");
 
-        //- Determine the sort order from the region ids.
-        //  Returns region list and sets faceMap to indices within faceLst
-        static surfRegionList sortedRegionsById
+        //- Determine the sort order from the zone ids.
+        //  Returns zone list and sets faceMap to indices within faceLst
+        static surfZoneList sortedZonesById
         (
-            const UList<label>& regionIds,
-            const Map<word>& regionNames,
+            const UList<label>& zoneIds,
+            const Map<word>& zoneNames,
             labelList& faceMap
         );
 
diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.C b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.C
index 17110ab948cb40dcca135390d34507208bc76f73..2058b3e8f3c0d8eb20547d1d426effa26c2ab68e 100644
--- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.C
@@ -37,7 +37,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
     Ostream& os,
     const pointField& pointLst,
     const Face& f,
-    const label regionI
+    const label zoneI
 )
 {
     // simple triangulation about f[0].
@@ -45,7 +45,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
     const point& p0 = pointLst[f[0]];
     for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
     {
-        label fp2 = (fp1 + 1) % f.size();
+        label fp2 = f.fcIndex(fp1);
 
         const point& p1 = pointLst[f[fp1]];
         const point& p2 = pointLst[f[fp2]];
@@ -53,8 +53,8 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
         os  << p0.x() << ' ' << p0.y() << ' ' << p0.z() << ' '
             << p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
             << p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
-            // region as colour
-            << "0x" << hex << regionI << dec << endl;
+            // zone as colour
+            << "0x" << hex << zoneI << dec << endl;
     }
 }
 
@@ -87,12 +87,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
     // transfer points
     this->storedPoints().transfer(reader.points());
 
-    // retrieve the original region information
+    // retrieve the original zone information
     List<label> sizes(reader.sizes().xfer());
-    List<label> regionIds(reader.regionIds().xfer());
+    List<label> zoneIds(reader.zoneIds().xfer());
 
     // generate the (sorted) faces
-    List<Face> faceLst(regionIds.size());
+    List<Face> faceLst(zoneIds.size());
 
     if (reader.sorted())
     {
@@ -108,7 +108,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
         // unsorted - determine the sorted order:
         // avoid SortableList since we discard the main list anyhow
         List<label> faceMap;
-        sortedOrder(regionIds, faceMap);
+        sortedOrder(zoneIds, faceMap);
 
         // generate sorted faces
         forAll(faceMap, faceI)
@@ -117,12 +117,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
             faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
         }
     }
-    regionIds.clear();
+    zoneIds.clear();
 
     // transfer:
     this->storedFaces().transfer(faceLst);
 
-    this->addRegions(sizes);
+    this->addZones(sizes);
     this->stitchFaces(SMALL);
     return true;
 }
@@ -132,25 +132,34 @@ template<class Face>
 void Foam::fileFormats::TRIsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const pointField& pointLst = surf.points();
-    const List<Face>& faceLst  = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             const Face& f = faceLst[faceIndex++];
-            writeShell(os, pointLst, f, regionI);
+            writeShell(os, pointLst, f, zoneI);
         }
     }
 }
 
 
+template<class Face>
+void Foam::fileFormats::TRIsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
+}
+
+
 template<class Face>
 void Foam::fileFormats::TRIsurfaceFormat<Face>::write
 (
@@ -162,8 +171,8 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
     const List<Face>& faceLst  = surf.faces();
 
     bool doSort = false;
-    // a single region needs no sorting
-    if (surf.regionToc().size() == 1)
+    // a single zone needs no sorting
+    if (surf.zoneToc().size() == 1)
     {
         doSort = false;
     }
@@ -171,25 +180,25 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
     if (doSort)
     {
         labelList faceMap;
-        List<surfRegion> regionLst = surf.sortedRegions(faceMap);
+        List<surfZone> zoneLst = surf.sortedZones(faceMap);
 
         label faceIndex = 0;
-        forAll(regionLst, regionI)
+        forAll(zoneLst, zoneI)
         {
-            forAll(regionLst[regionI], localFaceI)
+            forAll(zoneLst[zoneI], localFaceI)
             {
                 const Face& f = faceLst[faceMap[faceIndex++]];
-                writeShell(os, pointLst, f, regionI);
+                writeShell(os, pointLst, f, zoneI);
             }
         }
     }
     else
     {
-        const List<label>& regionIds  = surf.regionIds();
+        const List<label>& zoneIds  = surf.zoneIds();
 
         forAll(faceLst, faceI)
         {
-            writeShell(os, pointLst, faceLst[faceI], regionIds[faceI]);
+            writeShell(os, pointLst, faceLst[faceI], zoneIds[faceI]);
         }
     }
 }
diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.H b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.H
index 062e17be0cb1052b55f33c4b3c9dbb56b5659407..6506954b0402f7b5829b6cc2c4882aa1fbbe40c0 100644
--- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormat.H
@@ -29,7 +29,7 @@ Description
     Provide a means of reading/writing .tri format.
 
 Note
-    For efficiency, the regions are sorted before creating the faces.
+    For efficiency, the zones are sorted before creating the faces.
     The class is thus derived from MeshedSurface.
 
 SourceFiles
@@ -54,7 +54,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class TRIsurfaceFormat Declaration
+                      Class TRIsurfaceFormat Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Face>
@@ -69,7 +69,7 @@ class TRIsurfaceFormat
             Ostream&,
             const pointField&,
             const Face&,
-            const label regionI
+            const label zoneI
         );
 
         //- Disallow default bitwise copy construct
@@ -105,6 +105,15 @@ public:
         //- Read from file
         virtual bool read(const fileName&);
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
@@ -123,7 +132,7 @@ public:
         }
 
         //- Write UnsortedMeshedSurface
-        //  By default, the output is not sorted by regions
+        //  By default, the output is not sorted by zones
         static void write
         (
             Ostream&,
@@ -131,7 +140,7 @@ public:
         );
 
         //- Write UnsortedMeshedSurface
-        //  By default, the output is not sorted by regions
+        //  By default, the output is not sorted by zones
         static void write
         (
             const fileName& name,
diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C
index 0afd91d00fe950c77e7b86c3f1af7f0c9bf49d8b..8bb4e875e2bfde07a3502dc37b2e3416488c0b1a 100644
--- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C
@@ -43,7 +43,7 @@ Foam::fileFormats::TRIsurfaceFormatCore::TRIsurfaceFormatCore
 :
     sorted_(true),
     points_(0),
-    regionIds_(0),
+    zoneIds_(0),
     sizes_(0)
 {
     read(filename);
@@ -79,14 +79,14 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
     // uses similar structure as STL, just some points
     // the rest of the reader resembles the STL binary reader
     DynamicList<point> dynPoints;
-    DynamicList<label> dynRegions;
+    DynamicList<label> dynZones;
     DynamicList<label> dynSizes;
     HashTable<label>   lookup;
 
-    // place faces without a group in region0
-    label regionI = 0;
-    dynSizes.append(regionI);
-    lookup.insert("regionI", regionI);
+    // place faces without a group in zone0
+    label zoneI = 0;
+    dynSizes.append(zoneI);
+    lookup.insert("zoneI", zoneI);
 
     while (is.good())
     {
@@ -130,56 +130,56 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
             )
         );
 
-        // Region/colour in .tri file starts with 0x. Skip.
+        // zone/colour in .tri file starts with 0x. Skip.
         // ie, instead of having 0xFF, skip 0 and leave xFF to
-        // get read as a word and name it "regionFF"
+        // get read as a word and name it "zoneFF"
 
         char zero;
         lineStream >> zero;
 
         word rawName(lineStream);
-        word name("region" + rawName(1, rawName.size()-1));
+        word name("zone" + rawName(1, rawName.size()-1));
 
         HashTable<label>::const_iterator fnd = lookup.find(name);
         if (fnd != lookup.end())
         {
-            if (regionI != fnd())
+            if (zoneI != fnd())
             {
                 // group appeared out of order
                 sorted_ = false;
             }
-            regionI = fnd();
+            zoneI = fnd();
         }
         else
         {
-            regionI = dynSizes.size();
-            lookup.insert(name, regionI);
+            zoneI = dynSizes.size();
+            lookup.insert(name, zoneI);
             dynSizes.append(0);
         }
 
-        dynRegions.append(regionI);
-        dynSizes[regionI]++;
+        dynZones.append(zoneI);
+        dynSizes[zoneI]++;
     }
 
     // skip empty groups
-    label nRegion = 0;
-    forAll(dynSizes, regionI)
+    label nZone = 0;
+    forAll(dynSizes, zoneI)
     {
-        if (dynSizes[regionI])
+        if (dynSizes[zoneI])
         {
-            if (nRegion != regionI)
+            if (nZone != zoneI)
             {
-                dynSizes[nRegion] = dynSizes[regionI];
+                dynSizes[nZone] = dynSizes[zoneI];
             }
-            nRegion++;
+            nZone++;
         }
     }
     // truncate addressed size
-    dynSizes.setCapacity(nRegion);
+    dynSizes.setCapacity(nZone);
 
     // transfer to normal lists
     points_.transfer(dynPoints);
-    regionIds_.transfer(dynRegions);
+    zoneIds_.transfer(dynZones);
     sizes_.transfer(dynSizes);
 
     return true;
diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.H
index 776f40e9926e88e6e6ae738462bf36d7cbd03dc5..18855d8696d30595425a63e30a5495d7c3910634 100644
--- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.H
@@ -50,7 +50,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class TRIsurfaceFormatCore Declaration
+                    Class TRIsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class TRIsurfaceFormatCore
@@ -64,8 +64,8 @@ class TRIsurfaceFormatCore
         //- The points supporting the facets
         pointField points_;
 
-        //- The regions associated with the faces
-        List<label> regionIds_;
+        //- The zones associated with the faces
+        List<label> zoneIds_;
 
         //- The solid count, in the order of their first appearance
         List<label> sizes_;
@@ -104,7 +104,7 @@ public:
         {
             sorted_ = true;
             points_.clear();
-            regionIds_.clear();
+            zoneIds_.clear();
             sizes_.clear();
         }
 
@@ -114,13 +114,13 @@ public:
             return points_;
         }
 
-        //- Return full access to the regions
-        List<label>& regionIds()
+        //- Return full access to the zones
+        List<label>& zoneIds()
         {
-            return regionIds_;
+            return zoneIds_;
         }
 
-        //- The list of region sizes in the order of their first appearance
+        //- The list of zone sizes in the order of their first appearance
         List<label>& sizes()
         {
             return sizes_;
diff --git a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C
index da52bd4d7728635df8fc79187e4af04f88b34288..9a8723dd3b964e8145b90645da65c46fa8b7cf43 100644
--- a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C
+++ b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.C
@@ -62,19 +62,18 @@ template<class Face>
 void Foam::fileFormats::VTKsurfaceFormat<Face>::write
 (
     Ostream& os,
-    const MeshedSurface<Face>& surf
+    const pointField& pointLst,
+    const List<Face>& faceLst,
+    const List<surfZone>& zoneLst
 )
 {
-    const List<Face>& faceLst = surf.faces();
-    const List<surfRegion>& regionLst = surf.regions();
-
-    writeHeader(os, surf.points());
+    writeHeader(os, pointLst);
     writeHeaderPolygons(os, faceLst);
 
     label faceIndex = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             const Face& f = faceLst[faceIndex++];
 
@@ -87,7 +86,18 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
         }
     }
 
-    writeTail(os, regionLst);
+    writeTail(os, zoneLst);
+}
+
+
+template<class Face>
+void Foam::fileFormats::VTKsurfaceFormat<Face>::write
+(
+    Ostream& os,
+    const MeshedSurface<Face>& surf
+)
+{
+    write(os, surf.points(), surf.faces(), surf.zones());
 }
 
 
@@ -115,7 +125,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
         os << ' ' << nl;
     }
 
-    writeTail(os, surf.regionIds());
+    writeTail(os, surf.zoneIds());
 }
 
 
diff --git a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.H b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.H
index fe9f38621cf73e958fb5ec1dbbdc415526469223..22dc33ebc15ac8e4caa5015d0b63350495c85505 100644
--- a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.H
+++ b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormat.H
@@ -27,7 +27,7 @@ Class
 
 Description
     Provide a means of writing VTK legacy format.
-    The output is never sorted by region.
+    The output is never sorted by zone.
 
 SourceFiles
     VTKsurfaceFormat.C
@@ -89,6 +89,15 @@ public:
 
         // Write
 
+        //- Write surface mesh components
+        static void write
+        (
+            Ostream&,
+            const pointField&,
+            const List<Face>&,
+            const List<surfZone>&
+        );
+
         //- Write MeshedSurface
         static void write
         (
diff --git a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
index adbb487e14fbae90f96d3b76502310145509fbd6..fefb0de03c99719d1560effe20bd0ac8653a5ca7 100644
--- a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
+++ b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
@@ -58,25 +58,25 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
 (
     Ostream& os,
-    const UList<surfRegion>& regionLst
+    const UList<surfZone>& zoneLst
 )
 {
     label nFaces = 0;
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        nFaces += regionLst[regionI].size();
+        nFaces += zoneLst[zoneI].size();
     }
 
-    // Print region numbers
+    // Print zone numbers
     os  << nl
         << "CELL_DATA " << nFaces << nl
         << "FIELD attributes 1" << nl
-        << "region 1 " << nFaces << " float" << nl;
+        << "zone 1 " << nFaces << " float" << nl;
 
 
-    forAll(regionLst, regionI)
+    forAll(zoneLst, zoneI)
     {
-        forAll(regionLst[regionI], localFaceI)
+        forAll(zoneLst[zoneI], localFaceI)
         {
             if (localFaceI)
             {
@@ -89,7 +89,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
                     os << nl;
                 }
             }
-            os  << regionI + 1;
+            os  << zoneI + 1;
         }
         os  << nl;
     }
@@ -99,17 +99,16 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
 (
     Ostream& os,
-    const UList<label>& regionIds
+    const UList<label>& zoneIds
 )
 {
-    // Print region numbers
+    // Print zone numbers
     os  << nl
-        << "CELL_DATA " << regionIds.size() << nl
+        << "CELL_DATA " << zoneIds.size() << nl
         << "FIELD attributes 1" << nl
-        << "region 1 " << regionIds.size() << " float" << nl;
+        << "zone 1 " << zoneIds.size() << " float" << nl;
 
-
-    forAll(regionIds, faceI)
+    forAll(zoneIds, faceI)
     {
         if (faceI)
         {
@@ -122,7 +121,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
                 os << nl;
             }
         }
-        os  << regionIds[faceI] + 1;
+        os  << zoneIds[faceI] + 1;
     }
     os  << nl;
 }
diff --git a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H
index a68b4197cacd59f1216d08240f113f992deadd61..5165dfea127fef49dd50541766e1cfcddd3f822c 100644
--- a/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H
+++ b/src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H
@@ -49,7 +49,7 @@ namespace fileFormats
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class VTKsurfaceFormatCore Declaration
+                    Class VTKsurfaceFormatCore Declaration
 \*---------------------------------------------------------------------------*/
 
 class VTKsurfaceFormatCore
@@ -64,11 +64,11 @@ protected:
         const pointField&
     );
 
-    //- Write trailing information with region information
-    static void writeTail(Ostream&, const UList<surfRegion>&);
+    //- Write trailing information with zone information
+    static void writeTail(Ostream&, const UList<surfZone>&);
 
-    //- Write trailing information with region Ids
-    static void writeTail(Ostream&, const UList<label>& regionIds);
+    //- Write trailing information with zone Ids
+    static void writeTail(Ostream&, const UList<label>& zoneIds);
 
 };
 
diff --git a/src/surfMesh/surfaceRegistry/surfaceRegistry.C b/src/surfMesh/surfaceRegistry/surfaceRegistry.C
new file mode 100644
index 0000000000000000000000000000000000000000..335acfff0d8854299ce7a6e6ceb4ed49afa98ed4
--- /dev/null
+++ b/src/surfMesh/surfaceRegistry/surfaceRegistry.C
@@ -0,0 +1,68 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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 "surfaceRegistry.H"
+#include "Time.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+defineTypeNameAndDebug(Foam::surfaceRegistry, 0);
+
+const Foam::word Foam::surfaceRegistry::subInstance("surfaces");
+Foam::word Foam::surfaceRegistry::defaultName("default");
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::surfaceRegistry::surfaceRegistry
+(
+    const objectRegistry& obr,
+    const word& surfName
+)
+:
+    objectRegistry
+    (
+        IOobject
+        (
+            ( surfName.size() ? surfName : defaultName ),
+            obr.time().timeName(),
+            subInstance,
+            obr,
+            IOobject::NO_READ,
+            IOobject::NO_WRITE
+        )
+    )
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::surfaceRegistry::~surfaceRegistry()
+{}
+
+// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
+
+
+// ************************************************************************* //
diff --git a/src/surfMesh/surfaceRegistry/surfaceRegistry.H b/src/surfMesh/surfaceRegistry/surfaceRegistry.H
new file mode 100644
index 0000000000000000000000000000000000000000..fa4bad64eacc187a897479a184c0284d716bf34f
--- /dev/null
+++ b/src/surfMesh/surfaceRegistry/surfaceRegistry.H
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 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::surfaceRegistry
+
+Description
+    Wraps the normal objectRegistry with a local instance for %surfaces.
+
+SourceFiles
+    surfaceRegistry.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef surfaceRegistry_H
+#define surfaceRegistry_H
+
+#include "objectRegistry.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class surfaceRegistry Declaration
+\*---------------------------------------------------------------------------*/
+
+class surfaceRegistry
+:
+    public objectRegistry
+{
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        surfaceRegistry(const surfaceRegistry&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const surfaceRegistry&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("surfaceRegistry");
+
+        //- The subInstance (local) to prefix: %surfaces
+        static const word subInstance;
+
+        //- The default surface name: %default
+        static word defaultName;
+
+    // Constructors
+
+        //- Construct for the given objectRegistry and named surface
+        surfaceRegistry(const objectRegistry&, const word& surfName = "");
+
+
+    // Destructor
+
+        virtual ~surfaceRegistry();
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/thermophysicalModels/combustion/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/combustion/chemistryReaders/chemkinReader/chemkinReader.C
index a3ca294f019faec8cd12ac4ecbb5b79649f900fd..f04995cd3e241f41090f6f2b08f211dfb4bd2ecd 100644
--- a/src/thermophysicalModels/combustion/chemistryReaders/chemkinReader/chemkinReader.C
+++ b/src/thermophysicalModels/combustion/chemistryReaders/chemkinReader/chemkinReader.C
@@ -797,7 +797,7 @@ void Foam::chemkinReader::read
     const fileName& thermoFileName
 )
 {
-    if (thermoFileName != fileName::null)
+    if (thermoFileName.size())
     {
         std::ifstream thermoStream(thermoFileName.c_str());
 
diff --git a/src/triSurface/faceTriangulation/faceTriangulation.C b/src/triSurface/faceTriangulation/faceTriangulation.C
index 0317c3a94630bf0e37979eb5391c118dc2a29cd8..a2f1ed2aa087cebabca1028a1a3e6c05d9270566 100644
--- a/src/triSurface/faceTriangulation/faceTriangulation.C
+++ b/src/triSurface/faceTriangulation/faceTriangulation.C
@@ -33,17 +33,17 @@ License
 const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1E-6;
 
 
-//- Edge to the right of face vertex i
+// Edge to the right of face vertex i
 Foam::label Foam::faceTriangulation::right(const label, label i)
 {
     return i;
 }
 
 
-//- Edge to the left of face vertex i
+// Edge to the left of face vertex i
 Foam::label Foam::faceTriangulation::left(const label size, label i)
 {
-    return i == 0 ? size - 1 : (i - 1);
+    return i ? i-1 : size-1;
 }
 
 
@@ -60,10 +60,8 @@ Foam::tmp<Foam::vectorField> Foam::faceTriangulation::calcEdges
 
     forAll(f, i)
     {
-        label ni = f.fcIndex(i);
-
         point thisPt = points[f[i]];
-        point nextPt = points[f[ni]];
+        point nextPt = points[f[f.fcIndex(i)]];
 
         vector vec(nextPt - thisPt);
         vec /= mag(vec) + VSMALL;
@@ -109,7 +107,7 @@ void Foam::faceTriangulation::calcHalfAngle
 // Return true and intersection point if intersection between p1 and p2.
 Foam::pointHit Foam::faceTriangulation::rayEdgeIntersect
 (
-    const vector& normal, 
+    const vector& normal,
     const point& rayOrigin,
     const vector& rayDir,
     const point& p1,
@@ -225,10 +223,10 @@ void Foam::faceTriangulation::findDiagonal
     label minIndex = -1;
     scalar minPosOnEdge = GREAT;
 
-    for(label i = 0; i < f.size() - 2; i++)
+    for (label i = 0; i < f.size() - 2; i++)
     {
         scalar posOnEdge;
-        pointHit inter = 
+        pointHit inter =
             rayEdgeIntersect
             (
                 normal,
@@ -258,7 +256,7 @@ void Foam::faceTriangulation::findDiagonal
 
         index1 = -1;
         index2 = -1;
-        return;   
+        return;
     }
 
     const label leftIndex = minIndex;
@@ -299,7 +297,7 @@ void Foam::faceTriangulation::findDiagonal
 
     // all vertices except for startIndex and ones to left and right of it.
     faceVertI = f.fcIndex(f.fcIndex(startIndex));
-    for(label i = 0; i < f.size() - 3; i++)
+    for (label i = 0; i < f.size() - 3; i++)
     {
         const point& pt = points[f[faceVertI]];
 
@@ -400,7 +398,7 @@ Foam::label Foam::faceTriangulation::findStart
 
     return minIndex;
 }
-            
+
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
diff --git a/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.C b/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.C
index 1154d64c5607b9d7ce29414fc245e7c89121eec8..811525b0c551eeff8c9434cb1b50a7b25ef070c1 100644
--- a/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.C
+++ b/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.C
@@ -43,7 +43,7 @@ geometricSurfacePatch::geometricSurfacePatch()
 :
     geometricType_("empty"),
     name_("patch"),
-    boundaryIndex_(0)
+    index_(0)
 {}
 
 
@@ -57,7 +57,7 @@ geometricSurfacePatch::geometricSurfacePatch
 :
     geometricType_(geometricType),
     name_(name),
-    boundaryIndex_(index)
+    index_(index)
 
 {
     if (geometricType_.empty())
@@ -72,7 +72,7 @@ geometricSurfacePatch::geometricSurfacePatch(Istream& is, const label index)
 :
     geometricType_(is),
     name_(is),
-    boundaryIndex_(index)
+    index_(index)
 {
     if (geometricType_.empty())
     {
@@ -91,7 +91,7 @@ geometricSurfacePatch::geometricSurfacePatch
 :
     geometricType_(dict.lookup("geometricType")),
     name_(name),
-    boundaryIndex_(index)
+    index_(index)
 {
     if (geometricType_.empty())
     {
diff --git a/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.H b/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.H
index ffb935baee8c4bf465fd27288a6db62dde405c65..7db3f27bd99cfc25d46778f001b7fa3ddc867cd8 100644
--- a/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.H
+++ b/src/triSurface/triSurface/geometricSurfacePatch/geometricSurfacePatch.H
@@ -63,7 +63,7 @@ class geometricSurfacePatch
         word name_;
 
         //- Index of patch in boundary
-        label boundaryIndex_;
+        label index_;
 
 public:
 
@@ -125,7 +125,7 @@ public:
         //- Return the index of this patch in the boundaryMesh
         label index() const
         {
-            return boundaryIndex_;
+            return index_;
         }
 
         //- Write
diff --git a/src/triSurface/triSurface/interfaces/OBJ/readOBJ.C b/src/triSurface/triSurface/interfaces/OBJ/readOBJ.C
index cfab7e726f84593ec2025d49523debff5463e583..20c3d9cc65d4ebda88b31578e000283efac832c0 100644
--- a/src/triSurface/triSurface/interfaces/OBJ/readOBJ.C
+++ b/src/triSurface/triSurface/interfaces/OBJ/readOBJ.C
@@ -153,7 +153,7 @@ bool triSurface::readOBJ(const fileName& OBJfileName)
             // Cannot use face::triangulation since no complete points yet.
             for (label fp = 1; fp < verts.size() - 1; fp++)
             {
-                label fp1 = (fp + 1) % verts.size();
+                label fp1 = verts.fcIndex(fp);
 
                 labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
 
diff --git a/src/triSurface/triSurface/interfaces/STL/readSTLBINARY.C b/src/triSurface/triSurface/interfaces/STL/readSTLBINARY.C
index 4c7c9e859a0f8fe8bab58ccceea07404dbead039..f2a615fe9ff5d35bf86e9bcba3a1980d9e039480 100644
--- a/src/triSurface/triSurface/interfaces/STL/readSTLBINARY.C
+++ b/src/triSurface/triSurface/interfaces/STL/readSTLBINARY.C
@@ -47,8 +47,9 @@ bool triSurface::readSTLBINARY(const fileName& STLfileName)
     (
         new ifstream(STLfileName.c_str(), std::ios::binary)
     );
+
     // If the file is compressed, decompress it before reading.
-    if (!STLfilePtr->good() && file(STLfileName + ".gz"))
+    if (!STLfilePtr->good() && isFile(STLfileName + ".gz", false))
     {
         compressed = true;
         STLfilePtr.reset(new igzstream((STLfileName + ".gz").c_str()));
diff --git a/src/triSurface/triSurface/stitchTriangles.C b/src/triSurface/triSurface/stitchTriangles.C
index c53f429c3903b851702c80e2bc1c20929bb93067..7ef6ad719b6e3faf4e87bc09fa5863b8d81b08f1 100644
--- a/src/triSurface/triSurface/stitchTriangles.C
+++ b/src/triSurface/triSurface/stitchTriangles.C
@@ -54,7 +54,7 @@ bool triSurface::stitchTriangles
                 << " points down to " << newPoints.size() << endl;
         }
 
-        pointField& ps = const_cast<pointField&>(points());
+        pointField& ps = storedPoints();
 
         // Set the coordinates to the merged ones
         ps = newPoints;
diff --git a/src/triSurface/triSurface/triSurface.C b/src/triSurface/triSurface/triSurface.C
index e589ec61586a684e335d4135710414004e8960a1..9b63d3de86259314aad1db4227c38f16476c11ec 100644
--- a/src/triSurface/triSurface/triSurface.C
+++ b/src/triSurface/triSurface/triSurface.C
@@ -67,7 +67,7 @@ Foam::fileName Foam::triSurface::triSurfInstance(const Time& d)
     {
         for (label j=i; j>=0; j--)
         {
-            if (file(d.path()/ts[j].name()/typeName/foamName))
+            if (isFile(d.path()/ts[j].name()/typeName/foamName))
             {
                 if (debug)
                 {
@@ -471,8 +471,7 @@ Foam::boolList Foam::triSurface::checkOrientation(const bool verbose)
 // Read triangles, points from Istream
 bool Foam::triSurface::read(Istream& is)
 {
-    is  >> patches_ >> const_cast<pointField&>(points())
-        >> static_cast<List<labelledTri>&>(*this);
+    is  >> patches_ >> storedPoints() >> storedFaces();
 
     return true;
 }
@@ -724,7 +723,7 @@ void Foam::triSurface::setDefaultPatches()
 
 Foam::triSurface::triSurface()
 :
-    MeshStorage(List<FaceType>(), pointField()),
+    ParentType(List<Face>(), pointField()),
     patches_(0),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -739,7 +738,7 @@ Foam::triSurface::triSurface
     const pointField& points
 )
 :
-    MeshStorage(triangles, points),
+    ParentType(triangles, points),
     patches_(patches),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -754,7 +753,7 @@ Foam::triSurface::triSurface
     const bool reUse
 )
 :
-    MeshStorage(triangles, points, reUse),
+    ParentType(triangles, points, reUse),
     patches_(patches),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -767,7 +766,7 @@ Foam::triSurface::triSurface
     const pointField& points
 )
 :
-    MeshStorage(triangles, points),
+    ParentType(triangles, points),
     patches_(),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -782,7 +781,7 @@ Foam::triSurface::triSurface
     const pointField& points
 )
 :
-    MeshStorage(convertToTri(triangles, 0), points),
+    ParentType(convertToTri(triangles, 0), points),
     patches_(),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -793,7 +792,7 @@ Foam::triSurface::triSurface
 
 Foam::triSurface::triSurface(const fileName& name)
 :
-    MeshStorage(List<FaceType>(), pointField()),
+    ParentType(List<Face>(), pointField()),
     patches_(),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -808,7 +807,7 @@ Foam::triSurface::triSurface(const fileName& name)
 
 Foam::triSurface::triSurface(Istream& is)
 :
-    MeshStorage(List<FaceType>(), pointField()),
+    ParentType(List<Face>(), pointField()),
     patches_(),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -821,7 +820,7 @@ Foam::triSurface::triSurface(Istream& is)
 
 Foam::triSurface::triSurface(const Time& d)
 :
-    MeshStorage(List<FaceType>(), pointField()),
+    ParentType(List<Face>(), pointField()),
     patches_(),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -840,7 +839,7 @@ Foam::triSurface::triSurface(const Time& d)
 
 Foam::triSurface::triSurface(const triSurface& ts)
 :
-    MeshStorage(ts, ts.points()),
+    ParentType(ts, ts.points()),
     patches_(ts.patches()),
     sortedEdgeFacesPtr_(NULL),
     edgeOwnerPtr_(NULL)
@@ -859,7 +858,7 @@ Foam::triSurface::~triSurface()
 
 void Foam::triSurface::clearTopology()
 {
-    MeshStorage::clearTopology();
+    ParentType::clearTopology();
     deleteDemandDrivenData(sortedEdgeFacesPtr_);
     deleteDemandDrivenData(edgeOwnerPtr_);
 }
@@ -867,13 +866,13 @@ void Foam::triSurface::clearTopology()
 
 void Foam::triSurface::clearPatchMeshAddr()
 {
-    MeshStorage::clearPatchMeshAddr();
+    ParentType::clearPatchMeshAddr();
 }
 
 
 void Foam::triSurface::clearOut()
 {
-    MeshStorage::clearOut();
+    ParentType::clearOut();
 
     clearTopology();
     clearPatchMeshAddr();
@@ -909,10 +908,10 @@ void Foam::triSurface::movePoints(const pointField& newPoints)
     deleteDemandDrivenData(sortedEdgeFacesPtr_);
 
     // Adapt for new point position
-    MeshStorage::movePoints(newPoints);
+    ParentType::movePoints(newPoints);
 
     // Copy new points
-    const_cast<pointField&>(points()) = newPoints;
+    storedPoints() = newPoints;
 }
 
 
@@ -926,9 +925,9 @@ void Foam::triSurface::scalePoints(const scalar& scaleFactor)
         clearTopology();
 
         // Adapt for new point position
-        MeshStorage::movePoints(pointField());
+        ParentType::movePoints(pointField());
 
-        const_cast<pointField&>(points()) *= scaleFactor;
+        storedPoints() *= scaleFactor;
     }
 }
 
@@ -1240,7 +1239,7 @@ void Foam::triSurface::operator=(const triSurface& ts)
 {
     List<labelledTri>::operator=(ts);
     clearOut();
-    const_cast<pointField&>(points()) = ts.points();
+    storedPoints() = ts.points();
     patches_ = ts.patches();
 }
 
diff --git a/src/triSurface/triSurface/triSurface.H b/src/triSurface/triSurface/triSurface.H
index b9bf8cdbb012bd7fcb08f557c52f8a87bcc1c4d9..e6fb6239afec2313987fcd7ec582774740e29a02 100644
--- a/src/triSurface/triSurface/triSurface.H
+++ b/src/triSurface/triSurface/triSurface.H
@@ -58,27 +58,21 @@ class IFstream;
 
 class triSurface
 :
-    public PrimitivePatch<labelledTri, List, pointField, point>
+    public PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
 {
-protected:
-
-    // Protected Member Data
-
-        //- Typedef for similar code in keyedSurface and meshedSurface
-        typedef labelledTri FaceType;
-
-private:
-
     // Private typedefs
 
+    //- Typedefs for convenience
+        typedef labelledTri Face;
         typedef PrimitivePatch
         <
-            FaceType,
+            labelledTri,
             ::Foam::List,
             pointField,
             point
         >
-        MeshStorage;
+        ParentType;
+
 
     // Private data
 
@@ -201,17 +195,39 @@ private:
         //- helper function to print triangle info
         static void printTriangle
         (
-            Ostream& os,
+            Ostream&,
             const Foam::string& pre,
-            const labelledTri& f,
-            const pointField& points
+            const labelledTri&,
+            const pointField&
         );
 
         //- read non-comment line
         static string getLineNoComment(IFstream&);
 
+protected:
+
+    // Protected Member Functions
+
+        //- Non-const access to global points
+        pointField& storedPoints()
+        {
+            return const_cast<pointField&>(ParentType::points());
+        }
+
+        //- Non-const access to the faces
+        List<Face>& storedFaces()
+        {
+            return static_cast<List<Face>&>(*this);
+        }
+
 public:
 
+    // Public typedefs
+
+        //- Placeholder only, but do not remove - it is needed for GeoMesh
+        typedef bool BoundaryMesh;
+
+
         //- Runtime type information
         ClassName("triSurface");
 
diff --git a/src/triSurface/triSurfaceFields/triSurfaceFields.C b/src/triSurface/triSurfaceFields/triSurfaceFields.C
index e40a26a89344264be1fff7eb34aa4e54ce94f67b..f206d52d28ccbce3ab5efd52cd5800d68f55dc00 100644
--- a/src/triSurface/triSurfaceFields/triSurfaceFields.C
+++ b/src/triSurface/triSurfaceFields/triSurfaceFields.C
@@ -25,8 +25,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "triSurfaceFields.H"
-#include "DimensionedField.H"
-#include "triSurfaceGeoMesh.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/triSurface/triSurfaceFields/triSurfaceGeoMesh.H b/src/triSurface/triSurfaceFields/triSurfaceGeoMesh.H
index eeeb995bb773beb9436deb5f67a9f18419b5cf16..0e129f441f8e860bec814d212e965da49ba13649 100644
--- a/src/triSurface/triSurfaceFields/triSurfaceGeoMesh.H
+++ b/src/triSurface/triSurfaceFields/triSurfaceGeoMesh.H
@@ -26,13 +26,16 @@ Class
     Foam::triSurfaceGeoMesh
 
 Description
-    The triSurface geoMesh
+    The triSurface GeoMesh (for holding fields).
+
+    Similar to the volGeoMesh used for the Finite Volume discretization.
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef triSurfaceGeoMesh_H
 #define triSurfaceGeoMesh_H
 
+#include "GeoMesh.H"
 #include "triSurface.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -43,52 +46,33 @@ namespace Foam
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 class triSurfaceGeoMesh
+:
+    public GeoMesh<triSurface>
 {
 
-protected:
-
-    // Protected data
-
-        //- Reference to Mesh
-        const triSurface& mesh_;
-
-
 public:
 
-    // Public typedefs
-
-        typedef triSurface Mesh;
-
-
     // Constructors
 
-        //- Construct from Mesh
+        //- Construct from triSurface reference
         explicit triSurfaceGeoMesh(const triSurface& mesh)
         :
-            mesh_(mesh)
+            GeoMesh<triSurface>(mesh)
         {}
 
 
     // Member Functions
 
-        //- Return size
-        label size() const
-        {
-            return size(mesh_);
-        }
-
         //- Return size
         static label size(const triSurface& mesh)
         {
             return mesh.size();
         }
 
-    // Member Operators
-
-        //- Return reference to triSurface
-        const triSurface& operator()() const
+        //- Return size
+        label size() const
         {
-            return mesh_;
+            return size(mesh_);
         }
 
 };
diff --git a/tutorials/MRFSimpleFoam/mixerVessel2D/system/controlDict b/tutorials/MRFSimpleFoam/mixerVessel2D/system/controlDict
index 7102d4b8a6e4a3d79a56b89221132f53a936844a..2afc0afc4f479af8ad94b9d8e534b7fd5754a334 100644
--- a/tutorials/MRFSimpleFoam/mixerVessel2D/system/controlDict
+++ b/tutorials/MRFSimpleFoam/mixerVessel2D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application simpleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/XiFoam/moriyoshiHomogeneous/system/controlDict b/tutorials/XiFoam/moriyoshiHomogeneous/system/controlDict
index ca4477d3c7bb1b558449cb698d199bd4640770b7..8cf37a24956d56096a164d5e82f1b323176694e1 100644
--- a/tutorials/XiFoam/moriyoshiHomogeneous/system/controlDict
+++ b/tutorials/XiFoam/moriyoshiHomogeneous/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application XiFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/Xoodles/pitzDaily/system/controlDict b/tutorials/Xoodles/pitzDaily/system/controlDict
index a0d269e353698883654d7bc726726a132f214991..eb71c634bbed219bdd043b57d6161d9901bdad21 100644
--- a/tutorials/Xoodles/pitzDaily/system/controlDict
+++ b/tutorials/Xoodles/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application Xoodles;
 
 startFrom       startTime;
 
@@ -52,7 +51,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/Xoodles/pitzDaily3D/system/controlDict b/tutorials/Xoodles/pitzDaily3D/system/controlDict
index d6a13d876c19a542eaadaf8eff8e46dc07c7ab4c..26a0e1c65af2be625a4902ab7e09847d3a4e75a8 100644
--- a/tutorials/Xoodles/pitzDaily3D/system/controlDict
+++ b/tutorials/Xoodles/pitzDaily3D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application Xoodles;
 
 startFrom       startTime;
 
@@ -52,7 +51,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/boundaryFoam/boundaryLaunderSharma/system/controlDict b/tutorials/boundaryFoam/boundaryLaunderSharma/system/controlDict
index 8d6ce6be99c0f0b4fb994a2c11fc4d1f3654b946..db61aae9da3e4d163f18be4fc796458e99b90e12 100644
--- a/tutorials/boundaryFoam/boundaryLaunderSharma/system/controlDict
+++ b/tutorials/boundaryFoam/boundaryLaunderSharma/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application boundaryFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/boundaryFoam/boundaryWallFunctions/system/controlDict b/tutorials/boundaryFoam/boundaryWallFunctions/system/controlDict
index 91d4f859c5b6ec5ea84865bb6582cfac7598fd58..0ae7a20daf5398aa2cc17f488b8ed315f2016084 100644
--- a/tutorials/boundaryFoam/boundaryWallFunctions/system/controlDict
+++ b/tutorials/boundaryFoam/boundaryWallFunctions/system/controlDict
@@ -15,7 +15,6 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // Foam Application Class
-application boundaryFoam;
 
 // Start point of run
 startFrom       startTime;
diff --git a/tutorials/bubbleFoam/bubbleColumn/system/controlDict b/tutorials/bubbleFoam/bubbleColumn/system/controlDict
index 81d138664958178f49d70e431c2d33fdaece98f7..aad7cb2e7540f810f3fee89159c6e089b21fccb9 100644
--- a/tutorials/bubbleFoam/bubbleColumn/system/controlDict
+++ b/tutorials/bubbleFoam/bubbleColumn/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application bubbleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/buoyantFoam/hotRoom/system/controlDict b/tutorials/buoyantFoam/hotRoom/system/controlDict
index 914a70cd73be5a496f641138a928c820389b85e9..513d5d8d857441f6bd89ea580b71ce538fe98ba5 100644
--- a/tutorials/buoyantFoam/hotRoom/system/controlDict
+++ b/tutorials/buoyantFoam/hotRoom/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application buoyantFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/buoyantSimpleFoam/hotRoom/system/controlDict b/tutorials/buoyantSimpleFoam/hotRoom/system/controlDict
index ffea3fc1620bbeea236ceaa7455708a2d519734d..b29648dddaa5e148ddcae7e6a39a9ecc25d69edb 100644
--- a/tutorials/buoyantSimpleFoam/hotRoom/system/controlDict
+++ b/tutorials/buoyantSimpleFoam/hotRoom/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application buoyantSimpleFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/buoyantSimpleRadiationFoam/hotRadiationRoom/system/controlDict b/tutorials/buoyantSimpleRadiationFoam/hotRadiationRoom/system/controlDict
index 53bd0fbe62690f6887e58c11f5cefe183ed44555..b29648dddaa5e148ddcae7e6a39a9ecc25d69edb 100644
--- a/tutorials/buoyantSimpleRadiationFoam/hotRadiationRoom/system/controlDict
+++ b/tutorials/buoyantSimpleRadiationFoam/hotRadiationRoom/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     buoyantSimpleRadiationFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/lesCavitatingFoam/Allclean b/tutorials/cavitatingFoam/les/Allclean
similarity index 100%
rename from tutorials/lesCavitatingFoam/Allclean
rename to tutorials/cavitatingFoam/les/Allclean
diff --git a/tutorials/lesCavitatingFoam/Allrun b/tutorials/cavitatingFoam/les/Allrun
similarity index 100%
rename from tutorials/lesCavitatingFoam/Allrun
rename to tutorials/cavitatingFoam/les/Allrun
diff --git a/tutorials/lesCavitatingFoam/throttle/0/U b/tutorials/cavitatingFoam/les/throttle/0/U
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/U
rename to tutorials/cavitatingFoam/les/throttle/0/U
diff --git a/tutorials/lesCavitatingFoam/throttle/0/gamma b/tutorials/cavitatingFoam/les/throttle/0/gamma
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/gamma
rename to tutorials/cavitatingFoam/les/throttle/0/gamma
diff --git a/tutorials/lesCavitatingFoam/throttle/0/k b/tutorials/cavitatingFoam/les/throttle/0/k
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/k
rename to tutorials/cavitatingFoam/les/throttle/0/k
diff --git a/tutorials/lesCavitatingFoam/throttle/0/nuSgs b/tutorials/cavitatingFoam/les/throttle/0/nuSgs
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/nuSgs
rename to tutorials/cavitatingFoam/les/throttle/0/nuSgs
diff --git a/tutorials/lesCavitatingFoam/throttle/0/p b/tutorials/cavitatingFoam/les/throttle/0/p
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/p
rename to tutorials/cavitatingFoam/les/throttle/0/p
diff --git a/tutorials/lesCavitatingFoam/throttle/0/rho b/tutorials/cavitatingFoam/les/throttle/0/rho
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/0/rho
rename to tutorials/cavitatingFoam/les/throttle/0/rho
diff --git a/tutorials/lesCavitatingFoam/throttle/constant/LESProperties b/tutorials/cavitatingFoam/les/throttle/constant/LESProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/constant/LESProperties
rename to tutorials/cavitatingFoam/les/throttle/constant/LESProperties
diff --git a/tutorials/lesCavitatingFoam/throttle/constant/polyMesh/blockMeshDict b/tutorials/cavitatingFoam/les/throttle/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/constant/polyMesh/blockMeshDict
rename to tutorials/cavitatingFoam/les/throttle/constant/polyMesh/blockMeshDict
diff --git a/tutorials/lesCavitatingFoam/throttle/constant/polyMesh/boundary b/tutorials/cavitatingFoam/les/throttle/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/constant/polyMesh/boundary
rename to tutorials/cavitatingFoam/les/throttle/constant/polyMesh/boundary
diff --git a/tutorials/lesCavitatingFoam/throttle/constant/thermodynamicProperties b/tutorials/cavitatingFoam/les/throttle/constant/thermodynamicProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/constant/thermodynamicProperties
rename to tutorials/cavitatingFoam/les/throttle/constant/thermodynamicProperties
diff --git a/tutorials/lesCavitatingFoam/throttle/constant/transportProperties b/tutorials/cavitatingFoam/les/throttle/constant/transportProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/constant/transportProperties
rename to tutorials/cavitatingFoam/les/throttle/constant/transportProperties
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/turbulenceProperties b/tutorials/cavitatingFoam/les/throttle/constant/turbulenceProperties
similarity index 97%
rename from tutorials/interFoam/nozzleFlow2D/constant/turbulenceProperties
rename to tutorials/cavitatingFoam/les/throttle/constant/turbulenceProperties
index e53dd92be33834460d1da9362d9166ff22dd4626..dcadcf17cd97481597090cf391913d3fe6432687 100644
--- a/tutorials/interFoam/nozzleFlow2D/constant/turbulenceProperties
+++ b/tutorials/cavitatingFoam/les/throttle/constant/turbulenceProperties
@@ -14,6 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-simulationType LESModel;
+simulationType  LESModel;
 
 // ************************************************************************* //
diff --git a/tutorials/lesCavitatingFoam/throttle/system/cellSetDict.1 b/tutorials/cavitatingFoam/les/throttle/system/cellSetDict.1
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/cellSetDict.1
rename to tutorials/cavitatingFoam/les/throttle/system/cellSetDict.1
diff --git a/tutorials/lesCavitatingFoam/throttle/system/cellSetDict.2 b/tutorials/cavitatingFoam/les/throttle/system/cellSetDict.2
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/cellSetDict.2
rename to tutorials/cavitatingFoam/les/throttle/system/cellSetDict.2
diff --git a/tutorials/lesCavitatingFoam/throttle/system/cellSetDict.3 b/tutorials/cavitatingFoam/les/throttle/system/cellSetDict.3
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/cellSetDict.3
rename to tutorials/cavitatingFoam/les/throttle/system/cellSetDict.3
diff --git a/tutorials/lesCavitatingFoam/throttle/system/controlDict b/tutorials/cavitatingFoam/les/throttle/system/controlDict
similarity index 97%
rename from tutorials/lesCavitatingFoam/throttle/system/controlDict
rename to tutorials/cavitatingFoam/les/throttle/system/controlDict
index 737c51177ac6c7b1db2ee2bab838a440eb5c840d..8c40820a16523c37fd0b3d8430345fc7408b0ad6 100644
--- a/tutorials/lesCavitatingFoam/throttle/system/controlDict
+++ b/tutorials/cavitatingFoam/les/throttle/system/controlDict
@@ -54,7 +54,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled false;
 
diff --git a/tutorials/lesCavitatingFoam/throttle/system/fvSchemes b/tutorials/cavitatingFoam/les/throttle/system/fvSchemes
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/fvSchemes
rename to tutorials/cavitatingFoam/les/throttle/system/fvSchemes
diff --git a/tutorials/lesCavitatingFoam/throttle/system/fvSolution b/tutorials/cavitatingFoam/les/throttle/system/fvSolution
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/fvSolution
rename to tutorials/cavitatingFoam/les/throttle/system/fvSolution
diff --git a/tutorials/lesCavitatingFoam/throttle/system/refineMeshDict b/tutorials/cavitatingFoam/les/throttle/system/refineMeshDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle/system/refineMeshDict
rename to tutorials/cavitatingFoam/les/throttle/system/refineMeshDict
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/U b/tutorials/cavitatingFoam/les/throttle3D/0.org/U
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/U
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/U
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/gamma b/tutorials/cavitatingFoam/les/throttle3D/0.org/gamma
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/gamma
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/gamma
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/k b/tutorials/cavitatingFoam/les/throttle3D/0.org/k
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/k
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/k
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/nuSgs b/tutorials/cavitatingFoam/les/throttle3D/0.org/nuSgs
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/nuSgs
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/nuSgs
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/p b/tutorials/cavitatingFoam/les/throttle3D/0.org/p
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/p
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/p
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0.org/rho b/tutorials/cavitatingFoam/les/throttle3D/0.org/rho
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0.org/rho
rename to tutorials/cavitatingFoam/les/throttle3D/0.org/rho
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/U b/tutorials/cavitatingFoam/les/throttle3D/0/U
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/U
rename to tutorials/cavitatingFoam/les/throttle3D/0/U
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/gamma b/tutorials/cavitatingFoam/les/throttle3D/0/gamma
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/gamma
rename to tutorials/cavitatingFoam/les/throttle3D/0/gamma
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/k b/tutorials/cavitatingFoam/les/throttle3D/0/k
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/k
rename to tutorials/cavitatingFoam/les/throttle3D/0/k
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/nuSgs b/tutorials/cavitatingFoam/les/throttle3D/0/nuSgs
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/nuSgs
rename to tutorials/cavitatingFoam/les/throttle3D/0/nuSgs
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/p b/tutorials/cavitatingFoam/les/throttle3D/0/p
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/p
rename to tutorials/cavitatingFoam/les/throttle3D/0/p
diff --git a/tutorials/lesCavitatingFoam/throttle3D/0/rho b/tutorials/cavitatingFoam/les/throttle3D/0/rho
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/0/rho
rename to tutorials/cavitatingFoam/les/throttle3D/0/rho
diff --git a/tutorials/lesCavitatingFoam/throttle3D/constant/LESProperties b/tutorials/cavitatingFoam/les/throttle3D/constant/LESProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/constant/LESProperties
rename to tutorials/cavitatingFoam/les/throttle3D/constant/LESProperties
diff --git a/tutorials/lesCavitatingFoam/throttle3D/constant/polyMesh/blockMeshDict b/tutorials/cavitatingFoam/les/throttle3D/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/constant/polyMesh/blockMeshDict
rename to tutorials/cavitatingFoam/les/throttle3D/constant/polyMesh/blockMeshDict
diff --git a/tutorials/lesCavitatingFoam/throttle3D/constant/polyMesh/boundary b/tutorials/cavitatingFoam/les/throttle3D/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/constant/polyMesh/boundary
rename to tutorials/cavitatingFoam/les/throttle3D/constant/polyMesh/boundary
diff --git a/tutorials/lesCavitatingFoam/throttle3D/constant/thermodynamicProperties b/tutorials/cavitatingFoam/les/throttle3D/constant/thermodynamicProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/constant/thermodynamicProperties
rename to tutorials/cavitatingFoam/les/throttle3D/constant/thermodynamicProperties
diff --git a/tutorials/lesCavitatingFoam/throttle3D/constant/transportProperties b/tutorials/cavitatingFoam/les/throttle3D/constant/transportProperties
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/constant/transportProperties
rename to tutorials/cavitatingFoam/les/throttle3D/constant/transportProperties
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.1 b/tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.1
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.1
rename to tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.1
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.2 b/tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.2
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.2
rename to tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.2
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.3 b/tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.3
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/cellSetDict.3
rename to tutorials/cavitatingFoam/les/throttle3D/system/cellSetDict.3
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/controlDict b/tutorials/cavitatingFoam/les/throttle3D/system/controlDict
similarity index 97%
rename from tutorials/lesCavitatingFoam/throttle3D/system/controlDict
rename to tutorials/cavitatingFoam/les/throttle3D/system/controlDict
index e724478c85a379c5ef59a3a4876f788cfdb5bda3..903c0569a51c7c07ebdc28649a2b1e30eb78d4c8 100644
--- a/tutorials/lesCavitatingFoam/throttle3D/system/controlDict
+++ b/tutorials/cavitatingFoam/les/throttle3D/system/controlDict
@@ -54,7 +54,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled false;
 
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/decomposeParDict b/tutorials/cavitatingFoam/les/throttle3D/system/decomposeParDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/decomposeParDict
rename to tutorials/cavitatingFoam/les/throttle3D/system/decomposeParDict
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/fvSchemes b/tutorials/cavitatingFoam/les/throttle3D/system/fvSchemes
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/fvSchemes
rename to tutorials/cavitatingFoam/les/throttle3D/system/fvSchemes
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/fvSolution b/tutorials/cavitatingFoam/les/throttle3D/system/fvSolution
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/fvSolution
rename to tutorials/cavitatingFoam/les/throttle3D/system/fvSolution
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/mapFieldsDict b/tutorials/cavitatingFoam/les/throttle3D/system/mapFieldsDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/mapFieldsDict
rename to tutorials/cavitatingFoam/les/throttle3D/system/mapFieldsDict
diff --git a/tutorials/lesCavitatingFoam/throttle3D/system/refineMeshDict b/tutorials/cavitatingFoam/les/throttle3D/system/refineMeshDict
similarity index 100%
rename from tutorials/lesCavitatingFoam/throttle3D/system/refineMeshDict
rename to tutorials/cavitatingFoam/les/throttle3D/system/refineMeshDict
diff --git a/tutorials/rasCavitatingFoam/throttle/0/U b/tutorials/cavitatingFoam/ras/throttle/0/U
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/U
rename to tutorials/cavitatingFoam/ras/throttle/0/U
diff --git a/tutorials/rasCavitatingFoam/throttle/0/gamma b/tutorials/cavitatingFoam/ras/throttle/0/gamma
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/gamma
rename to tutorials/cavitatingFoam/ras/throttle/0/gamma
diff --git a/tutorials/rasCavitatingFoam/throttle/0/k b/tutorials/cavitatingFoam/ras/throttle/0/k
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/k
rename to tutorials/cavitatingFoam/ras/throttle/0/k
diff --git a/tutorials/rasCavitatingFoam/throttle/0/omega b/tutorials/cavitatingFoam/ras/throttle/0/omega
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/omega
rename to tutorials/cavitatingFoam/ras/throttle/0/omega
diff --git a/tutorials/rasCavitatingFoam/throttle/0/p b/tutorials/cavitatingFoam/ras/throttle/0/p
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/p
rename to tutorials/cavitatingFoam/ras/throttle/0/p
diff --git a/tutorials/rasCavitatingFoam/throttle/0/rho b/tutorials/cavitatingFoam/ras/throttle/0/rho
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/0/rho
rename to tutorials/cavitatingFoam/ras/throttle/0/rho
diff --git a/tutorials/rasCavitatingFoam/throttle/Allclean b/tutorials/cavitatingFoam/ras/throttle/Allclean
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/Allclean
rename to tutorials/cavitatingFoam/ras/throttle/Allclean
diff --git a/tutorials/rasCavitatingFoam/throttle/Allrun b/tutorials/cavitatingFoam/ras/throttle/Allrun
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/Allrun
rename to tutorials/cavitatingFoam/ras/throttle/Allrun
diff --git a/tutorials/rasCavitatingFoam/throttle/constant/RASProperties b/tutorials/cavitatingFoam/ras/throttle/constant/RASProperties
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/constant/RASProperties
rename to tutorials/cavitatingFoam/ras/throttle/constant/RASProperties
diff --git a/tutorials/rasCavitatingFoam/throttle/constant/polyMesh/blockMeshDict b/tutorials/cavitatingFoam/ras/throttle/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/constant/polyMesh/blockMeshDict
rename to tutorials/cavitatingFoam/ras/throttle/constant/polyMesh/blockMeshDict
diff --git a/tutorials/rasCavitatingFoam/throttle/constant/polyMesh/boundary b/tutorials/cavitatingFoam/ras/throttle/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/constant/polyMesh/boundary
rename to tutorials/cavitatingFoam/ras/throttle/constant/polyMesh/boundary
diff --git a/tutorials/rasCavitatingFoam/throttle/constant/thermodynamicProperties b/tutorials/cavitatingFoam/ras/throttle/constant/thermodynamicProperties
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/constant/thermodynamicProperties
rename to tutorials/cavitatingFoam/ras/throttle/constant/thermodynamicProperties
diff --git a/tutorials/rasCavitatingFoam/throttle/constant/transportProperties b/tutorials/cavitatingFoam/ras/throttle/constant/transportProperties
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/constant/transportProperties
rename to tutorials/cavitatingFoam/ras/throttle/constant/transportProperties
diff --git a/tutorials/cavitatingFoam/ras/throttle/constant/turbulenceProperties b/tutorials/cavitatingFoam/ras/throttle/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..07f85c68df22113b7c7747b89457597b0ea41d66
--- /dev/null
+++ b/tutorials/cavitatingFoam/ras/throttle/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  RASModel;
+
+// ************************************************************************* //
diff --git a/tutorials/rasCavitatingFoam/throttle/system/cellSetDict.1 b/tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.1
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/cellSetDict.1
rename to tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.1
diff --git a/tutorials/rasCavitatingFoam/throttle/system/cellSetDict.2 b/tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.2
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/cellSetDict.2
rename to tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.2
diff --git a/tutorials/rasCavitatingFoam/throttle/system/cellSetDict.3 b/tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.3
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/cellSetDict.3
rename to tutorials/cavitatingFoam/ras/throttle/system/cellSetDict.3
diff --git a/tutorials/rasCavitatingFoam/throttle/system/controlDict b/tutorials/cavitatingFoam/ras/throttle/system/controlDict
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/controlDict
rename to tutorials/cavitatingFoam/ras/throttle/system/controlDict
diff --git a/tutorials/rasCavitatingFoam/throttle/system/fvSchemes b/tutorials/cavitatingFoam/ras/throttle/system/fvSchemes
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/fvSchemes
rename to tutorials/cavitatingFoam/ras/throttle/system/fvSchemes
diff --git a/tutorials/rasCavitatingFoam/throttle/system/fvSolution b/tutorials/cavitatingFoam/ras/throttle/system/fvSolution
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/fvSolution
rename to tutorials/cavitatingFoam/ras/throttle/system/fvSolution
diff --git a/tutorials/rasCavitatingFoam/throttle/system/refineMeshDict b/tutorials/cavitatingFoam/ras/throttle/system/refineMeshDict
similarity index 100%
rename from tutorials/rasCavitatingFoam/throttle/system/refineMeshDict
rename to tutorials/cavitatingFoam/ras/throttle/system/refineMeshDict
diff --git a/tutorials/channelOodles/channel395/0.org/B b/tutorials/channelFoam/channel395/0.org/B
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/B
rename to tutorials/channelFoam/channel395/0.org/B
diff --git a/tutorials/channelOodles/channel395/0.org/U b/tutorials/channelFoam/channel395/0.org/U
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/U
rename to tutorials/channelFoam/channel395/0.org/U
diff --git a/tutorials/channelOodles/channel395/0.org/k b/tutorials/channelFoam/channel395/0.org/k
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/k
rename to tutorials/channelFoam/channel395/0.org/k
diff --git a/tutorials/channelOodles/channel395/0.org/nuSgs b/tutorials/channelFoam/channel395/0.org/nuSgs
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/nuSgs
rename to tutorials/channelFoam/channel395/0.org/nuSgs
diff --git a/tutorials/channelOodles/channel395/0.org/nuTilda b/tutorials/channelFoam/channel395/0.org/nuTilda
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/nuTilda
rename to tutorials/channelFoam/channel395/0.org/nuTilda
diff --git a/tutorials/channelOodles/channel395/0.org/p b/tutorials/channelFoam/channel395/0.org/p
similarity index 100%
rename from tutorials/channelOodles/channel395/0.org/p
rename to tutorials/channelFoam/channel395/0.org/p
diff --git a/tutorials/channelOodles/channel395/0/B.gz b/tutorials/channelFoam/channel395/0/B.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/B.gz
rename to tutorials/channelFoam/channel395/0/B.gz
diff --git a/tutorials/channelOodles/channel395/0/U.gz b/tutorials/channelFoam/channel395/0/U.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/U.gz
rename to tutorials/channelFoam/channel395/0/U.gz
diff --git a/tutorials/channelOodles/channel395/0/k.gz b/tutorials/channelFoam/channel395/0/k.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/k.gz
rename to tutorials/channelFoam/channel395/0/k.gz
diff --git a/tutorials/channelOodles/channel395/0/nuSgs.gz b/tutorials/channelFoam/channel395/0/nuSgs.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/nuSgs.gz
rename to tutorials/channelFoam/channel395/0/nuSgs.gz
diff --git a/tutorials/channelOodles/channel395/0/nuTilda.gz b/tutorials/channelFoam/channel395/0/nuTilda.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/nuTilda.gz
rename to tutorials/channelFoam/channel395/0/nuTilda.gz
diff --git a/tutorials/channelOodles/channel395/0/p.gz b/tutorials/channelFoam/channel395/0/p.gz
similarity index 100%
rename from tutorials/channelOodles/channel395/0/p.gz
rename to tutorials/channelFoam/channel395/0/p.gz
diff --git a/tutorials/channelOodles/channel395/Allrun b/tutorials/channelFoam/channel395/Allrun
similarity index 100%
rename from tutorials/channelOodles/channel395/Allrun
rename to tutorials/channelFoam/channel395/Allrun
diff --git a/tutorials/channelOodles/channel395/constant/LESProperties b/tutorials/channelFoam/channel395/constant/LESProperties
similarity index 99%
rename from tutorials/channelOodles/channel395/constant/LESProperties
rename to tutorials/channelFoam/channel395/constant/LESProperties
index ad24e882c7c6b43f2e6531c7116f75477ab2206c..da3b2d07d56ad9c2569a517238d4e20482b1cbd9 100644
--- a/tutorials/channelOodles/channel395/constant/LESProperties
+++ b/tutorials/channelFoam/channel395/constant/LESProperties
@@ -16,6 +16,8 @@ FoamFile
 
 LESModel            oneEqEddy;
 
+turbulence          on;
+
 printCoeffs         on;
 
 delta               vanDriest;
diff --git a/tutorials/channelOodles/channel395/constant/polyMesh/blockMeshDict b/tutorials/channelFoam/channel395/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/channelOodles/channel395/constant/polyMesh/blockMeshDict
rename to tutorials/channelFoam/channel395/constant/polyMesh/blockMeshDict
diff --git a/tutorials/channelOodles/channel395/constant/polyMesh/boundary b/tutorials/channelFoam/channel395/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/channelOodles/channel395/constant/polyMesh/boundary
rename to tutorials/channelFoam/channel395/constant/polyMesh/boundary
diff --git a/tutorials/channelOodles/channel395/constant/postChannelDict b/tutorials/channelFoam/channel395/constant/postChannelDict
similarity index 100%
rename from tutorials/channelOodles/channel395/constant/postChannelDict
rename to tutorials/channelFoam/channel395/constant/postChannelDict
diff --git a/tutorials/channelOodles/channel395/constant/transportProperties b/tutorials/channelFoam/channel395/constant/transportProperties
similarity index 100%
rename from tutorials/channelOodles/channel395/constant/transportProperties
rename to tutorials/channelFoam/channel395/constant/transportProperties
diff --git a/tutorials/channelOodles/channel395/system/controlDict b/tutorials/channelFoam/channel395/system/controlDict
similarity index 95%
rename from tutorials/channelOodles/channel395/system/controlDict
rename to tutorials/channelFoam/channel395/system/controlDict
index b45428a9737b4d110bbee57bff0a8dfa7ec77f07..8ac4d8f359239087919e5ac021bf5762053f1cf5 100644
--- a/tutorials/channelOodles/channel395/system/controlDict
+++ b/tutorials/channelFoam/channel395/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application channelOodles;
 
 startFrom       startTime;
 
@@ -52,7 +51,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/channelOodles/channel395/system/fvSchemes b/tutorials/channelFoam/channel395/system/fvSchemes
similarity index 100%
rename from tutorials/channelOodles/channel395/system/fvSchemes
rename to tutorials/channelFoam/channel395/system/fvSchemes
diff --git a/tutorials/channelOodles/channel395/system/fvSolution b/tutorials/channelFoam/channel395/system/fvSolution
similarity index 100%
rename from tutorials/channelOodles/channel395/system/fvSolution
rename to tutorials/channelFoam/channel395/system/fvSolution
diff --git a/tutorials/chtMultiRegionFoam/multiRegionHeater/constant/bottomAir/turbulenceProperties b/tutorials/chtMultiRegionFoam/multiRegionHeater/constant/bottomAir/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..07f85c68df22113b7c7747b89457597b0ea41d66
--- /dev/null
+++ b/tutorials/chtMultiRegionFoam/multiRegionHeater/constant/bottomAir/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  RASModel;
+
+// ************************************************************************* //
diff --git a/tutorials/chtMultiRegionFoam/multiRegionHeater/system/controlDict b/tutorials/chtMultiRegionFoam/multiRegionHeater/system/controlDict
index c95460bc8a0d40d4d791505acef1a4452504f8b7..946dee0084cb5f0d655ef16d3f6fd5e78080aeaf 100644
--- a/tutorials/chtMultiRegionFoam/multiRegionHeater/system/controlDict
+++ b/tutorials/chtMultiRegionFoam/multiRegionHeater/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     chtMultiRegionFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/compressibleInterFoam/depthCharge2D/system/controlDict b/tutorials/compressibleInterFoam/depthCharge2D/system/controlDict
index 0580c2dc55ca809e76c4343122de4b83d3ace7e3..03f0c207d6fd268ad7267214f33a705e87554c1f 100644
--- a/tutorials/compressibleInterFoam/depthCharge2D/system/controlDict
+++ b/tutorials/compressibleInterFoam/depthCharge2D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application lesInterFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/compressibleInterFoam/depthCharge3D/system/controlDict b/tutorials/compressibleInterFoam/depthCharge3D/system/controlDict
index 0580c2dc55ca809e76c4343122de4b83d3ace7e3..03f0c207d6fd268ad7267214f33a705e87554c1f 100644
--- a/tutorials/compressibleInterFoam/depthCharge3D/system/controlDict
+++ b/tutorials/compressibleInterFoam/depthCharge3D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application lesInterFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/dieselFoam/aachenBomb/system/controlDict b/tutorials/dieselFoam/aachenBomb/system/controlDict
index fec5f8c06adfed85c3df78e59db5280306466add..951d757ff8aae1c119347b3faf588293f5dc8482 100644
--- a/tutorials/dieselFoam/aachenBomb/system/controlDict
+++ b/tutorials/dieselFoam/aachenBomb/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application    dieselFoam;
 
 startFrom           startTime;
 
diff --git a/tutorials/dnsFoam/boxTurb16/system/controlDict b/tutorials/dnsFoam/boxTurb16/system/controlDict
index e87caca7e92c8caf23c3a153613464affe74fe7f..f059d93cded33ce2cef6394c0492ccefa8b50dd6 100644
--- a/tutorials/dnsFoam/boxTurb16/system/controlDict
+++ b/tutorials/dnsFoam/boxTurb16/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application dnsFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/electrostaticFoam/chargedWire/system/controlDict b/tutorials/electrostaticFoam/chargedWire/system/controlDict
index d24d002cb268f69c8d98b724312abffd0dbb0256..7c2f3213b79c680ce2eebca320f7f98dd047001a 100644
--- a/tutorials/electrostaticFoam/chargedWire/system/controlDict
+++ b/tutorials/electrostaticFoam/chargedWire/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application electrostaticFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/engineFoam/kivaTest/system/controlDict b/tutorials/engineFoam/kivaTest/system/controlDict
index d3c9a998580fcf3bcab63c2431f57d94d7b39a5a..ba6351bc7c82956eb660e048c9329eb90aa56d63 100644
--- a/tutorials/engineFoam/kivaTest/system/controlDict
+++ b/tutorials/engineFoam/kivaTest/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass engineFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/financialFoam/europeanCall/system/controlDict b/tutorials/financialFoam/europeanCall/system/controlDict
index a63d175961caa59ec829b9ce8063c05061d37c64..4cb5448f1deb2a5d31ab8b2809bdb3e37a9eee47 100644
--- a/tutorials/financialFoam/europeanCall/system/controlDict
+++ b/tutorials/financialFoam/europeanCall/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application financialFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/icoDyMFoam/movingCone/system/controlDict b/tutorials/icoDyMFoam/movingCone/system/controlDict
index 2a1d902241a8bb298a73d5e9fa11cad072b91edd..f6035d845c358f98088c6077d36f147d3d40638d 100644
--- a/tutorials/icoDyMFoam/movingCone/system/controlDict
+++ b/tutorials/icoDyMFoam/movingCone/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoamAutoMotion;
 
 startFrom       startTime;
 
diff --git a/tutorials/icoFoam/cavity/system/controlDict b/tutorials/icoFoam/cavity/system/controlDict
index 7ec93257f68868f41b90a80da50198b5bca92529..17032f75aba95125660fccdb4a0c4f3c1dbb93b2 100644
--- a/tutorials/icoFoam/cavity/system/controlDict
+++ b/tutorials/icoFoam/cavity/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/icoFoam/cavityClipped/system/controlDict b/tutorials/icoFoam/cavityClipped/system/controlDict
index ba892134b21e37724af869dd92001287470159b1..5c66b311095841f56dba45729a25059cf138d867 100644
--- a/tutorials/icoFoam/cavityClipped/system/controlDict
+++ b/tutorials/icoFoam/cavityClipped/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/icoFoam/cavityGrade/system/controlDict b/tutorials/icoFoam/cavityGrade/system/controlDict
index ef3c25268befcf060b41d5c52e2600c5c928e7b8..266d138f79283742bc98b4aad8bf7a5a8bbc52a4 100644
--- a/tutorials/icoFoam/cavityGrade/system/controlDict
+++ b/tutorials/icoFoam/cavityGrade/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/icoFoam/elbow/system/controlDict b/tutorials/icoFoam/elbow/system/controlDict
index 4be58101c9ea739c402b6d9ad19689abf32a2c98..07c621ef1862c02b3d3cfac734380d3ae93ff516 100644
--- a/tutorials/icoFoam/elbow/system/controlDict
+++ b/tutorials/icoFoam/elbow/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/interDyMFoam/damBreakWithObstacle/system/controlDict b/tutorials/interDyMFoam/damBreakWithObstacle/system/controlDict
index 0ad41244b48a160c0e09c86d51f34ac436034100..f560d7c85b5347667d40360680158761709e773a 100644
--- a/tutorials/interDyMFoam/damBreakWithObstacle/system/controlDict
+++ b/tutorials/interDyMFoam/damBreakWithObstacle/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application interFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/interDyMFoam/sloshingTank2D/system/controlDict b/tutorials/interDyMFoam/sloshingTank2D/system/controlDict
index e3e71671692505a881cca18639e5416d6eaa8ac1..a4d077ea1919324987eb0d533fdc4615840f0eef 100644
--- a/tutorials/interDyMFoam/sloshingTank2D/system/controlDict
+++ b/tutorials/interDyMFoam/sloshingTank2D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sloshingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interDyMFoam/sloshingTank2D3DoF/system/controlDict b/tutorials/interDyMFoam/sloshingTank2D3DoF/system/controlDict
index 410cb58d6d2f9b939c537de5ae8347e865e90383..0bacce4c995976475551971d1842b33a846c1d20 100644
--- a/tutorials/interDyMFoam/sloshingTank2D3DoF/system/controlDict
+++ b/tutorials/interDyMFoam/sloshingTank2D3DoF/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sloshingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D/system/controlDict b/tutorials/interDyMFoam/sloshingTank3D/system/controlDict
index 208bb1c29a60ee3d4de68293773a3f3d8d96b2e9..959e229e953ce20fe0db08f76ba8b25023588583 100644
--- a/tutorials/interDyMFoam/sloshingTank3D/system/controlDict
+++ b/tutorials/interDyMFoam/sloshingTank3D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sloshingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D3DoF/system/controlDict b/tutorials/interDyMFoam/sloshingTank3D3DoF/system/controlDict
index 208bb1c29a60ee3d4de68293773a3f3d8d96b2e9..959e229e953ce20fe0db08f76ba8b25023588583 100644
--- a/tutorials/interDyMFoam/sloshingTank3D3DoF/system/controlDict
+++ b/tutorials/interDyMFoam/sloshingTank3D3DoF/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sloshingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D6DoF/system/controlDict b/tutorials/interDyMFoam/sloshingTank3D6DoF/system/controlDict
index 208bb1c29a60ee3d4de68293773a3f3d8d96b2e9..959e229e953ce20fe0db08f76ba8b25023588583 100644
--- a/tutorials/interDyMFoam/sloshingTank3D6DoF/system/controlDict
+++ b/tutorials/interDyMFoam/sloshingTank3D6DoF/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sloshingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interFoam/Allrun b/tutorials/interFoam/Allrun
index 99db32d37aee3949480199a7b63f6075d4dd9549..91f49e0a7fb9296f6c2e86fb695cddf6afed2c9f 100755
--- a/tutorials/interFoam/Allrun
+++ b/tutorials/interFoam/Allrun
@@ -3,50 +3,46 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=${PWD##*/}
+application="interFoam"
 
-setDamBreakFine ()
+laminarCases="damBreak"
+rasCases="damBreak"
+lesCases="nozzleFlow2D"
+
+computeCase()
 {
-    blockMeshDict="constant/polyMesh/blockMeshDict"
-    controlDict="system/controlDict"
-    sed \
-    -e s/"23 8"/"46 10"/g \
-    -e s/"19 8"/"40 10"/g \
-    -e s/"23 42\(.*\) 1 1)"/"46 76\1 2 1)"/g \
-    -e s/"4 42\(.*\) 1 1)"/"4 76\1 2 1)"/g \
-    -e s/"19 42\(.*\) 1 1)"/"40 76\1 2 1)"/g \
-    $blockMeshDict > temp.$$
-    mv temp.$$ $blockMeshDict
-    sed \
-    -e s/"\(deltaT[ \t]*\) 0.001;"/"\1 5e-04;"/g \
-    -e s/"\(endTime[ \t]*\) 1;"/"\1 0.4;"/g \
-    $controlDict > temp.$$
-    mv temp.$$ $controlDict
+    if [ -f Allrun ] ; then
+        ./Allrun
+    else
+        runApplication blockMesh
+        runApplication changeDictionary
+        runApplication $application
+    fi
 }
 
-# Do damBreak
-cd damBreak
-    runApplication blockMesh
-    runApplication setFields
-    runApplication $application
+cd laminar
+for case in $laminarCases
+do
+    cd $case
+    computeCase
+    cd ..
+done
 cd ..
 
-# Clone case
-cloneCase damBreak damBreakFine
-
-cd damBreakFine
-    # Modify case
-    setDamBreakFine
-    cp ../damBreak/0/alpha1.org 0/alpha1
-    # And execute
-    runApplication blockMesh
-    runApplication setFields
-    runApplication decomposePar
-    hostname > system/machines
-    runParallel $application 4 system/machines
-    runApplication reconstructPar
+cd ras
+for case in $rasCases
+do
+    cd $case
+    computeCase
+    cd ..
+done
 cd ..
 
-cd nozzleFlow2D
-    ./Allrun
+cd les
+for case in $lesCases
+do
+    cd $case
+    computeCase
+    cd ..
+done
 cd ..
diff --git a/tutorials/interFoam/Allclean b/tutorials/interFoam/laminar/Allclean
similarity index 100%
rename from tutorials/interFoam/Allclean
rename to tutorials/interFoam/laminar/Allclean
diff --git a/tutorials/interFoam/laminar/Allrun b/tutorials/interFoam/laminar/Allrun
new file mode 100755
index 0000000000000000000000000000000000000000..99db32d37aee3949480199a7b63f6075d4dd9549
--- /dev/null
+++ b/tutorials/interFoam/laminar/Allrun
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Source tutorial run functions
+. $WM_PROJECT_DIR/bin/tools/RunFunctions
+
+# Get application name from directory
+application=${PWD##*/}
+
+setDamBreakFine ()
+{
+    blockMeshDict="constant/polyMesh/blockMeshDict"
+    controlDict="system/controlDict"
+    sed \
+    -e s/"23 8"/"46 10"/g \
+    -e s/"19 8"/"40 10"/g \
+    -e s/"23 42\(.*\) 1 1)"/"46 76\1 2 1)"/g \
+    -e s/"4 42\(.*\) 1 1)"/"4 76\1 2 1)"/g \
+    -e s/"19 42\(.*\) 1 1)"/"40 76\1 2 1)"/g \
+    $blockMeshDict > temp.$$
+    mv temp.$$ $blockMeshDict
+    sed \
+    -e s/"\(deltaT[ \t]*\) 0.001;"/"\1 5e-04;"/g \
+    -e s/"\(endTime[ \t]*\) 1;"/"\1 0.4;"/g \
+    $controlDict > temp.$$
+    mv temp.$$ $controlDict
+}
+
+# Do damBreak
+cd damBreak
+    runApplication blockMesh
+    runApplication setFields
+    runApplication $application
+cd ..
+
+# Clone case
+cloneCase damBreak damBreakFine
+
+cd damBreakFine
+    # Modify case
+    setDamBreakFine
+    cp ../damBreak/0/alpha1.org 0/alpha1
+    # And execute
+    runApplication blockMesh
+    runApplication setFields
+    runApplication decomposePar
+    hostname > system/machines
+    runParallel $application 4 system/machines
+    runApplication reconstructPar
+cd ..
+
+cd nozzleFlow2D
+    ./Allrun
+cd ..
diff --git a/tutorials/interFoam/damBreak/0/U b/tutorials/interFoam/laminar/damBreak/0/U
similarity index 100%
rename from tutorials/interFoam/damBreak/0/U
rename to tutorials/interFoam/laminar/damBreak/0/U
diff --git a/tutorials/interFoam/damBreak/0/alpha1 b/tutorials/interFoam/laminar/damBreak/0/alpha1
similarity index 100%
rename from tutorials/interFoam/damBreak/0/alpha1
rename to tutorials/interFoam/laminar/damBreak/0/alpha1
diff --git a/tutorials/interFoam/damBreak/0/alpha1.org b/tutorials/interFoam/laminar/damBreak/0/alpha1.org
similarity index 100%
rename from tutorials/interFoam/damBreak/0/alpha1.org
rename to tutorials/interFoam/laminar/damBreak/0/alpha1.org
diff --git a/tutorials/interFoam/damBreak/0/pd b/tutorials/interFoam/laminar/damBreak/0/pd
similarity index 100%
rename from tutorials/interFoam/damBreak/0/pd
rename to tutorials/interFoam/laminar/damBreak/0/pd
diff --git a/tutorials/interFoam/damBreak/constant/dynamicMeshDict b/tutorials/interFoam/laminar/damBreak/constant/dynamicMeshDict
similarity index 100%
rename from tutorials/interFoam/damBreak/constant/dynamicMeshDict
rename to tutorials/interFoam/laminar/damBreak/constant/dynamicMeshDict
diff --git a/tutorials/interFoam/damBreak/constant/environmentalProperties b/tutorials/interFoam/laminar/damBreak/constant/environmentalProperties
similarity index 100%
rename from tutorials/interFoam/damBreak/constant/environmentalProperties
rename to tutorials/interFoam/laminar/damBreak/constant/environmentalProperties
diff --git a/tutorials/interFoam/damBreak/constant/polyMesh/blockMeshDict b/tutorials/interFoam/laminar/damBreak/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/interFoam/damBreak/constant/polyMesh/blockMeshDict
rename to tutorials/interFoam/laminar/damBreak/constant/polyMesh/blockMeshDict
diff --git a/tutorials/interFoam/damBreak/constant/polyMesh/boundary b/tutorials/interFoam/laminar/damBreak/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/interFoam/damBreak/constant/polyMesh/boundary
rename to tutorials/interFoam/laminar/damBreak/constant/polyMesh/boundary
diff --git a/tutorials/interFoam/damBreak/constant/transportProperties b/tutorials/interFoam/laminar/damBreak/constant/transportProperties
similarity index 100%
rename from tutorials/interFoam/damBreak/constant/transportProperties
rename to tutorials/interFoam/laminar/damBreak/constant/transportProperties
diff --git a/tutorials/interFoam/damBreak/constant/turbulenceProperties b/tutorials/interFoam/laminar/damBreak/constant/turbulenceProperties
similarity index 97%
rename from tutorials/interFoam/damBreak/constant/turbulenceProperties
rename to tutorials/interFoam/laminar/damBreak/constant/turbulenceProperties
index 11c91f0a1e42a95ae426081d72d755827c0e84ad..0efb448180f1ba26ac35d2dda07035e9ec6873f6 100644
--- a/tutorials/interFoam/damBreak/constant/turbulenceProperties
+++ b/tutorials/interFoam/laminar/damBreak/constant/turbulenceProperties
@@ -14,6 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-simulationType laminar;
+simulationType  laminar;
 
 // ************************************************************************* //
diff --git a/tutorials/interFoam/damBreak/system/controlDict b/tutorials/interFoam/laminar/damBreak/system/controlDict
similarity index 98%
rename from tutorials/interFoam/damBreak/system/controlDict
rename to tutorials/interFoam/laminar/damBreak/system/controlDict
index 92ca66517f8214ea98c28109b7f1b9b3d0046543..8415c7bc8498b6f83bbbe706963987ae7210136c 100644
--- a/tutorials/interFoam/damBreak/system/controlDict
+++ b/tutorials/interFoam/laminar/damBreak/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application interFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/interFoam/damBreak/system/decomposeParDict b/tutorials/interFoam/laminar/damBreak/system/decomposeParDict
similarity index 100%
rename from tutorials/interFoam/damBreak/system/decomposeParDict
rename to tutorials/interFoam/laminar/damBreak/system/decomposeParDict
diff --git a/tutorials/interFoam/damBreak/system/fvSchemes b/tutorials/interFoam/laminar/damBreak/system/fvSchemes
similarity index 100%
rename from tutorials/interFoam/damBreak/system/fvSchemes
rename to tutorials/interFoam/laminar/damBreak/system/fvSchemes
diff --git a/tutorials/interFoam/damBreak/system/fvSolution b/tutorials/interFoam/laminar/damBreak/system/fvSolution
similarity index 100%
rename from tutorials/interFoam/damBreak/system/fvSolution
rename to tutorials/interFoam/laminar/damBreak/system/fvSolution
diff --git a/tutorials/interFoam/damBreak/system/setFieldsDict b/tutorials/interFoam/laminar/damBreak/system/setFieldsDict
similarity index 100%
rename from tutorials/interFoam/damBreak/system/setFieldsDict
rename to tutorials/interFoam/laminar/damBreak/system/setFieldsDict
diff --git a/tutorials/interFoam/nozzleFlow2D/0/B b/tutorials/interFoam/les/nozzleFlow2D/0/B
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/B
rename to tutorials/interFoam/les/nozzleFlow2D/0/B
diff --git a/tutorials/interFoam/nozzleFlow2D/0/U b/tutorials/interFoam/les/nozzleFlow2D/0/U
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/U
rename to tutorials/interFoam/les/nozzleFlow2D/0/U
diff --git a/tutorials/interFoam/nozzleFlow2D/0/alpha1 b/tutorials/interFoam/les/nozzleFlow2D/0/alpha1
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/alpha1
rename to tutorials/interFoam/les/nozzleFlow2D/0/alpha1
diff --git a/tutorials/interFoam/nozzleFlow2D/0/data/ptrace b/tutorials/interFoam/les/nozzleFlow2D/0/data/Ubulk
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/data/ptrace
rename to tutorials/interFoam/les/nozzleFlow2D/0/data/Ubulk
diff --git a/tutorials/interFoam/les/nozzleFlow2D/0/data/ptrace b/tutorials/interFoam/les/nozzleFlow2D/0/data/ptrace
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/tutorials/interFoam/nozzleFlow2D/0/k b/tutorials/interFoam/les/nozzleFlow2D/0/k
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/k
rename to tutorials/interFoam/les/nozzleFlow2D/0/k
diff --git a/tutorials/interFoam/nozzleFlow2D/0/nuSgs b/tutorials/interFoam/les/nozzleFlow2D/0/nuSgs
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/nuSgs
rename to tutorials/interFoam/les/nozzleFlow2D/0/nuSgs
diff --git a/tutorials/interFoam/nozzleFlow2D/0/nuTilda b/tutorials/interFoam/les/nozzleFlow2D/0/nuTilda
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/nuTilda
rename to tutorials/interFoam/les/nozzleFlow2D/0/nuTilda
diff --git a/tutorials/interFoam/nozzleFlow2D/0/pd b/tutorials/interFoam/les/nozzleFlow2D/0/pd
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/0/pd
rename to tutorials/interFoam/les/nozzleFlow2D/0/pd
diff --git a/tutorials/interFoam/nozzleFlow2D/Allclean b/tutorials/interFoam/les/nozzleFlow2D/Allclean
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/Allclean
rename to tutorials/interFoam/les/nozzleFlow2D/Allclean
diff --git a/tutorials/interFoam/nozzleFlow2D/Allrun b/tutorials/interFoam/les/nozzleFlow2D/Allrun
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/Allrun
rename to tutorials/interFoam/les/nozzleFlow2D/Allrun
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/LESProperties b/tutorials/interFoam/les/nozzleFlow2D/constant/LESProperties
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/LESProperties
rename to tutorials/interFoam/les/nozzleFlow2D/constant/LESProperties
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/environmentalProperties b/tutorials/interFoam/les/nozzleFlow2D/constant/environmentalProperties
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/environmentalProperties
rename to tutorials/interFoam/les/nozzleFlow2D/constant/environmentalProperties
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/blockMeshDict b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/blockMeshDict
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/blockMeshDict
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/boundary b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/boundary
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/boundary
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/boundary.org b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/boundary.org
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/boundary.org
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/boundary.org
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/c0 b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/c0
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/c0
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/c0
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/c0_old b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/c0_old
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/c0_old
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/c0_old
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/refinedCells b/tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/refinedCells
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/polyMesh/sets/refinedCells
rename to tutorials/interFoam/les/nozzleFlow2D/constant/polyMesh/sets/refinedCells
diff --git a/tutorials/interFoam/nozzleFlow2D/constant/transportProperties b/tutorials/interFoam/les/nozzleFlow2D/constant/transportProperties
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/constant/transportProperties
rename to tutorials/interFoam/les/nozzleFlow2D/constant/transportProperties
diff --git a/tutorials/interFoam/les/nozzleFlow2D/constant/turbulenceProperties b/tutorials/interFoam/les/nozzleFlow2D/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..dcadcf17cd97481597090cf391913d3fe6432687
--- /dev/null
+++ b/tutorials/interFoam/les/nozzleFlow2D/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  LESModel;
+
+// ************************************************************************* //
diff --git a/tutorials/interFoam/nozzleFlow2D/system/cellSetDict b/tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/cellSetDict
rename to tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict
diff --git a/tutorials/interFoam/nozzleFlow2D/system/cellSetDict.1 b/tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict.1
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/cellSetDict.1
rename to tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict.1
diff --git a/tutorials/interFoam/nozzleFlow2D/system/cellSetDict.2 b/tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict.2
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/cellSetDict.2
rename to tutorials/interFoam/les/nozzleFlow2D/system/cellSetDict.2
diff --git a/tutorials/interFoam/nozzleFlow2D/system/controlDict b/tutorials/interFoam/les/nozzleFlow2D/system/controlDict
similarity index 97%
rename from tutorials/interFoam/nozzleFlow2D/system/controlDict
rename to tutorials/interFoam/les/nozzleFlow2D/system/controlDict
index 06a945316dad95f82ab2ac28cb3b511e14c8a455..e7a4ac1b84c109aceed597154e81ba5c9dcc3648 100644
--- a/tutorials/interFoam/nozzleFlow2D/system/controlDict
+++ b/tutorials/interFoam/les/nozzleFlow2D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application lesInterFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/interFoam/nozzleFlow2D/system/fvSchemes b/tutorials/interFoam/les/nozzleFlow2D/system/fvSchemes
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/fvSchemes
rename to tutorials/interFoam/les/nozzleFlow2D/system/fvSchemes
diff --git a/tutorials/interFoam/nozzleFlow2D/system/fvSolution b/tutorials/interFoam/les/nozzleFlow2D/system/fvSolution
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/fvSolution
rename to tutorials/interFoam/les/nozzleFlow2D/system/fvSolution
diff --git a/tutorials/interFoam/nozzleFlow2D/system/refineMeshDict b/tutorials/interFoam/les/nozzleFlow2D/system/refineMeshDict
similarity index 100%
rename from tutorials/interFoam/nozzleFlow2D/system/refineMeshDict
rename to tutorials/interFoam/les/nozzleFlow2D/system/refineMeshDict
diff --git a/tutorials/rasInterFoam/Allclean b/tutorials/interFoam/ras/Allclean
similarity index 100%
rename from tutorials/rasInterFoam/Allclean
rename to tutorials/interFoam/ras/Allclean
diff --git a/tutorials/rasInterFoam/Allrun b/tutorials/interFoam/ras/Allrun
similarity index 100%
rename from tutorials/rasInterFoam/Allrun
rename to tutorials/interFoam/ras/Allrun
diff --git a/tutorials/rasInterFoam/damBreak/0/R b/tutorials/interFoam/ras/damBreak/0/R
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/R
rename to tutorials/interFoam/ras/damBreak/0/R
diff --git a/tutorials/rasInterFoam/damBreak/0/U b/tutorials/interFoam/ras/damBreak/0/U
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/U
rename to tutorials/interFoam/ras/damBreak/0/U
diff --git a/tutorials/rasInterFoam/damBreak/0/epsilon b/tutorials/interFoam/ras/damBreak/0/epsilon
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/epsilon
rename to tutorials/interFoam/ras/damBreak/0/epsilon
diff --git a/tutorials/rasInterFoam/damBreak/0/gamma b/tutorials/interFoam/ras/damBreak/0/gamma
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/gamma
rename to tutorials/interFoam/ras/damBreak/0/gamma
diff --git a/tutorials/rasInterFoam/damBreak/0/gamma.org b/tutorials/interFoam/ras/damBreak/0/gamma.org
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/gamma.org
rename to tutorials/interFoam/ras/damBreak/0/gamma.org
diff --git a/tutorials/rasInterFoam/damBreak/0/k b/tutorials/interFoam/ras/damBreak/0/k
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/k
rename to tutorials/interFoam/ras/damBreak/0/k
diff --git a/tutorials/rasInterFoam/damBreak/0/nuTilda b/tutorials/interFoam/ras/damBreak/0/nuTilda
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/nuTilda
rename to tutorials/interFoam/ras/damBreak/0/nuTilda
diff --git a/tutorials/rasInterFoam/damBreak/0/pd b/tutorials/interFoam/ras/damBreak/0/pd
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/0/pd
rename to tutorials/interFoam/ras/damBreak/0/pd
diff --git a/tutorials/rasInterFoam/damBreak/Allrun b/tutorials/interFoam/ras/damBreak/Allrun
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/Allrun
rename to tutorials/interFoam/ras/damBreak/Allrun
diff --git a/tutorials/rasInterFoam/damBreak/constant/RASProperties b/tutorials/interFoam/ras/damBreak/constant/RASProperties
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/constant/RASProperties
rename to tutorials/interFoam/ras/damBreak/constant/RASProperties
diff --git a/tutorials/rasInterFoam/damBreak/constant/environmentalProperties b/tutorials/interFoam/ras/damBreak/constant/environmentalProperties
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/constant/environmentalProperties
rename to tutorials/interFoam/ras/damBreak/constant/environmentalProperties
diff --git a/tutorials/rasInterFoam/damBreak/constant/polyMesh/blockMeshDict b/tutorials/interFoam/ras/damBreak/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/constant/polyMesh/blockMeshDict
rename to tutorials/interFoam/ras/damBreak/constant/polyMesh/blockMeshDict
diff --git a/tutorials/rasInterFoam/damBreak/constant/polyMesh/boundary b/tutorials/interFoam/ras/damBreak/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/constant/polyMesh/boundary
rename to tutorials/interFoam/ras/damBreak/constant/polyMesh/boundary
diff --git a/tutorials/rasInterFoam/damBreak/constant/transportProperties b/tutorials/interFoam/ras/damBreak/constant/transportProperties
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/constant/transportProperties
rename to tutorials/interFoam/ras/damBreak/constant/transportProperties
diff --git a/tutorials/interFoam/ras/damBreak/constant/turbulenceProperties b/tutorials/interFoam/ras/damBreak/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..07f85c68df22113b7c7747b89457597b0ea41d66
--- /dev/null
+++ b/tutorials/interFoam/ras/damBreak/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  RASModel;
+
+// ************************************************************************* //
diff --git a/tutorials/rasInterFoam/damBreak/system/controlDict b/tutorials/interFoam/ras/damBreak/system/controlDict
similarity index 97%
rename from tutorials/rasInterFoam/damBreak/system/controlDict
rename to tutorials/interFoam/ras/damBreak/system/controlDict
index 47e28307b20d2e7af484d82d05e4fc169878adbb..92227befc184c30b09f90bbd20d1b2f01bd82570 100644
--- a/tutorials/rasInterFoam/damBreak/system/controlDict
+++ b/tutorials/interFoam/ras/damBreak/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application rasInterFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rasInterFoam/damBreak/system/decomposeParDict b/tutorials/interFoam/ras/damBreak/system/decomposeParDict
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/system/decomposeParDict
rename to tutorials/interFoam/ras/damBreak/system/decomposeParDict
diff --git a/tutorials/rasInterFoam/damBreak/system/fvSchemes b/tutorials/interFoam/ras/damBreak/system/fvSchemes
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/system/fvSchemes
rename to tutorials/interFoam/ras/damBreak/system/fvSchemes
diff --git a/tutorials/rasInterFoam/damBreak/system/fvSolution b/tutorials/interFoam/ras/damBreak/system/fvSolution
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/system/fvSolution
rename to tutorials/interFoam/ras/damBreak/system/fvSolution
diff --git a/tutorials/rasInterFoam/damBreak/system/setFieldsDict b/tutorials/interFoam/ras/damBreak/system/setFieldsDict
similarity index 100%
rename from tutorials/rasInterFoam/damBreak/system/setFieldsDict
rename to tutorials/interFoam/ras/damBreak/system/setFieldsDict
diff --git a/tutorials/laplacianFoam/flange/system/controlDict b/tutorials/laplacianFoam/flange/system/controlDict
index 24386fe5ffb77380872ec49513a02f70c95882ba..07a21543108361fa7020e9b6aebdff6d16117f2f 100644
--- a/tutorials/laplacianFoam/flange/system/controlDict
+++ b/tutorials/laplacianFoam/flange/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application laplacianFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/mhdFoam/hartmann/system/controlDict b/tutorials/mhdFoam/hartmann/system/controlDict
index a73912667543f62f9ed37c6c38ee85df75ff2293..267187bdbf65f957449ab63638753b485a977c22 100644
--- a/tutorials/mhdFoam/hartmann/system/controlDict
+++ b/tutorials/mhdFoam/hartmann/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application mhdFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/multiphaseInterFoam/damBreak4phase/system/controlDict b/tutorials/multiphaseInterFoam/damBreak4phase/system/controlDict
index ac70ee93e0045aeabbd9851575b220c8f0b307c6..03b8dd3beff45c667bb1a783d63fbfaf32a68bbd 100644
--- a/tutorials/multiphaseInterFoam/damBreak4phase/system/controlDict
+++ b/tutorials/multiphaseInterFoam/damBreak4phase/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application interFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/multiphaseInterFoam/damBreak4phaseFine/system/controlDict b/tutorials/multiphaseInterFoam/damBreak4phaseFine/system/controlDict
index ac70ee93e0045aeabbd9851575b220c8f0b307c6..03b8dd3beff45c667bb1a783d63fbfaf32a68bbd 100644
--- a/tutorials/multiphaseInterFoam/damBreak4phaseFine/system/controlDict
+++ b/tutorials/multiphaseInterFoam/damBreak4phaseFine/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application interFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/nonNewtonianIcoFoam/offsetCylinder/system/controlDict b/tutorials/nonNewtonianIcoFoam/offsetCylinder/system/controlDict
index 68e0a0fe066bf8a1dcbf8c430824a35aaee24c9e..4d404e35f6b94583d0b7734d136f1ada114f48b4 100644
--- a/tutorials/nonNewtonianIcoFoam/offsetCylinder/system/controlDict
+++ b/tutorials/nonNewtonianIcoFoam/offsetCylinder/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application nonNewtonianIcoFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/pimpleFoam/t-junction/system/controlDict b/tutorials/pimpleFoam/t-junction/system/controlDict
index b5f0d20f7e2cd66501bd7b248f537d0db8804fb9..ca979c4a6b9dea96ecead463ee5c8b5067bac38a 100644
--- a/tutorials/pimpleFoam/t-junction/system/controlDict
+++ b/tutorials/pimpleFoam/t-junction/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application turbFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/pisoFoam/Allrun b/tutorials/pisoFoam/Allrun
new file mode 100755
index 0000000000000000000000000000000000000000..7d6114dd5037f136433502b3d3c2e6112249b10e
--- /dev/null
+++ b/tutorials/pisoFoam/Allrun
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Source tutorial run functions
+. $WM_PROJECT_DIR/bin/tools/RunFunctions
+
+# Get application name from directory
+application="pisoFoam"
+
+rasCases="cavity"
+lesCases="pitzDaily pitzDailyDirectMapped"
+
+computeCase()
+{
+    if [ -f Allrun ] ; then
+        ./Allrun
+    else
+        runApplication blockMesh
+        runApplication $application
+    fi
+}
+
+cd ras
+for case in $rasCases
+do
+    cd $case
+    computeCase
+    cd ..
+done
+cd ..
+
+cd les
+for case in $lesCases
+do
+    cd $case
+    computeCase
+    cd ..
+done
+cd ..
diff --git a/tutorials/coodles/pitzDaily/0/B b/tutorials/pisoFoam/les/pitzDaily/0/B
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/B
rename to tutorials/pisoFoam/les/pitzDaily/0/B
diff --git a/tutorials/coodles/pitzDaily/0/U b/tutorials/pisoFoam/les/pitzDaily/0/U
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/U
rename to tutorials/pisoFoam/les/pitzDaily/0/U
diff --git a/tutorials/coodles/pitzDaily/0/k b/tutorials/pisoFoam/les/pitzDaily/0/k
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/k
rename to tutorials/pisoFoam/les/pitzDaily/0/k
diff --git a/tutorials/oodles/pitzDaily/0/nuSgs b/tutorials/pisoFoam/les/pitzDaily/0/nuSgs
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/nuSgs
rename to tutorials/pisoFoam/les/pitzDaily/0/nuSgs
diff --git a/tutorials/oodles/pitzDaily/0/nuTilda b/tutorials/pisoFoam/les/pitzDaily/0/nuTilda
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/nuTilda
rename to tutorials/pisoFoam/les/pitzDaily/0/nuTilda
diff --git a/tutorials/oodles/pitzDaily/0/p b/tutorials/pisoFoam/les/pitzDaily/0/p
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/p
rename to tutorials/pisoFoam/les/pitzDaily/0/p
diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/LESProperties b/tutorials/pisoFoam/les/pitzDaily/constant/LESProperties
similarity index 99%
rename from tutorials/oodles/pitzDailyDirectMapped/constant/LESProperties
rename to tutorials/pisoFoam/les/pitzDaily/constant/LESProperties
index 05339f675aaeeb891be623cf2a85ec15b6509e5b..336220cfbb49c0b792f2e7ec104a60ca04ad55ad 100644
--- a/tutorials/oodles/pitzDailyDirectMapped/constant/LESProperties
+++ b/tutorials/pisoFoam/les/pitzDaily/constant/LESProperties
@@ -14,6 +14,8 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+turbulence          on;
+
 LESModel            oneEqEddy;
 
 delta               cubeRootVol;
diff --git a/tutorials/coodles/pitzDaily/constant/polyMesh/blockMeshDict b/tutorials/pisoFoam/les/pitzDaily/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/coodles/pitzDaily/constant/polyMesh/blockMeshDict
rename to tutorials/pisoFoam/les/pitzDaily/constant/polyMesh/blockMeshDict
diff --git a/tutorials/pisoFoam/les/pitzDaily/constant/polyMesh/boundary b/tutorials/pisoFoam/les/pitzDaily/constant/polyMesh/boundary
new file mode 100644
index 0000000000000000000000000000000000000000..313dcceba1abd7b93d57320c4c674f1734692506
--- /dev/null
+++ b/tutorials/pisoFoam/les/pitzDaily/constant/polyMesh/boundary
@@ -0,0 +1,52 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       polyBoundaryMesh;
+    location    "constant/polyMesh";
+    object      boundary;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+5
+(
+    inlet
+    {
+        type            patch;
+        nFaces          30;
+        startFace       24170;
+    }
+    outlet
+    {
+        type            patch;
+        nFaces          57;
+        startFace       24200;
+    }
+    upperWall
+    {
+        type            wall;
+        nFaces          223;
+        startFace       24257;
+    }
+    lowerWall
+    {
+        type            wall;
+        nFaces          250;
+        startFace       24480;
+    }
+    frontAndBack
+    {
+        type            empty;
+        nFaces          24450;
+        startFace       24730;
+    }
+)
+
+// ************************************************************************* //
diff --git a/tutorials/oodles/pitzDaily/constant/transportProperties b/tutorials/pisoFoam/les/pitzDaily/constant/transportProperties
similarity index 100%
rename from tutorials/oodles/pitzDaily/constant/transportProperties
rename to tutorials/pisoFoam/les/pitzDaily/constant/transportProperties
diff --git a/tutorials/pisoFoam/les/pitzDaily/constant/turbulenceProperties b/tutorials/pisoFoam/les/pitzDaily/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..dcadcf17cd97481597090cf391913d3fe6432687
--- /dev/null
+++ b/tutorials/pisoFoam/les/pitzDaily/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  LESModel;
+
+// ************************************************************************* //
diff --git a/tutorials/oodles/pitzDaily/system/controlDict b/tutorials/pisoFoam/les/pitzDaily/system/controlDict
similarity index 97%
rename from tutorials/oodles/pitzDaily/system/controlDict
rename to tutorials/pisoFoam/les/pitzDaily/system/controlDict
index 3caefe8b0755c320e8187c1c01fa0b69e8a4e0c2..627a1b2516eae4c0246f8660912a9018f5201ef7 100644
--- a/tutorials/oodles/pitzDaily/system/controlDict
+++ b/tutorials/pisoFoam/les/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application oodles;
 
 startFrom       startTime;
 
@@ -84,7 +83,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/oodles/pitzDaily/system/fvSchemes b/tutorials/pisoFoam/les/pitzDaily/system/fvSchemes
similarity index 100%
rename from tutorials/oodles/pitzDaily/system/fvSchemes
rename to tutorials/pisoFoam/les/pitzDaily/system/fvSchemes
diff --git a/tutorials/oodles/pitzDaily/system/fvSolution b/tutorials/pisoFoam/les/pitzDaily/system/fvSolution
similarity index 100%
rename from tutorials/oodles/pitzDaily/system/fvSolution
rename to tutorials/pisoFoam/les/pitzDaily/system/fvSolution
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/B b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/B
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/B
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/B
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/U b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/U
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/U
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/U
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/k b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/k
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/k
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/k
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/nuSgs b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/nuSgs
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/nuSgs
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/nuSgs
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/nuTilda b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/nuTilda
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/nuTilda
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/nuTilda
diff --git a/tutorials/oodles/pitzDailyDirectMapped/0/p b/tutorials/pisoFoam/les/pitzDailyDirectMapped/0/p
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/0/p
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/0/p
diff --git a/tutorials/oodles/pitzDailyDirectMapped/Allrun b/tutorials/pisoFoam/les/pitzDailyDirectMapped/Allrun
similarity index 90%
rename from tutorials/oodles/pitzDailyDirectMapped/Allrun
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/Allrun
index 1e0106247872479a16ec5f2bf3f60574cbc78895..d23000a160182734de209f890271050fafedb183 100755
--- a/tutorials/oodles/pitzDailyDirectMapped/Allrun
+++ b/tutorials/pisoFoam/les/pitzDailyDirectMapped/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application="oodles"
+application="pisoFoam"
 
 runApplication blockMesh
 runApplication changeDictionary
diff --git a/tutorials/oodles/pitzDaily/constant/LESProperties b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/LESProperties
similarity index 99%
rename from tutorials/oodles/pitzDaily/constant/LESProperties
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/LESProperties
index 05339f675aaeeb891be623cf2a85ec15b6509e5b..336220cfbb49c0b792f2e7ec104a60ca04ad55ad 100644
--- a/tutorials/oodles/pitzDaily/constant/LESProperties
+++ b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/LESProperties
@@ -14,6 +14,8 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+turbulence          on;
+
 LESModel            oneEqEddy;
 
 delta               cubeRootVol;
diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/blockMeshDict b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/blockMeshDict
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/polyMesh/blockMeshDict
diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/polyMesh/boundary
similarity index 90%
rename from tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/polyMesh/boundary
index 3f70c82e6755e02de59c615fbabcd399dfcec25c..8f75d94824cb714851d10e610a52c55725f09605 100644
--- a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary
+++ b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/polyMesh/boundary
@@ -2,7 +2,7 @@
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
 |  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
@@ -18,7 +18,7 @@ FoamFile
 
 5
 (
-inlet           
+inlet
 {
     type            directMappedPatch;
     nFaces          30;
@@ -28,28 +28,28 @@ inlet
     offset          ( 0.0495 0 0 );
 }
 
-outlet          
+outlet
 {
     type            patch;
     nFaces          57;
     startFace       27268;
 }
 
-upperWall       
+upperWall
 {
     type            wall;
     nFaces          275;
     startFace       27325;
 }
 
-lowerWall       
+lowerWall
 {
     type            wall;
     nFaces          302;
     startFace       27600;
 }
 
-frontAndBack    
+frontAndBack
 {
     type            empty;
     nFaces          27570;
diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/transportProperties b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/transportProperties
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/constant/transportProperties
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/transportProperties
diff --git a/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/turbulenceProperties b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..dcadcf17cd97481597090cf391913d3fe6432687
--- /dev/null
+++ b/tutorials/pisoFoam/les/pitzDailyDirectMapped/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  LESModel;
+
+// ************************************************************************* //
diff --git a/tutorials/oodles/pitzDailyDirectMapped/system/changeDictionaryDict b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/changeDictionaryDict
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/system/changeDictionaryDict
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/system/changeDictionaryDict
diff --git a/tutorials/oodles/pitzDailyDirectMapped/system/controlDict b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/controlDict
similarity index 97%
rename from tutorials/oodles/pitzDailyDirectMapped/system/controlDict
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/system/controlDict
index 3caefe8b0755c320e8187c1c01fa0b69e8a4e0c2..627a1b2516eae4c0246f8660912a9018f5201ef7 100644
--- a/tutorials/oodles/pitzDailyDirectMapped/system/controlDict
+++ b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application oodles;
 
 startFrom       startTime;
 
@@ -84,7 +83,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/oodles/pitzDailyDirectMapped/system/decomposeParDict b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/decomposeParDict
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/system/decomposeParDict
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/system/decomposeParDict
diff --git a/tutorials/oodles/pitzDailyDirectMapped/system/fvSchemes b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/fvSchemes
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/system/fvSchemes
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/system/fvSchemes
diff --git a/tutorials/oodles/pitzDailyDirectMapped/system/fvSolution b/tutorials/pisoFoam/les/pitzDailyDirectMapped/system/fvSolution
similarity index 100%
rename from tutorials/oodles/pitzDailyDirectMapped/system/fvSolution
rename to tutorials/pisoFoam/les/pitzDailyDirectMapped/system/fvSolution
diff --git a/tutorials/rhoTurbFoam/cavity/0/R b/tutorials/pisoFoam/ras/cavity/0/R
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/R
rename to tutorials/pisoFoam/ras/cavity/0/R
diff --git a/tutorials/turbFoam/cavity/0/U b/tutorials/pisoFoam/ras/cavity/0/U
similarity index 100%
rename from tutorials/turbFoam/cavity/0/U
rename to tutorials/pisoFoam/ras/cavity/0/U
diff --git a/tutorials/turbFoam/cavity/0/epsilon b/tutorials/pisoFoam/ras/cavity/0/epsilon
similarity index 70%
rename from tutorials/turbFoam/cavity/0/epsilon
rename to tutorials/pisoFoam/ras/cavity/0/epsilon
index b24ccfb3802fe4d844039522afaf26e6fed39fe7..6b009c939ad092fdef7f54b8ecb9b755fb70ac3c 100644
--- a/tutorials/turbFoam/cavity/0/epsilon
+++ b/tutorials/pisoFoam/ras/cavity/0/epsilon
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
@@ -10,6 +10,7 @@ FoamFile
     version     2.0;
     format      ascii;
     class       volScalarField;
+    location    "0";
     object      epsilon;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -20,20 +21,21 @@ internalField   uniform 0.000765;
 
 boundaryField
 {
-    movingWall      
+    movingWall
     {
-        type            zeroGradient;
+        type            epsilonWallFunction;
+        value           uniform 0.000765;
     }
-
-    fixedWalls      
+    fixedWalls
     {
-        type            zeroGradient;
+        type            epsilonWallFunction;
+        value           uniform 0.000765;
     }
-
-    frontAndBack    
+    frontAndBack
     {
         type            empty;
     }
 }
 
+
 // ************************************************************************* //
diff --git a/tutorials/turbFoam/cavity/0/k b/tutorials/pisoFoam/ras/cavity/0/k
similarity index 70%
rename from tutorials/turbFoam/cavity/0/k
rename to tutorials/pisoFoam/ras/cavity/0/k
index 7cbb3473bab716c2f2ab079295a740c1302a54f4..5242962b3b24e867f6b6b8db4b0c278faee0a476 100644
--- a/tutorials/turbFoam/cavity/0/k
+++ b/tutorials/pisoFoam/ras/cavity/0/k
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
@@ -10,6 +10,7 @@ FoamFile
     version     2.0;
     format      ascii;
     class       volScalarField;
+    location    "0";
     object      k;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -20,20 +21,21 @@ internalField   uniform 0.00325;
 
 boundaryField
 {
-    movingWall      
+    movingWall
     {
-        type            zeroGradient;
+        type            kQRWallFunction;
+        value           uniform 0.00325;
     }
-
-    fixedWalls      
+    fixedWalls
     {
-        type            zeroGradient;
+        type            kQRWallFunction;
+        value           uniform 0.00325;
     }
-
-    frontAndBack    
+    frontAndBack
     {
         type            empty;
     }
 }
 
+
 // ************************************************************************* //
diff --git a/tutorials/turbFoam/cavity/0/nuTilda b/tutorials/pisoFoam/ras/cavity/0/nuTilda
similarity index 100%
rename from tutorials/turbFoam/cavity/0/nuTilda
rename to tutorials/pisoFoam/ras/cavity/0/nuTilda
diff --git a/tutorials/oodles/pitzDaily/constant/polyMesh/boundary b/tutorials/pisoFoam/ras/cavity/0/nut
similarity index 54%
rename from tutorials/oodles/pitzDaily/constant/polyMesh/boundary
rename to tutorials/pisoFoam/ras/cavity/0/nut
index 8eb7d98937fcdab8a13949fd6bdc743a0928e6d0..dc341e7a1c76b1bafc28d58d8ca450c0b77d0e14 100644
--- a/tutorials/oodles/pitzDaily/constant/polyMesh/boundary
+++ b/tutorials/pisoFoam/ras/cavity/0/nut
@@ -1,55 +1,41 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
 {
     version     2.0;
     format      ascii;
-    class       polyBoundaryMesh;
-    object      boundary;
+    class       volScalarField;
+    location    "0";
+    object      nut;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-5
-(
-inlet
-{
-    type patch;
-    nFaces 30;
-    startFace 24170;
-}
+dimensions      [0 2 -1 0 0 0 0];
 
-outlet
-{
-    type patch;
-    nFaces 57;
-    startFace 24200;
-}
+internalField   uniform 0;
 
-upperWall
+boundaryField
 {
-    type wall;
-    nFaces 223;
-    startFace 24257;
+    movingWall
+    {
+        type            nutWallFunction;
+        value           uniform 0;
+    }
+    fixedWalls
+    {
+        type            nutWallFunction;
+        value           uniform 0;
+    }
+    frontAndBack
+    {
+        type            empty;
+    }
 }
 
-lowerWall
-{
-    type wall;
-    nFaces 250;
-    startFace 24480;
-}
-
-frontAndBack
-{
-    type empty;
-    nFaces 24450;
-    startFace 24730;
-}
-)
 
 // ************************************************************************* //
diff --git a/tutorials/turbFoam/cavity/0/p b/tutorials/pisoFoam/ras/cavity/0/p
similarity index 100%
rename from tutorials/turbFoam/cavity/0/p
rename to tutorials/pisoFoam/ras/cavity/0/p
diff --git a/tutorials/turbFoam/cavity/constant/RASProperties b/tutorials/pisoFoam/ras/cavity/constant/RASProperties
similarity index 100%
rename from tutorials/turbFoam/cavity/constant/RASProperties
rename to tutorials/pisoFoam/ras/cavity/constant/RASProperties
diff --git a/tutorials/rhoTurbFoam/cavity/constant/polyMesh/blockMeshDict b/tutorials/pisoFoam/ras/cavity/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/constant/polyMesh/blockMeshDict
rename to tutorials/pisoFoam/ras/cavity/constant/polyMesh/blockMeshDict
diff --git a/tutorials/turbFoam/cavity/constant/polyMesh/boundary b/tutorials/pisoFoam/ras/cavity/constant/polyMesh/boundary
similarity index 86%
rename from tutorials/turbFoam/cavity/constant/polyMesh/boundary
rename to tutorials/pisoFoam/ras/cavity/constant/polyMesh/boundary
index cc15fe93fcfd889832b45cd9d31b58e296d2b585..61feadd97403fbf58a57c925fc262f3de46ec95a 100644
--- a/tutorials/turbFoam/cavity/constant/polyMesh/boundary
+++ b/tutorials/pisoFoam/ras/cavity/constant/polyMesh/boundary
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
@@ -10,6 +10,7 @@ FoamFile
     version     2.0;
     format      ascii;
     class       polyBoundaryMesh;
+    location    "constant/polyMesh";
     object      boundary;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/turbFoam/cavity/constant/transportProperties b/tutorials/pisoFoam/ras/cavity/constant/transportProperties
similarity index 100%
rename from tutorials/turbFoam/cavity/constant/transportProperties
rename to tutorials/pisoFoam/ras/cavity/constant/transportProperties
diff --git a/tutorials/pisoFoam/ras/cavity/constant/turbulenceProperties b/tutorials/pisoFoam/ras/cavity/constant/turbulenceProperties
new file mode 100644
index 0000000000000000000000000000000000000000..07f85c68df22113b7c7747b89457597b0ea41d66
--- /dev/null
+++ b/tutorials/pisoFoam/ras/cavity/constant/turbulenceProperties
@@ -0,0 +1,19 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  1.5                                   |
+|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      turbulenceProperties;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+simulationType  RASModel;
+
+// ************************************************************************* //
diff --git a/tutorials/turbFoam/cavity/system/controlDict b/tutorials/pisoFoam/ras/cavity/system/controlDict
similarity index 98%
rename from tutorials/turbFoam/cavity/system/controlDict
rename to tutorials/pisoFoam/ras/cavity/system/controlDict
index b62cd7f22b2fa6dabeebab7c86b02d44e9070a61..54904fd3daadf40e61fb4fb207420ff90004ece2 100644
--- a/tutorials/turbFoam/cavity/system/controlDict
+++ b/tutorials/pisoFoam/ras/cavity/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application turbFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/turbFoam/cavity/system/fvSchemes b/tutorials/pisoFoam/ras/cavity/system/fvSchemes
similarity index 100%
rename from tutorials/turbFoam/cavity/system/fvSchemes
rename to tutorials/pisoFoam/ras/cavity/system/fvSchemes
diff --git a/tutorials/turbFoam/cavity/system/fvSolution b/tutorials/pisoFoam/ras/cavity/system/fvSolution
similarity index 93%
rename from tutorials/turbFoam/cavity/system/fvSolution
rename to tutorials/pisoFoam/ras/cavity/system/fvSolution
index a425dc16847dcb6ab27339e23c2d1563ce8b118c..0da9f4a3b69b072a2c8a103884a0777a1e05effd 100644
--- a/tutorials/turbFoam/cavity/system/fvSolution
+++ b/tutorials/pisoFoam/ras/cavity/system/fvSolution
@@ -17,6 +17,12 @@ FoamFile
 solvers
 {
     p PCG
+    {
+        preconditioner   DIC;
+        tolerance        1e-06;
+        relTol           0.1;
+    };
+    pFinal PCG
     {
         preconditioner   DIC;
         tolerance        1e-06;
diff --git a/tutorials/potentialFoam/cylinder/system/controlDict b/tutorials/potentialFoam/cylinder/system/controlDict
index 266d1cb20743fbbc68eaa585757a593c7161f34c..2300e2c09ea24050334b25de1cd227b6fbb88806 100644
--- a/tutorials/potentialFoam/cylinder/system/controlDict
+++ b/tutorials/potentialFoam/cylinder/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application potentialFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/potentialFoam/pitzDaily/system/controlDict b/tutorials/potentialFoam/pitzDaily/system/controlDict
index 266d1cb20743fbbc68eaa585757a593c7161f34c..2300e2c09ea24050334b25de1cd227b6fbb88806 100644
--- a/tutorials/potentialFoam/pitzDaily/system/controlDict
+++ b/tutorials/potentialFoam/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application potentialFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoCentralFoam/obliqueShock/system/controlDict b/tutorials/rhoCentralFoam/obliqueShock/system/controlDict
index 468da70d9a3799d7081ae987d4474b9aab1adb0e..d5385089b9f456c55835fc5ee302edc0f7f68c3f 100644
--- a/tutorials/rhoCentralFoam/obliqueShock/system/controlDict
+++ b/tutorials/rhoCentralFoam/obliqueShock/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     centralFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoCentralFoam/shockTube/system/controlDict b/tutorials/rhoCentralFoam/shockTube/system/controlDict
index 1e1f1a16a9f7023c1cbfaaa89d0b1e9ffcdb0d5d..38434ebd6fbf28789e6116d60a0ad349eee12ff4 100644
--- a/tutorials/rhoCentralFoam/shockTube/system/controlDict
+++ b/tutorials/rhoCentralFoam/shockTube/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass rhopSonicFoam;
 
 startFrom startTime;
 
diff --git a/tutorials/rhoCentralFoam/wedge15Ma5/system/controlDict b/tutorials/rhoCentralFoam/wedge15Ma5/system/controlDict
index e4bc93f3d08364aa5f856181534791ad47f0e97e..301694b88c4e9d42cf37bde9bbc9115f9a5c1fe4 100644
--- a/tutorials/rhoCentralFoam/wedge15Ma5/system/controlDict
+++ b/tutorials/rhoCentralFoam/wedge15Ma5/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass rhopSonicFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoPimpleFoam/angledDuct/system/controlDict b/tutorials/rhoPimpleFoam/angledDuct/system/controlDict
index 47dad418f7ea17265979555b70168e095cb96ff6..3924b69fcc5eeea0fa23e981c4a86f4dfb21486e 100644
--- a/tutorials/rhoPimpleFoam/angledDuct/system/controlDict
+++ b/tutorials/rhoPimpleFoam/angledDuct/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application rhoTurbFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/oodles/pitzDaily/0/B b/tutorials/rhoPisoFoam/les/pitzDaily/0/B
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/B
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/B
diff --git a/tutorials/coodles/pitzDaily/0/T b/tutorials/rhoPisoFoam/les/pitzDaily/0/T
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/T
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/T
diff --git a/tutorials/oodles/pitzDaily/0/U b/tutorials/rhoPisoFoam/les/pitzDaily/0/U
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/U
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/U
diff --git a/tutorials/oodles/pitzDaily/0/k b/tutorials/rhoPisoFoam/les/pitzDaily/0/k
similarity index 100%
rename from tutorials/oodles/pitzDaily/0/k
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/k
diff --git a/tutorials/coodles/pitzDaily/0/muSgs b/tutorials/rhoPisoFoam/les/pitzDaily/0/muSgs
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/muSgs
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/muSgs
diff --git a/tutorials/coodles/pitzDaily/0/muTilda b/tutorials/rhoPisoFoam/les/pitzDaily/0/muTilda
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/muTilda
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/muTilda
diff --git a/tutorials/coodles/pitzDaily/0/p b/tutorials/rhoPisoFoam/les/pitzDaily/0/p
similarity index 100%
rename from tutorials/coodles/pitzDaily/0/p
rename to tutorials/rhoPisoFoam/les/pitzDaily/0/p
diff --git a/tutorials/coodles/pitzDaily/constant/LESProperties b/tutorials/rhoPisoFoam/les/pitzDaily/constant/LESProperties
similarity index 100%
rename from tutorials/coodles/pitzDaily/constant/LESProperties
rename to tutorials/rhoPisoFoam/les/pitzDaily/constant/LESProperties
diff --git a/tutorials/oodles/pitzDaily/constant/polyMesh/blockMeshDict b/tutorials/rhoPisoFoam/les/pitzDaily/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/oodles/pitzDaily/constant/polyMesh/blockMeshDict
rename to tutorials/rhoPisoFoam/les/pitzDaily/constant/polyMesh/blockMeshDict
diff --git a/tutorials/coodles/pitzDaily/constant/polyMesh/boundary b/tutorials/rhoPisoFoam/les/pitzDaily/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/coodles/pitzDaily/constant/polyMesh/boundary
rename to tutorials/rhoPisoFoam/les/pitzDaily/constant/polyMesh/boundary
diff --git a/tutorials/coodles/pitzDaily/constant/thermophysicalProperties b/tutorials/rhoPisoFoam/les/pitzDaily/constant/thermophysicalProperties
similarity index 100%
rename from tutorials/coodles/pitzDaily/constant/thermophysicalProperties
rename to tutorials/rhoPisoFoam/les/pitzDaily/constant/thermophysicalProperties
diff --git a/tutorials/coodles/pitzDaily/system/controlDict b/tutorials/rhoPisoFoam/les/pitzDaily/system/controlDict
similarity index 96%
rename from tutorials/coodles/pitzDaily/system/controlDict
rename to tutorials/rhoPisoFoam/les/pitzDaily/system/controlDict
index 77b748c8293040d93a4018fa76d6b92dd5518348..a5870996dd1b84b595517af4ba98625a49f07b9a 100644
--- a/tutorials/coodles/pitzDaily/system/controlDict
+++ b/tutorials/rhoPisoFoam/les/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application coodles;
 
 startFrom       startTime;
 
@@ -52,7 +51,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         enabled true;
 
diff --git a/tutorials/coodles/pitzDaily/system/fvSchemes b/tutorials/rhoPisoFoam/les/pitzDaily/system/fvSchemes
similarity index 100%
rename from tutorials/coodles/pitzDaily/system/fvSchemes
rename to tutorials/rhoPisoFoam/les/pitzDaily/system/fvSchemes
diff --git a/tutorials/coodles/pitzDaily/system/fvSolution b/tutorials/rhoPisoFoam/les/pitzDaily/system/fvSolution
similarity index 100%
rename from tutorials/coodles/pitzDaily/system/fvSolution
rename to tutorials/rhoPisoFoam/les/pitzDaily/system/fvSolution
diff --git a/tutorials/turbFoam/cavity/0/R b/tutorials/rhoPisoFoam/ras/cavity/0/R
similarity index 100%
rename from tutorials/turbFoam/cavity/0/R
rename to tutorials/rhoPisoFoam/ras/cavity/0/R
diff --git a/tutorials/rhoTurbFoam/cavity/0/T b/tutorials/rhoPisoFoam/ras/cavity/0/T
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/T
rename to tutorials/rhoPisoFoam/ras/cavity/0/T
diff --git a/tutorials/rhoTurbFoam/cavity/0/U b/tutorials/rhoPisoFoam/ras/cavity/0/U
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/U
rename to tutorials/rhoPisoFoam/ras/cavity/0/U
diff --git a/tutorials/rhoTurbFoam/cavity/0/epsilon b/tutorials/rhoPisoFoam/ras/cavity/0/epsilon
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/epsilon
rename to tutorials/rhoPisoFoam/ras/cavity/0/epsilon
diff --git a/tutorials/rhoTurbFoam/cavity/0/k b/tutorials/rhoPisoFoam/ras/cavity/0/k
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/k
rename to tutorials/rhoPisoFoam/ras/cavity/0/k
diff --git a/tutorials/rhoTurbFoam/cavity/0/omega b/tutorials/rhoPisoFoam/ras/cavity/0/omega
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/omega
rename to tutorials/rhoPisoFoam/ras/cavity/0/omega
diff --git a/tutorials/rhoTurbFoam/cavity/0/p b/tutorials/rhoPisoFoam/ras/cavity/0/p
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/0/p
rename to tutorials/rhoPisoFoam/ras/cavity/0/p
diff --git a/tutorials/rhoTurbFoam/cavity/constant/RASProperties b/tutorials/rhoPisoFoam/ras/cavity/constant/RASProperties
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/constant/RASProperties
rename to tutorials/rhoPisoFoam/ras/cavity/constant/RASProperties
diff --git a/tutorials/turbFoam/cavity/constant/polyMesh/blockMeshDict b/tutorials/rhoPisoFoam/ras/cavity/constant/polyMesh/blockMeshDict
similarity index 100%
rename from tutorials/turbFoam/cavity/constant/polyMesh/blockMeshDict
rename to tutorials/rhoPisoFoam/ras/cavity/constant/polyMesh/blockMeshDict
diff --git a/tutorials/rhoTurbFoam/cavity/constant/polyMesh/boundary b/tutorials/rhoPisoFoam/ras/cavity/constant/polyMesh/boundary
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/constant/polyMesh/boundary
rename to tutorials/rhoPisoFoam/ras/cavity/constant/polyMesh/boundary
diff --git a/tutorials/rhoTurbFoam/cavity/constant/thermophysicalProperties b/tutorials/rhoPisoFoam/ras/cavity/constant/thermophysicalProperties
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/constant/thermophysicalProperties
rename to tutorials/rhoPisoFoam/ras/cavity/constant/thermophysicalProperties
diff --git a/tutorials/rhoTurbFoam/cavity/system/controlDict b/tutorials/rhoPisoFoam/ras/cavity/system/controlDict
similarity index 98%
rename from tutorials/rhoTurbFoam/cavity/system/controlDict
rename to tutorials/rhoPisoFoam/ras/cavity/system/controlDict
index f5ff06d5533d385dd142ece0b1a195afcd0751c4..be7feda05dc9a744cf538743ec7aedc6df1a31df 100644
--- a/tutorials/rhoTurbFoam/cavity/system/controlDict
+++ b/tutorials/rhoPisoFoam/ras/cavity/system/controlDict
@@ -15,7 +15,6 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // Foam Application Class
-application rhoTurbFoam;
 
 // Start point of run
 startFrom       startTime;
diff --git a/tutorials/rhoTurbFoam/cavity/system/fvSchemes b/tutorials/rhoPisoFoam/ras/cavity/system/fvSchemes
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/system/fvSchemes
rename to tutorials/rhoPisoFoam/ras/cavity/system/fvSchemes
diff --git a/tutorials/rhoTurbFoam/cavity/system/fvSolution b/tutorials/rhoPisoFoam/ras/cavity/system/fvSolution
similarity index 100%
rename from tutorials/rhoTurbFoam/cavity/system/fvSolution
rename to tutorials/rhoPisoFoam/ras/cavity/system/fvSolution
diff --git a/tutorials/rhoPorousSimpleFoam/angledDuctExplicit/system/controlDict b/tutorials/rhoPorousSimpleFoam/angledDuctExplicit/system/controlDict
index 92b222d865b8273da482ad8bb55c5bb6584fbe44..691db89a86f361d2ae2ca4ed9bb939e03eb452ca 100644
--- a/tutorials/rhoPorousSimpleFoam/angledDuctExplicit/system/controlDict
+++ b/tutorials/rhoPorousSimpleFoam/angledDuctExplicit/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     rhoPorousSimpleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoPorousSimpleFoam/angledDuctImplicit/system/controlDict b/tutorials/rhoPorousSimpleFoam/angledDuctImplicit/system/controlDict
index 047374fa695c2dc7b3d5134eb2f4a4ef6046ebc1..b354267d9e85882f79c51118a48ea47d26ba024e 100644
--- a/tutorials/rhoPorousSimpleFoam/angledDuctImplicit/system/controlDict
+++ b/tutorials/rhoPorousSimpleFoam/angledDuctImplicit/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     rhoPorousSimpleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoSonicFoam/forwardStep/system/controlDict b/tutorials/rhoSonicFoam/forwardStep/system/controlDict
index 323ae66cd68f706b220587ad9cbcc5fe75035e41..4a7ac2d55093860131e3519f96fa5623cc787eb8 100644
--- a/tutorials/rhoSonicFoam/forwardStep/system/controlDict
+++ b/tutorials/rhoSonicFoam/forwardStep/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application rhoSonicFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/rhoSonicFoam/shockTube/system/controlDict b/tutorials/rhoSonicFoam/shockTube/system/controlDict
index c7b171b29660b4bdc58a82df74d1f367d558f547..cf7893b7647e2594cc0ec63d3681a4a5d2a9cb3d 100644
--- a/tutorials/rhoSonicFoam/shockTube/system/controlDict
+++ b/tutorials/rhoSonicFoam/shockTube/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application rhoSonicFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/system/controlDict b/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/system/controlDict
index f2eb50dbcf8424a37d41de20c35eb465c7362d1b..02438600d45b5de30a38cabe9c62bb3cdda06ebe 100644
--- a/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/system/controlDict
+++ b/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/system/controlDict
@@ -15,7 +15,6 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // Foam Application Class
-application     rhoTurbThermoParcelFoam;
 
 // Start point of run
 startFrom       latestTime;
diff --git a/tutorials/rhopSonicFoam/shockTube/system/controlDict b/tutorials/rhopSonicFoam/shockTube/system/controlDict
index e17a0a5bc6a4a5bcc25175ee6848a1426d7659e9..dae184a1a5d92b54a7e69c641a1a7db17b3eb1f7 100644
--- a/tutorials/rhopSonicFoam/shockTube/system/controlDict
+++ b/tutorials/rhopSonicFoam/shockTube/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass rhopSonicFoam;
 
 startFrom startTime;
 
diff --git a/tutorials/rhopSonicFoam/wedge15Ma5/system/controlDict b/tutorials/rhopSonicFoam/wedge15Ma5/system/controlDict
index e4bc93f3d08364aa5f856181534791ad47f0e97e..301694b88c4e9d42cf37bde9bbc9115f9a5c1fe4 100644
--- a/tutorials/rhopSonicFoam/wedge15Ma5/system/controlDict
+++ b/tutorials/rhopSonicFoam/wedge15Ma5/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass rhopSonicFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/scalarTransportFoam/pitzDaily/system/controlDict b/tutorials/scalarTransportFoam/pitzDaily/system/controlDict
index 216d9846522d796a8d43ade03fe7fccf31a85970..754277eb2551d37d6b5180d30402c53697e91de6 100644
--- a/tutorials/scalarTransportFoam/pitzDaily/system/controlDict
+++ b/tutorials/scalarTransportFoam/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application scalarTransportFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/settlingFoam/dahl/system/controlDict b/tutorials/settlingFoam/dahl/system/controlDict
index 6c19417512ce5894610bfc667b8868eaec201a3d..7b2093120b87fed8c8d2c2ea24d24331d2f63597 100644
--- a/tutorials/settlingFoam/dahl/system/controlDict
+++ b/tutorials/settlingFoam/dahl/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application settlingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/settlingFoam/tank3D/system/controlDict b/tutorials/settlingFoam/tank3D/system/controlDict
index 9debaf4d9d48830febbc202d753e9cf3dc860f62..f7c7ecd1d65dbf11ff2c06511f1b752f58f2b183 100644
--- a/tutorials/settlingFoam/tank3D/system/controlDict
+++ b/tutorials/settlingFoam/tank3D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application settlingFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/simpleFoam/airFoil2D/system/controlDict b/tutorials/simpleFoam/airFoil2D/system/controlDict
index 7990420d0b4f2b4e0dd78da072202713685673d1..3b6e0b2a477c6f7cc7897a8cd0a353c2c438e97e 100644
--- a/tutorials/simpleFoam/airFoil2D/system/controlDict
+++ b/tutorials/simpleFoam/airFoil2D/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application simpleFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/simpleFoam/pitzDaily/system/controlDict b/tutorials/simpleFoam/pitzDaily/system/controlDict
index 9c461643e781f76491405dbc7b118946818e3bc4..77e3a65b502c713669b69feb25d664894139c35f 100644
--- a/tutorials/simpleFoam/pitzDaily/system/controlDict
+++ b/tutorials/simpleFoam/pitzDaily/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application simpleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/simpleFoam/pitzDailyExptInlet/system/controlDict b/tutorials/simpleFoam/pitzDailyExptInlet/system/controlDict
index 9c461643e781f76491405dbc7b118946818e3bc4..77e3a65b502c713669b69feb25d664894139c35f 100644
--- a/tutorials/simpleFoam/pitzDailyExptInlet/system/controlDict
+++ b/tutorials/simpleFoam/pitzDailyExptInlet/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application simpleFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/simpleSRFFoam/mixer/system/controlDict b/tutorials/simpleSRFFoam/mixer/system/controlDict
index 029a7142319e34c1d2bed780b78634bf93d2916f..b50c43e4d8e33d82cf15abb63810d2a99130f9b1 100644
--- a/tutorials/simpleSRFFoam/mixer/system/controlDict
+++ b/tutorials/simpleSRFFoam/mixer/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     simpleSRFFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/snappyHexMesh/iglooWithFridges/system/controlDict b/tutorials/snappyHexMesh/iglooWithFridges/system/controlDict
index 36315909db259dc47a42ff0abf1d85da1f4dedfb..b2622384ddabbbd9022f1607b1080bc55f64a584 100644
--- a/tutorials/snappyHexMesh/iglooWithFridges/system/controlDict
+++ b/tutorials/snappyHexMesh/iglooWithFridges/system/controlDict
@@ -15,7 +15,6 @@ FoamFile
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/snappyHexMesh/motorBike/system/controlDict b/tutorials/snappyHexMesh/motorBike/system/controlDict
index 36315909db259dc47a42ff0abf1d85da1f4dedfb..b2622384ddabbbd9022f1607b1080bc55f64a584 100644
--- a/tutorials/snappyHexMesh/motorBike/system/controlDict
+++ b/tutorials/snappyHexMesh/motorBike/system/controlDict
@@ -15,7 +15,6 @@ FoamFile
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application icoFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/solidDisplacementFoam/plateHole/system/controlDict b/tutorials/solidDisplacementFoam/plateHole/system/controlDict
index 9adaec782acf39d2e0a4e85635723a02b1d548f1..14218ed2cf9afeb4868b3cca87a9fcdc7541d715 100644
--- a/tutorials/solidDisplacementFoam/plateHole/system/controlDict
+++ b/tutorials/solidDisplacementFoam/plateHole/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     solidDisplacementFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/sonicFoam/forwardStep/system/controlDict b/tutorials/sonicFoam/forwardStep/system/controlDict
index 123e2bd3e0192a64678ae2a8e3f683e67e7ba660..be42312415b2ef6708bb457a4b7580bca3474579 100644
--- a/tutorials/sonicFoam/forwardStep/system/controlDict
+++ b/tutorials/sonicFoam/forwardStep/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application sonicFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/sonicFoam/shockTube/system/controlDict b/tutorials/sonicFoam/shockTube/system/controlDict
index 2e7a586eb454aa199b665cdd98b9c68f6e24676b..cf7893b7647e2594cc0ec63d3681a4a5d2a9cb3d 100644
--- a/tutorials/sonicFoam/shockTube/system/controlDict
+++ b/tutorials/sonicFoam/shockTube/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application sonicFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/sonicLiquidFoam/decompressionTank/system/controlDict b/tutorials/sonicLiquidFoam/decompressionTank/system/controlDict
index b11905a6b2e4c498be4bb7b25feaa772e030b05b..f2cc0d0177ce23100a4bf9caa1ba4e99b71ff2c2 100644
--- a/tutorials/sonicLiquidFoam/decompressionTank/system/controlDict
+++ b/tutorials/sonicLiquidFoam/decompressionTank/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application sonicLiquidFoam;
 
 startFrom       startTime;
 
diff --git a/tutorials/sonicTurbFoam/nacaAirfoil/system/controlDict b/tutorials/sonicTurbFoam/nacaAirfoil/system/controlDict
index 26f03536a79f079701dcebe28d3988ed5047ec07..41047af140f30e70db37ba7d6b0e667058ac49cd 100644
--- a/tutorials/sonicTurbFoam/nacaAirfoil/system/controlDict
+++ b/tutorials/sonicTurbFoam/nacaAirfoil/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application     sonicTurbFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/sonicTurbFoam/prism/system/controlDict b/tutorials/sonicTurbFoam/prism/system/controlDict
index 853aeb0d9c4492a1ddad72a81a838429f6246fed..34291293c0ebe9171282cfc87d9ad3b93245f9fe 100644
--- a/tutorials/sonicTurbFoam/prism/system/controlDict
+++ b/tutorials/sonicTurbFoam/prism/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application sonicTurbFoam;
 
 startFrom       latestTime;
 
diff --git a/tutorials/twoPhaseEulerFoam/bed/system/controlDict b/tutorials/twoPhaseEulerFoam/bed/system/controlDict
index 1fc42f5c6e6ce9d65058b976e1ac59ecbafe8931..026a5ed2a4e4b19322ba7bbe6c32418ebb797ff2 100644
--- a/tutorials/twoPhaseEulerFoam/bed/system/controlDict
+++ b/tutorials/twoPhaseEulerFoam/bed/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass twoPhaseEulerFoam;
 
 startFrom       latestTime;
 
@@ -58,7 +57,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         // Fields to be  averaged - runTime modifiable
         fields
diff --git a/tutorials/twoPhaseEulerFoam/bed2/system/controlDict b/tutorials/twoPhaseEulerFoam/bed2/system/controlDict
index 85c8fc5cb84d409f16b9751dc6c3d99182104c1f..df4a5a205e8138e14ff465ba229bbd829e1f8478 100644
--- a/tutorials/twoPhaseEulerFoam/bed2/system/controlDict
+++ b/tutorials/twoPhaseEulerFoam/bed2/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-applicationClass twoPhaseEulerFoam;
 
 startFrom       latestTime;
 
@@ -58,7 +57,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         outputControl outputTime;
 
diff --git a/tutorials/twoPhaseEulerFoam/bubbleColumn/system/controlDict b/tutorials/twoPhaseEulerFoam/bubbleColumn/system/controlDict
index f159012fa92a27c27ac43f29eeff8948a2bb2315..c2e280e5dc8b2c2fda7c06bb32dad2889a449fbd 100644
--- a/tutorials/twoPhaseEulerFoam/bubbleColumn/system/controlDict
+++ b/tutorials/twoPhaseEulerFoam/bubbleColumn/system/controlDict
@@ -14,7 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-application twoPhaseEulerFoam;
 
 startFrom       startTime;
 
@@ -58,7 +57,7 @@ functions
         type fieldAverage;
 
         // Where to load it from (if not already in solver)
-        functionObjectLibs ("libfieldAverage.so");
+        functionObjectLibs ("libfieldFunctionObjects.so");
 
         // Fields to be  averaged - runTime modifiable
         fields
diff --git a/wmake/wmake b/wmake/wmake
index 911e7fbc30561127055b155247ec9c1a4b0d0dcc..473119fd01eb7db0834442c4b790fa385a8d2721 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -163,8 +163,9 @@ then
         exit $?
     elif [ ! -d $MakeDir ]
     then
-        #FOAM_APPS=`find . -maxdepth 1 \( -type d -a ! -name "." -a ! -name "Optional" -a ! -name "Make" \)  -printf "%f "`
-        FOAM_APPS=`for d in *; do if [ -d "$d" -a "$d" != "Optional" -a "$d" != "Make" ]; then echo "$d"; fi; done | xargs`
+        # FOAM_APPS=$(find . -maxdepth 1 \( -type d -a ! -name "." -a ! -name Optional -a ! -name Make \)  -printf "%f ")
+        # avoid 'find' with '-printf' ... not entirely portable
+        FOAM_APPS=$(for d in *; do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] && echo "$d"; done | xargs)
         $make -k -f $WM_DIR/MakefileApps FOAM_APPS="$FOAM_APPS"
         exit $?
     fi