diff --git a/ReleaseNotes-1.5 b/ReleaseNotes-1.5
index faa5dad6b2c23bfc5b0926440e7faf2fa3dfffe1..387d65d9a0960311a790cb33caab86946b424519 100644
--- a/ReleaseNotes-1.5
+++ b/ReleaseNotes-1.5
@@ -2,7 +2,7 @@
 #
 #+TITLE:          *OpenFOAM release notes for version 1.5*
 #+AUTHOR:                      OpenCFD Ltd.
-#+DATE:                       26 August 2008
+#+DATE:                       07 October 2008
 #+LINK:                  http://www.opencfd.co.uk
 #+OPTIONS: author:nil ^:{}
 
@@ -34,7 +34,7 @@
     and $WM_COMPILER_ARCH environment variables in the OpenFOAM-1.5/etc/bashrc
     (or cshrc) file.
   + The location of the installation of the compiler is controlled by the
-    $WM_COMPILER_INST environment variable in the OpenFOAM-1.5/etc/settings.sh
+    $compilerInstall environment variable in the OpenFOAM-1.5/etc/settings.sh
     (or settings.csh) file.
 
 * Developments to solvers (applications)
diff --git a/ReleaseNotes-1.5.html b/ReleaseNotes-1.5.html
index a1805d5e9d00f9773be208fdee73fe50b49fa821..d1c62c685bd621ac2f4dfee64221039c7e91f923 100644
--- a/ReleaseNotes-1.5.html
+++ b/ReleaseNotes-1.5.html
@@ -49,7 +49,7 @@ quires the installation of Qt 4.3.? for ParaView-3 to run.
     $WM_COMPILER and $WM_COMPILER_ARCH environment variables in the
     OpenFOAM-1.5/etc/bashrc (or cshrc) file.
   * The location of the installation of the compiler is controlled by the
-    $WM_COMPILER_INST environment variable in the OpenFOAM-1.5/etc/settings.sh
+    $compilerInstall environment variable in the OpenFOAM-1.5/etc/settings.sh
     (or settings.csh) file.
 
 4 Developments to solvers (applications)
@@ -202,7 +202,7 @@ To aid common monitoring and post-processing activities.
   * Non-blocking, non-buffered, parallel transfers with potential scaling
     benefits for larger number of processors.
 
-Date: 26 August 2008
+Date: 07 October 2008
 
 HTML generated by org-mode 6.06b in emacs 23
 
diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
index 4db4faac505f40e5b0b8a40d152a48843bf9d119..5a17820680fc602afaad19b9c931fb21d1c8c171 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
@@ -157,9 +157,8 @@ void maxwellSlipUFvPatchVectorField::updateCoeffs()
 
     if(thermalCreep_)
     {
-        const GeometricField<scalar, fvPatchField, volMesh>& vsfT =
-            this->db().objectRegistry::
-            lookupObject<GeometricField<scalar, fvPatchField, volMesh> >("T");
+        const volScalarField& vsfT =
+            this->db().objectRegistry::lookupObject<volScalarField>("T");
         label patchi = this->patch().index();
         const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
         Field<vector> gradpT = fvc::grad(vsfT)().boundaryField()[patchi];
diff --git a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C
index b9b46a3cc9472054bf10081efbf02945192cfb5c..19933091a0517bfd983bb935f2acc9d7f15a7a19 100644
--- a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C
+++ b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C
@@ -26,8 +26,8 @@ Application
     boundaryFoam
 
 Description
-    Steady-state solver for 1D turbulent flow, typically to generate boundary 
-    layer conditions at an inlet, for use in a simulation. 
+    Steady-state solver for 1D turbulent flow, typically to generate boundary
+    layer conditions at an inlet, for use in a simulation.
 
     Boundary layer code to calculate the U, k and epsilon distributions.
     Used to create inlet boundary conditions for experimental comparisons
@@ -82,11 +82,14 @@ int main(int argc, char *argv[])
         U += (Ubar - UbarStar);
         gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
 
+        label id = y.size() - 1;
+
         scalar wallShearStress =
-            flowDirection & turbulence->R()()[0] & wallNormal;
+            flowDirection & turbulence->R()()[id] & wallNormal;
 
         scalar yplusWall
-            = ::sqrt(mag(wallShearStress))*y[0]/laminarTransport.nu()()[0];
+//            = ::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id];
+            = ::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id];
 
         Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab
             << "pressure gradient = " << (flowDirection & gradP.value()) << tab
diff --git a/applications/solvers/incompressible/oodles/oodles.C b/applications/solvers/incompressible/oodles/oodles.C
index eb5fa65dcf6bd67668c26dd3d2026e658f711f7e..8c51065db1d06490ed8fba17107553c52f0b2be0 100644
--- a/applications/solvers/incompressible/oodles/oodles.C
+++ b/applications/solvers/incompressible/oodles/oodles.C
@@ -66,6 +66,9 @@ int main(int argc, char *argv[])
           + sgsModel->divDevBeff(U)
         );
 
+        // Optionally ensure diagonal-dominance of the momentum matrix
+        UEqn.relax();
+
         if (momentumPredictor)
         {
             solve(UEqn == -fvc::grad(p));
diff --git a/applications/solvers/incompressible/simpleFoam/Make/options b/applications/solvers/incompressible/simpleFoam/Make/options
index e1ffa287732d80b41bb08082b41b67556a286165..8a31f7e5abb705153daf5f003b320fbee11cdf32 100644
--- a/applications/solvers/incompressible/simpleFoam/Make/options
+++ b/applications/solvers/incompressible/simpleFoam/Make/options
@@ -7,5 +7,4 @@ EXE_LIBS = \
     -lincompressibleRASModels \
     -lincompressibleTransportModels \
     -lfiniteVolume \
-    -lmeshTools \
-    /* $(LIB_WM_OPTIONS_DIR)/libfbsdmalloc.o */
+    -lmeshTools
diff --git a/applications/test/List/ListLoop.s b/applications/test/List/ListLoop.s
deleted file mode 100644
index 4acfadf82927ac4349de52d34f02bed8ce3b929d..0000000000000000000000000000000000000000
--- a/applications/test/List/ListLoop.s
+++ /dev/null
@@ -1,224 +0,0 @@
-	.file	"ListLoop.C"
-	.section	.ctors,"aw",@progbits
-	.align 4
-	.long	_GLOBAL__I__Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_
-	.text
-	.align 2
-	.p2align 4,,15
-	.type	_Z41__static_initialization_and_destruction_0ii, @function
-_Z41__static_initialization_and_destruction_0ii:
-.LFB2550:
-	pushl	%ebp
-.LCFI0:
-	movl	%esp, %ebp
-.LCFI1:
-	pushl	%ebx
-.LCFI2:
-	call	__i686.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	subl	$20, %esp
-.LCFI3:
-	decl	%eax
-	je	.L7
-.L5:
-	addl	$20, %esp
-	popl	%ebx
-	leave
-	ret
-	.p2align 4,,7
-.L7:
-	cmpl	$65535, %edx
-	jne	.L5
-	leal	_ZSt8__ioinit@GOTOFF(%ebx), %eax
-	movl	%eax, (%esp)
-	call	_ZNSt8ios_base4InitC1Ev@PLT
-	movl	__dso_handle@GOT(%ebx), %eax
-	movl	$0, 4(%esp)
-	movl	%eax, 8(%esp)
-	leal	__tcf_0@GOTOFF(%ebx), %eax
-	movl	%eax, (%esp)
-	call	__cxa_atexit@PLT
-	addl	$20, %esp
-	popl	%ebx
-	leave
-	ret
-.LFE2550:
-	.size	_Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
-.globl __gxx_personality_v0
-	.align 2
-	.p2align 4,,15
-	.type	_GLOBAL__I__Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_, @function
-_GLOBAL__I__Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_:
-.LFB2552:
-	pushl	%ebp
-.LCFI4:
-	movl	$65535, %edx
-	movl	$1, %eax
-	movl	%esp, %ebp
-.LCFI5:
-	leave
-	jmp	_Z41__static_initialization_and_destruction_0ii
-.LFE2552:
-	.size	_GLOBAL__I__Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_, .-_GLOBAL__I__Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_
-	.align 2
-	.p2align 4,,15
-	.type	__tcf_0, @function
-__tcf_0:
-.LFB2551:
-	pushl	%ebp
-.LCFI6:
-	movl	%esp, %ebp
-.LCFI7:
-	pushl	%ebx
-.LCFI8:
-	call	__i686.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	subl	$4, %esp
-.LCFI9:
-	leal	_ZSt8__ioinit@GOTOFF(%ebx), %eax
-	movl	%eax, (%esp)
-	call	_ZNSt8ios_base4InitD1Ev@PLT
-	addl	$4, %esp
-	popl	%ebx
-	leave
-	ret
-.LFE2551:
-	.size	__tcf_0, .-__tcf_0
-	.align 2
-	.p2align 4,,15
-.globl _Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_
-	.type	_Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_, @function
-_Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_:
-.LFB2352:
-	pushl	%ebp
-.LCFI10:
-	movl	%esp, %ebp
-.LCFI11:
-	pushl	%edi
-.LCFI12:
-	pushl	%esi
-.LCFI13:
-	subl	$12, %esp
-.LCFI14:
-	movl	8(%ebp), %edx
-	movl	(%edx), %eax
-	testl	%eax, %eax
-	movl	%eax, -20(%ebp)
-	jle	.L16
-	movl	16(%ebp), %eax
-	movl	4(%edx), %edx
-	xorl	%ecx, %ecx
-	movl	4(%eax), %eax
-	movl	%edx, -12(%ebp)
-	movl	%eax, -16(%ebp)
-	movl	20(%ebp), %eax
-	movl	4(%eax), %edi
-	movl	12(%ebp), %eax
-	movl	4(%eax), %esi
-	.p2align 4,,7
-.L15:
-	movl	-16(%ebp), %edx
-	movl	(%edx,%ecx,4), %eax
-	movl	-12(%ebp), %edx
-	leal	(%edx,%eax,8), %eax
-	movl	(%edi,%ecx,4), %edx
-	incl	%ecx
-	cmpl	%ecx, -20(%ebp)
-	fldl	(%eax)
-	fsubl	(%esi,%edx,8)
-	fstpl	(%eax)
-	jne	.L15
-.L16:
-	addl	$12, %esp
-	popl	%esi
-	popl	%edi
-	leave
-	ret
-.LFE2352:
-	.size	_Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_, .-_Z4funcRN4Foam4ListIdEERKS1_RKNS0_IiEES7_
-	.local	_ZSt8__ioinit
-	.comm	_ZSt8__ioinit,1,1
-	.section	.eh_frame,"a",@progbits
-.Lframe1:
-	.long	.LECIE1-.LSCIE1
-.LSCIE1:
-	.long	0x0
-	.byte	0x1
-	.string	"zPR"
-	.uleb128 0x1
-	.sleb128 -4
-	.byte	0x8
-	.uleb128 0x6
-	.byte	0x9b
-	.long	DW.ref.__gxx_personality_v0-.
-	.byte	0x1b
-	.byte	0xc
-	.uleb128 0x4
-	.uleb128 0x4
-	.byte	0x88
-	.uleb128 0x1
-	.align 4
-.LECIE1:
-.LSFDE1:
-	.long	.LEFDE1-.LASFDE1
-.LASFDE1:
-	.long	.LASFDE1-.Lframe1
-	.long	.LFB2550-.
-	.long	.LFE2550-.LFB2550
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI0-.LFB2550
-	.byte	0xe
-	.uleb128 0x8
-	.byte	0x85
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI1-.LCFI0
-	.byte	0xd
-	.uleb128 0x5
-	.byte	0x4
-	.long	.LCFI2-.LCFI1
-	.byte	0x83
-	.uleb128 0x3
-	.align 4
-.LEFDE1:
-.LSFDE5:
-	.long	.LEFDE5-.LASFDE5
-.LASFDE5:
-	.long	.LASFDE5-.Lframe1
-	.long	.LFB2551-.
-	.long	.LFE2551-.LFB2551
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI6-.LFB2551
-	.byte	0xe
-	.uleb128 0x8
-	.byte	0x85
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI7-.LCFI6
-	.byte	0xd
-	.uleb128 0x5
-	.byte	0x4
-	.long	.LCFI8-.LCFI7
-	.byte	0x83
-	.uleb128 0x3
-	.align 4
-.LEFDE5:
-	.hidden DW.ref.__gxx_personality_v0
-	.weak	DW.ref.__gxx_personality_v0
-	.section	.data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
-	.align 4
-	.type	DW.ref.__gxx_personality_v0, @object
-	.size	DW.ref.__gxx_personality_v0, 4
-DW.ref.__gxx_personality_v0:
-	.long	__gxx_personality_v0
-	.ident	"GCC: (GNU) 4.1.1"
-	.section	.text.__i686.get_pc_thunk.bx,"axG",@progbits,__i686.get_pc_thunk.bx,comdat
-.globl __i686.get_pc_thunk.bx
-	.hidden	__i686.get_pc_thunk.bx
-	.type	__i686.get_pc_thunk.bx, @function
-__i686.get_pc_thunk.bx:
-	movl	(%esp), %ebx
-	ret
-	.section	.note.GNU-stack,"",@progbits
diff --git a/applications/test/xfer/Make/files b/applications/test/xfer/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..92414c039e1c4213fb72884b447ca821d7a1ec08
--- /dev/null
+++ b/applications/test/xfer/Make/files
@@ -0,0 +1,4 @@
+xferListTest.C
+
+/* EXE = $(FOAM_USER_APPBIN)/xferListTest */
+EXE = ./xferListTest
diff --git a/applications/test/xfer/Make/options b/applications/test/xfer/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H b/applications/test/xfer/xferListTest.C
similarity index 51%
rename from src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H
rename to applications/test/xfer/xferListTest.C
index d1b048c020e7c8cbfd2c09b396f98f3ab1dc289d..6fce6b2bd0e2203bb834136d650ed7d171eec577 100644
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H
+++ b/applications/test/xfer/xferListTest.C
@@ -22,51 +22,66 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    kOmegaWallViscosity
+Application
 
 Description
-    Calculate wall viscosity from wall-functions.
 
 \*---------------------------------------------------------------------------*/
 
-{
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
+#include "OSspecific.H"
+
+#include "IOstreams.H"
+#include "IStringStream.H"
+#include "labelList.H"
+
+using namespace Foam;
 
-    const fvPatchList& patches = mesh_.boundary();
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
 
-    forAll(patches, patchi)
+int main(int argc, char *argv[])
+{
+    List<label> lstA(10);
+    List<label> lstC(IStringStream("(1 2 3 4)")());
+    
+    forAll(lstA, i)
     {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            const scalarField& rhow = rho_.boundaryField()[patchi];
-
-            const scalarField& muw = mu().boundaryField()[patchi];
-            scalarField& mutw = mut_.boundaryField()[patchi];
-
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[faceCelli]
-                   *sqrt(k_[faceCelli])/(muw[facei]/rhow[facei]);
-
-                if (yPlus > yPlusLam_)
-                {
-                    mutw[facei] =
-                         muw[facei]
-                        *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1);
-                }
-                else
-                {
-                    mutw[facei] = 0.0;
-                }
-            }
-        }
+        lstA[i] = i;
     }
+        
+    Info<< "lstA: " << lstA << endl;
+    Info<< "lstC: " << lstC << endl;
+
+    xfer<List<label> > xA(lstA, true);
+    xfer<List<label> > xB;
+
+//    List<label> lstB( xferTmp(List<label>, lstC) );
+//    List<label> lstB( xfer<List<label> >(lstC) );
+    List<label> lstB( xA );
+
+    Info<< "xA: " << *xA << endl;
+    Info<< "xB: " << *xB << endl;
+    Info<< "lstA: " << lstA << endl;
+    Info<< "lstB: " << lstB << endl;
+    Info<< "lstC: " << lstC << endl;
+
+    xA = lstB;
+
+    Info<< "xA: " << *xA << endl;
+    Info<< "xB: " << *xB << endl;
+    Info<< "lstA: " << lstA << endl;
+    Info<< "lstB: " << lstB << endl;
+    Info<< "lstC: " << lstC << endl;
+
+    xB = xA;
+
+    Info<< "xA: " << *xA << endl;
+    Info<< "xB: " << *xB << endl;
+    Info<< "lstA: " << lstA << endl;
+    Info<< "lstB: " << lstB << endl;
+    Info<< "lstC: " << lstC << endl;
+
+    return 0;
 }
 
 
diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
index bc25b97012c68681a0e19d0d3e7455e0ce96eecf..9890f63dfda325361919472fcb9741916b6d033a 100644
--- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
+++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C
@@ -462,6 +462,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     scalar minLen(readScalar(IStringStream(args.additionalArgs()[0])()));
diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C
index 5412ef5b1c1bd0f3a684d7bc14bff9cf38c2afc7..ac7eac71c17d22f0fc0088ddc3409a8d103f65fa 100644
--- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C
+++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C
@@ -439,6 +439,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
index 207d3d9cbc77f8a69b5c174da79400cd71ccc369..68ea711a06313363a53f00a00e3a1a4a881603b8 100644
--- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
+++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
@@ -332,6 +332,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     bool overwrite = args.options().found("overwrite");
diff --git a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
index 33d9ba71aff5d82ccc9326f44a275c13258060c7..0fcea92bfef17d64242a903c6c4766d7dc162ea2 100644
--- a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
+++ b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C
@@ -56,6 +56,7 @@ int main(int argc, char *argv[])
     argList::validArgs.append("cellSet");
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
     pointMesh pMesh(mesh);
 
diff --git a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C
index f4336bce92fe9da6d322c4ff1108b6fd8be6dce8..6f476206fbc742abbdf48d7a8d9ff9bc43ece387 100644
--- a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C
+++ b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C
@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     word patchName(args.additionalArgs()[0]);
diff --git a/applications/utilities/mesh/advanced/removeFaces/removeFaces.C b/applications/utilities/mesh/advanced/removeFaces/removeFaces.C
index 5cf8473b5dba9e39bff786784e55d4c51ab75ec2..b1b5695c7072e61346c32c2db5b9e5f1f452b056 100644
--- a/applications/utilities/mesh/advanced/removeFaces/removeFaces.C
+++ b/applications/utilities/mesh/advanced/removeFaces/removeFaces.C
@@ -53,6 +53,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
     bool overwrite = args.options().found("overwrite");
diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C
index b5a67074e63952a46a1ea00b5c31c69ddd5c0d51..be28bf68930f8e916b17782eb79be41331bbf45f 100644
--- a/applications/utilities/mesh/advanced/splitCells/splitCells.C
+++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C
@@ -532,6 +532,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
diff --git a/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C
index e982206e6150d31b1c7df6a5f3a0885dbe4f3bcb..ffa83149528d13d447f0179ca5c9997bf99f7611 100644
--- a/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C
+++ b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C
@@ -47,6 +47,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
diff --git a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C
index 1d2eaae78b222b364a569e402d955410e0c28a31..59423a9d04c8c5b914ad4af97c6be4f1f63c96fc 100644
--- a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C
+++ b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C
@@ -346,6 +346,7 @@ int main(int argc, char *argv[])
 #   include "addTimeOptions.H"
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 
     bool patchFaces = args.options().found("patchFaces");
     bool doCell = args.options().found("cell");
diff --git a/applications/utilities/mesh/generation/extrude2DMesh/doExtrude2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/doExtrude2DMesh.C
index d974dc8da292bcf9617c1d73f5b354f4a4812126..30a8bce0fcdf8b094f3fd3efea18b2cee9e92944 100644
--- a/applications/utilities/mesh/generation/extrude2DMesh/doExtrude2DMesh.C
+++ b/applications/utilities/mesh/generation/extrude2DMesh/doExtrude2DMesh.C
@@ -61,6 +61,7 @@ int main(int argc, char *argv[])
     argList::validOptions.insert("overwrite", "");
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     scalar thickness(readScalar(IStringStream(args.additionalArgs()[0])()));
diff --git a/applications/utilities/mesh/generation/extrudeMesh/Make/options b/applications/utilities/mesh/generation/extrudeMesh/Make/options
index 8326ac3b501c22acf304a4059f5191d0d60354e6..ce0e27f401b48c65f68ffed57b4edb710b8401a7 100644
--- a/applications/utilities/mesh/generation/extrudeMesh/Make/options
+++ b/applications/utilities/mesh/generation/extrudeMesh/Make/options
@@ -1,8 +1,8 @@
 EXE_INC = \
     -IextrudedMesh \
     -IextrudeModel/lnInclude \
-    -I$(FOAM_SRC)/meshTools/lnInclude \
-    -I$(FOAM_SRC)/dynamicMesh/lnInclude 
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/dynamicMesh/lnInclude
 
 EXE_LIBS = \
     -lmeshTools \
diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/Make/options b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/Make/options
index 2a37902358eba8010e6f1e85ecfb3c453304f0da..3c57befe4f755eb3522c5a1c7c3564d7b030fe55 100644
--- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/Make/options
+++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/Make/options
@@ -1,6 +1,6 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/meshTools/lnInclude \
-    -I$(FOAM_SRC)/dynamicMesh/lnInclude
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/dynamicMesh/lnInclude
 
 EXE_LIBS = \
     -lmeshTools \
diff --git a/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C b/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C
index b808dd7521772ef4b316a27e73ccfe4c2ebfae3e..2b0f894e98643721d1a1379e1ae2958e089a71bb 100644
--- a/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C
+++ b/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C
@@ -46,6 +46,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     bool overwrite = args.options().found("overwrite");
diff --git a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
index 3ea6a2a02b53e169abf3fda98c6997842f176155..f7cea3d4a0a763244a91df072107fdd8951c8d6e 100644
--- a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
+++ b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     Info<< "Mesh read in = "
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/Make/files b/applications/utilities/mesh/manipulation/checkMesh.save/Make/files
deleted file mode 100644
index f0b7c166946761f10023900d29f2bb92e60b67b6..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/Make/files
+++ /dev/null
@@ -1,6 +0,0 @@
-printMeshStats.C
-checkTopology.C
-checkGeometry.C
-checkMesh.C
-
-EXE = $(FOAM_APPBIN)/checkMesh
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/Make/options b/applications/utilities/mesh/manipulation/checkMesh.save/Make/options
deleted file mode 100644
index 54c035b8f55d183c1ad02bc372398feceaf31718..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/Make/options
+++ /dev/null
@@ -1,5 +0,0 @@
-EXE_INC = \
-    -I$(LIB_SRC)/meshTools/lnInclude
-
-EXE_LIBS = \
-    -lmeshTools
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.C
deleted file mode 100644
index 9eb4ef63ad7d362ebdb66931c288ea67d81d76f2..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.C
+++ /dev/null
@@ -1,220 +0,0 @@
-#include "checkGeometry.H"
-#include "polyMesh.H"
-#include "globalMeshData.H"
-#include "cellSet.H"
-#include "faceSet.H"
-#include "pointSet.H"
-
-Foam::label Foam::checkGeometry
-(
-    const polyMesh& mesh,
-    bool checkPointNearness,
-    bool checkCellDeterminant
-)
-{
-    label noFailedChecks = 0;
-
-    Info<< "\nChecking geometry..." << endl;
-
-    boundBox bb(mesh.points());
-
-    Pout<< "    Domain bounding box: "
-           << bb.min() << " " << bb.max() << endl;
-
-    // Get a small relative length from the bounding box
-    const boundBox& globalBb = mesh.globalData().bb();
-
-    if (Pstream::parRun())
-    {
-        Info<< "    Overall domain bounding box: "
-            << globalBb.min() << " " << globalBb.max() << endl;
-    }
-
-
-    // Min length
-    scalar minDistSqr = magSqr(1e-6*(globalBb.max() - globalBb.min()));
-
-    
-    if (mesh.checkClosedBoundary(true)) noFailedChecks++;
-
-    {
-        cellSet cells(mesh, "nonClosedCells", mesh.nCells()/100+1);
-        cellSet aspectCells(mesh, "highAspectRatioCells", mesh.nCells()/100+1);
-        if (mesh.checkClosedCells(true, &cells, &aspectCells))
-        {
-            noFailedChecks++;
-
-            if (cells.size() > 0)
-            {
-                Pout<< "  <<Writing " << cells.size()
-                    << " non closed cells to set " << cells.name() << endl;
-                cells.write();
-            }
-        }
-        if (aspectCells.size() > 0)
-        {
-            Pout<< "  <<Writing " << aspectCells.size()
-                << " cells with high aspect ratio to set "
-                << aspectCells.name() << endl;
-            aspectCells.write();
-        }
-    }
-
-    {
-        faceSet faces(mesh, "zeroAreaFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFaceAreas(true, &faces))
-        {
-            noFailedChecks++;
-
-            if (faces.size() > 0)
-            {
-                Pout<< "  <<Writing " << faces.size()
-                    << " zero area faces to set " << faces.name() << endl;
-                faces.write();
-            }
-        }
-    }
-
-    {
-        cellSet cells(mesh, "zeroVolumeCells", mesh.nCells()/100 + 1);
-        if (mesh.checkCellVolumes(true, &cells))
-        {
-            noFailedChecks++;
-
-            if (cells.size() > 0)
-            {
-                Pout<< "  <<Writing " << cells.size()
-                    << " zero volume cells to set " << cells.name() << endl;
-                cells.write();
-            }
-        }
-    }
-
-    {
-        faceSet faces(mesh, "nonOrthoFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFaceOrthogonality(true, &faces))
-        {
-            noFailedChecks++;
-        }
-
-        if (faces.size() > 0)
-        {
-            Pout<< "  <<Writing " << faces.size()
-                << " non-orthogonal faces to set " << faces.name() << endl;
-            faces.write();
-        }
-    }
-
-
-    {
-        faceSet faces(mesh, "wrongOrientedFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFacePyramids(true, -SMALL, &faces))
-        {
-            noFailedChecks++;
-
-            if (faces.size() > 0)
-            {
-                Pout<< "  <<Writing " << faces.size()
-                    << " faces with incorrect orientation to set "
-                    << faces.name() << endl;
-                faces.write();
-            }
-        }
-    }
-
-    {
-        faceSet faces(mesh, "skewFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFaceSkewness(true, &faces))
-        {
-            noFailedChecks++;
-
-            if (faces.size() > 0)
-            {
-                Pout<< "  <<Writing " << faces.size()
-                    << " skew faces to set " << faces.name() << endl;
-                faces.write();
-            }
-        }
-    }
-
-    if (checkPointNearness)
-    {
-        // Note use of nPoints since don't want edge construction.
-        pointSet points(mesh, "shortEdges", mesh.nPoints()/1000 + 1);
-        if (mesh.checkEdgeLength(true, minDistSqr, &points))
-        {
-            //noFailedChecks++;
-
-            if (points.size() > 0)
-            {
-                Pout<< "  <<Writing " << points.size()
-                    << " points on short edges to set " << points.name()
-                    << endl;
-                points.write();
-            }
-        }
-
-        label nEdgeClose = points.size();
-
-        if (mesh.checkPointNearness(false, minDistSqr, &points))
-        {
-            //noFailedChecks++;
-
-            if (points.size() > nEdgeClose)
-            {
-                pointSet nearPoints(mesh, "nearPoints", points);
-                Pout<< "  <<Writing " << nearPoints.size()
-                    << " near (closer than " << Foam::sqrt(minDistSqr)
-                    << " apart) points to set " << nearPoints.name() << endl;
-                nearPoints.write();
-            }
-        }
-    }
-
-    {
-        faceSet faces(mesh, "concaveFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFaceAngles(true, 10, &faces))
-        {
-            //noFailedChecks++;
-
-            if (faces.size() > 0)
-            {
-                Pout<< "  <<Writing " << faces.size()
-                    << " faces with concave angles to set " << faces.name()
-                    << endl;
-                faces.write();
-            }
-        }
-    }
-
-    {
-        faceSet faces(mesh, "warpedFaces", mesh.nFaces()/100 + 1);
-        if (mesh.checkFaceFlatness(true, 0.8, &faces))
-        {
-            //noFailedChecks++;
-
-            if (faces.size() > 0)
-            {
-                Pout<< "  <<Writing " << faces.size()
-                    << " warped faces to set " << faces.name() << endl;
-                faces.write();
-            }
-        }
-    }
-
-    if (checkCellDeterminant)
-    {
-        cellSet cells(mesh, "underdeterminedCells", mesh.nCells()/100);
-        if (mesh.checkCellDeterminant(true, &cells))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << cells.size()
-                << " under-determines cells to set " << cells.name() << endl;
-            cells.write();
-        }
-    }
-    
-
-    return noFailedChecks;
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.H b/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.H
deleted file mode 100644
index 791b007820d76fa8b4dff2626c8fcdccfe02a8ee..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/checkGeometry.H
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "label.H"
-
-namespace Foam
-{
-    class polyMesh;
-
-    label checkGeometry
-    (
-        const polyMesh& mesh,
-        bool checkPointNearness,
-        bool checkCellDeterminant
-    );
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh.save/checkMesh.C
deleted file mode 100644
index ec598b4c215b45114ed9e9dc7268582c6d688dc5..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/checkMesh.C
+++ /dev/null
@@ -1,152 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 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
-    checkMesh
-
-Description
-    Checks validity of a mesh
-
-\*---------------------------------------------------------------------------*/
-
-#include "argList.H"
-#include "Time.H"
-#include "polyMesh.H"
-#include "globalMeshData.H"
-
-#include "printMeshStats.H"
-#include "checkTopology.H"
-#include "checkGeometry.H"
-
-using namespace Foam;
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-int main(int argc, char *argv[])
-{
-
-#   include "addTimeOptionsNoConstant.H"
-
-    argList::validOptions.insert("fullTopology", "");
-    argList::validOptions.insert("pointNearness", "");
-    argList::validOptions.insert("cellDeterminant", "");
-
-#   include "setRootCase.H"
-#   include "createTime.H"
-
-    // Get times list
-    instantList Times = runTime.times();
-
-#   include "checkTimeOptionsNoConstant.H"
-
-    runTime.setTime(Times[startTime], startTime);
-
-#   include "createPolyMesh.H"
-
-    bool firstCheck = true;
-
-    for (label i=startTime; i<endTime; i++)
-    {
-        runTime.setTime(Times[i], i);
-
-        polyMesh::readUpdateState state = mesh.readUpdate();
-
-        if
-        (
-            firstCheck
-         || state == polyMesh::TOPO_CHANGE
-         || state == polyMesh::TOPO_PATCH_CHANGE
-        )
-        {
-            firstCheck = false;
-
-            Info<< "Time = " << runTime.timeName() << nl << endl;
-
-            // Clear mesh before checking
-            mesh.clearOut();
-
-            // Reconstruct globalMeshData
-            mesh.globalData();
-
-            printMeshStats(mesh);
-
-            label noFailedChecks = 0;
-
-            noFailedChecks += checkTopology
-            (
-                mesh,
-                args.options().found("fullTopology")
-            );
-
-            noFailedChecks += checkGeometry
-            (
-                mesh,
-                args.options().found("pointNearness"),
-                args.options().found("cellDeterminant")
-            );
-
-            reduce(noFailedChecks, sumOp<label>());
-
-            if (noFailedChecks == 0)
-            {
-                Info<< "\nMesh OK."
-                    << nl << endl;
-            }
-            else
-            {
-                Info<< "\nFailed " << noFailedChecks << " mesh checks."
-                    << nl << endl;
-            }
-        }
-        else if (state == polyMesh::POINTS_MOVED)
-        {
-            label noFailedChecks = checkGeometry
-            (
-                mesh,
-                args.options().found("pointNearness"),
-                args.options().found("cellDeterminant")
-            );
-
-            reduce(noFailedChecks, sumOp<label>());
-
-            if (noFailedChecks == 0)
-            {
-                Info << "\nMesh OK."
-                    << nl << endl;
-            }
-            else
-            {
-                Info<< "\nFailed " << noFailedChecks << " mesh checks."
-                    << nl << endl;
-            }
-        }
-    }
-
-    Info<< "End\n" << endl;
-
-    return(0);
-}
-
-
-// ************************************************************************* //
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.C
deleted file mode 100644
index 885c5f36aa9fa94021fc4f5667d60e29443dd63c..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.C
+++ /dev/null
@@ -1,236 +0,0 @@
-#include "checkTopology.H"
-#include "polyMesh.H"
-#include "Time.H"
-#include "regionSplit.H"
-#include "cellSet.H"
-#include "faceSet.H"
-#include "pointSet.H"
-#include "IOmanip.H"
-
-Foam::label Foam::checkTopology(const polyMesh& mesh, bool fullTopology)
-{
-    label noFailedChecks = 0;
-
-    Pout<< "Checking topology..." << endl;
-
-    // Check if the boundary definition is unique
-    mesh.boundaryMesh().checkDefinition(true);
-
-    // Check if the boundary processor patches are correct
-    mesh.boundaryMesh().checkParallelSync(true);
-
-    {
-        pointSet points(mesh, "unusedPoints", mesh.nPoints()/100);
-        if (mesh.checkPoints(true, &points))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << points.size()
-                << " unused points to set " << points.name() << endl;
-            points.write();
-        }
-    }
-
-    {
-        faceSet faces(mesh, "upperTriangularFace", mesh.nFaces()/100);
-        if (mesh.checkUpperTriangular(true, &faces))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << faces.size()
-                << " unordered faces to set " << faces.name() << endl;
-            faces.write();
-        }
-    }
-
-    {
-        cellSet cells(mesh, "zipUpCells", mesh.nCells()/100);
-        if (mesh.checkCellsZipUp(true, &cells))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << cells.size()
-                << " cells with over used edges to set " << cells.name()
-                << endl;
-            cells.write();
-        }
-    }
-
-    {
-        faceSet faces(mesh, "outOfRangeFaces", mesh.nFaces()/100);
-        if (mesh.checkFaceVertices(true, &faces))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << faces.size()
-                << " faces with out-of-range vertices to set " << faces.name()
-                << endl;
-            faces.write();
-        }
-    }
-
-    {
-        faceSet faces(mesh, "edgeFaces", mesh.nFaces()/100);
-        if (mesh.checkFaceFaces(true, &faces))
-        {
-            noFailedChecks++;
-
-            Pout<< "  <<Writing " << faces.size()
-                << " faces with incorrect edges to set " << faces.name()
-                << endl;
-            faces.write();
-        }
-    }
-
-    {
-        regionSplit rs(mesh);
-
-        if (rs.nRegions() == 1)
-        {
-            Info<< "    Number of regions: " << rs.nRegions() << " (OK)."
-                << endl;
-        
-        }
-        else
-        {
-            Info<< "   *Number of regions: " << rs.nRegions() << endl;
-
-            Info<< "    The mesh has multiple regions which are not connected "
-                   "by any face." << endl
-                << "  <<Writing region information to "
-                << mesh.time().timeName()/"cellToRegion"
-                << endl;
-
-            labelIOList ctr
-            (
-                IOobject
-                (
-                    "cellToRegion",
-                    mesh.time().timeName(),
-                    mesh,
-                    IOobject::NO_READ,
-                    IOobject::NO_WRITE
-                ),
-                rs
-            );
-            ctr.write();
-        }
-    }
-
-    if (!Pstream::parRun())
-    {
-        Pout<< "\nChecking patch topology for multiply connected surfaces ..."
-            << endl;
-
-        const polyBoundaryMesh& patches = mesh.boundaryMesh();
-
-        // Non-manifold points
-        pointSet points
-        (
-            mesh,
-            "nonManifoldPoints",
-            mesh.nPoints()/100
-        );
-
-        Pout.setf(ios_base::left);
-
-        Pout<< "    "
-            << setw(20) << "Patch"
-            << setw(9) << "Faces"
-            << setw(9) << "Points"
-            << " Surface" << endl;
-
-        forAll(patches, patchI)
-        {
-            const polyPatch& pp = patches[patchI];
-
-            primitivePatch::surfaceTopo pTyp = pp.surfaceType();
-
-            if (pp.size() == 0)
-            {
-                Pout<< "    "
-                    << setw(20) << pp.name()
-                    << setw(9) << pp.size()
-                    << setw(9) << pp.nPoints()
-                    << " ok (empty)" << endl;
-            }
-            else if (pTyp == primitivePatch::MANIFOLD)
-            {
-                if (pp.checkPointManifold(true, &points))
-                {
-                    Pout<< "    " 
-                        << setw(20) << pp.name()
-                        << setw(9) << pp.size()
-                        << setw(9) << pp.nPoints()
-                        << " multiply connected (shared point)" << endl;
-                }
-                else
-                {
-                    Pout<< "    "
-                        << setw(20) << pp.name()
-                        << setw(9) << pp.size()
-                        << setw(9) << pp.nPoints()
-                        << " ok (closed singly connected surface)" << endl;
-                }
-
-                // Add points on non-manifold edges to make set complete
-                pp.checkTopology(false, &points);
-            }
-            else
-            {
-                pp.checkTopology(false, &points);
-
-                if (pTyp == primitivePatch::OPEN)
-                {
-                    Pout<< "    "
-                        << setw(20) << pp.name()
-                        << setw(9) << pp.size()
-                        << setw(9) << pp.nPoints()
-                        << " ok (not multiply connected)" << endl;
-                }
-                else
-                {
-                    Pout<< "    "
-                        << setw(20) << pp.name()
-                        << setw(9) << pp.size()
-                        << setw(9) << pp.nPoints()
-                        << " multiply connected surface (shared edge)"
-                        << endl;
-                }
-            }
-        }
-
-        if (points.size() > 0)
-        {
-            Pout<< "  <<Writing " << points.size()
-                << " conflicting points to set "
-                << points.name() << endl;
-
-            points.write();
-        }
-
-        //Pout.setf(ios_base::right);
-    }
-
-    // Force creation of all addressing if requested.
-    // Errors will be reported as required
-    if (fullTopology)
-    {
-        mesh.cells();
-        mesh.faces();
-        mesh.edges();
-        mesh.points();
-        mesh.faceOwner();
-        mesh.faceNeighbour();
-        mesh.cellCells();
-        mesh.edgeCells();
-        mesh.pointCells();
-        mesh.edgeFaces();
-        mesh.pointFaces();
-        mesh.cellEdges();
-        mesh.faceEdges();
-        mesh.pointEdges();
-    }
-
-    return noFailedChecks;
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.H b/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.H
deleted file mode 100644
index 6db7e0d3c502623329afc29badb2692a15104f22..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/checkTopology.H
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "label.H"
-
-namespace Foam
-{
-    class polyMesh;
-
-    label checkTopology(const polyMesh& mesh, bool fullTopology);
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.C b/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.C
deleted file mode 100644
index 30da859db629c8b227571343cf919395b9b6eaf5..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.C
+++ /dev/null
@@ -1,95 +0,0 @@
-#include "printMeshStats.H"
-#include "polyMesh.H"
-#include "globalMeshData.H"
-
-#include "hexMatcher.H"
-#include "wedgeMatcher.H"
-#include "prismMatcher.H"
-#include "pyrMatcher.H"
-#include "tetWedgeMatcher.H"
-#include "tetMatcher.H"
-
-
-void Foam::printMeshStats(const polyMesh& mesh)
-{
-    Pout<< "Mesh stats" << nl
-        << "    points:           " << mesh.points().size() << nl
-        << "    faces:            " << mesh.faces().size() << nl
-        << "    internal faces:   " << mesh.faceNeighbour().size() << nl
-        << "    cells:            " << mesh.cells().size() << nl
-        << "    boundary patches: " << mesh.boundaryMesh().size() << nl
-        << "    point zones:      " << mesh.pointZones().size() << nl
-        << "    face zones:       " << mesh.faceZones().size() << nl
-        << "    cell zones:       " << mesh.cellZones().size() << nl
-        << endl;
-
-    if (Pstream::parRun())
-    {
-        const globalMeshData& parData = mesh.globalData();
-
-        Info<< "Overall stats" << nl
-            << "    points:   " << parData.nTotalPoints() << nl
-            << "    faces:    " << parData.nTotalFaces() << nl
-            << "    cells:    " << parData.nTotalCells() << nl
-            << endl;
-    }
-
-    // Construct shape recognizers
-    hexMatcher hex;
-    prismMatcher prism;
-    wedgeMatcher wedge;
-    pyrMatcher pyr;
-    tetWedgeMatcher tetWedge;
-    tetMatcher tet;
-
-    // Counters for different cell types
-    label nHex = 0;
-    label nWedge = 0;
-    label nPrism = 0;
-    label nPyr = 0;
-    label nTet = 0;
-    label nTetWedge = 0;
-    label nUnknown = 0;
-
-    for(label cellI = 0; cellI < mesh.nCells(); cellI++)
-    {
-        if (hex.isA(mesh, cellI))
-        {
-            nHex++;
-        }
-        else if (tet.isA(mesh, cellI))
-        {
-            nTet++;
-        }
-        else if (pyr.isA(mesh, cellI))
-        {
-            nPyr++;
-        }
-        else if (prism.isA(mesh, cellI))
-        {
-            nPrism++;
-        }
-        else if (wedge.isA(mesh, cellI))
-        {
-            nWedge++;
-        }
-        else if (tetWedge.isA(mesh, cellI))
-        {
-            nTetWedge++;
-        }
-        else
-        {   
-            nUnknown++;
-        }
-    }
-
-    Pout<< "Number of cells of each type: " << nl
-        << "    hexahedra:     " << nHex << nl
-        << "    prisms:        " << nPrism << nl
-        << "    wedges:        " << nWedge << nl
-        << "    pyramids:      " << nPyr << nl
-        << "    tet wedges:    " << nTetWedge << nl
-        << "    tetrahedra:    " << nTet << nl
-        << "    polyhedra:     " << nUnknown
-        << nl << endl;
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.H b/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.H
deleted file mode 100644
index 2da12011883452de3d88f4b1df938906b0cf081b..0000000000000000000000000000000000000000
--- a/applications/utilities/mesh/manipulation/checkMesh.save/printMeshStats.H
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Foam
-{
-    class polyMesh;
-
-    void printMeshStats(const polyMesh& mesh);
-}
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C
index 6b1a10d90e6f7e1b771a7672e0f5bafdd28bc800..8eb1f3f05fbb1a92ef5c889418e0741796e7dd72 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C
@@ -39,10 +39,15 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         if (mesh.checkEdgeAlignment(true, validDirs, &nonAlignedPoints))
         {
             noFailedChecks++;
+            label nNonAligned = returnReduce
+            (
+                nonAlignedPoints.size(),
+                sumOp<label>()
+            );
 
-            if (nonAlignedPoints.size() > 0)
+            if (nNonAligned > 0)
             {
-                Pout<< "  <<Writing " << nonAlignedPoints.size()
+                Info<< "  <<Writing " << nNonAligned
                     << " points on non-aligned edges to set "
                     << nonAlignedPoints.name() << endl;
                 nonAlignedPoints.write();
@@ -59,16 +64,21 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            if (cells.size() > 0)
+            label nNonClosed = returnReduce(cells.size(), sumOp<label>());
+
+            if (nNonClosed > 0)
             {
-                Pout<< "  <<Writing " << cells.size()
+                Info<< "  <<Writing " << nNonClosed
                     << " non closed cells to set " << cells.name() << endl;
                 cells.write();
             }
         }
-        if (aspectCells.size() > 0)
+
+        label nHighAspect = returnReduce(aspectCells.size(), sumOp<label>());
+
+        if (nHighAspect > 0)
         {
-            Pout<< "  <<Writing " << aspectCells.size()
+            Info<< "  <<Writing " << nHighAspect
                 << " cells with high aspect ratio to set "
                 << aspectCells.name() << endl;
             aspectCells.write();
@@ -81,9 +91,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            if (faces.size() > 0)
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            if (nFaces > 0)
             {
-                Pout<< "  <<Writing " << faces.size()
+                Info<< "  <<Writing " << nFaces
                     << " zero area faces to set " << faces.name() << endl;
                 faces.write();
             }
@@ -96,9 +108,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            if (cells.size() > 0)
+            label nCells = returnReduce(cells.size(), sumOp<label>());
+
+            if (nCells > 0)
             {
-                Pout<< "  <<Writing " << cells.size()
+                Info<< "  <<Writing " << nCells
                     << " zero volume cells to set " << cells.name() << endl;
                 cells.write();
             }
@@ -112,9 +126,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
             noFailedChecks++;
         }
 
-        if (faces.size() > 0)
+        label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+        if (nFaces > 0)
         {
-            Pout<< "  <<Writing " << faces.size()
+            Info<< "  <<Writing " << nFaces
                 << " non-orthogonal faces to set " << faces.name() << endl;
             faces.write();
         }
@@ -127,9 +143,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            if (faces.size() > 0)
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            if (nFaces > 0)
             {
-                Pout<< "  <<Writing " << faces.size()
+                Info<< "  <<Writing " << nFaces
                     << " faces with incorrect orientation to set "
                     << faces.name() << endl;
                 faces.write();
@@ -143,9 +161,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            if (faces.size() > 0)
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            if (nFaces > 0)
             {
-                Pout<< "  <<Writing " << faces.size()
+                Info<< "  <<Writing " << nFaces
                     << " skew faces to set " << faces.name() << endl;
                 faces.write();
             }
@@ -160,25 +180,29 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             //noFailedChecks++;
 
-            if (points.size() > 0)
+            label nPoints = returnReduce(points.size(), sumOp<label>());
+
+            if (nPoints > 0)
             {
-                Pout<< "  <<Writing " << points.size()
+                Info<< "  <<Writing " << nPoints
                     << " points on short edges to set " << points.name()
                     << endl;
                 points.write();
             }
         }
 
-        label nEdgeClose = points.size();
+        label nEdgeClose = returnReduce(points.size(), sumOp<label>());
 
         if (mesh.checkPointNearness(false, minDistSqr, &points))
         {
             //noFailedChecks++;
 
-            if (points.size() > nEdgeClose)
+            label nPoints = returnReduce(points.size(), sumOp<label>());
+
+            if (nPoints > nEdgeClose)
             {
                 pointSet nearPoints(mesh, "nearPoints", points);
-                Pout<< "  <<Writing " << nearPoints.size()
+                Info<< "  <<Writing " << nPoints
                     << " near (closer than " << Foam::sqrt(minDistSqr)
                     << " apart) points to set " << nearPoints.name() << endl;
                 nearPoints.write();
@@ -193,9 +217,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             //noFailedChecks++;
 
-            if (faces.size() > 0)
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            if (nFaces > 0)
             {
-                Pout<< "  <<Writing " << faces.size()
+                Info<< "  <<Writing " << nFaces
                     << " faces with concave angles to set " << faces.name()
                     << endl;
                 faces.write();
@@ -210,9 +236,11 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             //noFailedChecks++;
 
-            if (faces.size() > 0)
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            if (nFaces > 0)
             {
-                Pout<< "  <<Writing " << faces.size()
+                Info<< "  <<Writing " << nFaces
                     << " warped faces to set " << faces.name() << endl;
                 faces.write();
             }
@@ -226,7 +254,9 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
         {
             noFailedChecks++;
 
-            Pout<< "  <<Writing " << cells.size()
+            label nCells = returnReduce(cells.size(), sumOp<label>());
+
+            Info<< "  <<Writing " << nCells
                 << " under-determined cells to set " << cells.name() << endl;
             cells.write();
         }
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
index 85dc0bae62720f8bf7f8fd1219624cc176c29289..ac924136e1cf104e13e9a1fdc861e9ad6ba9c911 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C
@@ -16,7 +16,7 @@ Foam::label Foam::checkTopology
 {
     label noFailedChecks = 0;
 
-    Pout<< "Checking topology..." << endl;
+    Info<< "Checking topology..." << endl;
 
     // Check if the boundary definition is unique
     mesh.boundaryMesh().checkDefinition(true);
@@ -30,7 +30,9 @@ Foam::label Foam::checkTopology
         {
             noFailedChecks++;
 
-            Pout<< "  <<Writing " << points.size()
+            label nPoints = returnReduce(points.size(), sumOp<label>());
+
+            Info<< "  <<Writing " << nPoints
                 << " unused points to set " << points.name() << endl;
             points.write();
         }
@@ -42,9 +44,12 @@ Foam::label Foam::checkTopology
         {
             noFailedChecks++;
         }
-        if (faces.size() > 0)
+
+        label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+        if (nFaces > 0)
         {
-            Pout<< "  <<Writing " << faces.size()
+            Info<< "  <<Writing " << nFaces
                 << " unordered faces to set " << faces.name() << endl;
             faces.write();
         }
@@ -57,7 +62,9 @@ Foam::label Foam::checkTopology
         {
             noFailedChecks++;
 
-            Pout<< "  <<Writing " << cells.size()
+            label nCells = returnReduce(cells.size(), sumOp<label>());
+
+            Info<< "  <<Writing " << nCells
                 << " cells with over used edges to set " << cells.name()
                 << endl;
             cells.write();
@@ -70,7 +77,9 @@ Foam::label Foam::checkTopology
         {
             noFailedChecks++;
 
-            Pout<< "  <<Writing " << faces.size()
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            Info<< "  <<Writing " << nFaces
                 << " faces with out-of-range or duplicate vertices to set "
                 << faces.name() << endl;
             faces.write();
@@ -84,7 +93,9 @@ Foam::label Foam::checkTopology
         {
             noFailedChecks++;
 
-            Pout<< "  <<Writing " << faces.size()
+            label nFaces = returnReduce(faces.size(), sumOp<label>());
+
+            Info<< "  <<Writing " << nFaces
                 << " faces with incorrect edges to set " << faces.name()
                 << endl;
             faces.write();
diff --git a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C b/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C
index 9c608b689d7958ba94344a5208124cdafcc2d3c2..9a2c9396afba0a645483f86eec3d65239372cb43 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C
@@ -12,43 +12,72 @@
 
 void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
 {
-    Pout<< "Mesh stats" << nl
-        << "    points:           " << mesh.points().size() << nl;
+    Info<< "Mesh stats" << nl
+        << "    points:           "
+        << returnReduce(mesh.points().size(), sumOp<label>()) << nl;
 
-    if (mesh.nInternalPoints() != -1)
+    label nInternalPoints = returnReduce
+    (
+        mesh.nInternalPoints(),
+        sumOp<label>()
+    );
+
+    if (nInternalPoints != -Pstream::nProcs())
     {
-        Pout<< "    internal points:  " << mesh.nInternalPoints() << nl;
+        Info<< "    internal points:  " << nInternalPoints << nl;
+
+        if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1)
+        {
+            WarningIn("Foam::printMeshStats(const polyMesh&, const bool)")
+                << "Some processors have their points sorted into internal"
+                << " and external and some do not." << endl
+                << "This can cause problems later on." << endl;
+        }
     }
 
-    if (allTopology && mesh.nInternalPoints() != -1)
+    if (allTopology && nInternalPoints != -Pstream::nProcs())
     {
-        Pout<< "    edges:            " << mesh.nEdges() << nl
-            << "    internal edges:   " << mesh.nInternalEdges() << nl
+        label nEdges = returnReduce(mesh.nEdges(), sumOp<label>());
+        label nInternalEdges = returnReduce
+        (
+            mesh.nInternalEdges(),
+            sumOp<label>()
+        );
+        label nInternal1Edges = returnReduce
+        (
+            mesh.nInternal1Edges(),
+            sumOp<label>()
+        );
+        label nInternal0Edges = returnReduce
+        (
+            mesh.nInternal0Edges(),
+            sumOp<label>()
+        );
+
+        Info<< "    edges:            " << nEdges << nl
+            << "    internal edges:   " << nInternalEdges << nl
             << "    internal edges using one boundary point:   "
-            << mesh.nInternal1Edges()-mesh.nInternal0Edges() << nl
+            << nInternal1Edges-nInternal0Edges << nl
             << "    internal edges using two boundary points:  "
-            << mesh.nInternalEdges()-mesh.nInternal1Edges() << nl;
+            << nInternalEdges-nInternal1Edges << nl;
     }
 
-    Pout<< "    faces:            " << mesh.faces().size() << nl
-        << "    internal faces:   " << mesh.faceNeighbour().size() << nl
-        << "    cells:            " << mesh.cells().size() << nl
-        << "    boundary patches: " << mesh.boundaryMesh().size() << nl
-        << "    point zones:      " << mesh.pointZones().size() << nl
-        << "    face zones:       " << mesh.faceZones().size() << nl
-        << "    cell zones:       " << mesh.cellZones().size() << nl
+    Info<< "    faces:            "
+        << returnReduce(mesh.faces().size(), sumOp<label>()) << nl
+        << "    internal faces:   "
+        << returnReduce(mesh.faceNeighbour().size(), sumOp<label>()) << nl
+        << "    cells:            "
+        << returnReduce(mesh.cells().size(), sumOp<label>()) << nl
+        << "    boundary patches: "
+        << returnReduce(mesh.boundaryMesh().size(), sumOp<label>()) << nl
+        << "    point zones:      "
+        << returnReduce(mesh.pointZones().size(), sumOp<label>()) << nl
+        << "    face zones:       "
+        << returnReduce(mesh.faceZones().size(), sumOp<label>()) << nl
+        << "    cell zones:       "
+        << returnReduce(mesh.cellZones().size(), sumOp<label>()) << nl
         << endl;
 
-    if (Pstream::parRun())
-    {
-        const globalMeshData& parData = mesh.globalData();
-
-        Info<< "Overall stats" << nl
-            << "    points:   " << parData.nTotalPoints() << nl
-            << "    faces:    " << parData.nTotalFaces() << nl
-            << "    cells:    " << parData.nTotalCells() << nl
-            << endl;
-    }
 
     // Construct shape recognizers
     hexMatcher hex;
@@ -99,7 +128,15 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
         }
     }
 
-    Pout<< "Number of cells of each type: " << nl
+    reduce(nHex,sumOp<label>());
+    reduce(nPrism,sumOp<label>()); 
+    reduce(nWedge,sumOp<label>());
+    reduce(nPyr,sumOp<label>());
+    reduce(nTetWedge,sumOp<label>());
+    reduce(nTet,sumOp<label>());
+    reduce(nUnknown,sumOp<label>());
+
+    Info<< "Overall number of cells of each type:" << nl
         << "    hexahedra:     " << nHex << nl
         << "    prisms:        " << nPrism << nl
         << "    wedges:        " << nWedge << nl
diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
index 2f1fd57634f8be21a62c62e432b61a5628a94745..882b7461e5afe8c30e9bf3d44fd32087662365b9 100644
--- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
+++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C
index 9ba825083ff51b896bdaac5db3f1914a3da7dce5..01df2c2f284329f542596fd141e33c2318660b94 100644
--- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C
+++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C
@@ -34,6 +34,7 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
+#include "cyclicPolyPatch.H"
 #include "syncTools.H"
 #include "argList.H"
 #include "polyMesh.H"
@@ -256,27 +257,6 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
                 );
             }
 
-//            cycPatch.writeOBJ
-//            (
-//                prefix+cycPatch.name()+"_half0.obj",
-//                SubList<face>
-//                (
-//                    cycPatch,
-//                    halfSize
-//                ),
-//                cycPatch.points()
-//            );
-//            cycPatch.writeOBJ
-//            (
-//                prefix+cycPatch.name()+"_half1.obj",
-//                SubList<face>
-//                (
-//                    cycPatch,
-//                    halfSize,
-//                    halfSize
-//                ),
-//                cycPatch.points()
-//            );
 
             // Lines between corresponding face centres
             OFstream str(prefix+cycPatch.name()+"_match.obj");
@@ -289,7 +269,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
                 vertI++;
 
                 label nbrFaceI = halfSize + faceI;
-                const point& fc1 = mesh.faceCentres()[cycPatch.start()+nbrFaceI];
+                const point& fc1 =
+                    mesh.faceCentres()[cycPatch.start()+nbrFaceI];
                 meshTools::writeOBJ(str, fc1);
                 vertI++;
 
@@ -300,6 +281,247 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
 }
 
 
+void separateList
+(
+    const vectorField& separation,
+    UList<vector>& field
+)
+{
+    if (separation.size() == 1)
+    {
+        // Single value for all.
+
+        forAll(field, i)
+        {
+            field[i] += separation[0];
+        }
+    }
+    else if (separation.size() == field.size())
+    {
+        forAll(field, i)
+        {
+            field[i] += separation[i];
+        }
+    }
+    else
+    {
+        FatalErrorIn
+        (
+            "separateList(const vectorField&, UList<vector>&)"
+        )   << "Sizes of field and transformation not equal. field:"
+            << field.size() << " transformation:" << separation.size()
+            << abort(FatalError);
+    }
+}
+
+
+// Synchronise points on both sides of coupled boundaries.
+template <class CombineOp>
+void syncPoints
+(
+    const polyMesh& mesh,
+    pointField& points,
+    const CombineOp& cop,
+    const point& nullValue
+)
+{
+    if (points.size() != mesh.nPoints())
+    {
+        FatalErrorIn
+        (
+            "syncPoints"
+            "(const polyMesh&, pointField&, const CombineOp&, const point&)"
+        )   << "Number of values " << points.size()
+            << " is not equal to the number of points in the mesh "
+            << mesh.nPoints() << abort(FatalError);
+    }
+
+    const polyBoundaryMesh& patches = mesh.boundaryMesh();
+
+    // Is there any coupled patch with transformation?
+    bool hasTransformation = false;
+
+    if (Pstream::parRun())
+    {
+        // Send
+
+        forAll(patches, patchI)
+        {
+            const polyPatch& pp = patches[patchI];
+
+            if
+            (
+                isA<processorPolyPatch>(pp)
+             && pp.nPoints() > 0
+             && refCast<const processorPolyPatch>(pp).owner()
+            )
+            {
+                const processorPolyPatch& procPatch =
+                    refCast<const processorPolyPatch>(pp);
+
+                // Get data per patchPoint in neighbouring point numbers.
+                pointField patchInfo(procPatch.nPoints(), nullValue);
+
+                const labelList& meshPts = procPatch.meshPoints();
+                const labelList& nbrPts = procPatch.neighbPoints();
+
+                forAll(nbrPts, pointI)
+                {
+                    label nbrPointI = nbrPts[pointI];
+                    if (nbrPointI >= 0 && nbrPointI < patchInfo.size())
+                    {
+                        patchInfo[nbrPointI] = points[meshPts[pointI]];
+                    }
+                }
+
+                OPstream toNbr(Pstream::blocking, procPatch.neighbProcNo());
+                toNbr << patchInfo;
+            }
+        }
+
+
+        // Receive and set.
+
+        forAll(patches, patchI)
+        {
+            const polyPatch& pp = patches[patchI];
+
+            if
+            (
+                isA<processorPolyPatch>(pp)
+             && pp.nPoints() > 0
+             && !refCast<const processorPolyPatch>(pp).owner()
+            )
+            {
+                const processorPolyPatch& procPatch =
+                    refCast<const processorPolyPatch>(pp);
+
+                pointField nbrPatchInfo(procPatch.nPoints());
+                {
+                    // We do not know the number of points on the other side
+                    // so cannot use Pstream::read.
+                    IPstream fromNbr
+                    (
+                        Pstream::blocking,
+                        procPatch.neighbProcNo()
+                    );
+                    fromNbr >> nbrPatchInfo;
+                }
+                // Null any value which is not on neighbouring processor
+                nbrPatchInfo.setSize(procPatch.nPoints(), nullValue);
+
+                if (!procPatch.parallel())
+                {
+                    hasTransformation = true;
+                    transformList(procPatch.forwardT(), nbrPatchInfo);
+                }
+                else if (procPatch.separated())
+                {
+                    hasTransformation = true;
+                    separateList(-procPatch.separation(), nbrPatchInfo);
+                }
+
+                const labelList& meshPts = procPatch.meshPoints();
+
+                forAll(meshPts, pointI)
+                {
+                    label meshPointI = meshPts[pointI];
+                    points[meshPointI] = nbrPatchInfo[pointI];
+                }
+            }
+        }
+    }
+
+    // Do the cyclics.
+    forAll(patches, patchI)
+    {
+        const polyPatch& pp = patches[patchI];
+
+        if (isA<cyclicPolyPatch>(pp))
+        {
+            const cyclicPolyPatch& cycPatch =
+                refCast<const cyclicPolyPatch>(pp);
+
+            const edgeList& coupledPoints = cycPatch.coupledPoints();
+            const labelList& meshPts = cycPatch.meshPoints();
+
+            pointField half0Values(coupledPoints.size());
+
+            forAll(coupledPoints, i)
+            {
+                const edge& e = coupledPoints[i];
+                label point0 = meshPts[e[0]];
+                half0Values[i] = points[point0];
+            }
+
+            if (!cycPatch.parallel())
+            {
+                hasTransformation = true;
+                transformList(cycPatch.reverseT(), half0Values);
+            }
+            else if (cycPatch.separated())
+            {
+                hasTransformation = true;
+                const vectorField& v = cycPatch.coupledPolyPatch::separation();
+                separateList(v, half0Values);
+            }
+
+            forAll(coupledPoints, i)
+            {
+                const edge& e = coupledPoints[i];
+                label point1 = meshPts[e[1]];
+                points[point1] = half0Values[i];
+            }
+        }
+    }
+
+    //- Note: hasTransformation is only used for warning messages so
+    //  reduction not strictly nessecary.
+    //reduce(hasTransformation, orOp<bool>());
+
+    // Synchronize multiple shared points.
+    const globalMeshData& pd = mesh.globalData();
+
+    if (pd.nGlobalPoints() > 0)
+    {
+        if (hasTransformation)
+        {
+            WarningIn
+            (
+                "syncPoints"
+                "(const polyMesh&, pointField&, const CombineOp&, const point&)"
+            )   << "There are decomposed cyclics in this mesh with"
+                << " transformations." << endl
+                << "This is not supported. The result will be incorrect"
+                << endl;
+        }
+
+
+        // Values on shared points.
+        pointField sharedPts(pd.nGlobalPoints(), nullValue);
+
+        forAll(pd.sharedPointLabels(), i)
+        {
+            label meshPointI = pd.sharedPointLabels()[i];
+            // Fill my entries in the shared points
+            sharedPts[pd.sharedPointAddr()[i]] = points[meshPointI];
+        }
+
+        // Combine on master.
+        Pstream::listCombineGather(sharedPts, cop);
+        Pstream::listCombineScatter(sharedPts);
+
+        // Now we will all have the same information. Merge it back with
+        // my local information.
+        forAll(pd.sharedPointLabels(), i)
+        {
+            label meshPointI = pd.sharedPointLabels()[i];
+            points[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
+        }
+    }
+}
+
+
 // Main program:
 
 int main(int argc, char *argv[])
@@ -308,6 +530,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 
     const bool overwrite = args.options().found("overwrite");
 
@@ -392,25 +615,28 @@ int main(int argc, char *argv[])
 
             label destPatchI = patches.findPatchID(patchName);
 
-            word patchType(dict.lookup("type"));
-
             if (destPatchI == -1)
             {
+                dictionary patchDict(dict.subDict("dictionary"));
+
                 destPatchI = allPatches.size();
 
                 Info<< "Adding new patch " << patchName
-                    << " of type " << patchType
-                    << " as patch " << destPatchI << endl;
+                    << " as patch " << destPatchI
+                    << " from " << patchDict << endl;
+
+                patchDict.remove("nFaces");
+                patchDict.add("nFaces", 0);
+                patchDict.remove("startFace");
+                patchDict.add("startFace", startFaceI);
 
                 // Add an empty patch.
                 allPatches.append
                 (
                     polyPatch::New
                     (
-                        patchType,
                         patchName,
-                        0,              // size
-                        startFaceI,     // start
+                        patchDict,
                         destPatchI,
                         patches
                     ).ptr()
@@ -556,16 +782,100 @@ int main(int argc, char *argv[])
     }
     else
     {
+        Info<< "Synchronising points." << nl << endl;
+
+        // This is a bit tricky. Both normal and position might be out and
+        // current separation also includes the normal
+        // ( separation_ = (nf&(Cr - Cf))*nf ).
+
+        // For processor patches:
+        // - disallow multiple separation/transformation. This basically
+        //   excludes decomposed cyclics. Use the (probably 0) separation
+        //   to align the points.
+        // For cyclic patches:
+        // - for separated ones use our own recalculated offset vector
+        // - for rotational ones use current one.
+
+        forAll(mesh.boundaryMesh(), patchI)
+        {
+            const polyPatch& pp = mesh.boundaryMesh()[patchI];
+
+            if (pp.size() && isA<coupledPolyPatch>(pp))
+            {
+                const coupledPolyPatch& cpp =
+                    refCast<const coupledPolyPatch>(pp);
+
+                if (cpp.separated())
+                {
+                    Info<< "On coupled patch " << pp.name()
+                        << " separation[0] was "
+                        << cpp.separation()[0] << endl;
+
+                    if (isA<cyclicPolyPatch>(pp))
+                    {
+                        const cyclicPolyPatch& cycpp =
+                            refCast<const cyclicPolyPatch>(pp);
+
+                        if (cycpp.transform() == cyclicPolyPatch::TRANSLATIONAL)
+                        {
+                            Info<< "On cyclic translation patch " << pp.name()
+                                << " forcing uniform separation of "
+                                << cycpp.separationVector() << endl;
+                            const_cast<vectorField&>(cpp.separation()) =
+                                pointField(1, cycpp.separationVector());
+                        }
+                        else
+                        {
+                            const_cast<vectorField&>(cpp.separation()) =
+                                pointField
+                                (
+                                    1,
+                                    pp[pp.size()/2].centre(mesh.points())
+                                  - pp[0].centre(mesh.points())
+                                );
+                        }
+                    }
+                    else
+                    {
+                        const_cast<vectorField&>(cpp.separation())
+                        .setSize(1);
+                    }
+                    Info<< "On coupled patch " << pp.name()
+                        << " forcing uniform separation of "
+                        << cpp.separation() << endl;
+                }
+                else if (!cpp.parallel())
+                {
+                    Info<< "On coupled patch " << pp.name()
+                        << " forcing uniform rotation of "
+                        << cpp.forwardT()[0] << endl;
+
+                    const_cast<tensorField&>
+                    (
+                        cpp.forwardT()
+                    ).setSize(1);
+                    const_cast<tensorField&>
+                    (
+                        cpp.reverseT()
+                    ).setSize(1);
+
+                    Info<< "On coupled patch " << pp.name()
+                        << " forcing uniform rotation of "
+                        << cpp.forwardT() << endl;
+                }
+            }
+        }
+
         Info<< "Synchronising points." << endl;
 
         pointField newPoints(mesh.points());
-        syncTools::syncPointList
+
+        syncPoints
         (
             mesh,
             newPoints,
-            nearestEqOp(),              // cop
-            point(GREAT, GREAT, GREAT), // nullValue
-            true                        // applySeparation
+            nearestEqOp(),
+            point(GREAT, GREAT, GREAT)
         );
 
         scalarField diff(mag(newPoints-mesh.points()));
diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatchDict b/applications/utilities/mesh/manipulation/createPatch/createPatchDict
index 1153d0204d7db267d52ed8830556e52fe1010032..5f3597f21af7ebb740e5dac56e5076c26fee4953 100644
--- a/applications/utilities/mesh/manipulation/createPatch/createPatchDict
+++ b/applications/utilities/mesh/manipulation/createPatch/createPatchDict
@@ -1,58 +1,77 @@
-/*--------------------------------*- C++ -*----------------------------------*\
+/*---------------------------------------------------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
-|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
+|  \\    /   O peration     | Version:  1.0                                   |
+|   \\  /    A nd           | Web:      http://www.openfoam.org               |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
+
 FoamFile
 {
-    version     2.0;
-    format      ascii;
-    class       dictionary;
-    object      createPatchDict;
+    version         2.0;
+    format          ascii;
+
+    root            "";
+    case            "";
+    instance        "system";
+    local           "";
+
+    class           dictionary;
+    object          createPatcheDict;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // Tolerance used in matching faces. Absolute tolerance is span of
 // face times this factor.
-matchTolerance 1E-3;
+matchTolerance 1E-6;
 
 // Do a synchronisation of coupled points.
 pointSync true;
 
+
 // Patches to create.
 // If no patches does a coupled point and face synchronisation anyway.
 patches
 (
     {
         // Name of new patch
-        name leftRight0;
+        name sidePatches;
 
-        // Type of new patch
-        type cyclic;
+        // Dictionary for new patch
+        dictionary
+        {
+            type cyclic;
+            // Optional: used when matching and synchronising points.
+            //transform translational;
+            //separationVector (-2289 0 0);
+        }
 
         // How to construct: either 'patches' or 'set'
         constructFrom patches;
 
         // If constructFrom = patches : names of patches
-        patches (half0 half1);
+        //patches (periodic-1 periodic-2);
+        patches (outlet-side1 outlet-side2);
 
         // If constructFrom = set : name of faceSet
         set f0;
     }
 
-    {
-        name bottom;
-        type patch;
-
-        constructFrom set;
-
-        patches (half0 half1);
-
-        set bottomFaces;
-    }
+    //{
+    //    name bottom;
+    //    // Dictionary for new patch
+    //    dictionary
+    //    {
+    //        type patch;
+    //    }
+    //
+    //    constructFrom set;
+    //
+    //    patches (half0 half1);
+    //
+    //    set bottomFaces;
+    //}
 
 );
 
diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
index 8ec01e2920bc3484513cd18854f5750002b4a6cc..cbd2d9e4191ccceac1505046fc5b468abbf20cd8 100644
--- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
+++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
@@ -160,6 +160,7 @@ int main(int argc, char *argv[])
     argList::validOptions.insert("overwrite", "");
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
     bool split = args.options().found("split");
diff --git a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
index 33bb0e00d9f492e7477ae826b2a8362f83864a03..8cde78ceb4092860013bc9066593c0776c71f5e6 100644
--- a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
+++ b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C
@@ -298,6 +298,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     printEdgeStats(mesh);
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
index be3a2debb7194a5c8acc33b3fed2e3972d5678f9..c7e85f0a6efc8ad27a670c743bbc8252f1571c15 100644
--- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
+++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C
@@ -374,6 +374,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 
     // Get times list
     instantList Times = runTime.times();
diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C
index d902303bcae6147fba733637a875b4077ebdee73..38a09fe2e1ba1e81fd32d207664e5f93544774dc 100644
--- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C
+++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C
@@ -122,6 +122,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createPolyMesh.H"
 
     word setName(args.additionalArgs()[0]);
diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
index 511141ac66f8c5a6fb7023a8799564f771be26f1..eb116fc23150a6f5b910388ddd38a37bf04a3dbf 100644
--- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
+++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
@@ -1122,6 +1122,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
     word blockedFacesName;
diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
index e3c558ce5022229e260540766661b0c73a874e36..4452bf46ca2f28a81d3db39d6dfa393a10d23dbe 100644
--- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
+++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
@@ -135,6 +135,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
 
diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
index d49fd4c6b5e5d7129a698745c6bf51c675c33c6c..b245f0bd0b7546278e7be80aa95c5bc40f8cc927 100644
--- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
+++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
@@ -157,6 +157,7 @@ int main(int argc, char *argv[])
 
 #   include "setRootCase.H"
 #   include "createTime.H"
+    runTime.functionObjects().off();
 #   include "createMesh.H"
 
     word setName(args.additionalArgs()[0]);
diff --git a/applications/utilities/miscellaneous/foamFormatConvert/Make/options b/applications/utilities/miscellaneous/foamFormatConvert/Make/options
index 69ea8798afcbd15a9308cb53aa25f30661c67596..10105d2d8a610405bcce2afd11b7784a040e087f 100644
--- a/applications/utilities/miscellaneous/foamFormatConvert/Make/options
+++ b/applications/utilities/miscellaneous/foamFormatConvert/Make/options
@@ -1,8 +1,7 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/finiteVolume/lnInclude \
-    -I$(FOAM_SRC)/meshTools/lnInclude \
-    -I$(FOAM_SRC)/lagrangian/basic/lnInclude \
-
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/lagrangian/basic/lnInclude
 
 EXE_LIBS = \
     -lmeshTools \
diff --git a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C
index 50bf81035fac657552a0f55b8096aaa9670e9d7b..7bff5f4c237ca718db35eec765765e5b3c18bc07 100644
--- a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C
+++ b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C
@@ -100,13 +100,23 @@ int main(int argc, char *argv[])
 
                 if (dict.found(entryNames[0]))
                 {
-                    const entry* entPtr = &dict.lookupEntry(entryNames[0]);
+                    const entry* entPtr = &dict.lookupEntry
+                    (
+                        entryNames[0],
+                        false,
+                        true            // wildcards
+                    );
 
                     for (int i=1; i<entryNames.size(); i++)
                     {
                         if (entPtr->dict().found(entryNames[i]))
                         {
-                            entPtr = &entPtr->dict().lookupEntry(entryNames[i]);
+                            entPtr = &entPtr->dict().lookupEntry
+                            (
+                                entryNames[i],
+                                false,
+                                true    // wildcards
+                            );
                         }
                         else
                         {
diff --git a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructor.H b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructor.H
index 201ce6681111194590e600626ee825cab9032545..71ac3341333f0f3f00046593dacbff788f8c696a 100644
--- a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructor.H
+++ b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructor.H
@@ -151,18 +151,20 @@ public:
             const IOobject& fieldIoObject
         );
 
-        //- Reconstruct and write all volume fields
+        //- Reconstruct and write all/selected volume fields
         template<class Type>
         void reconstructFvVolumeFields
         (
-            const IOobjectList& objects
+            const IOobjectList& objects,
+            const HashSet<word>& selectedFields
         );
 
-        //- Reconstruct and write all volume fields
+        //- Reconstruct and write all/selected volume fields
         template<class Type>
         void reconstructFvSurfaceFields
         (
-            const IOobjectList& objects
+            const IOobjectList& objects,
+            const HashSet<word>& selectedFields
         );
 };
 
diff --git a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C
index 06f4f6a6345ef3f597076aa6ab9e0f48d893aa1e..2ad0735ccfa499cba11f9115b7a0dde581f77776 100644
--- a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C
+++ b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C
@@ -131,7 +131,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
                 forAll(cp, faceI)
                 {
                     // Subtract one to take into account offsets for
-                    // face direction.  
+                    // face direction.
                     reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
                 }
 
@@ -151,7 +151,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
                 forAll(cp, faceI)
                 {
                     // Subtract one to take into account offsets for
-                    // face direction.  
+                    // face direction.
                     label curF = cp[faceI] - 1;
 
                     // Is the face on the boundary?
@@ -282,7 +282,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
 
         // It is necessary to create a copy of the addressing array to
         // take care of the face direction offset trick.
-        // 
+        //
         {
             labelList curAddr(faceProcAddressing_[procI]);
 
@@ -342,7 +342,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
                 forAll(cp, faceI)
                 {
                     // Subtract one to take into account offsets for
-                    // face direction.  
+                    // face direction.
                     reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
                 }
 
@@ -452,11 +452,12 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
 }
 
 
-// Reconstruct and write all volume fields
+// Reconstruct and write all/selected volume fields
 template<class Type>
 void Foam::fvFieldReconstructor::reconstructFvVolumeFields
 (
-    const IOobjectList& objects
+    const IOobjectList& objects,
+    const HashSet<word>& selectedFields
 )
 {
     const word& fieldClassName =
@@ -468,27 +469,29 @@ void Foam::fvFieldReconstructor::reconstructFvVolumeFields
     {
         Info<< "    Reconstructing " << fieldClassName << "s\n" << endl;
 
-        for
-        (
-            IOobjectList::const_iterator fieldIter = fields.begin();
-            fieldIter != fields.end();
-            ++fieldIter
-        )
+        forAllConstIter(IOobjectList, fields, fieldIter)
         {
-            Info<< "        " << fieldIter()->name() << endl;
+            if
+            (
+                !selectedFields.size()
+             || selectedFields.found(fieldIter()->name())
+            )
+            {
+                Info<< "        " << fieldIter()->name() << endl;
 
-            reconstructFvVolumeField<Type>(*fieldIter())().write();
+                reconstructFvVolumeField<Type>(*fieldIter())().write();
+            }
         }
-
         Info<< endl;
     }
 }
 
-// Reconstruct and write all surface fields
+// Reconstruct and write all/selected surface fields
 template<class Type>
 void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
 (
-    const IOobjectList& objects
+    const IOobjectList& objects,
+    const HashSet<word>& selectedFields
 )
 {
     const word& fieldClassName =
@@ -500,18 +503,19 @@ void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
     {
         Info<< "    Reconstructing " << fieldClassName << "s\n" << endl;
 
-        for
-        (
-            IOobjectList::const_iterator fieldIter = fields.begin();
-            fieldIter != fields.end();
-            ++fieldIter
-        )
+        forAllConstIter(IOobjectList, fields, fieldIter)
         {
-            Info<< "        " << fieldIter()->name() << endl;
+            if
+            (
+                !selectedFields.size()
+             || selectedFields.found(fieldIter()->name())
+            )
+            {
+                Info<< "        " << fieldIter()->name() << endl;
 
-            reconstructFvSurfaceField<Type>(*fieldIter())().write();
+                reconstructFvSurfaceField<Type>(*fieldIter())().write();
+            }
         }
-
         Info<< endl;
     }
 }
diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
index db14efe3e5eb2c8a395d6815641c0d43bda0e65d..50818f4db9cdd78a60b23d6b4c2626d023b26018 100644
--- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
+++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
@@ -48,9 +48,17 @@ int main(int argc, char *argv[])
     argList::noParallel();
     timeSelector::addOptions();
 #   include "addRegionOption.H"
+    argList::validOptions.insert("fields", "\"(list of fields)\"");
+
 #   include "setRootCase.H"
 #   include "createTime.H"
 
+    HashSet<word> selectedFields;
+    if (args.options().found("fields"))
+    {
+        IStringStream(args.options()["fields"])() >> selectedFields;
+    }
+
     // determine the processor count directly
     label nProcs = 0;
     while (dir(args.path()/(word("processor") + name(nProcs))))
@@ -184,13 +192,37 @@ int main(int argc, char *argv[])
                 procMeshes.boundaryProcAddressing()
             );
 
-            fvReconstructor.reconstructFvVolumeFields<scalar>(objects);
-            fvReconstructor.reconstructFvVolumeFields<vector>(objects);
-            fvReconstructor.reconstructFvVolumeFields<sphericalTensor>(objects);
-            fvReconstructor.reconstructFvVolumeFields<symmTensor>(objects);
-            fvReconstructor.reconstructFvVolumeFields<tensor>(objects);
+            fvReconstructor.reconstructFvVolumeFields<scalar>
+            (
+                objects,
+                selectedFields
+            );
+            fvReconstructor.reconstructFvVolumeFields<vector>
+            (
+                objects,
+                selectedFields
+            );
+            fvReconstructor.reconstructFvVolumeFields<sphericalTensor>
+            (
+                objects,
+                selectedFields
+            );
+            fvReconstructor.reconstructFvVolumeFields<symmTensor>
+            (
+                objects,
+                selectedFields
+            );
+            fvReconstructor.reconstructFvVolumeFields<tensor>
+            (
+                objects,
+                selectedFields
+            );
 
-            fvReconstructor.reconstructFvSurfaceFields<scalar>(objects);
+            fvReconstructor.reconstructFvSurfaceFields<scalar>
+            (
+                objects,
+                selectedFields
+            );
         }
         else
         {
diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt
index fc69d0e60a5143482892666e56926cc3ba47af45..01d4f5a9fe0031eb8b03760bcb3cb294de083c82 100644
--- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt
+++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt
@@ -1,4 +1,3 @@
-
 # create a plugin that adds a reader to the ParaView GUI
 # it is added in the file dialog when doing opens/saves.
 
@@ -16,8 +15,8 @@ LINK_DIRECTORIES(
 )
 
 INCLUDE_DIRECTORIES(
-    $ENV{FOAM_SRC}/OpenFOAM/lnInclude
-    $ENV{FOAM_SRC}/finiteVolume/lnInclude
+    $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
+    $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
     ${PROJECT_SOURCE_DIR}/../vtkPV3Foam
 )
 
@@ -52,3 +51,4 @@ TARGET_LINK_LIBRARIES(
     finiteVolume
     vtkPV3Foam
 )
+#-----------------------------------------------------------------------------
diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H
index 8f9f682cdc083f92f1456c0d597704c467fbf022..427c0a6fdef14a98f1ad515c1078b09e247429d2 100644
--- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H
+++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H
@@ -37,7 +37,7 @@ inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str)
         {
             ++n;
         }
-        return word(str, n);
+        return word(str, n, true);
     }
     else
     {
diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt
index 83ece8b49cacf7f79c98fbce9d155e029f6ec5fe..acbe2254eb0a63be837caad19a7727dc231c0160 100644
--- a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt
+++ b/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt
@@ -16,8 +16,12 @@ SET(PVFoamReader_LIBS
   vtkGraphics
 )
 
-INCLUDE_DIRECTORIES($ENV{FOAM_SRC}/OpenFOAM/lnInclude $ENV{FOAM_SRC}/finiteVolume/lnInclude)
-INCLUDE_DIRECTORIES($ENV{ParaView_INST_DIR}/include ../vtkFoam/lnInclude)
+INCLUDE_DIRECTORIES(
+    $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
+    $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
+    $ENV{ParaView_INST_DIR}/include
+    ../vtkFoam/lnInclude
+)
 ADD_DEFINITIONS(-D$ENV{WM_PRECISION_OPTION})
 
 #-----------------------------------------------------------------------------
@@ -72,3 +76,4 @@ CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in
                ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE)
 
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam)
+#-----------------------------------------------------------------------------
diff --git a/applications/utilities/postProcessing/graphics/fieldview9Reader/Make/options b/applications/utilities/postProcessing/graphics/fieldview9Reader/Make/options
index f5285ce39e8371795f0ee29990683684c685b68b..b21a3eef2d65b888295482d95d44f7dbf22da620 100644
--- a/applications/utilities/postProcessing/graphics/fieldview9Reader/Make/options
+++ b/applications/utilities/postProcessing/graphics/fieldview9Reader/Make/options
@@ -94,7 +94,7 @@ EXE_INC = \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
     -I$(LIB_SRC)/meshTools/lnInclude \
     -I$(LIB_SRC)/browser/lnInclude \
-    -I$(FOAM_SRC)/lagrangian/basic/lnInclude
+    -I$(LIB_SRC)/lagrangian/basic/lnInclude
 
 EXE_LIBS = \
     $(FV_LIBS) \
diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/options b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/options
index 4f059b58dee81c8d262a65b108c07280f56938d1..601df67db4b504a1a5f2b07f80e4418f40f31c18 100644
--- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/options
+++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
     -I$(LIB_SRC)/transportModels \
     -I$(LIB_SRC)/turbulenceModels/RAS \
diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C
index b848e330eafca601a981104e740901ee297ac37c..3f7a99040b762cc0be440094f7531713067b3ae5 100644
--- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C
+++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C
@@ -139,7 +139,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
 
         IOobject LESPropertiesHeader
         (
-            "RASProperties",
+            "LESProperties",
             runTime.constant(),
             mesh,
             IOobject::MUST_READ,
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/Make/options b/applications/utilities/postProcessing/miscellaneous/postChannel/Make/options
index d38cd8b1801b429e5f42c7b0ba2ab58ba2cd1d11..b90b6fdd4e1c3b114664c9123a92ff043fca7244 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/Make/options
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/Make/options
@@ -1,7 +1,9 @@
 EXE_INC = \
+    -I$(LIB_SRC)/meshTools/lnInclude \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
     -I$(LIB_SRC)/sampling/lnInclude
 
 EXE_LIBS = \
+    -lmeshTools \
     -lfiniteVolume \
     -lsampling
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
index 74315de31a44e057b2c64017cf9d2c343081048d..cdba8c0201dd0ce865a5750ea7b584990f584d71 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
@@ -25,156 +25,269 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "channelIndex.H"
+#include "boolList.H"
+#include "syncTools.H"
+#include "OFstream.H"
+#include "meshTools.H"
+#include "Time.H"
+#include "SortableList.H"
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * * //
 
-channelIndex::channelIndex(const fvMesh& m)
-:
-    indexingDict_
-    (
-        IOobject
-        (
-            "postChannelDict",
-            m.time().constant(),
-            m,
-            IOobject::MUST_READ,
-            IOobject::NO_WRITE
-        )
-    ),
-    nx_(readLabel(indexingDict_.lookup("Nx"))),
-    ny_(indexingDict_.lookup("Ny")),
-    nz_(readLabel(indexingDict_.lookup("Nz"))),
-    symmetric_
-    (
-        readBool(indexingDict_.lookup("symmetric"))
-    ),
-    cumNy_(ny_.size()),
-    nLayers_(ny_[0])
+template<>
+const char* Foam::NamedEnum<Foam::vector::components, 3>::names[] =
 {
-    // initialise the layers
-    cumNy_[0] = ny_[0];
-
-    for (label j=1; j<ny_.size(); j++)
-    {
-        nLayers_ += ny_[j];
-        cumNy_[j] = ny_[j]+cumNy_[j-1];
-    }
-}
-
+    "x",
+    "y",
+    "z"
+};
 
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+const Foam::NamedEnum<Foam::vector::components, 3>
+    Foam::channelIndex::vectorComponentsNames_;
 
-channelIndex::~channelIndex()
-{}
 
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-scalarField channelIndex::collapse
+// Determines face blocking
+void Foam::channelIndex::walkOppositeFaces
 (
-    const volScalarField& vsf,
-    const bool asymmetric
-) const
+    const polyMesh& mesh,
+    const labelList& startFaces,
+    boolList& blockedFace
+)
 {
-    scalarField cs(nLayers(), 0.0);
+    const cellList& cells = mesh.cells();
+    const faceList& faces = mesh.faces();
+    label nBnd = mesh.nFaces() - mesh.nInternalFaces();
+
+    DynamicList<label> frontFaces(startFaces);
+    forAll(frontFaces, i)
+    {
+        label faceI = frontFaces[i];
+        blockedFace[faceI] = true;
+    }
 
-    forAll(cs, j)
+    while (returnReduce(frontFaces.size(), sumOp<label>()) > 0)
     {
-        // sweep over all cells in this layer
-        for (label i=0; i<nx(); i++)
+        // Transfer across.
+        boolList isFrontBndFace(nBnd, false);
+        forAll(frontFaces, i)
         {
-            for (label k=0; k<nz(); k++)
+            label faceI = frontFaces[i];
+
+            if (!mesh.isInternalFace(faceI))
             {
-                cs[j] += vsf[operator()(i,j,k)];
+                isFrontBndFace[faceI-mesh.nInternalFaces()] = true;
             }
         }
+        syncTools::swapBoundaryFaceList(mesh, isFrontBndFace, false);
 
-        // and divide by the number of cells in the layer
-        cs[j] /= scalar(nx()*nz());
-    }
+        // Add 
+        forAll(isFrontBndFace, i)
+        {
+            label faceI = mesh.nInternalFaces()+i;
+            if (isFrontBndFace[i] && !blockedFace[faceI])
+            {
+                blockedFace[faceI] = true;
+                frontFaces.append(faceI);
+            }
+        }
 
-    if (symmetric_)
-    {
-        label nlb2 = nLayers()/2;
+        // Transfer across cells
+        DynamicList<label> newFrontFaces(frontFaces.size());
 
-        if (asymmetric)
+        forAll(frontFaces, i)
         {
-            for (label j=0; j<nlb2; j++)
+            label faceI = frontFaces[i];
+
             {
-                cs[j] = 0.5*(cs[j] - cs[nLayers() - j - 1]);
+                const cell& ownCell = cells[mesh.faceOwner()[faceI]];
+
+                label oppositeFaceI = ownCell.opposingFaceLabel(faceI, faces);
+
+                if (oppositeFaceI == -1)
+                {
+                    FatalErrorIn("channelIndex::walkOppositeFaces(..)")
+                        << "Face:" << faceI << " owner cell:" << ownCell
+                        << " is not a hex?" << abort(FatalError);
+                }
+                else
+                {
+                    if (!blockedFace[oppositeFaceI])
+                    {
+                        blockedFace[oppositeFaceI] = true;
+                        newFrontFaces.append(oppositeFaceI);
+                    }
+                }
+            }
+
+            if (mesh.isInternalFace(faceI))
+            {
+                const cell& neiCell = mesh.cells()[mesh.faceNeighbour()[faceI]];
+
+                label oppositeFaceI = neiCell.opposingFaceLabel(faceI, faces);
+
+                if (oppositeFaceI == -1)
+                {
+                    FatalErrorIn("channelIndex::walkOppositeFaces(..)")
+                        << "Face:" << faceI << " neighbour cell:" << neiCell
+                        << " is not a hex?" << abort(FatalError);
+                }
+                else
+                {
+                    if (!blockedFace[oppositeFaceI])
+                    {
+                        blockedFace[oppositeFaceI] = true;
+                        newFrontFaces.append(oppositeFaceI);
+                    }
+                }
             }
         }
-        else
+
+        frontFaces.transfer(newFrontFaces);
+    }
+}
+
+
+// Calculate regions.
+void Foam::channelIndex::calcLayeredRegions
+(
+    const polyMesh& mesh,
+    const labelList& startFaces
+)
+{
+    boolList blockedFace(mesh.nFaces(), false);
+    walkOppositeFaces
+    (
+        mesh,
+        startFaces,
+        blockedFace
+    );
+
+
+    if (false)
+    {
+        OFstream str(mesh.time().path()/"blockedFaces.obj");
+        label vertI = 0;
+        forAll(blockedFace, faceI)
         {
-            for (label j=0; j<nlb2; j++)
+            if (blockedFace[faceI])
             {
-                cs[j] = 0.5*(cs[j] + cs[nLayers() - j - 1]);
+                const face& f = mesh.faces()[faceI];
+                forAll(f, fp)
+                {
+                    meshTools::writeOBJ(str, mesh.points()[f[fp]]);
+                }
+                str<< 'f';
+                forAll(f, fp)
+                {
+                    str << ' ' << vertI+fp+1;
+                }
+                str << nl;
+                vertI += f.size();
             }
         }
-
-        cs.setSize(nlb2);
     }
 
-    return cs;
+
+    // Do analysis for connected regions
+    cellRegion_.reset(new regionSplit(mesh, blockedFace));
+
+    Info<< "Detected " << cellRegion_().nRegions() << " layers." << nl << endl;
+
+    // Sum number of entries per region
+    regionCount_ = regionSum(scalarField(mesh.nCells(), 1.0));
+
+    // Average cell centres to determine ordering.
+    pointField regionCc
+    (
+        regionSum(mesh.cellCentres())
+      / regionCount_
+    );
+
+    SortableList<scalar> sortComponent(regionCc.component(dir_));
+
+    sortMap_ = sortComponent.indices();
+
+    y_ = sortComponent;
+
+    if (symmetric_)
+    {
+        y_.setSize(cellRegion_().nRegions()/2);
+    }
 }
 
 
-scalarField channelIndex::y
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::channelIndex::channelIndex
 (
-    const volVectorField& cellCentres
-) const
+    const polyMesh& mesh,
+    const dictionary& dict
+)
+:
+    symmetric_(readBool(dict.lookup("symmetric"))),
+    dir_(vectorComponentsNames_.read(dict.lookup("component")))
 {
-    if (symmetric_)
+    const polyBoundaryMesh& patches = mesh.boundaryMesh();
+
+    const wordList patchNames(dict.lookup("patches"));
+
+    label nFaces = 0;
+
+    forAll(patchNames, i)
     {
-        scalarField Y(nLayers()/2);
+        label patchI = patches.findPatchID(patchNames[i]);
 
-        for (label j=0; j<nLayers()/2; j++)
+        if (patchI == -1)
         {
-            Y[j] = cellCentres[operator()(0, j, 0)].y();
+            FatalErrorIn("channelIndex::channelIndex(const polyMesh&)")
+                << "Illegal patch " << patchNames[i]
+                << ". Valid patches are " << patches.name()
+                << exit(FatalError);
         }
 
-        return Y;
+        nFaces += patches[patchI].size();
     }
-    else
+
+    labelList startFaces(nFaces);
+    nFaces = 0;
+
+    forAll(patchNames, i)
     {
-        scalarField Y(nLayers());
+        const polyPatch& pp = patches[patches.findPatchID(patchNames[i])];
 
-        for (label j=0; j<nLayers(); j++)
+        forAll(pp, j)
         {
-            Y[j] = cellCentres[operator()(0, j, 0)].y();
+            startFaces[nFaces++] = pp.start()+j;
         }
-
-        return Y;
     }
+
+    // Calculate regions.
+    calcLayeredRegions(mesh, startFaces);
 }
 
 
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-label channelIndex::operator()
+Foam::channelIndex::channelIndex
 (
-    const label Jx,
-    const label Jy,
-    const label Jz
-) const
+    const polyMesh& mesh,
+    const labelList& startFaces,
+    const bool symmetric,
+    const direction dir
+)
+:
+    symmetric_(symmetric),
+    dir_(dir)
 {
-    label index(0);
+    // Calculate regions.
+    calcLayeredRegions(mesh, startFaces);
+}
 
-    // count up `full' layers in the mesh
-    label j(0);
-    label tmpJy(Jy);
 
-    while(Jy >= cumNy_[j])
-    {
-        index += nx_*ny_[j]*nz_;
-        tmpJy -= ny_[j];
-        j++;
-    }
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-    index += Jx + nx_*tmpJy + nx_*ny_[j]*Jz;
 
-    return index;
-}
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 
 // ************************************************************************* //
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.H b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.H
index 500d13f4eb00469ee0e1599db2535efa025116e5..796e20160c4bb6a53c5352d403059035d0edc9c0 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.H
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.H
@@ -26,19 +26,25 @@ Class
     Foam::channelIndex
 
 Description
-    does indexing for a standard (Christer-style) channel.
-Assumes that the blocks are aranged in the y direction.
+    Does averaging of fields over layers of cells. Assumes layered mesh.
 
 SourceFiles
     channelIndex.C
-    channelIndexIO.C
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef channelIndex_H
 #define channelIndex_H
 
-#include "fvCFD.H"
+#include "regionSplit.H"
+#include "direction.H"
+#include "scalarField.H"
+#include "polyMesh.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
 
 
 /*---------------------------------------------------------------------------*\
@@ -47,21 +53,47 @@ SourceFiles
 
 class channelIndex
 {
+
     // Private data
 
-        IOdictionary indexingDict_;
+        static const NamedEnum<vector::components, 3> vectorComponentsNames_;
 
-        const label nx_;
-        const labelList ny_;
-        const label nz_;
+        //- Is mesh symmetric
         const bool symmetric_;
 
-        labelList cumNy_;
-        label nLayers_;
+        //- direction to sort
+        const direction dir_;
+
+        //- Per cell the global region
+        autoPtr<regionSplit> cellRegion_;
+
+        //- Per global region the number of cells (scalarField so we can use
+        //  field algebra)
+        scalarField regionCount_;
+
+        //- From sorted region back to unsorted global region
+        labelList sortMap_;
+
+        //- Sorted component of cell centres
+        scalarField y_;
+
 
 
     // Private Member Functions
 
+        void walkOppositeFaces
+        (
+            const polyMesh& mesh,
+            const labelList& startFaces,
+            boolList& blockedFace
+        );
+
+        void calcLayeredRegions
+        (
+            const polyMesh& mesh,
+            const labelList& startFaces
+        );
+
         //- Disallow default bitwise copy construct and assignment
         channelIndex(const channelIndex&);
         void operator=(const channelIndex&);
@@ -71,55 +103,53 @@ public:
 
     // Constructors
 
-        channelIndex(const fvMesh& m);
-
+        //- Construct from dictionary
+        channelIndex(const polyMesh&, const dictionary&);
 
-    // Destructor
-
-        ~channelIndex();
+        //- Construct from supplied starting faces
+        channelIndex
+        (
+            const polyMesh& mesh,
+            const labelList& startFaces,
+            const bool symmetric,
+            const direction dir
+        );
 
 
     // Member Functions
 
         // Access
 
-            //- return number of layers
-            label nLayers() const
-            {
-                return nLayers_;
-            }
-
-            //- number of cells in X direction
-            label nx() const
-            {
-                return nx_;
-            }
-
-            //- number of cells in Z direction
-            label nz() const
-            {
-                return nz_;
-            }
+            //- Sum field per region
+            template<class T>
+            Field<T> regionSum(const Field<T>& cellField) const;
 
             //- collapse a field to a line
-            scalarField collapse
+            template<class T>
+            Field<T> collapse
             (
-                const volScalarField& vsf,
+                const Field<T>& vsf,
                 const bool asymmetric=false
             ) const;
 
             //- return the field of Y locations from the cell centres
-            scalarField y
-            (
-                const volVectorField& cellCentres
-            ) const;
+            const scalarField& y() const
+            {
+                return y_;
+            }
 
+};
 
-    // Member Operators
 
-        label operator()(const label, const label, const label) const;
-};
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "channelIndexTemplates.C"
+#endif
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndexTemplates.C b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndexTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..9fc8ff03609b0681b67d664a54b70293b493091d
--- /dev/null
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndexTemplates.C
@@ -0,0 +1,101 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "channelIndex.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class T>
+Foam::Field<T> Foam::channelIndex::regionSum(const Field<T>& cellField) const
+{
+    Field<T> regionField(cellRegion_().nRegions(), pTraits<T>::zero);
+
+    forAll(cellRegion_(), cellI)
+    {
+        regionField[cellRegion_()[cellI]] += cellField[cellI];
+    }
+
+    // Global sum
+    Pstream::listCombineGather(regionField, plusEqOp<T>());
+    Pstream::listCombineScatter(regionField);
+
+    return regionField;
+}
+
+
+template<class T>
+Foam::Field<T> Foam::channelIndex::collapse
+(
+    const Field<T>& cellField,
+    const bool asymmetric
+) const
+{
+    // Average and order
+    Field<T> regionField
+    (
+        regionSum(cellField)
+      / regionCount_,
+        sortMap_
+    );
+
+    // Symmetry?
+    if (symmetric_)
+    {
+        label nlb2 = cellRegion_().nRegions()/2;
+
+        if (asymmetric)
+        {
+            for (label j=0; j<nlb2; j++)
+            {
+                regionField[j] =
+                    0.5
+                  * (
+                        regionField[j]
+                      - regionField[cellRegion_().nRegions() - j - 1]
+                    );
+            }
+        }
+        else
+        {
+            for (label j=0; j<nlb2; j++)
+            {
+                regionField[j] =
+                    0.5
+                  * (
+                        regionField[j]
+                      + regionField[cellRegion_().nRegions() - j - 1]
+                    );
+            }
+        }
+
+        regionField.setSize(nlb2);
+    }
+
+    return regionField;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/collapse.H b/applications/utilities/postProcessing/miscellaneous/postChannel/collapse.H
index ec047e58627ce52b4edd1b33cf2e21ffec7d596f..b3bf5594110835698535275ed2f58b647a7e238d 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/collapse.H
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/collapse.H
@@ -1,16 +1,16 @@
     scalarField UMeanXvalues = channelIndexing.collapse
     (
-        UMean.component(vector::X)
+        UMean.component(vector::X)()
     );
 
     scalarField UMeanYvalues = channelIndexing.collapse
     (
-        UMean.component(vector::Y)
+        UMean.component(vector::Y)()
     );
 
     scalarField UMeanZvalues = channelIndexing.collapse
     (
-        UMean.component(vector::Z)
+        UMean.component(vector::Z)()
     );
 
     scalarField RxxValues = channelIndexing.collapse(Rxx);
@@ -38,7 +38,7 @@
         0.5*(sqr(urmsValues) + sqr(vrmsValues) + sqr(wrmsValues));
 
 
-    scalarField y = channelIndexing.y(mesh.C());
+    const scalarField& y = channelIndexing.y();
 
     makeGraph(y, UMeanXvalues, "Uf", UMean.path(), gFormat);
     makeGraph(y, urmsValues, "u", UMean.path(), gFormat);
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/postChannel.C b/applications/utilities/postProcessing/miscellaneous/postChannel/postChannel.C
index 2de4c534a8f1751e09c29b8abdac0d61b0c4ee85..08051cb1da9bf18a47c54d1dfe845949d212b4d9 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/postChannel.C
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/postChannel.C
@@ -67,7 +67,20 @@ int main(int argc, char *argv[])
     const word& gFormat = runTime.graphFormat();
 
     // Setup channel indexing for averaging over channel down to a line
-    channelIndex channelIndexing(mesh);
+
+    IOdictionary channelDict
+    (
+        IOobject
+        (
+            "postChannelDict",
+            mesh.time().constant(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        )
+    );
+    channelIndex channelIndexing(mesh, channelDict);
+
 
     // For each time step read all fields
     for (label i=startTime; i<endTime; i++)
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/postChannelDict b/applications/utilities/postProcessing/miscellaneous/postChannel/postChannelDict
index 4c528ea24303edeb7b3d0e8f9abd296a1303be56..d63cd656675c6ebe4aecf1608dca9b561a5a3fe8 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/postChannelDict
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/postChannelDict
@@ -15,13 +15,14 @@ FoamFile
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-Nx 40; 
-Ny 
-( 
- 25 
- 25 
-); 
-Nz 30; 
- 
+// Seed patches to start layering from
+patches (bottomWall);
+
+// Direction in which the layers are
+component y;
+
+// Is the mesh symmetric? If so average(symmetric fields) or
+// subtract(asymmetric) contributions from both halves
+symmetric true;
 
 // ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H b/applications/utilities/postProcessing/miscellaneous/postChannel/sumData.C
similarity index 74%
rename from src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H
rename to applications/utilities/postProcessing/miscellaneous/postChannel/sumData.C
index eb1b3c59190d796207da478a265f3dfbdb0038b7..8662ec578b8ece2f4bdcff0a80c2abdf8b9dc0c4 100644
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/sumData.C
@@ -22,30 +22,28 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    wallOmega
+\*---------------------------------------------------------------------------*/
 
-Description
-    Set wall dissipation in the omega matrix
+#include "sumData.H"
 
-\*---------------------------------------------------------------------------*/
+// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
+Foam::Ostream& Foam::operator<<
+(
+    Foam::Ostream& os,
+    const Foam::sumData& wDist
+)
 {
-    const fvPatchList& patches = mesh_.boundary();
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& p = patches[patchi];
-
-        if (isType<wallFvPatch>(p))
-        {
-            omegaEqn().setValues
-            (
-                p.faceCells(),
-                omega_.boundaryField()[patchi].patchInternalField()
-            );
-        }
-    }
+    return os
+        << wDist.oldFace_ << token::SPACE
+        << wDist.sum_ << token::SPACE << wDist.count_;
 }
 
+
+Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::sumData& wDist)
+{
+    return is >> wDist.oldFace_ >> wDist.sum_ >> wDist.count_;
+}
+
+
 // ************************************************************************* //
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/sumData.H b/applications/utilities/postProcessing/miscellaneous/postChannel/sumData.H
new file mode 100644
index 0000000000000000000000000000000000000000..15a26a3aaa7142714929938c9f0dad6f2b3d84c7
--- /dev/null
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/sumData.H
@@ -0,0 +1,200 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::sumData
+
+Description
+    Sums data while walking across cells. Used in collapsing fields.
+
+SourceFiles
+    sumDataI.H
+    sumData.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef sumData_H
+#define sumData_H
+
+#include "point.H"
+#include "tensor.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class polyPatch;
+class polyMesh;
+
+/*---------------------------------------------------------------------------*\
+                           Class sumData Declaration
+\*---------------------------------------------------------------------------*/
+
+class sumData
+{
+    // Private data
+
+        //- Previous face
+        label oldFace_;
+
+        //- summed data
+        scalar sum_;
+
+        //- number of items summed
+        label count_;
+
+public:
+
+    // Constructors
+
+        //- Construct null
+        inline sumData();
+
+        //- Construct from count
+        inline sumData
+        (
+            const label oldFace,
+            const scalar sum,
+            const label count
+        );
+
+
+    // Member Functions
+
+        // Access
+
+            inline label oldFace() const
+            {
+                return oldFace_;
+            }
+
+            inline scalar sum() const
+            {
+                return sum_;
+            }
+
+            inline label count() const
+            {
+                return count_;
+            }
+
+
+        // Needed by FaceCellWave
+
+            //- Check whether origin has been changed at all or
+            //  still contains original (invalid) value.
+            inline bool valid() const;
+
+            //- Check for identical geometrical data. Used for cyclics checking.
+            inline bool sameGeometry
+            (
+                const polyMesh&,
+                const sumData&,
+                const scalar
+            ) const;
+
+            //- Convert any absolute coordinates into relative to (patch)face
+            //  centre
+            inline void leaveDomain
+            (
+                const polyMesh&,
+                const polyPatch&,
+                const label patchFaceI,
+                const point& faceCentre
+            );
+
+            //- Reverse of leaveDomain
+            inline void enterDomain
+            (
+                const polyMesh&,
+                const polyPatch&,
+                const label patchFaceI,
+                const point& faceCentre
+            );
+
+            //- Apply rotation matrix to any coordinates
+            inline void transform
+            (
+                const polyMesh&,
+                const tensor&
+            );
+
+            //- Influence of neighbouring face.
+            inline bool updateCell
+            (
+                const polyMesh&,
+                const label thisCellI,
+                const label neighbourFaceI,
+                const sumData& neighbourInfo,
+                const scalar tol
+            );
+
+            //- Influence of neighbouring cell.
+            inline bool updateFace
+            (
+                const polyMesh&,
+                const label thisFaceI,
+                const label neighbourCellI,
+                const sumData& neighbourInfo,
+                const scalar tol
+            );
+
+            //- Influence of different value on same face.
+            inline bool updateFace
+            (
+                const polyMesh&,
+                const label thisFaceI,
+                const sumData& neighbourInfo,
+                const scalar tol
+            );
+
+    // Member Operators
+
+        // Needed for List IO
+        inline bool operator==(const sumData&) const;
+
+        inline bool operator!=(const sumData&) const;
+
+
+    // IOstream Operators
+
+        friend Ostream& operator<<(Ostream&, const sumData&);
+        friend Istream& operator>>(Istream&, sumData&);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "sumDataI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/sumDataI.H b/applications/utilities/postProcessing/miscellaneous/postChannel/sumDataI.H
new file mode 100644
index 0000000000000000000000000000000000000000..107cba063dccdc7006cb43da53913ce11a29e6dc
--- /dev/null
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/sumDataI.H
@@ -0,0 +1,227 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "polyMesh.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+// Null constructor
+inline Foam::sumData::sumData()
+:
+    oldFace_(-1),
+    sum_(0.0),
+    count_(0)
+{}
+
+
+// Construct from components
+inline Foam::sumData::sumData
+(
+    const label oldFace,
+    const scalar sum,
+    const label count
+)
+:
+    oldFace_(oldFace),
+    sum_(sum),
+    count_(count)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline bool Foam::sumData::valid() const
+{
+    return oldFace_ != -1;
+}
+
+
+// No geometric data so never any problem on cyclics
+inline bool Foam::sumData::sameGeometry
+(
+    const polyMesh&,
+    const sumData&,
+    const scalar
+) const
+{
+    return true;
+}
+
+
+// No geometric data.
+inline void Foam::sumData::leaveDomain
+(
+    const polyMesh&,
+    const polyPatch& patch,
+    const label patchFaceI,
+    const point& faceCentre
+)
+{}
+
+
+// No geometric data.
+inline void Foam::sumData::transform
+(
+    const polyMesh&,
+    const tensor& rotTensor
+)
+{}
+
+
+// No geometric data.
+inline void Foam::sumData::enterDomain
+(
+    const polyMesh&,
+    const polyPatch& patch,
+    const label patchFaceI,
+    const point& faceCentre
+)
+{
+    oldFace_ = -1;
+}
+
+
+// Update cell with neighbouring face information
+inline bool Foam::sumData::updateCell
+(
+    const polyMesh&,
+    const label thisCellI,
+    const label neighbourFaceI,
+    const sumData& neighbourInfo,
+    const scalar tol
+)
+{
+    if (!valid())
+    {
+        FatalErrorIn("sumData::updateCell") << "problem"
+            << abort(FatalError);
+        return false;
+    }
+
+
+    if (count_ == 0)
+    {
+        sum_ += neighbourInfo.sum();
+        count_ = neighbourInfo.count() + 1;
+        oldFace_ = neighbourFaceI;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+// Update face with neighbouring cell information
+inline bool Foam::sumData::updateFace
+(
+    const polyMesh& mesh,
+    const label thisFaceI,
+    const label neighbourCellI,
+    const sumData& neighbourInfo,
+    const scalar tol
+)
+{
+    // From cell to its faces.
+
+    // Check that face is opposite the previous one.
+    const cell& cFaces = mesh.cells()[neighbourCellI];
+
+    label wantedFaceI = cFaces.opposingFaceLabel
+    (
+        neighbourInfo.oldFace(),
+        mesh.faces()
+    );
+
+    if (thisFaceI == wantedFaceI)
+    {
+        if (count_ != 0)
+        {
+            FatalErrorIn("sumData::updateFace") << "problem"
+                << abort(FatalError);
+            return false;
+        }
+
+        sum_ += neighbourInfo.sum();
+        count_ = neighbourInfo.count();
+        oldFace_ = thisFaceI;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+// Update face with coupled face information
+inline bool Foam::sumData::updateFace
+(
+    const polyMesh&,
+    const label thisFaceI,
+    const sumData& neighbourInfo,
+    const scalar tol
+)
+{
+    // From face to face (e.g. coupled faces)
+    if (count_ == 0)
+    {
+        sum_ += neighbourInfo.sum();
+        count_ = neighbourInfo.count();
+        oldFace_ = thisFaceI;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}    
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+inline bool Foam::sumData::operator==(const Foam::sumData& rhs)
+ const
+{
+    return
+        oldFace() == rhs.oldFace()
+     && sum() == rhs.sum()
+     && count() == rhs.count();
+}
+
+
+inline bool Foam::sumData::operator!=(const Foam::sumData& rhs)
+ const
+{
+    return !(*this == rhs);
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C
index 4b7a09acbf050c00170047099897380f6a3e9e3a..3c0e18a9cf37e841cd8ca6a79b9b4f6aeeeef11a 100644
--- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C
+++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
             }
 
             // Give patch area
-            Info<< "    Patch area = " << sum(mesh.Sf()) << endl;
+            Info<< "    Patch area = " << sum(mesh.Sf().boundaryField()[patchi]) << endl;
 
             if (fieldHeader.headerClassName() == "volScalarField")
             {
diff --git a/applications/utilities/postProcessing/velocityField/Co/Make/options b/applications/utilities/postProcessing/velocityField/Co/Make/options
index e647db04988870197da4f4382fb0047c921753db..7bd0a2d1e0bcaff6d521031cd87758d7066c40d2 100644
--- a/applications/utilities/postProcessing/velocityField/Co/Make/options
+++ b/applications/utilities/postProcessing/velocityField/Co/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude 
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/Lambda2/Make/options b/applications/utilities/postProcessing/velocityField/Lambda2/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/Lambda2/Make/options
+++ b/applications/utilities/postProcessing/velocityField/Lambda2/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/Mach/Make/options b/applications/utilities/postProcessing/velocityField/Mach/Make/options
index 635142c6cca869fbcf2066cc1b3bb513592843b7..132e3be94ae2bac59afae1a249501df4dbb5cd5b 100644
--- a/applications/utilities/postProcessing/velocityField/Mach/Make/options
+++ b/applications/utilities/postProcessing/velocityField/Mach/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
     -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
 
diff --git a/applications/utilities/postProcessing/velocityField/Pe/Make/options b/applications/utilities/postProcessing/velocityField/Pe/Make/options
index eaebf0991492cbbe660ecb984d386d3af20c1cec..46ede0d06f1c5b0a903c91d64e6d26ce13d7cdaf 100644
--- a/applications/utilities/postProcessing/velocityField/Pe/Make/options
+++ b/applications/utilities/postProcessing/velocityField/Pe/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
     -I$(LIB_SRC)/meshTools/lnInclude \
     -I$(LIB_SRC)/sampling/lnInclude \
diff --git a/applications/utilities/postProcessing/velocityField/Q/Make/options b/applications/utilities/postProcessing/velocityField/Q/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/Q/Make/options
+++ b/applications/utilities/postProcessing/velocityField/Q/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/enstrophy/Make/options b/applications/utilities/postProcessing/velocityField/enstrophy/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/enstrophy/Make/options
+++ b/applications/utilities/postProcessing/velocityField/enstrophy/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/flowType/Make/options b/applications/utilities/postProcessing/velocityField/flowType/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/flowType/Make/options
+++ b/applications/utilities/postProcessing/velocityField/flowType/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/uprime/Make/options b/applications/utilities/postProcessing/velocityField/uprime/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/uprime/Make/options
+++ b/applications/utilities/postProcessing/velocityField/uprime/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/postProcessing/velocityField/vorticity/Make/options b/applications/utilities/postProcessing/velocityField/vorticity/Make/options
index 41164260772b6d1bd213d329e2dfbccf6cacfb99..cbe51627f28e7e1f78ab617dbbc88f38a3a8af78 100644
--- a/applications/utilities/postProcessing/velocityField/vorticity/Make/options
+++ b/applications/utilities/postProcessing/velocityField/vorticity/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(FOAM_SRC)/postProcessing/postCalc \
+    -I$(LIB_SRC)/postProcessing/postCalc \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..58f5dd39748fbd9b7b8f892f4d24109ac4a899c4
--- /dev/null
+++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files
@@ -0,0 +1,3 @@
+applyWallFunctionBounaryConditions.C
+
+EXE = $(FOAM_APPBIN)/applyWallFunctionBounaryConditions
diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..89e52b6d520dc088e6516df08f0f521f188a6353
--- /dev/null
+++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options
@@ -0,0 +1,6 @@
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude
+
+EXE_LIBS = \
+    -lfiniteVolume
+
diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C
new file mode 100644
index 0000000000000000000000000000000000000000..e571cc4373f42948202f6ff8fc42ea51895ce17a
--- /dev/null
+++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C
@@ -0,0 +1,279 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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
+    applyWallFunctionBounaryConditions
+
+Description
+    Updates OpenFOAM RAS cases to use the new wall function framework
+    Attempts to determine whether case is compressible or incompressible, or
+    can be supplied with -compressible command line argument
+
+\*---------------------------------------------------------------------------*/
+
+
+#include "argList.H"
+#include "fvMesh.H"
+#include "Time.H"
+#include "volFields.H"
+#include "surfaceFields.H"
+
+#include "wallPolyPatch.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+bool caseIsCompressible(const fvMesh& mesh)
+{
+    // Attempt flux field
+    IOobject phiHeader
+    (
+        "phi",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (phiHeader.headerOk())
+    {
+        surfaceScalarField phi(phiHeader, mesh);
+        if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
+        {
+            return true;
+        }
+    }
+
+    // Attempt density field
+    IOobject rhoHeader
+    (
+        "rho",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (rhoHeader.headerOk())
+    {
+        volScalarField rho(rhoHeader, mesh);
+        if (rho.dimensions() == dimDensity)
+        {
+            return true;
+        }
+    }
+
+    // Attempt pressure field
+    IOobject pHeader
+    (
+        "p",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (pHeader.headerOk())
+    {
+        volScalarField p(pHeader, mesh);
+        if (p.dimensions() == dimMass/sqr(dimTime)/dimLength)
+        {
+            return true;
+        }
+    }
+
+    // Attempt hydrostatic pressure field
+    IOobject pdHeader
+    (
+        "pd",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (pdHeader.headerOk())
+    {
+        volScalarField pd(pdHeader, mesh);
+        if (pd.dimensions() == dimMass/sqr(dimTime)/dimLength)
+        {
+            return true;
+        }
+    }
+
+    // If none of the above are true, assume that the case is incompressible
+    return false;
+}
+
+
+void createVolScalarField
+(
+    const fvMesh& mesh,
+    const word& fieldName,
+    const dimensionSet& dims
+)
+{
+    IOobject fieldHeader
+    (
+        fieldName,
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (!fieldHeader.headerOk())
+    {
+        Info<< "Creating field " << fieldName << nl << endl;
+
+        volScalarField field
+        (
+            IOobject
+            (
+                fieldName,
+                mesh.time().timeName(),
+                mesh,
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh,
+            dimensionedScalar("zero", dims, 0.0)
+        );
+
+        field.write();
+    }
+}
+
+
+void replaceBoundaryType
+(
+    const fvMesh& mesh,
+    const word& fieldName,
+    const word& boundaryType,
+    const string& boundaryValue
+)
+{
+    IOobject header
+    (
+        fieldName,
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (!header.headerOk())
+    {
+        return;
+    }
+
+    Info<< "Updating boundary types for field " << header.name() << endl;
+
+    const word oldTypeName = IOdictionary::typeName;
+    const_cast<word&>(IOdictionary::typeName) = word::null;
+
+    IOdictionary dict(header);
+
+    const_cast<word&>(IOdictionary::typeName) = oldTypeName;
+    const_cast<word&>(dict.type()) = dict.headerClassName();
+
+    // Make a backup of the old field
+    word backupName(dict.name() + ".old");
+    Info<< "    copying " << dict.name() << " to "
+        << backupName << endl;
+    IOdictionary dictOld = dict;
+    dictOld.rename(backupName);
+    dictOld.regIOobject::write();
+
+    // Loop through boundary patches and update
+    const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
+    dictionary& boundaryDict = dict.subDict("boundaryField");
+    forAll(bMesh, patchI)
+    {
+        if (isType<wallPolyPatch>(bMesh[patchI]))
+        {
+            word patchName = bMesh[patchI].name();
+            dictionary& oldPatch = boundaryDict.subDict(patchName);
+
+            dictionary newPatch(dictionary::null);
+            newPatch.add("type", boundaryType);
+            newPatch.add("value", ("uniform " + boundaryValue).c_str());
+
+            oldPatch = newPatch;
+        }
+    }
+
+    Info<< "    writing updated " << dict.name() << nl << endl;
+    dict.regIOobject::write();
+}
+
+
+int main(int argc, char *argv[])
+{
+
+#   include "addTimeOptions.H"
+    argList::validOptions.insert("compressible", "");
+
+#   include "setRootCase.H"
+#   include "createTime.H"
+#   include "createMesh.H"
+
+    bool compressible = args.options().found("compressible");
+
+    Info<< "Updating turbulence fields to operate using new run time "
+        << "selectable" << nl << "wall functions"
+        << nl << endl;
+
+    if (compressible || caseIsCompressible(mesh))
+    {
+        Info<< "Case treated as compressible" << nl << endl;
+        createVolScalarField
+        (
+            mesh,
+            "mut",
+            dimArea/dimTime*dimDensity
+        );
+        replaceBoundaryType(mesh, "mut", "mutWallFunction", "0");
+    }
+    else
+    {
+        Info<< "Case treated as incompressible" << nl << endl;
+        createVolScalarField(mesh, "nut", dimArea/dimTime);
+        replaceBoundaryType(mesh, "nut", "nutWallFunction", "0");
+    }
+
+    replaceBoundaryType(mesh, "epsilon", "epsilonWallFunction", "0");
+    replaceBoundaryType(mesh, "omega", "omegaWallFunction", "0");
+    replaceBoundaryType(mesh, "k", "kQRWallFunction", "0");
+    replaceBoundaryType(mesh, "q", "kQRWallFunction", "0");
+    replaceBoundaryType(mesh, "R", "kQRWallFunction", "(0 0 0 0 0 0)");
+
+    Info<< "End\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
index f24729da976cb9eb4692f72812ecb01a36e719f9..ec5d0193103e08d7c5bc9b1235f3061d57b61725 100644
--- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
+++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
@@ -164,7 +164,16 @@ int main(int argc, char *argv[])
             forAll(dictList, i)
             {
                 doneKeys[i] = dictList[i].keyword();
-                dictList.set(i, fieldDict.lookupEntry(doneKeys[i]).clone());
+                dictList.set
+                (
+                    i,
+                    fieldDict.lookupEntry
+                    (
+                        doneKeys[i],
+                        false,
+                        true
+                    ).clone()
+                );
                 fieldDict.remove(doneKeys[i]);
             }
             // Add remaining entries
diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C
index aa30790b5caba2ad74e4ca0548abfdb3e2537236..f6312b32a4ddff7a4212dbc59bdc2f8ac0e08cfc 100644
--- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C
+++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C
@@ -100,6 +100,11 @@ int main(int argc, char *argv[])
         meshSubsetDict.lookup("addFaceNeighbours")
     );
 
+    Switch invertSelection
+    (
+        meshSubsetDict.lookup("invertSelection")
+    );
+
     // Mark the cells for the subset
 
     // Faces to subset
@@ -337,6 +342,27 @@ int main(int argc, char *argv[])
             << " faces because of addFaceNeighbours" << endl;
     }
 
+
+    if (invertSelection)
+    {
+        Info<< "Inverting selection." << endl;
+        boolList newFacesToSubset(facesToSubset.size());
+
+        forAll(facesToSubset, i)
+        {
+            if (facesToSubset[i])
+            {
+                newFacesToSubset[i] = false;
+            }
+            else
+            {
+                newFacesToSubset[i] = true;
+            }
+        }
+        facesToSubset.transfer(newFacesToSubset);
+    }
+
+
     // Create subsetted surface
     labelList pointMap;
     labelList faceMap;
diff --git a/bin/mpirunDebug b/bin/mpirunDebug
index 013a63997fb00b09004726d0183314f8deb4d40c..8d0be2375c4beda9ca56943fef8f2308e8816448 100755
--- a/bin/mpirunDebug
+++ b/bin/mpirunDebug
@@ -70,15 +70,17 @@ if [ ! -x "$exec" ]; then
     exit 1
 fi
 
+if [ ! "$PWD" ]; then
+    PWD=`pwd`
+fi
 
+echo "run $args" > $PWD/gdbCommands
+echo "where" >> $PWD/gdbCommands
+echo "Constructed gdb initialization file $PWD/gdbCommands"
 
-echo "run $args" > $HOME/gdbCommands
-echo "where" >> $HOME/gdbCommands
-echo "Constructed gdb initialization file $HOME/gdbCommands"
-
-$ECHO "Choose running method: 1)gdb+xterm  2)gdb  3)log  4)log+xterm  5)xterm+valgrind: \c"
+$ECHO "Choose running method: 0)normal  1)gdb+xterm  2)gdb  3)log  4)log+xterm  5)xterm+valgrind: \c"
 read method
-if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 -a "$method" -ne 5 ]; then
+if [ "$method" -ne 0 -a "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 -a "$method" -ne 5 ]; then
     printUsage
     exit 1
 fi
@@ -119,15 +121,15 @@ fi
 
 echo "**sourceFoam:$sourceFoam"
 
-rm -f $HOME/mpirun.schema
-touch $HOME/mpirun.schema
+rm -f $PWD/mpirun.schema
+touch $PWD/mpirun.schema
 
 proc=0
 xpos=0
 ypos=0
 for ((proc=0; proc<$nProcs; proc++))
 do
-    procCmdFile="$HOME/processor${proc}.sh"
+    procCmdFile="$PWD/processor${proc}.sh"
     procLog="processor${proc}.log"
     geom="-geometry 120x20+$xpos+$ypos"
     node=""
@@ -141,22 +143,25 @@ do
     fi
 
     echo "#!/bin/sh" > $procCmdFile
-    if [ "$method" -eq 1 ]; then
-        echo "$sourceFoam; cd $PWD; gdb -command $HOME/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
+    if [ "$method" -eq 0 ]; then
+        echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile
+        echo "${node}$procCmdFile" >> $PWD/mpirun.schema
+    elif [ "$method" -eq 1 ]; then
+        echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
         #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema
+        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
     elif [ "$method" -eq 2 ]; then
-        echo "$sourceFoam; cd $PWD; gdb -command $HOME/gdbCommands >& $procLog" >> $procCmdFile
-        echo "${node}$procCmdFile" >> $HOME/mpirun.schema
+        echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands >& $procLog" >> $procCmdFile
+        echo "${node}$procCmdFile" >> $PWD/mpirun.schema
     elif [ "$method" -eq 3 ]; then
         echo "$sourceFoam; cd $PWD; $exec $args >& $procLog" >> $procCmdFile
-        echo "${node}$procCmdFile" >> $HOME/mpirun.schema
+        echo "${node}$procCmdFile" >> $PWD/mpirun.schema
     elif [ "$method" -eq 4 ]; then
         echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema
+        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
     elif [ "$method" -eq 5 ]; then
         echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema
+        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
     fi
 
     chmod +x $procCmdFile
@@ -176,10 +181,17 @@ do
     echo "    tail -f $procLog"
 done
 
-$ECHO "Constructed $HOME/mpirun.schema file. Press return to execute.\c"
-read dummy
+cmd=""
 if [ .$WM_MPLIB = .OPENMPI ]; then
-    mpirun -app $HOME/mpirun.schema </dev/null
+    cmd="mpirun -app $PWD/mpirun.schema </dev/null"
 elif [ .$WM_MPLIB = .LAM ]; then
-    mpirun $HOME/mpirun.schema </dev/null
+    cmd="mpirun $PWD/mpirun.schema </dev/null"
 fi
+
+echo "Constructed $PWD/mpirun.schema file."
+echo ""
+echo "    $cmd"
+echo ""
+$ECHO "Press return to execute.\c"
+read dummy
+exec $cmd
diff --git a/etc/bashrc b/etc/bashrc
index aff71726e007a72c927a9e862bb7763c82ffb808..b862b6a9331e28d874d921248fd48c5ac680680b 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -23,16 +23,17 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     bashrc
+#     etc/bashrc
 #
 # Description
 #     Startup file for OpenFOAM
 #     Sourced from ~/.profile or ~/.bashrc
+#     Should be usable by any POSIX-compliant shell (eg, ksh)
 #
 #------------------------------------------------------------------------------
 
 export WM_PROJECT=OpenFOAM
-#export WM_PROJECT_VERSION=1.5
+#export WM_PROJECT_VERSION=1.5.x
 : ${WM_PROJECT_VERSION:=dev}; export WM_PROJECT_VERSION
 
 
@@ -53,7 +54,7 @@ foamInstall=$HOME/$WM_PROJECT
 # Location of site/user files
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
-export WM_PROJECT_DIR=$FOAM_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
+export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
 
 
@@ -163,7 +164,7 @@ esac
 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
 
 # Remove anything under top-level foam directory
-wildCards="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
+wildCards="$WM_PROJECT_INST_DIR $HOME/$WM_PROJECT/$USER"
 
 #- Clean path/PATH
 cleanPath=`$cleanProg "$PATH" "$wildCards"` && PATH="$cleanPath"
@@ -182,9 +183,7 @@ _foamSource()
 {
    while [ $# -ge 1 ]
    do
-      if [ "$FOAM_VERBOSE" -a "$PS1" ]; then
-         echo "Sourcing: $1"
-      fi
+      [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
       . $1
       shift
    done
diff --git a/etc/cshrc b/etc/cshrc
index ace795241c27ec66c59cae2c4e6e43cfc816efcd..b39618f7401c0568ad23ced096fd88185471b0a4 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -23,7 +23,7 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     cshrc
+#     etc/cshrc
 #
 # Description
 #     Startup file for OpenFOAM
@@ -32,7 +32,7 @@
 #------------------------------------------------------------------------------
 
 setenv WM_PROJECT OpenFOAM
-#setenv WM_PROJECT_VERSION 1.5
+#setenv WM_PROJECT_VERSION 1.5.x
 if ( ! $?WM_PROJECT_VERSION ) setenv WM_PROJECT_VERSION dev
 
 #!!User:
@@ -52,7 +52,7 @@ if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
 # Location of site/user files
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR
-setenv WM_PROJECT_DIR $FOAM_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
+setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
 setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
 
 
@@ -167,7 +167,7 @@ if (! $?MANPATH) then
 endif
 
 # Remove anything under top-level foam directory
-set wildCards="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
+set wildCards="$WM_PROJECT_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
 
 #- Clean path/PATH
 set colonPath=`echo "$path" | sed -e 's/ /:/g'`
@@ -219,5 +219,8 @@ endif
 
 # cleanup environment:
 # ~~~~~~~~~~~~~~~~~~~~
+unset cleanProg
+unset wildCards
+unset colonPath
 unalias _foamSource
 # -----------------------------------------------------------------------------
diff --git a/etc/settings.csh b/etc/settings.csh
index d21268aafb6f4340dff1cd0ddbd7cee6dc8d6f04..dc312646e08581ddc07a5ae5edc94e812c03757e 100644
--- a/etc/settings.csh
+++ b/etc/settings.csh
@@ -23,7 +23,7 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     settings.csh
+#     etc/settings.csh
 #
 # Description
 #     Startup file for OpenFOAM
@@ -31,58 +31,70 @@
 #
 #------------------------------------------------------------------------------
 
-alias _foamAddPath 'set path=(\!* $path) ; if ( ! -d \!* ) mkdir -p \!*'
-alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH} ; if ( ! -d \!* ) mkdir -p \!*'
+# prefix to PATH
+alias _foamAddPath 'set path=(\!* $path)'
+# prefix to LD_LIBRARY_PATH
+alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}'
+# make directory if it doesn't already exist
+alias _foamMkDir 'if ( ! -d \!* ) mkdir -p \!*'
 
+# location of the jobControl directory
+setenv FOAM_JOB_DIR $WM_PROJECT_INST_DIR/jobControl
 
-#- Add the system-specific executables path to the path
-set path=($WM_PROJECT_DIR/bin $FOAM_INST_DIR/$WM_ARCH/bin $path)
-
-#- Location of the jobControl directory
-setenv FOAM_JOB_DIR $FOAM_INST_DIR/jobControl
-
+# wmake configuration
 setenv WM_DIR $WM_PROJECT_DIR/wmake
 setenv WM_LINK_LANGUAGE c++
 setenv WM_OPTIONS $WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
-set path=($WM_DIR $path)
 
+# base configuration
 setenv FOAM_SRC $WM_PROJECT_DIR/src
 setenv FOAM_LIB $WM_PROJECT_DIR/lib
-setenv FOAM_LIBBIN $FOAM_LIB/$WM_OPTIONS
-_foamAddLib $FOAM_LIBBIN
-
+setenv FOAM_LIBBIN $WM_PROJECT_DIR/lib/$WM_OPTIONS
 setenv FOAM_APP $WM_PROJECT_DIR/applications
 setenv FOAM_APPBIN $WM_PROJECT_DIR/applications/bin/$WM_OPTIONS
-_foamAddPath $FOAM_APPBIN
 
+# user configuration
+setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/lib/$WM_OPTIONS
+setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/applications/bin/$WM_OPTIONS
+
+# convenience
 setenv FOAM_TUTORIALS $WM_PROJECT_DIR/tutorials
 setenv FOAM_UTILITIES $FOAM_APP/utilities
 setenv FOAM_SOLVERS $FOAM_APP/solvers
+setenv FOAM_RUN $WM_PROJECT_USER_DIR/run
 
-setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/lib/$WM_OPTIONS
-_foamAddLib $FOAM_USER_LIBBIN
+# add OpenFOAM scripts and wmake to the path
+set path=($WM_DIR $WM_PROJECT_DIR/bin $path)
 
-setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/applications/bin/$WM_OPTIONS
+_foamAddPath $FOAM_APPBIN
 _foamAddPath $FOAM_USER_APPBIN
+_foamAddLib  $FOAM_LIBBIN
+_foamAddLib  $FOAM_USER_LIBBIN
 
-setenv FOAM_RUN $WM_PROJECT_USER_DIR/run
+# create these directories if necessary:
+_foamMkDir $FOAM_LIBBIN
+_foamMkDir $FOAM_APPBIN
+_foamMkDir $FOAM_USER_LIBBIN
+_foamMkDir $FOAM_USER_APPBIN
 
 
 # Compiler settings
 # ~~~~~~~~~~~~~~~~~
-set WM_COMPILER_BIN=
-set WM_COMPILER_LIB=
+set compilerBin=
+set compilerLib=
 
 # Select compiler installation
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# WM_COMPILER_INST = OpenFOAM | System
-set WM_COMPILER_INST=OpenFOAM
+# compilerInstall = OpenFOAM | System
+set compilerInstall=OpenFOAM
 
-switch ("$WM_COMPILER_INST")
+switch ("$compilerInstall")
 case OpenFOAM:
     switch ("$WM_COMPILER")
     case Gcc:
-        setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH
+        setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
+        _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
+        _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
     breaksw
     case Gcc42:
         setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH
@@ -95,27 +107,22 @@ case OpenFOAM:
         echo "Warning in $WM_PROJECT_DIR/etc/settings.csh:"
         echo "    Cannot find $WM_COMPILER_DIR installation."
         echo "    Please install this compiler version or if you wish to use the system compiler,"
-        echo "    change the WM_COMPILER_INST setting to 'System' in this file"
+        echo "    change the 'compilerInstall' setting to 'System' in this file"
         echo
     endif
 
-    set WM_COMPILER_BIN="$WM_COMPILER_DIR/bin"
-    set WM_COMPILER_LIB=$WM_COMPILER_DIR/lib${WM_COMPILER_LIB_ARCH}:$WM_COMPILER_DIR/lib
+    set compilerBin=$WM_COMPILER_DIR/bin
+    set compilerLib=$WM_COMPILER_DIR/lib$WM_COMPILER_LIB_ARCH:$WM_COMPILER_DIR/lib
     breaksw
 endsw
 
-if ($?WM_COMPILER_BIN) then
-    set path=($WM_COMPILER_BIN $path)
-
-    if ($?LD_LIBRARY_PATH) then
-        setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB}:${LD_LIBRARY_PATH}
-    else
-        setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB}
-    endif
+if ($?compilerBin) then
+    _foamAddPath $compilerBin
+    _foamAddLib  $compilerLib
 endif
 
-unset WM_COMPILER_BIN
-unset WM_COMPILER_LIB
+unset compilerBin
+unset compilerLib
 
 
 # Communications library
@@ -132,8 +139,8 @@ case OPENMPI:
     # Tell OpenMPI where to find its install directory
     setenv OPAL_PREFIX $MPI_ARCH_PATH
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -146,8 +153,8 @@ case LAM:
     setenv LAMHOME $WM_THIRD_PARTY_DIR/$mpi_version
     # note: LAMHOME is deprecated, should probably point to MPI_ARCH_PATH too
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -159,8 +166,8 @@ case MPICH:
     setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS
     setenv MPICH_ROOT $MPI_ARCH_PATH
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -172,9 +179,9 @@ case MPICH-GM:
     setenv MPICH_ROOT $MPI_ARCH_PATH
     setenv GM_LIB_PATH /opt/gm/lib64
 
+    _foamAddPath $MPI_ARCH_PATH/bin
     _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddLib  $GM_LIB_PATH
-    _foamAddPath $MPI_ARCH_PATH/bin
 
     setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpich-gm
     breaksw
@@ -218,8 +225,8 @@ endif
 
 # cleanup environment:
 # ~~~~~~~~~~~~~~~~~~~~
-unalias _foamAddLib
 unalias _foamAddPath
-
+unalias _foamAddLib
+unalias _foamMkDir
 
 # -----------------------------------------------------------------------------
diff --git a/etc/settings.sh b/etc/settings.sh
index 612719e292e08c756f2b7cd84a2fd6ab8a8ba0d0..133137d3a4f64851ed8fa52ca6213db01285581e 100644
--- a/etc/settings.sh
+++ b/etc/settings.sh
@@ -23,7 +23,7 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     settings.sh
+#     etc/settings.sh
 #
 # Description
 #     Startup file for OpenFOAM
@@ -31,75 +31,89 @@
 #
 #------------------------------------------------------------------------------
 
+# prefix to PATH
 _foamAddPath()
 {
-    while [ $# -ge 1 ]
-    do
-        [ -d $1 ] || mkdir -p $1
-        export PATH=$1:$PATH
-        shift
-    done
+   while [ $# -ge 1 ]
+   do
+      export PATH=$1:$PATH
+      shift
+   done
 }
 
+# prefix to LD_LIBRARY_PATH
 _foamAddLib()
 {
-    while [ $# -ge 1 ]
-    do
-        [ -d $1 ] || mkdir -p $1
-        export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
-        shift
-    done
+   while [ $# -ge 1 ]
+   do
+      export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
+      shift
+   done
 }
 
 
-#- Add the system-specific executables path to the path
-export PATH=$WM_PROJECT_DIR/bin:$FOAM_INST_DIR/$WM_ARCH/bin:$PATH
+# make directories if they don't already exist
+_foamMkDir()
+{
+   while [ $# -ge 1 ]
+   do
+      [ -d $1 ] || mkdir -p $1
+      shift
+   done
+}
+
 
-#- Location of the jobControl directory
-export FOAM_JOB_DIR=$FOAM_INST_DIR/jobControl
+# location of the jobControl directory
+export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl
 
+# wmake configuration
 export WM_DIR=$WM_PROJECT_DIR/wmake
 export WM_LINK_LANGUAGE=c++
-export WM_OPTIONS=$WM_ARCH${WM_COMPILER}$WM_PRECISION_OPTION$WM_COMPILE_OPTION
-export PATH=$WM_DIR:$PATH
+export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
 
+# base configuration
 export FOAM_SRC=$WM_PROJECT_DIR/src
 export FOAM_LIB=$WM_PROJECT_DIR/lib
-export FOAM_LIBBIN=$FOAM_LIB/$WM_OPTIONS
-_foamAddLib $FOAM_LIBBIN
-
+export FOAM_LIBBIN=$WM_PROJECT_DIR/lib/$WM_OPTIONS
 export FOAM_APP=$WM_PROJECT_DIR/applications
 export FOAM_APPBIN=$WM_PROJECT_DIR/applications/bin/$WM_OPTIONS
-_foamAddPath $FOAM_APPBIN
 
+# user configuration
+export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/lib/$WM_OPTIONS
+export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/applications/bin/$WM_OPTIONS
+
+# convenience
 export FOAM_TUTORIALS=$WM_PROJECT_DIR/tutorials
 export FOAM_UTILITIES=$FOAM_APP/utilities
 export FOAM_SOLVERS=$FOAM_APP/solvers
+export FOAM_RUN=$WM_PROJECT_USER_DIR/run
 
-export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/lib/$WM_OPTIONS
-_foamAddLib $FOAM_USER_LIBBIN
+# add OpenFOAM scripts and wmake to the path
+export PATH=$WM_DIR:$WM_PROJECT_DIR/bin:$PATH
 
-export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/applications/bin/$WM_OPTIONS
-_foamAddPath $FOAM_USER_APPBIN
+_foamAddPath $FOAM_APPBIN $FOAM_USER_APPBIN
+_foamAddLib  $FOAM_LIBBIN $FOAM_USER_LIBBIN
 
-export FOAM_RUN=$WM_PROJECT_USER_DIR/run
+# create these directories if necessary:
+_foamMkDir $FOAM_LIBBIN $FOAM_USER_LIBBIN $FOAM_APPBIN $FOAM_USER_APPBIN
 
 
 # Compiler settings
 # ~~~~~~~~~~~~~~~~~
-WM_COMPILER_BIN=
-WM_COMPILER_LIB=
+unset compilerBin compilerLib
 
 # Select compiler installation
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# WM_COMPILER_INST = OpenFOAM | System
-WM_COMPILER_INST=OpenFOAM
+# compilerInstall = OpenFOAM | System
+compilerInstall=OpenFOAM
 
-case "$WM_COMPILER_INST" in
+case "$compilerInstall" in
 OpenFOAM)
     case "$WM_COMPILER" in
     Gcc)
-        export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH
+        export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH
+        _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
+        _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib
         ;;
     Gcc42)
         export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH
@@ -113,21 +127,22 @@ OpenFOAM)
         echo "Warning in $WM_PROJECT_DIR/etc/settings.sh:"
         echo "    Cannot find $WM_COMPILER_DIR installation."
         echo "    Please install this compiler version or if you wish to use the system compiler,"
-        echo "    change the WM_COMPILER_INST setting to 'System' in this file"
+        echo "    change the 'compilerInstall' setting to 'System' in this file"
         echo
     fi
 
-    WM_COMPILER_BIN=$WM_COMPILER_DIR/bin
-    WM_COMPILER_LIB=$WM_COMPILER_DIR/lib$WM_COMPILER_LIB_ARCH:$WM_COMPILER_DIR/lib
+    compilerBin=$WM_COMPILER_DIR/bin
+    compilerLib=$WM_COMPILER_DIR/lib$WM_COMPILER_LIB_ARCH:$WM_COMPILER_DIR/lib
     ;;
 esac
 
-if [ -d "$WM_COMPILER_BIN" ]; then
-    export PATH=$WM_COMPILER_BIN:$PATH
-    export LD_LIBRARY_PATH=$WM_COMPILER_LIB:$LD_LIBRARY_PATH
+if [ -d "$compilerBin" ]
+then
+    _foamAddPath $compilerBin
+    _foamAddLib  $compilerLib
 fi
 
-unset WM_COMPILER_BIN WM_COMPILER_LIB
+unset compilerBin compilerLib compilerInstall
 
 # Communications library
 # ~~~~~~~~~~~~~~~~~~~~~~
@@ -143,8 +158,8 @@ OPENMPI)
     # Tell OpenMPI where to find its install directory
     export OPAL_PREFIX=$MPI_ARCH_PATH
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -157,8 +172,8 @@ LAM)
     export LAMHOME=$WM_THIRD_PARTY_DIR/$mpi_version
     # note: LAMHOME is deprecated, should probably point to MPI_ARCH_PATH too
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -170,8 +185,8 @@ MPICH)
     export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS
     export MPICH_ROOT=$MPI_ARCH_PATH
 
-    _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddPath $MPI_ARCH_PATH/bin
+    _foamAddLib  $MPI_ARCH_PATH/lib
 
     export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
     unset mpi_version
@@ -183,9 +198,9 @@ MPICH-GM)
     export MPICH_ROOT=$MPI_ARCH_PATH
     export GM_LIB_PATH=/opt/gm/lib64
 
+    _foamAddPath $MPI_ARCH_PATH/bin
     _foamAddLib  $MPI_ARCH_PATH/lib
     _foamAddLib  $GM_LIB_PATH
-    _foamAddPath $MPI_ARCH_PATH/bin
 
     export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpich-gm
     ;;
@@ -227,6 +242,6 @@ export MPI_BUFFER_SIZE=20000000
 
 # cleanup environment:
 # ~~~~~~~~~~~~~~~~~~~~
-unset _foamAddLib _foamAddPath
+unset _foamAddPath _foamAddLib _foamMkDir
 
 # -----------------------------------------------------------------------------
diff --git a/src/Allwmake b/src/Allwmake
index 2c532a41aaf587895363cb889a38e819d0e5f64e..341ee2ed6f5c683bf1ea8ff1faec76c4eec7333f 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -2,7 +2,8 @@
 cd ${0%/*} || exit 1    # run from this directory
 set -x
 
-( cd OpenFOAM && wmakeLnInclude . )
+wmakeLnInclude -f OpenFOAM
+wmakeLnInclude -f OSspecific/$WM_OS
 ( cd Pstream && ./Allwmake )
 
 wmake libo  OSspecific/$WM_OS
diff --git a/src/ODE/ODE/ODE.H b/src/ODE/ODE/ODE.H
index 6b3c69011c79b8de7927b1a9c55dcf212c49b8d7..fe57cb91f4d45dcfeb5e0b88d50028fdeb39828e 100644
--- a/src/ODE/ODE/ODE.H
+++ b/src/ODE/ODE/ODE.H
@@ -34,7 +34,7 @@ Description
 #define ODE_H
 
 #include "scalarField.H"
-#include "Matrix.H"
+#include "scalarMatrices.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -80,7 +80,7 @@ public:
             const scalar x,
             const scalarField& y,
             scalarField& dfdx,
-            Matrix<scalar>& dfdy
+            scalarSquareMatrix& dfdy
         ) const = 0;
 };
 
diff --git a/src/ODE/ODESolvers/KRR4/KRR4.C b/src/ODE/ODESolvers/KRR4/KRR4.C
index fa00919a4266e72d71dfb80d42cb794c99ea2b32..ec3db0457484ed1d269f68e52abd1883ae0d7857 100644
--- a/src/ODE/ODESolvers/KRR4/KRR4.C
+++ b/src/ODE/ODESolvers/KRR4/KRR4.C
@@ -25,7 +25,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "KRR4.H"
-#include "simpleMatrix.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -36,11 +35,11 @@ namespace Foam
 {
     addToRunTimeSelectionTable(ODESolver, KRR4, ODE);
 
-const scalar 
+const scalar
     KRR4::safety = 0.9, KRR4::grow = 1.5, KRR4::pgrow = -0.25,
     KRR4::shrink = 0.5, KRR4::pshrink = (-1.0/3.0), KRR4::errcon = 0.1296;
 
-const scalar 
+const scalar
     KRR4::gamma = 1.0/2.0,
     KRR4::a21 = 2.0, KRR4::a31 = 48.0/25.0, KRR4::a32 = 6.0/25.0,
     KRR4::c21 = -8.0, KRR4::c31 = 372.0/25.0, KRR4::c32 = 12.0/5.0,
@@ -81,8 +80,8 @@ void Foam::KRR4::solve
     const ODE& ode,
     scalar& x,
     scalarField& y,
-    scalarField& dydx, 
-    const scalar eps, 
+    scalarField& dydx,
+    const scalar eps,
     const scalarField& yScale,
     const scalar hTry,
     scalar& hDid,
@@ -109,14 +108,14 @@ void Foam::KRR4::solve
             a_[i][i] += 1.0/(gamma*h);
         }
 
-        simpleMatrix<scalar>::LUDecompose(a_, pivotIndices_);
+        LUDecompose(a_, pivotIndices_);
 
         for (register label i=0; i<n_; i++)
         {
             g1_[i] = dydxTemp_[i] + h*c1X*dfdx_[i];
         }
 
-        simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g1_);
+        LUBacksubstitute(a_, pivotIndices_, g1_);
 
         for (register label i=0; i<n_; i++)
         {
@@ -131,7 +130,7 @@ void Foam::KRR4::solve
             g2_[i] = dydx_[i] + h*c2X*dfdx_[i] + c21*g1_[i]/h;
         }
 
-        simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g2_);
+        LUBacksubstitute(a_, pivotIndices_, g2_);
 
         for (register label i=0; i<n_; i++)
         {
@@ -146,7 +145,7 @@ void Foam::KRR4::solve
             g3_[i] = dydx[i] + h*c3X*dfdx_[i] + (c31*g1_[i] + c32*g2_[i])/h;
         }
 
-        simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g3_);
+        LUBacksubstitute(a_, pivotIndices_, g3_);
 
         for (register label i=0; i<n_; i++)
         {
@@ -154,7 +153,7 @@ void Foam::KRR4::solve
                 + (c41*g1_[i] + c42*g2_[i] + c43*g3_[i])/h;
         }
 
-        simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g4_);
+        LUBacksubstitute(a_, pivotIndices_, g4_);
 
         for (register label i=0; i<n_; i++)
         {
diff --git a/src/ODE/ODESolvers/KRR4/KRR4.H b/src/ODE/ODESolvers/KRR4/KRR4.H
index cf86ee3f1541a39349b55635e1e241d7ac465a0f..f5393159a63a2ad1146f6b37c14664ec9e56af7f 100644
--- a/src/ODE/ODESolvers/KRR4/KRR4.H
+++ b/src/ODE/ODESolvers/KRR4/KRR4.H
@@ -62,15 +62,15 @@ class KRR4
         mutable scalarField g4_;
         mutable scalarField yErr_;
         mutable scalarField dfdx_;
-        mutable Matrix<scalar> dfdy_;
-        mutable Matrix<scalar> a_;
+        mutable scalarSquareMatrix dfdy_;
+        mutable scalarSquareMatrix a_;
         mutable labelList pivotIndices_;
 
         static const int maxtry = 40;
 
         static const scalar safety, grow, pgrow, shrink, pshrink, errcon;
 
-        static const scalar 
+        static const scalar
             gamma,
             a21, a31, a32,
             c21, c31, c32, c41, c42, c43,
diff --git a/src/ODE/ODESolvers/SIBS/SIBS.H b/src/ODE/ODESolvers/SIBS/SIBS.H
index 75383bc38a2c190de0290f68c78eb35c8b59bfef..164b92d299418daab5e3cc720e2dc61bbeb882f2 100644
--- a/src/ODE/ODESolvers/SIBS/SIBS.H
+++ b/src/ODE/ODESolvers/SIBS/SIBS.H
@@ -60,8 +60,8 @@ class SIBS
         static const scalar safe1, safe2, redMax, redMin, scaleMX;
 
         mutable scalarField a_;
-        mutable Matrix<scalar> alpha_;
-        mutable Matrix<scalar> d_p_;
+        mutable scalarSquareMatrix alpha_;
+        mutable scalarSquareMatrix d_p_;
         mutable scalarField x_p_;
         mutable scalarField err_;
 
@@ -69,7 +69,7 @@ class SIBS
         mutable scalarField ySeq_;
         mutable scalarField yErr_;
         mutable scalarField dfdx_;
-        mutable Matrix<scalar> dfdy_;
+        mutable scalarSquareMatrix dfdy_;
 
         mutable label first_, kMax_, kOpt_;
         mutable scalar epsOld_, xNew_;
@@ -82,7 +82,7 @@ void SIMPR
     const scalarField& y,
     const scalarField& dydx,
     const scalarField& dfdx,
-    const Matrix<scalar>& dfdy, 
+    const scalarSquareMatrix& dfdy,
     const scalar deltaX,
     const label nSteps,
     scalarField& yEnd
@@ -97,7 +97,7 @@ void polyExtrapolate
     scalarField& yz,
     scalarField& dy,
     scalarField& x_p,
-    Matrix<scalar>& d_p
+    scalarSquareMatrix& d_p
 ) const;
 
 
diff --git a/src/ODE/ODESolvers/SIBS/SIMPR.C b/src/ODE/ODESolvers/SIBS/SIMPR.C
index f540f26d114af53e816f528b1496168d45427a06..671f1acec9449d3cc73cee97b87ebe3b04154608 100644
--- a/src/ODE/ODESolvers/SIBS/SIMPR.C
+++ b/src/ODE/ODESolvers/SIBS/SIMPR.C
@@ -25,7 +25,6 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "SIBS.H"
-#include "simpleMatrix.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -36,7 +35,7 @@ void Foam::SIBS::SIMPR
     const scalarField& y,
     const scalarField& dydx,
     const scalarField& dfdx,
-    const Matrix<scalar>& dfdy,
+    const scalarSquareMatrix& dfdy,
     const scalar deltaX,
     const label nSteps,
     scalarField& yEnd
@@ -44,7 +43,7 @@ void Foam::SIBS::SIMPR
 {
     scalar h = deltaX/nSteps;
 
-    Matrix<scalar> a(n_, n_);
+    scalarSquareMatrix a(n_);
     for (register label i=0; i<n_; i++)
     {
         for (register label j=0; j<n_; j++)
@@ -55,14 +54,14 @@ void Foam::SIBS::SIMPR
     }
 
     labelList pivotIndices(n_);
-    simpleMatrix<scalar>::LUDecompose(a, pivotIndices);
+    LUDecompose(a, pivotIndices);
 
     for (register label i=0; i<n_; i++)
     {
         yEnd[i] = h*(dydx[i] + h*dfdx[i]);
     }
 
-    simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
+    LUBacksubstitute(a, pivotIndices, yEnd);
 
     scalarField del(yEnd);
     scalarField ytemp(n_);
@@ -83,7 +82,7 @@ void Foam::SIBS::SIMPR
             yEnd[i] = h*yEnd[i] - del[i];
         }
 
-        simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
+        LUBacksubstitute(a, pivotIndices, yEnd);
 
         for (register label i=0; i<n_; i++)
         {
@@ -99,7 +98,7 @@ void Foam::SIBS::SIMPR
         yEnd[i] = h*yEnd[i] - del[i];
     }
 
-    simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
+    LUBacksubstitute(a, pivotIndices, yEnd);
 
     for (register label i=0; i<n_; i++)
     {
diff --git a/src/ODE/ODESolvers/SIBS/polyExtrapolate.C b/src/ODE/ODESolvers/SIBS/polyExtrapolate.C
index 3f3c45d3393f25f448d29f78dfdb6b01caaadc21..c22720a6b1330be652ef55ae3390d62c3ed593b2 100644
--- a/src/ODE/ODESolvers/SIBS/polyExtrapolate.C
+++ b/src/ODE/ODESolvers/SIBS/polyExtrapolate.C
@@ -36,7 +36,7 @@ void Foam::SIBS::polyExtrapolate
     scalarField& yz,
     scalarField& dy,
     scalarField& x,
-    Matrix<scalar>& d
+    scalarSquareMatrix& d
 ) const
 {
     label n = yz.size();
diff --git a/src/OSspecific/Unix/regularExpression.H b/src/OSspecific/Unix/regularExpression.H
new file mode 100644
index 0000000000000000000000000000000000000000..9924caef28fb7ecec52a9d272a91aa3328b8e6ba
--- /dev/null
+++ b/src/OSspecific/Unix/regularExpression.H
@@ -0,0 +1,121 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::regularExpression
+
+Description
+    Wrapper around regular expressions.
+
+SourceFiles
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef regularExpression_H
+#define regularExpression_H
+
+#include <sys/types.h>
+#include <regex.h>
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class regularExpression Declaration
+\*---------------------------------------------------------------------------*/
+
+class regularExpression
+{
+    // Private data
+
+        //- Precompiled regular expression
+        regex_t* preg_;
+
+
+    // Private member functions
+
+        //- Disallow default bitwise copy construct
+        regularExpression(const regularExpression&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const regularExpression&);
+
+public:
+
+
+    // Constructors
+
+        //- Construct from string
+        inline regularExpression(const string& s)
+        {
+            preg_ = new regex_t;
+
+            if (regcomp(preg_, s.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
+            {
+                FatalErrorIn
+                (
+                    "regularExpression::regularExpression(const char*)"
+                )   << "Failed to compile regular expression " << s
+                    << exit(FatalError);
+            }
+        }
+
+
+    // Destructor
+
+        //- Construct from string
+        inline ~regularExpression()
+        {
+            if (preg_)
+            {
+                regfree(preg_);
+                delete preg_;
+            }
+        }
+
+
+    // Member functions
+
+        //- Matches?
+        inline bool matches(const string& s) const
+        {
+            size_t nmatch = 0;
+            regmatch_t *pmatch = NULL;
+
+            return regexec(preg_, s.c_str(), nmatch, pmatch, 0) == 0;
+        }
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 7b137dedc036386457c906dff90927cfa2bcf610..e24fd6b5ec4411c30138924dd05fdb3eb94a3959 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -39,6 +39,7 @@ $(strings)/word/word.C
 $(strings)/word/wordIO.C
 $(strings)/fileName/fileName.C
 $(strings)/fileName/fileNameIO.C
+$(strings)/keyType/keyTypeIO.C
 
 primitives/random/Random.C
 
@@ -177,8 +178,9 @@ dimensionedTypes/dimensionedTensor/dimensionedTensor.C
 
 matrices/solution/solution.C
 
-scalarMatrix = matrices/scalarMatrix
-$(scalarMatrix)/scalarMatrix.C
+scalarMatrices = matrices/scalarMatrices
+$(scalarMatrices)/scalarMatrices.C
+$(scalarMatrices)/SVD/SVD.C
 
 LUscalarMatrix = matrices/LUscalarMatrix
 $(LUscalarMatrix)/LUscalarMatrix.C
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
index 97cb2b321b0d5f3a5246de0ed7bc07477244f687..676d579bb8f06b94baa6186f485530c483facb2c 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
@@ -83,6 +83,19 @@ HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
     }
 }
 
+template<class T, class Key, class Hash>
+HashTable<T, Key, Hash>::HashTable(const xfer<HashTable<T, Key, Hash> >& ht)
+:
+    HashTableName(),
+    tableSize_(0),
+    table_(NULL),
+    nElmts_(0),
+    endIter_(*this, NULL, 0),
+    endConstIter_(*this, NULL, 0)
+{
+    transfer(*ht);
+}
+
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
index 2f3913d2e2cd8f8bc8162738c47f8ccfaff04827..701d8456156572dd54f878b5dc7748636505a7be 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
@@ -41,6 +41,7 @@ SourceFiles
 #include "label.H"
 #include "word.H"
 #include "className.H"
+#include "xfer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -155,6 +156,9 @@ public:
         //- Construct as copy
         HashTable(const HashTable<T, Key, Hash>&);
 
+        //- Construct by transferring the parameter contents
+        HashTable(const xfer<HashTable<T, Key, Hash> >&);
+
 
     // Destructor
 
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C
index e5e47778140d8896237c2b43f36b7d9a39ba1268..688abd467dc2fb532691e7a7351e9f55d5577219 100644
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C
+++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C
@@ -76,6 +76,24 @@ StaticHashTable<T, Key, Hash>::StaticHashTable
 {}
 
 
+
+template<class T, class Key, class Hash>
+StaticHashTable<T, Key, Hash>::StaticHashTable
+(
+    const xfer<StaticHashTable<T, Key, Hash> >& ht
+)
+:
+    StaticHashTableName(),
+    keys_(0),
+    objects_(0),
+    nElmts_(0),
+    endIter_(*this, 0, 0),
+    endConstIter_(*this, 0, 0)
+{
+    transfer(*ht);
+}
+
+
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class T, class Key, class Hash>
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H
index 9eadf37b5e21a8ac791ffda2dbb129e90a8b2329..558519d81388968d7de9cf459c2027916067e3a3 100644
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H
+++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H
@@ -46,6 +46,7 @@ SourceFiles
 #include "label.H"
 #include "word.H"
 #include "className.H"
+#include "xfer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -146,6 +147,8 @@ public:
         //- Construct as copy
         StaticHashTable(const StaticHashTable<T, Key, Hash>&);
 
+        //- Construct as copy
+        StaticHashTable(const xfer<StaticHashTable<T, Key, Hash> >&);
 
     // Destructor
 
diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C
index 9be79966c6e83132631ac1b556a1dd9836fed510..1f683d98a52f57d3c6d48d3b73326cfdecf8b0cc 100644
--- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C
+++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C
@@ -92,6 +92,12 @@ CompactListList<T>::CompactListList(const UList<label>& rowSizes, const T& t)
 }
 
 
+template<class T>
+CompactListList<T>::CompactListList(const xfer<CompactListList<T> >& lst)
+{
+    transfer(*lst);
+}
+
 template<class T>
 CompactListList<T>::CompactListList(CompactListList<T>& cll, bool reUse)
 :
diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H
index 80bfee1b1e28333dab1d4d2e414ce20cf87308b8..775308b0759a46b359525c13ca8f0d4196894d73 100644
--- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H
+++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H
@@ -103,6 +103,9 @@ public:
         //- Construct given list of row-sizes
         CompactListList(const UList<label>& rowSizes, const T&);
 
+        //- Construct by transferring the parameter contents
+        CompactListList(const xfer<CompactListList<T> >&);
+
         //- Construct as copy or re-use as specified.
         CompactListList(CompactListList<T>&, bool reUse);
 
diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
index 04eb9118255c5ae0449b0ddedf6236d9fea726e5..95cb34932d05f6631af54feda68a63072a091731 100644
--- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
+++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
@@ -26,7 +26,7 @@ Class
     Foam::DynamicList
 
 Description
-    A 1D vector of objects of type \<T\> which resizes itself as necessary to
+    A 1D vector of objects of type \<T\> that resizes itself as necessary to
     accept the new objects.
 
     Internal storage is a compact array and the list can be shrunk to compact
@@ -149,7 +149,7 @@ public:
         //- Append an element at the end of the list
         inline void append(const T& e);
 
-        //- Return and remove the top element
+        //- Remove and return the top element
         inline T remove();
 
         //- Return non-const access to an element,
@@ -159,15 +159,9 @@ public:
         //- Assignment of all entries to the given value
         inline void operator=(const T&);
 
-        //- Assignment from List<T>
+        //- Assignment from List<T>. Also handles assignment from DynamicList.
         inline void operator=(const List<T>&);
 
-        //- Assignment from DynamicList<T>
-        inline void operator=
-        (
-            const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-        );
-
 
     // IOstream operators
 
diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
index 6da8a206784066e09c9e3e056e803de5f93eb1ff..b186893484bcd0ca451f9347db9bcd33b5f22d4f 100644
--- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
+++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
@@ -33,7 +33,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
     List<T>(SizeInc),
     allocSize_(SizeInc)
 {
-    List<T>::size() = 0;
+    List<T>::size(0);
 }
 
 
@@ -47,7 +47,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
     List<T>(s),
     allocSize_(s)
 {
-    List<T>::size() = 0;
+    List<T>::size(0);
 }
 
 
@@ -79,14 +79,18 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
     const label s
 )
 {
-    if (s < List<T>::size())
+    if (s <= List<T>::size())
     {
-        List<T>::size() = s;
+        // shrink addressable size, leave allocated size untouched
+        List<T>::size(s);
     }
-    else
+    else if (s > allocSize_)
     {
+        // increase allocated size, leave addressable size untouched
+        label nextFree = List<T>::size();
         allocSize_ = s;
         List<T>::setSize(allocSize_);
+        List<T>::size(nextFree);
     }
 }
 
@@ -98,14 +102,29 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
     const T& t
 )
 {
-    if (s < List<T>::size())
+    if (s <= List<T>::size())
     {
-        List<T>::size() = s;
+        // shrink addressable size, leave allocated size untouched
+        List<T>::size(s);
     }
-    else
+    else if (s > allocSize_)
     {
+        // increase allocated size, leave addressable size untouched
+        // fill in newly allocated values with constant value
+        label nextFree = List<T>::size();
         allocSize_ = s;
         List<T>::setSize(allocSize_, t);
+        List<T>::size(nextFree);
+    }
+    else
+    {
+        // leave allocated and addressable sizes untouched
+        // fill in new exposed values with constant value
+        label nextFree = List<T>::size();
+        while (nextFree < s)
+        {
+            this->operator[](nextFree++) = t;
+        }
     }
 }
 
@@ -113,14 +132,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
 template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
 inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear()
 {
-    List<T>::size() = 0;
+    List<T>::size(0);
 }
 
 
 template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
 inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
 {
-    List<T>::size() = allocSize_;    // make List<T> consistent
     List<T>::clear();
     allocSize_ = 0;
 }
@@ -166,8 +184,7 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
 )
 {
     allocSize_ = l.allocSize();
-    List<T>::transfer(l);       // take over storage
-    l.allocSize_ = 0;
+    List<T>::transfer(l);       // take over storage. Null l.
 }
 
 
@@ -189,9 +206,9 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append(const T& e)
         List<T>::setSize(allocSize_);
     }
 
-    this->operator[](nextFree - 1) = e;
+    List<T>::size(nextFree);
 
-    List<T>::size() = nextFree;
+    this->operator[](nextFree - 1) = e;
 }
 
 
@@ -202,11 +219,17 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
     {
         FatalErrorIn
         (
-            "void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()"
+            "Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()"
         )   << "List is empty" << abort(FatalError);
     }
 
-    return List<T>::operator[](--List<T>::size());
+    label nextFree = List<T>::size()-1;
+
+    const T& val = List<T>::operator[](nextFree);
+
+    List<T>::size(nextFree);
+
+    return val;
 }
 
 
@@ -232,7 +255,7 @@ inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
         List<T>::setSize(allocSize_);
     }
 
-    List<T>::size() = nextFree;
+    List<T>::size(nextFree);
 
     return this->operator[](i);
 }
@@ -260,15 +283,4 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
-(
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& l
-)
-{
-    List<T>::operator=(l);
-    allocSize_ = l.allocSize();
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C
index 21cc042050f2ed0436935667591f8ae10051a2e5..02e83b011b4596975334ea5607193be2b73b75e6 100644
--- a/src/OpenFOAM/containers/Lists/List/List.C
+++ b/src/OpenFOAM/containers/Lists/List/List.C
@@ -38,14 +38,11 @@ License
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
 
 // Construct with length specified
 template<class T>
-List<T>::List(const label s)
+Foam::List<T>::List(const label s)
 :
     UList<T>(NULL, s)
 {
@@ -69,7 +66,7 @@ List<T>::List(const label s)
 
 // Construct with length and single value specified
 template<class T>
-List<T>::List(const label s, const T& a)
+Foam::List<T>::List(const label s, const T& a)
 :
     UList<T>(NULL, s)
 {
@@ -98,7 +95,7 @@ List<T>::List(const label s, const T& a)
 
 // Construct as copy
 template<class T>
-List<T>::List(const List<T>& a)
+Foam::List<T>::List(const List<T>& a)
 :
     UList<T>(NULL, a.size_)
 {
@@ -128,9 +125,17 @@ List<T>::List(const List<T>& a)
 }
 
 
+// Construct by transferring the parameter contents
+template<class T>
+Foam::List<T>::List(const xfer<List<T> >& lst)
+{
+    transfer(*lst);
+}
+
+
 // Construct as copy or re-use as specified.
 template<class T>
-List<T>::List(List<T>& a, bool reUse)
+Foam::List<T>::List(List<T>& a, bool reUse)
 :
     UList<T>(NULL, a.size_)
 {
@@ -166,10 +171,10 @@ List<T>::List(List<T>& a, bool reUse)
 }
 
 
-// Construct given size and start and end iterators.
+// Construct given start and end iterators.
 template<class T>
 template<class InputIterator>
-List<T>::List(InputIterator first, InputIterator last)
+Foam::List<T>::List(InputIterator first, InputIterator last)
 {
     label s = 0;
     for
@@ -200,8 +205,8 @@ List<T>::List(InputIterator first, InputIterator last)
 
 // Construct as copy of FixedList<T, Size>
 template<class T>
-template<label Size>
-List<T>::List(const FixedList<T, Size>& fl)
+template<Foam::label Size>
+Foam::List<T>::List(const FixedList<T, Size>& fl)
 :
     UList<T>(NULL, Size)
 {
@@ -223,7 +228,7 @@ List<T>::List(const FixedList<T, Size>& fl)
 
 // Construct as copy of PtrList<T>
 template<class T>
-List<T>::List(const PtrList<T>& sptrl)
+Foam::List<T>::List(const PtrList<T>& sptrl)
 :
     UList<T>(NULL, sptrl.size())
 {
@@ -245,7 +250,7 @@ List<T>::List(const PtrList<T>& sptrl)
 
 // Construct as copy of SLList<T>
 template<class T>
-List<T>::List(const SLList<T>& sll)
+Foam::List<T>::List(const SLList<T>& sll)
 :
     UList<T>(NULL, sll.size())
 {
@@ -273,7 +278,7 @@ List<T>::List(const SLList<T>& sll)
 
 // Construct as copy of IndirectList<T>
 template<class T>
-List<T>::List(const IndirectList<T>& idl)
+Foam::List<T>::List(const IndirectList<T>& idl)
 :
     UList<T>(NULL, idl.size())
 {
@@ -295,7 +300,7 @@ List<T>::List(const IndirectList<T>& idl)
 
 // Construct as copy of BiIndirectList<T>
 template<class T>
-List<T>::List(const BiIndirectList<T>& idl)
+Foam::List<T>::List(const BiIndirectList<T>& idl)
 :
     UList<T>(NULL, idl.size())
 {
@@ -319,7 +324,7 @@ List<T>::List(const BiIndirectList<T>& idl)
 
 // Destroy list elements
 template<class T>
-List<T>::~List()
+Foam::List<T>::~List()
 {
     if (this->v_) delete[] this->v_;
 }
@@ -328,7 +333,7 @@ List<T>::~List()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class T>
-const List<T>& List<T>::null()
+const Foam::List<T>& Foam::List<T>::null()
 {
     List<T>* nullPtr = reinterpret_cast<List<T>*>(NULL);
     return *nullPtr;
@@ -336,7 +341,7 @@ const List<T>& List<T>::null()
 
 
 template<class T>
-void List<T>::setSize(const label newSize)
+void Foam::List<T>::setSize(const label newSize)
 {
     if (newSize < 0)
     {
@@ -382,7 +387,7 @@ void List<T>::setSize(const label newSize)
 
 
 template<class T>
-void List<T>::setSize(const label newSize, const T& a)
+void Foam::List<T>::setSize(const label newSize, const T& a)
 {
     label oldSize = this->size_;
     this->setSize(newSize);
@@ -397,7 +402,7 @@ void List<T>::setSize(const label newSize, const T& a)
 
 
 template<class T>
-void List<T>::clear()
+void Foam::List<T>::clear()
 {
     if (this->v_) delete[] this->v_;
     this->size_ = 0;
@@ -408,10 +413,9 @@ void List<T>::clear()
 // Transfer the contents of the argument List into this List
 // and anull the argument list
 template<class T>
-void List<T>::transfer(List<T>& a)
+void Foam::List<T>::transfer(List<T>& a)
 {
     if (this->v_) delete[] this->v_;
-
     this->size_ = a.size_;
     this->v_ = a.v_;
 
@@ -424,42 +428,41 @@ void List<T>::transfer(List<T>& a)
 // and anull the argument list
 template<class T>
 template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-void List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
+void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
 {
     if (this->v_) delete[] this->v_;
-
     this->size_ = a.size_;
     this->v_ = a.v_;
 
     a.size_ = 0;
-    a.allocSize_ = 0;
     a.v_ = 0;
+    a.allocSize_ = 0;
 }
 
 
 template<class T>
-void sort(List<T>& a)
+void Foam::sort(List<T>& a)
 {
     std::sort(a.begin(), a.end());
 }
 
 
 template<class T, class Cmp>
-void sort(List<T>& a, const Cmp& cmp)
+void Foam::sort(List<T>& a, const Cmp& cmp)
 {
     std::sort(a.begin(), a.end(), cmp);
 }
 
 
 template<class T>
-void stableSort(List<T>& a)
+void Foam::stableSort(List<T>& a)
 {
     std::stable_sort(a.begin(), a.end());
 }
 
 
 template<class T, class Cmp>
-void stableSort(List<T>& a, const Cmp& cmp)
+void Foam::stableSort(List<T>& a, const Cmp& cmp)
 {
     std::stable_sort(a.begin(), a.end(), cmp);
 }
@@ -469,7 +472,7 @@ void stableSort(List<T>& a, const Cmp& cmp)
 
 // Assignment to UList operator. Takes linear time.
 template<class T>
-void List<T>::operator=(const UList<T>& a)
+void Foam::List<T>::operator=(const UList<T>& a)
 {
     if (a.size_ != this->size_)
     {
@@ -501,7 +504,7 @@ void List<T>::operator=(const UList<T>& a)
 
 // Assignment operator. Takes linear time.
 template<class T>
-void List<T>::operator=(const List<T>& a)
+void Foam::List<T>::operator=(const List<T>& a)
 {
     if (this == &a)
     {
@@ -516,7 +519,7 @@ void List<T>::operator=(const List<T>& a)
 
 // Assignment operator. Takes linear time.
 template<class T>
-void List<T>::operator=(const SLList<T>& sll)
+void Foam::List<T>::operator=(const SLList<T>& sll)
 {
     if (sll.size() != this->size_)
     {
@@ -544,7 +547,7 @@ void List<T>::operator=(const SLList<T>& sll)
 
 // Assignment operator. Takes linear time.
 template<class T>
-void List<T>::operator=(const IndirectList<T>& idl)
+void Foam::List<T>::operator=(const IndirectList<T>& idl)
 {
     if (idl.size() != this->size_)
     {
@@ -566,7 +569,7 @@ void List<T>::operator=(const IndirectList<T>& idl)
 
 // Assignment operator. Takes linear time.
 template<class T>
-void List<T>::operator=(const BiIndirectList<T>& idl)
+void Foam::List<T>::operator=(const BiIndirectList<T>& idl)
 {
     if (idl.size() != this->size_)
     {
@@ -585,11 +588,6 @@ void List<T>::operator=(const BiIndirectList<T>& idl)
     }
 }
 
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // * * * * * * * * * * * * * * * *  IOStream operators * * * * * * * * * * * //
 
 #include "ListIO.C"
diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H
index 7269159ef7206dcc90a5494f0f77fbd6d79a0272..4f51878d454edac1b47e9a0ec5f48fa303a8a6b8 100644
--- a/src/OpenFOAM/containers/Lists/List/List.H
+++ b/src/OpenFOAM/containers/Lists/List/List.H
@@ -43,6 +43,7 @@ SourceFiles
 
 #include "UList.H"
 #include "autoPtr.H"
+#include "xfer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -77,6 +78,12 @@ class List
     public UList<T>
 {
 
+protected:
+
+    //- Override size to be inconsistent with allocated storage.
+    //  Use with care.
+    inline void size(const label);
+
 public:
 
     // Constructors
@@ -93,10 +100,13 @@ public:
         //- Copy constructor.
         List(const List<T>&);
 
+        //- Construct by transferring the parameter contents
+        List(const xfer<List<T> >&);
+
         //- Construct as copy or re-use as specified.
         List(List<T>&, bool reUse);
 
-        //- Construct given size and start and end iterators.
+        //- Construct given start and end iterators.
         template<class InputIterator>
         List(InputIterator first, InputIterator last);
 
@@ -166,11 +176,6 @@ public:
             //- Return subscript-checked element of UList.
             inline T& newElmt(const label);
 
-            //- Override size to be inconsistent with allocated storage.
-            //  Use with care.
-            inline label& size();
-
-
     // Member operators
 
         //- Assignment from UList operator. Takes linear time.
diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H
index d39b19f8841b615c99587f804e4223f665a3a129..4989e4f28e837804e008dee7cd7d0f204692a381 100644
--- a/src/OpenFOAM/containers/Lists/List/ListI.H
+++ b/src/OpenFOAM/containers/Lists/List/ListI.H
@@ -53,19 +53,18 @@ inline T& Foam::List<T>::newElmt(const label i)
 
 
 template<class T>
-inline Foam::label Foam::List<T>::size() const
+inline void Foam::List<T>::size(const label n)
 {
-    return UList<T>::size_;
+    UList<T>::size_ = n;
 }
 
 
 template<class T>
-inline Foam::label& Foam::List<T>::size()
+inline Foam::label Foam::List<T>::size() const
 {
     return UList<T>::size_;
 }
 
-
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 template<class T>
diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C
index dcbb8a469e12b90a0b84a2ba946a8cbb48825a3f..84364b6a4ce5e9354f370c7a8a208356228ef6dc 100644
--- a/src/OpenFOAM/containers/Lists/List/ListIO.C
+++ b/src/OpenFOAM/containers/Lists/List/ListIO.C
@@ -30,16 +30,11 @@ License
 #include "SLList.H"
 #include "contiguous.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
 // Construct from Istream
 template<class T>
-List<T>::List(Istream& is)
+Foam::List<T>::List(Istream& is)
 :
     UList<T>(NULL, 0)
 {
@@ -48,7 +43,7 @@ List<T>::List(Istream& is)
 
 
 template<class T>
-Istream& operator>>(Istream& is, List<T>& L)
+Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
 {
     // Anull list
     L.setSize(0);
@@ -161,9 +156,4 @@ Istream& operator>>(Istream& is, List<T>& L)
     return is;
 }
 
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
index 7c20b200b3e621a708d695e74f7eaa2f05a46964..23e72713bfe46f406f4723646e758d3b694a3aa9 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C
@@ -44,6 +44,7 @@ PackedList<nBits>::PackedList(const label size, const unsigned int val)
 }
 
 
+
 //- Copy constructor.
 template<int nBits>
 PackedList<nBits>::PackedList(const PackedList<nBits>& PList)
@@ -53,6 +54,13 @@ PackedList<nBits>::PackedList(const PackedList<nBits>& PList)
 {}
 
 
+template<int nBits>
+PackedList<nBits>::PackedList(const xfer<PackedList<nBits> >& lst)
+{
+    transfer(*lst);
+}
+
+
 //- Construct from labelList
 template<int nBits>
 PackedList<nBits>::PackedList(const labelList& lst)
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
index 5a966c6e681906d152de0b6d0e94b97b7215f739..c0e69950ac07784ebc3da208b409f2ac3218e96b 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
@@ -134,6 +134,9 @@ public:
         //- Copy constructor.
         PackedList(const PackedList<nBits>& PList);
 
+        //- Construct by transferring the parameter contents
+        PackedList(const xfer<PackedList<nBits> >&);
+
         //- Construct from labelList.
         PackedList(const labelList&);
 
diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.C b/src/OpenFOAM/containers/Lists/PtrList/PtrList.C
index 92caee45c3ceb17d5ab6ff77b16a98c585496168..68c5d613a0b8f641dde043e6af3e1b7452b5dd98 100644
--- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.C
+++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.C
@@ -71,6 +71,13 @@ Foam::PtrList<T>::PtrList(const PtrList<T>& a, const CloneArg& cloneArg)
 }
 
 
+template<class T>
+Foam::PtrList<T>::PtrList(const xfer<PtrList<T> >& lst)
+{
+    transfer(*lst);
+}
+
+
 template<class T>
 Foam::PtrList<T>::PtrList(PtrList<T>& a, bool reUse)
 :
diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
index 2a4ab2a46c5dc077eba64603d33576a9462816f8..fec6d3385cc6ee3823d3276c42228ce42e2e2965 100644
--- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
+++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H
@@ -129,6 +129,9 @@ public:
         template<class CloneArg>
         PtrList(const PtrList<T>&, const CloneArg&);
 
+        //- Construct by transferring the parameter contents
+        PtrList(const xfer<PtrList<T> >&);
+
         //- Construct as copy or re-use as specified.
         PtrList(PtrList<T>&, bool reUse);
 
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
index a4264578d1071c4ba0192b2c44106fce43b94746..1f3f53a165debf11a7b55bcc5849a0bfd478c3d4 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
@@ -40,6 +40,17 @@ Foam::SortableList<Type>::SortableList(const List<Type>& values)
     sort();
 }
 
+// Construct from List by transferring
+template <class Type>
+Foam::SortableList<Type>::SortableList(const xfer<List<Type> >& values)
+:
+    List<Type>(),
+    indices_((*values).size())
+{
+    List<Type>::transfer(*values);
+    sort();
+}
+
 
 // Construct given size. Sort later on.
 template <class Type>
@@ -86,7 +97,7 @@ void Foam::SortableList<Type>::sort()
         indices_[i] = i;
     }
 
-    //Foam::sort(indices_, less(*this));
+    // Foam::sort(indices_, less(*this));
     Foam::stableSort(indices_, less(*this));
 
     List<Type> tmpValues(this->size());
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
index dd0f0af0d43bb357b6059d572c97b22e2a306b68..1a5272e5b7823098dec984927c1ede3d23066286 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
@@ -29,6 +29,8 @@ Description
     A list that is sorted upon construction or when explicitly requested
     with the sort() method.
 
+    Uses the Foam::stableSort() algorithm.
+
 SourceFiles
     SortableList.C
 
@@ -84,10 +86,14 @@ public:
 
     // Constructors
 
-        //- Construct from List, sorting the elements. Starts with indices set
-        //  to index in argument
+        //- Construct from List, sorting the elements.
+        //  Starts with indices set to index in argument
         explicit SortableList(const List<Type>&);
 
+        //- Construct from tranferred List, sorting the elements.
+        //  Starts with indices set to index in argument
+        explicit SortableList(const xfer<List<Type> >&);
+
         //- Construct given size. Sort later on.
         explicit SortableList(const label size);
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C
index 24f824cd796d9cdc23802797030e3475d1a5db68..29816341630407321d6225f7373adc780a549d82 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListIO.C
+++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C
@@ -60,7 +60,7 @@ void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
 
 
 template<class T>
-Foam::Ostream& Foam:: operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
+Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
 {
     // Write list contents depending on data format
     if (os.format() == IOstream::ASCII || !contiguous<T>())
diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C
index 29089c4660163debb12d59b20a7046e413cdc012..8a2336922ca1ecb191be4dac509f1f3c664a58a1 100644
--- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C
+++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C
@@ -50,6 +50,13 @@ UPtrList<T>::UPtrList(const label s)
 {}
 
 
+template<class T>
+UPtrList<T>::UPtrList(const xfer<UPtrList<T> >& lst)
+{
+    transfer(*lst);
+}
+
+
 template<class T>
 UPtrList<T>::UPtrList(UPtrList<T>& a, bool reUse)
 :
diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
index 48c4715f457d153ba09e5d2aacf91aa0ed40a854..9cb7027a2db6bd3b0baa3e050e9cda272e4732c0 100644
--- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
+++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H
@@ -110,6 +110,9 @@ public:
         //- Construct with length specified.
         explicit UPtrList(const label);
 
+        //- Construct by transferring the parameter contents
+        UPtrList(const xfer<UPtrList<T> >&);
+
         //- Construct as copy or re-use as specified.
         UPtrList(UPtrList<T>&, bool reUse);
 
diff --git a/src/OpenFOAM/containers/misc/xfer.H b/src/OpenFOAM/containers/misc/xfer.H
new file mode 100644
index 0000000000000000000000000000000000000000..1a3ed752fa93f9d641236c8ac16bc830d088c7a6
--- /dev/null
+++ b/src/OpenFOAM/containers/misc/xfer.H
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::xfer
+
+Description
+    A simple container that can be used to copy or transfer the contents
+    of objects of type \<T\>.
+
+    Since it is decided upon construction of the xfer object whether the
+    parameter is to be copied or transferred, the contents of resulting
+    object can be transferred unconditionally.
+
+    This greatly simplifies defining the constructors for other classes
+    with mixed transfer/copy semantics.
+
+    The wrapped object of type \<T\> must implement a transfer() method and
+    an operator=() copy method.
+
+Note
+    The macros xferCopy(T,arg) and xferTmp(T,arg) can be used as workarounds
+    for passing temporaries to copy-constructors.
+
+SourceFiles
+    xferI.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef xfer_H
+#define xfer_H
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class xfer Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class T>
+class xfer
+{
+    // Private data
+
+        //- Pointer to temporary object
+        mutable T* ptr_;
+
+public:
+
+    // Constructors
+
+        //- Store object pointer and manage its deletion
+        //  Can also be used later to transfer by assignment
+        inline explicit xfer(T* = 0);
+
+        //- Construct by copying or by transferring the parameter contents
+        inline xfer(T&, bool allowTransfer=false);
+
+        //- Construct by copying the parameter contents
+        inline xfer(const T&);
+
+        //- Construct by transferring the contents
+        inline xfer(const xfer<T>&);
+
+    // Destructor
+
+        inline ~xfer();
+
+    // Member Operators
+
+        //- Transfer the contents into the object
+        inline void operator=(T&);
+
+        //- Transfer the contents into the object
+        inline void operator=(const xfer<T>&);
+
+        //- Return a non-const reference to const object
+        //  @sa xferTmp macro for an alternative for copy-constructors
+        inline const xfer<T>& operator()() const;
+
+        //- Reference to the underlying datatype
+        inline T& operator*() const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+/**
+ * @def xferCopy(T,arg)
+ * Construct by copying the contents of the @a arg
+ * and return a const reference to an xfer of type \<T\>
+ *
+ * Useful for constructors where the argument is temporary.
+ * This is a workaround for a template resolution issue.
+ *
+ * @sa xferTmp and Foam::xfer
+*/
+#define xferCopy(T,arg) \
+    (static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg)()))
+
+/**
+ * @def xferTmp(T,arg)
+ * Construct by transferring the contents of the @a arg
+ * and return a const reference to an xfer of type \<T\>
+ *
+ * Useful for constructors where the argument is temporary.
+ * This is a workaround for a template resolution issue.
+ *
+ * @par Example Use
+ * @code
+ *     List<label> a;
+ *     ...
+ *     List<label> b(xferTmp(List<label>, a));
+ * @endcode
+ *
+ * @sa xferCopy and Foam::xfer
+*/
+#define xferTmp(T,arg) \
+    (static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg, true)()))
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "xferI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/misc/xferI.H b/src/OpenFOAM/containers/misc/xferI.H
new file mode 100644
index 0000000000000000000000000000000000000000..8ad7ceb3aa13caf6267ec24513541f517745b975
--- /dev/null
+++ b/src/OpenFOAM/containers/misc/xferI.H
@@ -0,0 +1,113 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class T>
+inline Foam::xfer<T>::xfer(T* p)
+:
+    ptr_(p ? p : new T)
+{}
+
+
+template<class T>
+inline Foam::xfer<T>::xfer(T& t, bool allowTransfer)
+:
+    ptr_(new T)
+{
+    if (allowTransfer)
+    {
+        ptr_->transfer(t);
+    }
+    else
+    {
+        ptr_->operator=(t);
+    }
+}
+
+
+template<class T>
+inline Foam::xfer<T>::xfer(const T& t)
+:
+    ptr_(new T)
+{
+    ptr_->operator=(t);
+}
+
+
+template<class T>
+inline Foam::xfer<T>::xfer(const xfer<T>& t)
+:
+    ptr_(new T)
+{
+    ptr_->transfer(*(t.ptr_));
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+template<class T>
+inline Foam::xfer<T>::~xfer()
+{
+    delete ptr_;
+    ptr_ = 0;
+}
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+template<class T>
+inline void Foam::xfer<T>::operator=(T& t)
+{
+    ptr_->transfer(t);
+}
+
+
+template<class T>
+inline void Foam::xfer<T>::operator=(const xfer<T>& t)
+{
+    // silently ignore copy to self
+    if (this != &t)
+    {
+        ptr_->transfer(*(t.ptr_));
+    }
+}
+
+
+template<class T>
+inline const Foam::xfer<T>& Foam::xfer<T>::operator()() const
+{
+    return *this;
+}
+
+
+template<class T>
+inline T& Foam::xfer<T>::operator*() const
+{
+    return *ptr_;
+}
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C
index f0d3f8fd1ae85b726d6d295a4f35ca459bf21140..577494aa1cf435019fb43d7d770e5f511e31e987 100644
--- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C
+++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C
@@ -22,15 +22,31 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Description
-
 \*---------------------------------------------------------------------------*/
 
+#include "word.H"
 #include "Ostream.H"
 #include "token.H"
+#include "keyType.H"
+#include "IOstreams.H"
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+//- Write keyType
+Foam::Ostream& Foam::Ostream::write(const keyType& s)
+{
+    // Write as word?
+    if (s.isWildCard())
+    {
+        return write(static_cast<const string&>(s));
+    }
+    else
+    {
+        return write(static_cast<const word&>(s));
+    }
+}
+
+
 //- Decrememt the indent level
 void Foam::Ostream::decrIndent()
 {
@@ -47,7 +63,7 @@ void Foam::Ostream::decrIndent()
 
 
 // Write the keyword to the Ostream followed by appropriate indentation
-Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::word& keyword)
+Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::keyType& keyword)
 {
     indent();
     write(keyword);
diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
index bcd081df56d0a5076205a6d24804470d0938e67b..6dc7df259aef54ecbc44da928f4f99f0f89883f7 100644
--- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
+++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
@@ -35,6 +35,7 @@ Description
 #define Ostream_H
 
 #include "IOstream.H"
+#include "keyType.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -105,6 +106,9 @@ public:
             //- Write word
             virtual Ostream& write(const word&) = 0;
 
+            //- Write keyType
+            virtual Ostream& write(const keyType&);
+
             //- Write string
             virtual Ostream& write(const string&) = 0;
 
@@ -146,7 +150,7 @@ public:
 
             //- Write the keyword to the Ostream followed by
             //  appropriate indentation
-            Ostream& writeKeyword(const word& keyword);
+            Ostream& writeKeyword(const keyType& keyword);
 
 
         // Stream state functions
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C
index 6b078aa25dca55d736535cb4ef38caec678f57e5..7a1a680643c595b4a7b82b986d75f5cef35a4e86 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C
@@ -22,8 +22,6 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Description
-
 \*---------------------------------------------------------------------------*/
 
 #include "Pstream.H"
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index 8a38ff9ba24ca1092d4563f1ef62338eb5d0afa1..ad960e7405779f5cfb38063d6f246dbd84d7bc56 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -34,6 +34,72 @@ defineTypeNameAndDebug(Foam::dictionary, 0);
 
 const Foam::dictionary Foam::dictionary::null;
 
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+bool Foam::dictionary::findInWildcards
+(
+    const bool wildCardMatch,
+    const word& Keyword,
+    DLList<entry*>::const_iterator& wcLink,
+    DLList<autoPtr<regularExpression> >::const_iterator& reLink
+) const
+{
+    if (wildCardEntries_.size() > 0)
+    {
+        //wcLink = wildCardEntries_.begin();
+        //reLink = wildCardRegexps_.end();
+
+        while (wcLink != wildCardEntries_.end())
+        {
+            if (!wildCardMatch && wcLink()->keyword() == Keyword)
+            {
+                return true;
+            }
+            else if (wildCardMatch && reLink()->matches(Keyword))
+            {
+                return true;
+            }
+
+            ++reLink;
+            ++wcLink;
+        }
+    }
+
+    return false;
+}
+
+
+bool Foam::dictionary::findInWildcards
+(
+    const bool wildCardMatch,
+    const word& Keyword,
+    DLList<entry*>::iterator& wcLink,
+    DLList<autoPtr<regularExpression> >::iterator& reLink
+)
+{
+    if (wildCardEntries_.size() > 0)
+    {
+        while (wcLink != wildCardEntries_.end())
+        {
+            if (!wildCardMatch && wcLink()->keyword() == Keyword)
+            {
+                return true;
+            }
+            else if (wildCardMatch && reLink()->matches(Keyword))
+            {
+                return true;
+            }
+
+            ++reLink;
+            ++wcLink;
+        }
+    }
+
+    return false;
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::dictionary::dictionary()
@@ -60,6 +126,18 @@ Foam::dictionary::dictionary
     )
     {
         hashedEntries_.insert(iter().keyword(), &iter());
+
+        if (iter().keyword().isWildCard())
+        {
+            wildCardEntries_.insert(&iter());
+            wildCardRegexps_.insert
+            (
+                autoPtr<regularExpression>
+                (
+                    new regularExpression(iter().keyword())
+                )
+            );
+        }
     }
 }
 
@@ -81,6 +159,18 @@ Foam::dictionary::dictionary
     )
     {
         hashedEntries_.insert(iter().keyword(), &iter());
+
+        if (iter().keyword().isWildCard())
+        {
+            wildCardEntries_.insert(&iter());
+            wildCardRegexps_.insert
+            (
+                autoPtr<regularExpression>
+                (
+                    new regularExpression(iter().keyword())
+                )
+            );
+        }
     }
 }
 
@@ -133,13 +223,29 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
     {
         return true;
     }
-    else if (recursive && &parent_ != &dictionary::null)
-    {
-        return parent_.found(keyword, recursive);
-    }
     else
     {
-        return false;
+        if (wildCardEntries_.size() > 0)
+        {
+            DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
+            DLList<autoPtr<regularExpression> >::const_iterator reLink =
+                wildCardRegexps_.begin();
+
+            // Find in wildcards using regular expressions only
+            if (findInWildcards(true, keyword, wcLink, reLink))
+            {
+                return true;
+            }
+        }
+
+        if (recursive && &parent_ != &dictionary::null)
+        {
+            return parent_.found(keyword, recursive);
+        }
+        else
+        {
+            return false;
+        }
     }
 }
 
@@ -147,16 +253,31 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
 const Foam::entry* Foam::dictionary::lookupEntryPtr
 (
     const word& keyword,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 ) const
 {
     HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
 
     if (iter == hashedEntries_.end())
     {
+        if (wildCardMatch && wildCardEntries_.size() > 0)
+        {
+            DLList<entry*>::const_iterator wcLink =
+                wildCardEntries_.begin();
+            DLList<autoPtr<regularExpression> >::const_iterator reLink =
+                wildCardRegexps_.begin();
+
+            // Find in wildcards using regular expressions only
+            if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
+            {
+                return wcLink();
+            }
+        }
+
         if (recursive && &parent_ != &dictionary::null)
         {
-            return parent_.lookupEntryPtr(keyword, recursive);
+            return parent_.lookupEntryPtr(keyword, recursive, wildCardMatch);
         }
         else
         {
@@ -171,19 +292,34 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
 Foam::entry* Foam::dictionary::lookupEntryPtr
 (
     const word& keyword,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 )
 {
     HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
 
     if (iter == hashedEntries_.end())
     {
+        if (wildCardMatch && wildCardEntries_.size() > 0)
+        {
+            DLList<entry*>::iterator wcLink =
+                wildCardEntries_.begin();
+            DLList<autoPtr<regularExpression> >::iterator reLink =
+                wildCardRegexps_.begin();
+            // Find in wildcards using regular expressions only
+            if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
+            {
+                return wcLink();
+            }
+        }
+
         if (recursive && &parent_ != &dictionary::null)
         {
             return const_cast<dictionary&>(parent_).lookupEntryPtr
             (
                 keyword,
-                recursive
+                recursive,
+                wildCardMatch
             );
         }
         else
@@ -199,16 +335,17 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
 const Foam::entry& Foam::dictionary::lookupEntry
 (
     const word& keyword,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive);
+    const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
 
     if (entryPtr == NULL)
     {
         FatalIOErrorIn
         (
-            "dictionary::lookupEntry(const word& keyword) const",
+            "dictionary::lookupEntry(const word&, bool, bool) const",
             *this
         )   << "keyword " << keyword << " is undefined in dictionary "
             << name()
@@ -222,16 +359,18 @@ const Foam::entry& Foam::dictionary::lookupEntry
 Foam::ITstream& Foam::dictionary::lookup
 (
     const word& keyword,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 ) const
 {
-    return lookupEntry(keyword, recursive).stream();
+    return lookupEntry(keyword, recursive, wildCardMatch).stream();
 }
 
 
 bool Foam::dictionary::isDict(const word& keyword) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword);
+    // Find non-recursive with wildcards
+    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
 
     if (entryPtr)
     {
@@ -246,7 +385,7 @@ bool Foam::dictionary::isDict(const word& keyword) const
 
 const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword);
+    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
 
     if (entryPtr)
     {
@@ -261,7 +400,8 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
 
 const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword);
+    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
+
     if (entryPtr == NULL)
     {
         FatalIOErrorIn
@@ -278,7 +418,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 
 Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
 {
-    entry* entryPtr = lookupEntryPtr(keyword);
+    entry* entryPtr = lookupEntryPtr(keyword, false, true);
+
     if (entryPtr == NULL)
     {
         FatalIOErrorIn
@@ -314,7 +455,10 @@ Foam::wordList Foam::dictionary::toc() const
 
 bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
 {
-    HashTable<entry*>::iterator iter = hashedEntries_.find(entryPtr->keyword());
+    HashTable<entry*>::iterator iter = hashedEntries_.find
+    (
+        entryPtr->keyword()
+    );
 
     if (mergeEntry && iter != hashedEntries_.end())
     {
@@ -336,6 +480,19 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
             if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
             {
                 entryPtr->name() = name_ + "::" + entryPtr->keyword();
+
+                if (entryPtr->keyword().isWildCard())
+                {
+                    wildCardEntries_.insert(entryPtr);
+                    wildCardRegexps_.insert
+                    (
+                        autoPtr<regularExpression>
+                        (
+                            new regularExpression(entryPtr->keyword())
+                        )
+                    );
+                }
+
                 return true;
             }
             else
@@ -356,6 +513,18 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
         entryPtr->name() = name_ + "::" + entryPtr->keyword();
         IDLList<entry>::append(entryPtr);
 
+        if (entryPtr->keyword().isWildCard())
+        {
+            wildCardEntries_.insert(entryPtr);
+            wildCardRegexps_.insert
+            (
+                autoPtr<regularExpression>
+                (
+                    new regularExpression(entryPtr->keyword())
+                )
+            );
+        }
+
         return true;
     }
     else
@@ -376,27 +545,37 @@ void Foam::dictionary::add(const entry& e, bool mergeEntry)
     add(e.clone(*this).ptr(), mergeEntry);
 }
 
-void Foam::dictionary::add(const word& k, const word& w, bool overwrite)
+void Foam::dictionary::add(const keyType& k, const word& w, bool overwrite)
 {
     add(new primitiveEntry(k, token(w)), overwrite);
 }
 
-void Foam::dictionary::add(const word& k, const Foam::string& s, bool overwrite)
+void Foam::dictionary::add
+(
+    const keyType& k,
+    const Foam::string& s,
+    bool overwrite
+)
 {
     add(new primitiveEntry(k, token(s)), overwrite);
 }
 
-void Foam::dictionary::add(const word& k, const label l, bool overwrite)
+void Foam::dictionary::add(const keyType& k, const label l, bool overwrite)
 {
     add(new primitiveEntry(k, token(l)), overwrite);
 }
 
-void Foam::dictionary::add(const word& k, const scalar s, bool overwrite)
+void Foam::dictionary::add(const keyType& k, const scalar s, bool overwrite)
 {
     add(new primitiveEntry(k, token(s)), overwrite);
 }
 
-void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
+void Foam::dictionary::add
+(
+    const keyType& k,
+    const dictionary& d,
+    bool mergeEntry
+)
 {
     add(new dictionaryEntry(k, *this, d), mergeEntry);
 }
@@ -404,7 +583,7 @@ void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
 
 void Foam::dictionary::set(entry* entryPtr)
 {
-    entry* existingPtr = lookupEntryPtr(entryPtr->keyword());
+    entry* existingPtr = lookupEntryPtr(entryPtr->keyword(), false, true);
 
     // clear dictionary so merge acts like overwrite
     if (existingPtr && existingPtr->isDict())
@@ -420,7 +599,7 @@ void Foam::dictionary::set(const entry& e)
     set(e.clone(*this).ptr());
 }
 
-void Foam::dictionary::set(const word& k, const dictionary& d)
+void Foam::dictionary::set(const keyType& k, const dictionary& d)
 {
     set(new dictionaryEntry(k, *this, d));
 }
@@ -432,6 +611,19 @@ bool Foam::dictionary::remove(const word& Keyword)
 
     if (iter != hashedEntries_.end())
     {
+        // Delete from wildcards first
+        DLList<entry*>::iterator wcLink =
+            wildCardEntries_.begin();
+        DLList<autoPtr<regularExpression> >::iterator reLink =
+            wildCardRegexps_.begin();
+
+        // Find in wildcards using exact match only
+        if (findInWildcards(false, Keyword, wcLink, reLink))
+        {
+            wildCardEntries_.remove(wcLink);
+            wildCardRegexps_.remove(reLink);
+        }
+
         IDLList<entry>::remove(iter());
         delete iter();
         hashedEntries_.erase(iter);
@@ -447,8 +639,8 @@ bool Foam::dictionary::remove(const word& Keyword)
 
 bool Foam::dictionary::changeKeyword
 (
-    const word& oldKeyword,
-    const word& newKeyword,
+    const keyType& oldKeyword,
+    const keyType& newKeyword,
     bool forceOverwrite
 )
 {
@@ -466,6 +658,18 @@ bool Foam::dictionary::changeKeyword
         return false;
     }
 
+    if (iter()->keyword().isWildCard())
+    {
+        FatalErrorIn
+        (
+            "dictionary::changeKeyword(const word&, const word&, bool)"
+        )   << "Old keyword "<< oldKeyword
+            << " is a wildcard."
+            << "Wildcard replacement not yet implemented."
+            << exit(FatalError);
+    }
+
+
     HashTable<entry*>::iterator iter2 = hashedEntries_.find(newKeyword);
 
     // newKeyword already exists
@@ -473,14 +677,33 @@ bool Foam::dictionary::changeKeyword
     {
         if (forceOverwrite)
         {
+            if (iter2()->keyword().isWildCard())
+            {
+                // Delete from wildcards first
+                DLList<entry*>::iterator wcLink =
+                    wildCardEntries_.begin();
+                DLList<autoPtr<regularExpression> >::iterator reLink =
+                    wildCardRegexps_.begin();
+
+                // Find in wildcards using exact match only
+                if (findInWildcards(false, iter2()->keyword(), wcLink, reLink))
+                {
+                    wildCardEntries_.remove(wcLink);
+                    wildCardRegexps_.remove(reLink);
+                }
+            }
+
             IDLList<entry>::replace(iter2(), iter());
             delete iter2();
             hashedEntries_.erase(iter2);
+            
         }
         else
         {
-            WarningIn("dictionary::changeKeyword(const word&, const word&)")
-                << "cannot rename keyword "<< oldKeyword
+            WarningIn
+            (
+                "dictionary::changeKeyword(const word&, const word&, bool)"
+            )   << "cannot rename keyword "<< oldKeyword
                 << " to existing keyword " << newKeyword
                 << " in dictionary " << name() << endl;
             return false;
@@ -493,6 +716,18 @@ bool Foam::dictionary::changeKeyword
     hashedEntries_.erase(oldKeyword);
     hashedEntries_.insert(newKeyword, iter());
 
+    if (newKeyword.isWildCard())
+    {
+        wildCardEntries_.insert(iter());
+        wildCardRegexps_.insert
+        (
+            autoPtr<regularExpression>
+            (
+                new regularExpression(newKeyword)
+            )
+        );
+    }
+
     return true;
 }
 
@@ -579,6 +814,7 @@ void Foam::dictionary::operator=(const dictionary& dict)
 
     // Create clones of the entries in the given dictionary
     // resetting the parentDict to this dictionary
+
     for
     (
         IDLList<entry>::const_iterator iter = dict.begin();
@@ -586,17 +822,7 @@ void Foam::dictionary::operator=(const dictionary& dict)
         ++iter
     )
     {
-        IDLList<entry>::append(iter().clone(*this).ptr());
-    }
-
-    for
-    (
-        IDLList<entry>::iterator iter = begin();
-        iter != end();
-        ++iter
-    )
-    {
-        hashedEntries_.insert(iter().keyword(), &iter());
+        add(iter().clone(*this).ptr());
     }
 }
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index 05872cce61d82729ba4da8c3df60775b693de950..ac6ca6538968f56524931d0d6a84e2bf4c1f6370 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -27,7 +27,12 @@ Class
 
 Description
     A list of keyword definitions, which are a keyword followed by any number
-    of values (e.g. words and numbers).
+    of values (e.g. words and numbers). The keywords can represent wildcards
+    which are matched using Posix regular expressions. The general order for
+    searching is
+    - exact match
+    - wildcard match (in reverse order)
+    - optional recursion into subdictionaries
 
     The dictionary class is the base class for IOdictionary.
     It also serves as a bootstrap dictionary for the objectRegistry data
@@ -49,11 +54,13 @@ SourceFiles
 
 #include "entry.H"
 #include "IDLList.H"
+#include "DLList.H"
 #include "fileName.H"
 #include "ITstream.H"
 #include "HashTable.H"
 #include "wordList.H"
 #include "className.H"
+#include "regularExpression.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -80,12 +87,40 @@ class dictionary
         //- Dictionary name
         fileName name_;
 
-        //- HashTable of the enries held on the DL-list for quick lookup
+        //- HashTable of the entries held on the DL-list for quick lookup
         HashTable<entry*> hashedEntries_;
 
         //- Parent dictionary
         const dictionary& parent_;
 
+        //- Wildcard entries
+        DLList<entry*> wildCardEntries_;
+
+        //- Wildcard precompiled regex
+        DLList<autoPtr<regularExpression> > wildCardRegexps_;
+
+   // Private Member Functions
+
+        //- Search wildcard table either for exact match or for regular
+        //  expression match.
+        bool findInWildcards
+        (
+            const bool wildCardMatch,
+            const word& Keyword,
+            DLList<entry*>::const_iterator& wcLink,
+            DLList<autoPtr<regularExpression> >::const_iterator& reLink
+        ) const;
+
+        //- Search wildcard table either for exact match or for regular
+        //  expression match.
+        bool findInWildcards
+        (
+            const bool wildCardMatch,
+            const word& Keyword,
+            DLList<entry*>::iterator& wcLink,
+            DLList<autoPtr<regularExpression> >::iterator& reLink
+        );
+
 
 public:
 
@@ -181,24 +216,44 @@ public:
 
             //- Find and return an entry data stream pointer if present
             //  otherwise return NULL.
-            //  If recursive search parent dictionaries
+            //  If recursive search parent dictionaries. If wildCardMatch
+            //  use wildcards.
             const entry* lookupEntryPtr
             (
-                const word&, bool recursive=false
+                const word&,
+                bool recursive,
+                bool wildCardMatch
             ) const;
 
             //- Find and return an entry data stream pointer for manipulation
             //  if present otherwise return NULL.
-            //  If recursive search parent dictionaries
-            entry* lookupEntryPtr(const word&, bool recursive=false);
+            //  If recursive search parent dictionaries. If wildCardMatch
+            //  use wildcards.
+            entry* lookupEntryPtr
+            (
+                const word&,
+                bool recursive,
+                bool wildCardMatch
+            );
 
             //- Find and return an entry data stream if present otherwise error.
-            //  If recursive search parent dictionaries
-            const entry& lookupEntry(const word&, bool recursive=false) const;
+            //  If recursive search parent dictionaries. If wildCardMatch
+            //  use wildcards.
+            const entry& lookupEntry
+            (
+                const word&,
+                bool recursive,
+                bool wildCardMatch
+            ) const;
 
             //- Find and return an entry data stream
             //  If recursive search parent dictionaries
-            ITstream& lookup(const word&, bool recursive=false) const;
+            ITstream& lookup
+            (
+                const word&,
+                bool recursive=false,
+                bool wildCardMatch=true
+            ) const;
 
             //- Find and return a T,
             //  if not found return the given default value
@@ -208,7 +263,8 @@ public:
             (
                 const word&,
                 const T&,
-                bool recursive=false
+                bool recursive=false,
+                bool wildCardMatch=true
             ) const;
 
             //- Find and return a T, if not found return the given
@@ -219,7 +275,8 @@ public:
             (
                 const word&,
                 const T&,
-                bool recursive=false
+                bool recursive=false,
+                bool wildCardMatch=true
             );
 
             //- Find an entry if present, and assign to T
@@ -229,7 +286,8 @@ public:
             (
                 const word&,
                 T&,
-                bool recursive=false
+                bool recursive=false,
+                bool wildCardMatch=true
             ) const;
 
             //- Check if entry is a sub-dictionary
@@ -248,7 +306,6 @@ public:
             //- Return the table of contents
             wordList toc() const;
 
-
         // Editing
 
             //- Add a new entry
@@ -263,25 +320,25 @@ public:
 
             //- Add a word entry
             //  optionally overwrite an existing entry
-            void add(const word& keyword, const word&, bool overwrite=false);
+            void add(const keyType&, const word&, bool overwrite=false);
 
             //- Add a string entry
             //  optionally overwrite an existing entry
-            void add(const word& keyword, const string&, bool overwrite=false);
+            void add(const keyType&, const string&, bool overwrite=false);
 
             //- Add a label entry
             //  optionally overwrite an existing entry
-            void add(const word& keyword, const label, bool overwrite=false);
+            void add(const keyType&, const label, bool overwrite=false);
 
             //- Add a scalar entry
             //  optionally overwrite an existing entry
-            void add (const word& keyword, const scalar, bool overwrite=false);
+            void add (const keyType&, const scalar, bool overwrite=false);
 
             //- Add a dictionary entry
             //  optionally merge with an existing sub-dictionary
             void add
             (
-                const word& keyword,
+                const keyType& keyword,
                 const dictionary&,
                 bool mergeEntry=false
             );
@@ -289,7 +346,7 @@ public:
             //- Add a T entry
             //  optionally overwrite an existing entry
             template<class T>
-            void add(const word& keyword, const T&, bool overwrite=false);
+            void add(const keyType& keyword, const T&, bool overwrite=false);
 
             //- Assign a new entry, overwrite any existing entry
             void set(entry*);
@@ -298,11 +355,11 @@ public:
             void set(const entry&);
 
             //- Assign a dictionary entry, overwrite any existing entry
-            void set(const word& keyword, const dictionary&);
+            void set(const keyType& keyword, const dictionary&);
 
             //- Assign a T entry, overwrite any existing entry
             template<class T>
-            void set(const word& keyword, const T&);
+            void set(const keyType& keyword, const T&);
 
             //- Remove an entry specified by keyword
             bool remove(const word& keyword);
@@ -311,8 +368,8 @@ public:
             //  optionally forcing overwrite of an existing entry
             bool changeKeyword
             (
-                const word& oldKeyword,
-                const word& newKeyword,
+                const keyType& oldKeyword,
+                const keyType& newKeyword,
                 bool forceOverwrite = false
             );
 
@@ -361,11 +418,13 @@ public:
 
 // Global Operators
 
-//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
+//- Combine dictionaries starting from the entries in dict1 and then including
+//  those from dict2.
 //  Warn, but do not overwrite the entries from dict1.
 dictionary operator+(const dictionary& dict1, const dictionary& dict2);
 
-//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
+//- Combine dictionaries starting from the entries in dict1 and then including
+//  those from dict2.
 //  Do not overwrite the entries from dict1.
 dictionary operator|(const dictionary& dict1, const dictionary& dict2);
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
index 9beb835bcb0e301acc27c1fde181dc228ed7db80..6dea21250787246728b1e44c7e3d9d4ce5503278 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
@@ -30,7 +30,7 @@ License
 
 Foam::dictionaryEntry::dictionaryEntry
 (
-    const word& key,
+    const keyType& key,
     const dictionary& parentDict,
     const dictionary& dict
 )
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
index 2812c1b0bb47efcf73d4b08feaaf3d07bb0c4091..1909f4851ddc4bbdae66a9586965102ef613d7a9 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
@@ -79,7 +79,7 @@ public:
         //- Construct from the keyword, parent dictionary and a Istream
         dictionaryEntry
         (
-            const word& keyword,
+            const keyType& keyword,
             const dictionary& parentDict,
             Istream& is
         );
@@ -87,7 +87,7 @@ public:
         //- Construct from the keyword, parent dictionary and a dictionary
         dictionaryEntry
         (
-            const word& keyword,
+            const keyType& keyword,
             const dictionary& parentDict,
             const dictionary& dict
         );
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
index b6c2c2ebceecee7598b3948e7190d871375e8fb4..9cce3eb7de2879926bba9a9d7aa6de2767a3d11a 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
@@ -27,7 +27,9 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
+#include "keyType.H"
 #include "dictionaryEntry.H"
+#include "IOstreams.H"
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
@@ -43,14 +45,14 @@ Foam::dictionaryEntry::dictionaryEntry
     is.fatalCheck
     (
         "dictionaryEntry::dictionaryEntry"
-        "(Istream& is, const dictionary& parentDict)"
+        "(const dictionary& parentDict, Istream& is)"
     );
 }
 
 
 Foam::dictionaryEntry::dictionaryEntry
 (
-    const word& key,
+    const keyType& key,
     const dictionary& parentDict,
     Istream& is
 )
@@ -63,7 +65,7 @@ Foam::dictionaryEntry::dictionaryEntry
     is.fatalCheck
     (
         "dictionaryEntry::dictionaryEntry"
-        "(const word& keyword, const dictionary& parentDict, Istream& is)"
+        "(const keyType& keyword, const dictionary& parentDict, Istream& is)"
     );
 }
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C
index 53069af0b096b8c83624b3d7c2cb7618f51d9279..b1d5fbcbc452f760e8d7805a4764fdd0e7240fa2 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C
@@ -71,7 +71,7 @@ bool Foam::dictionary::substituteKeyword(const word& keyword)
     word varName = keyword(1, keyword.size()-1);
 
     // lookup the variable name in the given dictionary....
-    const entry* ePtr = lookupEntryPtr(varName, true);
+    const entry* ePtr = lookupEntryPtr(varName, true, true);
 
     // ...if defined insert its entries into this dictionary...
     if (ePtr != NULL)
@@ -137,6 +137,8 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
 
     dict.clear();
     dict.hashedEntries_.clear();
+    dict.wildCardEntries_.clear();
+    dict.wildCardRegexps_.clear();
     dict.read(is);
 
     return is;
diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
index 3dc32a7b51502641bba9b1410f4d5d3874084c0c..a47a97681472c2d47d42b035f7504c9171a5ffa7 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
@@ -34,10 +34,11 @@ T Foam::dictionary::lookupOrDefault
 (
     const word& keyword,
     const T& deflt,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive);
+    const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
 
     if (entryPtr == NULL)
     {
@@ -55,10 +56,11 @@ T Foam::dictionary::lookupOrAddDefault
 (
     const word& keyword,
     const T& deflt,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 )
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive);
+    const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
 
     if (entryPtr == NULL)
     {
@@ -77,10 +79,11 @@ bool Foam::dictionary::readIfPresent
 (
     const word& k,
     T& val,
-    bool recursive
+    bool recursive,
+    bool wildCardMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(k, recursive);
+    const entry* entryPtr = lookupEntryPtr(k, recursive, wildCardMatch);
 
     if (entryPtr == NULL)
     {
@@ -95,16 +98,17 @@ bool Foam::dictionary::readIfPresent
 
 
 template<class T>
-void Foam::dictionary::add(const word& k, const T& t, bool overwrite)
+void Foam::dictionary::add(const keyType& k, const T& t, bool overwrite)
 {
     add(new primitiveEntry(k, t), overwrite);
 }
 
 
 template<class T>
-void Foam::dictionary::set(const word& k, const T& t)
+void Foam::dictionary::set(const keyType& k, const T& t)
 {
     set(new primitiveEntry(k, t));
 }
 
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/entry/entry.C b/src/OpenFOAM/db/dictionary/entry/entry.C
index 93cf677b0b74304e24aa5dc5e56f9fe825422943..54581d869b38a8ff60b554ff445ffabebd5de00f 100644
--- a/src/OpenFOAM/db/dictionary/entry/entry.C
+++ b/src/OpenFOAM/db/dictionary/entry/entry.C
@@ -30,7 +30,7 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::entry::entry(const word& keyword)
+Foam::entry::entry(const keyType& keyword)
 :
     keyword_(keyword)
 {}
diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H
index 5afab95b5ad4e69083711f76b58ca404004d61e6..5ed8b929b6993d64db10a3ebce69047bdb83c64f 100644
--- a/src/OpenFOAM/db/dictionary/entry/entry.H
+++ b/src/OpenFOAM/db/dictionary/entry/entry.H
@@ -42,6 +42,7 @@ SourceFiles
 #ifndef entry_H
 #define entry_H
 
+#include "keyType.H"
 #include "IDLList.H"
 #include "fileName.H"
 #include "autoPtr.H"
@@ -70,13 +71,13 @@ class entry
     // Private data
 
         //- Keyword of entry
-        word keyword_;
+        keyType keyword_;
 
 
     // Private Member Functions
 
         //- Get the next valid keyword otherwise return false
-        static bool getKeyword(word& keyword, Istream& is);
+        static bool getKeyword(keyType& keyword, Istream& is);
 
 
 public:
@@ -84,7 +85,7 @@ public:
     // Constructors
 
         //- Construct from keyword
-        entry(const word& keyword);
+        entry(const keyType& keyword);
 
         //- Construct as copy
         entry(const entry&);
@@ -116,13 +117,13 @@ public:
     // Member functions
 
         //- Return keyword
-        const word& keyword() const
+        const keyType& keyword() const
         {
             return keyword_;
         }
 
         //- Return non-const access to keyword
-        word& keyword()
+        keyType& keyword()
         {
             return keyword_;
         }
diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C
index 830c21cf8a7cf759cc6b00a4c10b35a2e961b098..0142b302adcdfb272245bd4d17ab9121c1a7f456 100644
--- a/src/OpenFOAM/db/dictionary/entry/entryIO.C
+++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C
@@ -32,7 +32,7 @@ License
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-bool Foam::entry::getKeyword(word& keyword, Istream& is)
+bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
 {
     token keywordToken;
 
@@ -57,6 +57,12 @@ bool Foam::entry::getKeyword(word& keyword, Istream& is)
         keyword = keywordToken.wordToken();
         return true;
     }
+    else if (keywordToken.isString())
+    {
+        // Enable wildcards
+        keyword = keywordToken.stringToken();
+        return true;
+    }
     // If it is the end of the dictionary or file return false...
     else if (keywordToken == token::END_BLOCK || is.eof())
     {
@@ -67,7 +73,7 @@ bool Foam::entry::getKeyword(word& keyword, Istream& is)
     {
         cerr<< "--> FOAM Warning : " << std::endl
             << "    From function "
-            << "entry::getKeyword(word& keyword, Istream& is)" << std::endl
+            << "entry::getKeyword(keyType& keyword, Istream& is)" << std::endl
             << "    in file " << __FILE__
             << " at line " << __LINE__ << std::endl
             << "    Reading " << is.name().c_str() << std::endl
@@ -84,7 +90,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
 {
     is.fatalCheck("entry::New(const dictionary& parentDict, Istream& is)");
 
-    word keyword;
+    keyType keyword;
 
     // Get the next keyword and if invalid return false
     if (!getKeyword(keyword, is))
@@ -115,7 +121,13 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
             // Deal with duplicate entries
             bool mergeEntry = false;
 
-            entry* existingPtr = parentDict.lookupEntryPtr(keyword);
+            // See (using exact match) if entry already present
+            entry* existingPtr = parentDict.lookupEntryPtr
+            (
+                keyword,
+                false,
+                false
+            );
             if (existingPtr)
             {
                 if (functionEntries::inputModeEntry::overwrite())
@@ -158,7 +170,7 @@ Foam::autoPtr<Foam::entry> Foam::entry::New(Istream& is)
 {
     is.fatalCheck("entry::New(Istream& is)");
 
-    word keyword;
+    keyType keyword;
 
     // Get the next keyword and if invalid return false
     if (!getKeyword(keyword, is))
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
index df888cd064ae85cd61aea636b6dcf33180135fba..bc77cefef3e8afc2b15d334e19f305281eddd1fe 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
@@ -29,7 +29,7 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::primitiveEntry::primitiveEntry(const word& key, const ITstream& tokens)
+Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
 :
     entry(key),
     ITstream(tokens)
@@ -38,7 +38,7 @@ Foam::primitiveEntry::primitiveEntry(const word& key, const ITstream& tokens)
 }
 
 
-Foam::primitiveEntry::primitiveEntry(const word& keyword, const token& t)
+Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const token& t)
 :
     entry(keyword),
     ITstream(keyword, tokenList(1, t))
@@ -47,7 +47,7 @@ Foam::primitiveEntry::primitiveEntry(const word& keyword, const token& t)
 
 Foam::primitiveEntry::primitiveEntry
 (
-    const word& keyword,
+    const keyType& keyword,
     const tokenList& tokens
 )
 :
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
index b97452818a3091e457526664789d185871e3cbf3..86d8afd61daad8a3d4a1dce09fabd93fd0f1a75a 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
@@ -108,23 +108,23 @@ public:
     // Constructors
 
         //- Construct from keyword and a Istream
-        primitiveEntry(const word& keyword, Istream&);
+        primitiveEntry(const keyType& keyword, Istream&);
 
         //- Construct from keyword, parent dictionary and a Istream
-        primitiveEntry(const word& keyword, const dictionary&, Istream&);
+        primitiveEntry(const keyType& keyword, const dictionary&, Istream&);
 
         //- Construct from keyword and a ITstream
-        primitiveEntry(const word& keyword, const ITstream&);
+        primitiveEntry(const keyType& keyword, const ITstream&);
 
         //- Construct from keyword and a token
-        primitiveEntry(const word&, const token&);
+        primitiveEntry(const keyType&, const token&);
 
         //- Construct from keyword and a tokenList
-        primitiveEntry(const word&, const tokenList&);
+        primitiveEntry(const keyType&, const tokenList&);
 
         //- Construct from keyword and a T
         template<class T>
-        primitiveEntry(const word&, const T&);
+        primitiveEntry(const keyType&, const T&);
 
         autoPtr<entry> clone(const dictionary&) const
         {
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
index 10bc3c78c8b9bed0dffa1b947c085cfe9cf58bf1..58cf475303aa3babe486e87773d33311fdbc580d 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
@@ -81,7 +81,7 @@ bool Foam::primitiveEntry::expandVariable
     word varName = w(1, w.size()-1);
 
     // lookup the variable name in the given dictionary....
-    const entry* ePtr = dict.lookupEntryPtr(varName, true);
+    const entry* ePtr = dict.lookupEntryPtr(varName, true, true);
 
     // ...if defined insert its tokens into this 
     if (ePtr != NULL)
@@ -218,7 +218,7 @@ void Foam::primitiveEntry::readEntry(const dictionary& dict, Istream& is)
 
 Foam::primitiveEntry::primitiveEntry
 (
-    const word& key,
+    const keyType& key,
     const dictionary& dict,
     Istream& is
 )
@@ -236,7 +236,7 @@ Foam::primitiveEntry::primitiveEntry
 }
 
 
-Foam::primitiveEntry::primitiveEntry(const word& key, Istream& is)
+Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
 :
     entry(key),
     ITstream
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
index fce303173be1eb62ca1cf36e495ebdc4ea0c1d62..38e35b054ae4b5e42955ee5ccf6042e44daf9b20 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
@@ -30,7 +30,7 @@ License
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class T>
-Foam::primitiveEntry::primitiveEntry(const word& keyword, const T& t)
+Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const T& t)
 :
     entry(keyword),
     ITstream(keyword, tokenList(10))
diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H
index bb17ab6b0a779d59a41cb8971e6e69c024efd6dd..e360e8fd7a2ba4c5c0888b4bf4f2a5a8d9fa27b0 100644
--- a/src/OpenFOAM/db/regIOobject/regIOobject.H
+++ b/src/OpenFOAM/db/regIOobject/regIOobject.H
@@ -101,7 +101,7 @@ public:
         //- Construct as copy
         regIOobject(const regIOobject&);
 
-        //- Construct as copy, and transfering registry registration to copy
+        //- Construct as copy, and transferring registry registration to copy
         //  if registerCopy is true
         regIOobject(const regIOobject&, bool registerCopy);
 
diff --git a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C
new file mode 100644
index 0000000000000000000000000000000000000000..a31058eace5ac7e54e253eb04e562faeb2e849f0
--- /dev/null
+++ b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C
@@ -0,0 +1,100 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "DiagonalMatrix.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template<class Type>
+template<class Form>
+Foam::DiagonalMatrix<Type>::DiagonalMatrix(const Matrix<Form, Type>& a)
+:
+    List<Type>(min(a.n(), a.m()))
+{
+    forAll(*this, i)
+    {
+        this->operator[](i) = a[i][i];
+    }
+}
+
+
+template<class Type>
+Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label size)
+:
+    List<Type>(size)
+{}
+
+
+template<class Type>
+Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label size, const Type& val)
+:
+    List<Type>(size, val)
+{}
+
+
+template<class Type>
+Foam::DiagonalMatrix<Type>& Foam::DiagonalMatrix<Type>::invert()
+{
+    forAll(*this, i)
+    {
+        Type x = this->operator[](i);
+        if (mag(x) < VSMALL)
+        {
+            this->operator[](i) = Type(0);
+        }
+        else
+        {
+            this->operator[](i) = Type(1)/x;
+        }
+    }
+
+    return this;
+}
+
+
+template<class Type>
+Foam::DiagonalMatrix<Type> Foam::inv(const DiagonalMatrix<Type>& A)
+{
+    DiagonalMatrix<Type> Ainv = A;
+
+    forAll(A, i)
+    {
+        Type x = A[i];
+        if (mag(x) < VSMALL)
+        {
+            Ainv[i] = Type(0);
+        }
+        else
+        {
+            Ainv[i] = Type(1)/x;
+        }
+    }
+
+    return Ainv;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H
new file mode 100644
index 0000000000000000000000000000000000000000..ae8ceffc1c1d28510cd3f7167c3fea5e825c0bd4
--- /dev/null
+++ b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.H
@@ -0,0 +1,103 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::DiagonalMatrix<Type>
+
+Description
+    DiagonalMatrix<Type> is a 2D diagonal matrix of objects
+    of type Type, size nxn
+
+SourceFiles
+    DiagonalMatrix.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef DiagonalMatrix_H
+#define DiagonalMatrix_H
+
+#include "List.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * *  * * * * * * Class Forward declaration  * * * * * * * * * * * //
+
+template<class Form, class Type> class Matrix;
+
+/*---------------------------------------------------------------------------*\
+                           Class DiagonalMatrix Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class DiagonalMatrix
+:
+    public List<Type>
+{
+public:
+
+    // Constructors
+
+        //- Construct from diagonal component of a Matrix
+        template<class Form>
+        DiagonalMatrix<Type>(const Matrix<Form, Type>&);
+
+        //- Construct empty from size
+        DiagonalMatrix<Type>(const label size);
+
+        //- Construct from size and a value
+        DiagonalMatrix<Type>(const label, const Type&);
+
+
+    // Member functions
+
+        //- Invert the diaganol matrix and return itself
+        DiagonalMatrix<Type>& invert();
+};
+
+
+// Global functions
+
+//- Return the diagonal Matrix inverse
+template<class Type>
+DiagonalMatrix<Type> inv(const DiagonalMatrix<Type>&);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "DiagonalMatrix.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C
index 5de8693f2fe77f86791a7da1d6ee5b256bab522d..3e8fc3fe0f1a97af9f6d4bde61088518ee1f5011 100644
--- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C
+++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C
@@ -31,9 +31,9 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::LUscalarMatrix::LUscalarMatrix(const Matrix<scalar>& matrix)
+Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
 :
-    scalarMatrix(matrix),
+    scalarSquareMatrix(matrix),
     pivotIndices_(n())
 {
     LUDecompose(*this, pivotIndices_);
@@ -101,7 +101,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
                 nCells += lduMatrices[i].size();
             }
 
-            Matrix<scalar> m(nCells, nCells, 0.0);
+            scalarSquareMatrix m(nCells, nCells, 0.0);
             transfer(m);
             convert(lduMatrices);
         }
@@ -109,7 +109,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
     else
     {
         label nCells = ldum.lduAddr().size();
-        Matrix<scalar> m(nCells, nCells, 0.0);
+        scalarSquareMatrix m(nCells, nCells, 0.0);
         transfer(m);
         convert(ldum, interfaceCoeffs, interfaces);
     }
diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.H b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.H
index d5e79faf19392f5e23aec9b2f61313a8a1399ff1..2255cee236ca57bc5abd577bae299a06c8b312a9 100644
--- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.H
+++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.H
@@ -36,7 +36,7 @@ SourceFiles
 #ifndef LUscalarMatrix_H
 #define LUscalarMatrix_H
 
-#include "scalarMatrix.H"
+#include "scalarMatrices.H"
 #include "labelList.H"
 #include "FieldField.H"
 #include "lduInterfaceFieldPtrsList.H"
@@ -55,7 +55,7 @@ class procLduMatrix;
 
 class LUscalarMatrix
 :
-    public scalarMatrix
+    public scalarSquareMatrix
 {
     // Private data
 
@@ -78,7 +78,7 @@ class LUscalarMatrix
         void convert(const PtrList<procLduMatrix>& lduMatrices);
 
 
-        //- Print the ratio of the mag-sum of the off-diagonal coefficients 
+        //- Print the ratio of the mag-sum of the off-diagonal coefficients
         //  to the mag-diagonal
         void printDiagonalDominance() const;
 
@@ -87,8 +87,8 @@ public:
 
     // Constructors
 
-        //- Construct from Matrix<scalar> and perform LU decomposition
-        LUscalarMatrix(const Matrix<scalar>&);
+        //- Construct from scalarSquareMatrix and perform LU decomposition
+        LUscalarMatrix(const scalarSquareMatrix&);
 
         //- Construct from lduMatrix and perform LU decomposition
         LUscalarMatrix
diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C
index cbb59e2c8645ff7531331841b6e94c10b3658c50..ac0bc17207e641ade545c7fe2bac07524c9127f3 100644
--- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C
+++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C
@@ -28,16 +28,16 @@ License
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T>
-void Foam::LUscalarMatrix::solve(Field<T>& sourceSol) const
+template<class Type>
+void Foam::LUscalarMatrix::solve(Field<Type>& sourceSol) const
 {
     if (Pstream::parRun())
     {
-        Field<T> completeSourceSol(n());
+        Field<Type> completeSourceSol(n());
 
         if (Pstream::master())
         {
-            typename Field<T>::subField
+            typename Field<Type>::subField
             (
                 completeSourceSol,
                 sourceSol.size()
@@ -58,7 +58,7 @@ void Foam::LUscalarMatrix::solve(Field<T>& sourceSol) const
                     (
                         &(completeSourceSol[procOffsets_[slave]])
                     ),
-                    (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(T)
+                    (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(Type)
                 );
             }
         }
@@ -77,7 +77,7 @@ void Foam::LUscalarMatrix::solve(Field<T>& sourceSol) const
         {
             LUBacksubstitute(*this, pivotIndices_, completeSourceSol);
 
-            sourceSol = typename Field<T>::subField
+            sourceSol = typename Field<Type>::subField
             (
                 completeSourceSol,
                 sourceSol.size()
@@ -98,7 +98,7 @@ void Foam::LUscalarMatrix::solve(Field<T>& sourceSol) const
                     (
                         &(completeSourceSol[procOffsets_[slave]])
                     ),
-                    (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(T)
+                    (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(Type)
                 );
             }
         }
diff --git a/src/OpenFOAM/containers/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C
similarity index 59%
rename from src/OpenFOAM/containers/Matrix/Matrix.C
rename to src/OpenFOAM/matrices/Matrix/Matrix.C
index 733e04034ef5332731e8395db787abcdcd439e71..577cbcabcb9efc15dd9a9563bfd10df0866efcd2 100644
--- a/src/OpenFOAM/containers/Matrix/Matrix.C
+++ b/src/OpenFOAM/matrices/Matrix/Matrix.C
@@ -28,13 +28,13 @@ License
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
-template<class T>
-void Foam::Matrix<T>::allocate()
+template<class Form, class Type>
+void Foam::Matrix<Form, Type>::allocate()
 {
     if (n_ && m_)
     {
-        v_ = new T*[n_];
-        v_[0] = new T[n_*m_];
+        v_ = new Type*[n_];
+        v_[0] = new Type[n_*m_];
 
         for (register label i=1; i<n_; i++)
         {
@@ -46,12 +46,12 @@ void Foam::Matrix<T>::allocate()
 
 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
 
-template<class T>
-Foam::Matrix<T>::~Matrix()
+template<class Form, class Type>
+Foam::Matrix<Form, Type>::~Matrix()
 {
     if (v_)
     {
-		delete[] (v_[0]);
+        delete[] (v_[0]);
         delete[] v_;
     }
 }
@@ -59,16 +59,16 @@ Foam::Matrix<T>::~Matrix()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T>
-const Foam::Matrix<T>& Foam::Matrix<T>::null()
+template<class Form, class Type>
+const Foam::Matrix<Form, Type>& Foam::Matrix<Form, Type>::null()
 {
-    Matrix<T>* nullPtr = reinterpret_cast<Matrix<T>*>(NULL);
+    Matrix<Form, Type>* nullPtr = reinterpret_cast<Matrix<Form, Type>*>(NULL);
     return *nullPtr;
 }
 
 
-template<class T>
-Foam::Matrix<T>::Matrix(const label n, const label m)
+template<class Form, class Type>
+Foam::Matrix<Form, Type>::Matrix(const label n, const label m)
 :
     n_(n),
     m_(m),
@@ -76,7 +76,7 @@ Foam::Matrix<T>::Matrix(const label n, const label m)
 {
     if (n_ < 0 || m_ < 0)
     {
-        FatalErrorIn("Matrix<T>::Matrix(const label n, const label m)")
+        FatalErrorIn("Matrix<Form, Type>::Matrix(const label n, const label m)")
             << "bad n, m " << n_ << ", " << m_
             << abort(FatalError);
     }
@@ -85,8 +85,8 @@ Foam::Matrix<T>::Matrix(const label n, const label m)
 }
 
 
-template<class T>
-Foam::Matrix<T>::Matrix(const label n, const label m, const T& a)
+template<class Form, class Type>
+Foam::Matrix<Form, Type>::Matrix(const label n, const label m, const Type& a)
 :
     n_(n),
     m_(m),
@@ -96,7 +96,7 @@ Foam::Matrix<T>::Matrix(const label n, const label m, const T& a)
     {
         FatalErrorIn
         (
-            "Matrix<T>::Matrix(const label n, const label m, const T&)"
+            "Matrix<Form, Type>::Matrix(const label n, const label m, const T&)"
         )   << "bad n, m " << n_ << ", " << m_
             << abort(FatalError);
     }
@@ -105,7 +105,7 @@ Foam::Matrix<T>::Matrix(const label n, const label m, const T& a)
 
     if (v_)
     {
-        T* v = v_[0];
+        Type* v = v_[0];
 
         label nm = n_*m_;
 
@@ -117,8 +117,8 @@ Foam::Matrix<T>::Matrix(const label n, const label m, const T& a)
 }
 
 
-template<class T>
-Foam::Matrix<T>::Matrix(const Matrix<T>& a)
+template<class Form, class Type>
+Foam::Matrix<Form, Type>::Matrix(const Matrix<Form, Type>& a)
 :
     n_(a.n_),
     m_(a.m_),
@@ -127,8 +127,8 @@ Foam::Matrix<T>::Matrix(const Matrix<T>& a)
     if (a.v_)
     {
         allocate();
-        T* v = v_[0];
-        const T* av = a.v_[0];
+        Type* v = v_[0];
+        const Type* av = a.v_[0];
 
         label nm = n_*m_;
         for (register label i=0; i<nm; i++)
@@ -138,13 +138,13 @@ Foam::Matrix<T>::Matrix(const Matrix<T>& a)
     }
 }
 
-        
-template<class T>
-void Foam::Matrix<T>::clear()
+
+template<class Form, class Type>
+void Foam::Matrix<Form, Type>::clear()
 {
     if (v_)
     {
-		delete[] (v_[0]);
+        delete[] (v_[0]);
         delete[] v_;
     }
     n_ = 0;
@@ -153,8 +153,8 @@ void Foam::Matrix<T>::clear()
 }
 
 
-template<class T>
-void Foam::Matrix<T>::transfer(Matrix<T>& a)
+template<class Form, class Type>
+void Foam::Matrix<Form, Type>::transfer(Matrix<Form, Type>& a)
 {
     clear();
 
@@ -169,14 +169,32 @@ void Foam::Matrix<T>::transfer(Matrix<T>& a)
 }
 
 
+template<class Form, class Type>
+Form Foam::Matrix<Form, Type>::T() const
+{
+    const Matrix<Form, Type>& A = *this;
+    Form At(m(), n());
+
+    for (register label i=0; i<n(); i++)
+    {
+        for (register label j=0; j<m(); j++)
+        {
+            At[j][i] = A[i][j];
+        }
+    }
+
+    return At;
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-template<class T>
-void Foam::Matrix<T>::operator=(const T& t)
+template<class Form, class Type>
+void Foam::Matrix<Form, Type>::operator=(const Type& t)
 {
     if (v_)
     {
-        T* v = v_[0];
+        Type* v = v_[0];
 
         label nm = n_*m_;
         for (register label i=0; i<nm; i++)
@@ -188,12 +206,12 @@ void Foam::Matrix<T>::operator=(const T& t)
 
 
 // Assignment operator. Takes linear time.
-template<class T>
-void Foam::Matrix<T>::operator=(const Matrix<T>& a)
+template<class Form, class Type>
+void Foam::Matrix<Form, Type>::operator=(const Matrix<Form, Type>& a)
 {
     if (this == &a)
     {
-        FatalErrorIn("Matrix<T>::operator=(const Matrix<T>&)")
+        FatalErrorIn("Matrix<Form, Type>::operator=(const Matrix<Form, Type>&)")
             << "attempted assignment to self"
             << abort(FatalError);
     }
@@ -204,12 +222,12 @@ void Foam::Matrix<T>::operator=(const Matrix<T>& a)
         n_ = a.n_;
         m_ = a.m_;
         allocate();
-    } 
+    }
 
     if (v_)
     {
-        T* v = v_[0];
-        const T* av = a.v_[0];
+        Type* v = v_[0];
+        const Type* av = a.v_[0];
 
         label nm = n_*m_;
         for (register label i=0; i<nm; i++)
@@ -222,15 +240,15 @@ void Foam::Matrix<T>::operator=(const Matrix<T>& a)
 
 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
-template<class T>
-const T& Foam::max(const Matrix<T>& a)
+template<class Form, class Type>
+const Type& Foam::max(const Matrix<Form, Type>& a)
 {
     label nm = a.n_*a.m_;
 
     if (nm)
     {
         label curMaxI = 0;
-        const T* v = a.v_[0];
+        const Type* v = a.v_[0];
 
         for (register label i=1; i<nm; i++)
         {
@@ -244,7 +262,7 @@ const T& Foam::max(const Matrix<T>& a)
     }
     else
     {
-        FatalErrorIn("max(const Matrix<T>&)")
+        FatalErrorIn("max(const Matrix<Form, Type>&)")
             << "matrix is empty"
             << abort(FatalError);
 
@@ -254,15 +272,15 @@ const T& Foam::max(const Matrix<T>& a)
 }
 
 
-template<class T>
-const T& Foam::min(const Matrix<T>& a)
+template<class Form, class Type>
+const Type& Foam::min(const Matrix<Form, Type>& a)
 {
     label nm = a.n_*a.m_;
 
     if (nm)
     {
         label curMinI = 0;
-        const T* v = a.v_[0];
+        const Type* v = a.v_[0];
 
         for (register label i=1; i<nm; i++)
         {
@@ -276,7 +294,7 @@ const T& Foam::min(const Matrix<T>& a)
     }
     else
     {
-        FatalErrorIn("min(const Matrix<T>&)")
+        FatalErrorIn("min(const Matrix<Form, Type>&)")
             << "matrix is empty"
             << abort(FatalError);
 
@@ -288,15 +306,15 @@ const T& Foam::min(const Matrix<T>& a)
 
 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
 
-template<class T>
-Foam::Matrix<T> Foam::operator-(const Matrix<T>& a)
+template<class Form, class Type>
+Form Foam::operator-(const Matrix<Form, Type>& a)
 {
-    Matrix<T> na(a.n_, a.m_);
+    Form na(a.n_, a.m_);
 
     if (a.n_ && a.m_)
     {
-        T* nav = na.v_[0];
-        const T* av = a.v_[0];
+        Type* nav = na.v_[0];
+        const Type* av = a.v_[0];
 
         label nm = a.n_*a.m_;
         for (register label i=0; i<nm; i++)
@@ -309,30 +327,34 @@ Foam::Matrix<T> Foam::operator-(const Matrix<T>& a)
 }
 
 
-template<class T>
-Foam::Matrix<T> Foam::operator+(const Matrix<T>& a, const Matrix<T>& b)
+template<class Form, class Type>
+Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
 {
     if (a.n_ != b.n_)
     {
-        FatalErrorIn("Matrix<T>::operator+(const Matrix<T>&, const Matrix<T>&)")
-            << "attempted add matrices with different number of rows: "
+        FatalErrorIn
+        (
+            "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
+        )   << "attempted add matrices with different number of rows: "
             << a.n_ << ", " << b.n_
             << abort(FatalError);
     }
 
     if (a.m_ != b.m_)
     {
-        FatalErrorIn("Matrix<T>::operator+(const Matrix<T>&, const Matrix<T>&)")
-            << "attempted add matrices with different number of columns: "
+        FatalErrorIn
+        (
+            "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
+        )   << "attempted add matrices with different number of columns: "
             << a.m_ << ", " << b.m_
             << abort(FatalError);
     }
 
-    Matrix<T> ab(a.n_, a.m_);
+    Form ab(a.n_, a.m_);
 
-    T* abv = ab.v_[0];
-    const T* av = a.v_[0];
-    const T* bv = b.v_[0];
+    Type* abv = ab.v_[0];
+    const Type* av = a.v_[0];
+    const Type* bv = b.v_[0];
 
     label nm = a.n_*a.m_;;
     for (register label i=0; i<nm; i++)
@@ -344,30 +366,34 @@ Foam::Matrix<T> Foam::operator+(const Matrix<T>& a, const Matrix<T>& b)
 }
 
 
-template<class T>
-Foam::Matrix<T> Foam::operator-(const Matrix<T>& a, const Matrix<T>& b)
+template<class Form, class Type>
+Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
 {
     if (a.n_ != b.n_)
     {
-        FatalErrorIn("Matrix<T>::operator-(const Matrix<T>&, const Matrix<T>&)")
-            << "attempted add matrices with different number of rows: "
+        FatalErrorIn
+        (
+            "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
+        )   << "attempted add matrices with different number of rows: "
             << a.n_ << ", " << b.n_
             << abort(FatalError);
     }
 
     if (a.m_ != b.m_)
     {
-        FatalErrorIn("Matrix<T>::operator-(const Matrix<T>&, const Matrix<T>&)")
-            << "attempted add matrices with different number of columns: "
+        FatalErrorIn
+        (
+            "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
+        )   << "attempted add matrices with different number of columns: "
             << a.m_ << ", " << b.m_
             << abort(FatalError);
     }
 
-    Matrix<T> ab(a.n_, a.m_);
+    Form ab(a.n_, a.m_);
 
-    T* abv = ab.v_[0];
-    const T* av = a.v_[0];
-    const T* bv = b.v_[0];
+    Type* abv = ab.v_[0];
+    const Type* av = a.v_[0];
+    const Type* bv = b.v_[0];
 
     label nm = a.n_*a.m_;;
     for (register label i=0; i<nm; i++)
@@ -379,17 +405,17 @@ Foam::Matrix<T> Foam::operator-(const Matrix<T>& a, const Matrix<T>& b)
 }
 
 
-template<class T>
-Foam::Matrix<T> Foam::operator*(const scalar s, const Matrix<T>& a)
+template<class Form, class Type>
+Form Foam::operator*(const scalar s, const Matrix<Form, Type>& a)
 {
-    Matrix<T> sa(a.n_, a.m_);
+    Form sa(a.n_, a.m_);
 
     if (a.n_ && a.m_)
     {
-        T* sav = sa.v_[0];
-        const T* av = a.v_[0];
+        Type* sav = sa.v_[0];
+        const Type* av = a.v_[0];
 
-        label nm = a.n_*a.m_;;
+        label nm = a.n_*a.m_;
         for (register label i=0; i<nm; i++)
         {
             sav[i] = s*av[i];
diff --git a/src/OpenFOAM/containers/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H
similarity index 73%
rename from src/OpenFOAM/containers/Matrix/Matrix.H
rename to src/OpenFOAM/matrices/Matrix/Matrix.H
index ab68ce5badb0a9acad85b13ef311f3aaf66c1b38..7c63e6d53041d30a2f6eeb7549b42926be6faf63 100644
--- a/src/OpenFOAM/containers/Matrix/Matrix.H
+++ b/src/OpenFOAM/matrices/Matrix/Matrix.H
@@ -51,25 +51,26 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 
-template<class T> class Matrix;
+template<class Form, class Type> class Matrix;
 
-template<class T> const T& max(const Matrix<T>&);
-template<class T> const T& min(const Matrix<T>&);
+template<class Form, class Type> Istream& operator>>
+(
+    Istream&,
+    Matrix<Form, Type>&
+);
 
-template<class T> Matrix<T> operator-(const Matrix<T>&);
-template<class T> Matrix<T> operator+(const Matrix<T>&, const Matrix<T>&);
-template<class T> Matrix<T> operator-(const Matrix<T>&, const Matrix<T>&);
-template<class T> Matrix<T> operator*(const scalar, const Matrix<T>&);
-
-template<class T> Istream& operator>>(Istream&, Matrix<T>&);
-template<class T> Ostream& operator<<(Ostream&, const Matrix<T>&);
+template<class Form, class Type> Ostream& operator<<
+(
+    Ostream&,
+    const Matrix<Form, Type>&
+);
 
 
 /*---------------------------------------------------------------------------*\
                            Class Matrix Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class T>
+template<class Form, class Type>
 class Matrix
 {
     // Private data
@@ -78,7 +79,7 @@ class Matrix
         label n_, m_;
 
         //- Row pointers
-        T** __restrict__ v_;
+        Type** __restrict__ v_;
 
         //- Allocate the storage for the row-pointers and the data
         //  and set the row pointers
@@ -97,16 +98,16 @@ public:
 
         //- Construct with given number of rows and columns
         //  and value for all elements.
-        Matrix(const label n, const label m, const T&);
+        Matrix(const label n, const label m, const Type&);
 
         //- Copy constructor.
-        Matrix(const Matrix<T>&);
+        Matrix(const Matrix<Form, Type>&);
 
         //- Construct from Istream.
         Matrix(Istream&);
 
         //- Clone
-        inline autoPtr<Matrix<T> > clone() const;
+        inline autoPtr<Matrix<Form, Type> > clone() const;
 
 
     // Destructor
@@ -117,7 +118,7 @@ public:
     // Member functions
 
         //- Return a null Matrix
-        static const Matrix<T>& null();
+        static const Matrix<Form, Type>& null();
 
 
         // Access
@@ -148,46 +149,62 @@ public:
 
             //- Transfer the contents of the argument Matrix into this Matrix
             //  and annull the argument Matrix.
-            void transfer(Matrix<T>&);
+            void transfer(Matrix<Form, Type>&);
+
+
+        //- Return the transpose of the matrix
+        Form T() const;
 
 
     // Member operators
 
         //- Return subscript-checked element of Matrix.
-        inline T* operator[](const label);
+        inline Type* operator[](const label);
 
         //- Return subscript-checked element of constant Matrix.
-        inline const T* operator[](const label) const;
+        inline const Type* operator[](const label) const;
 
         //- Assignment operator. Takes linear time.
-        void operator=(const Matrix<T>&);
+        void operator=(const Matrix<Form, Type>&);
 
         //- Assignment of all entries to the given value
-        void operator=(const T&);
+        void operator=(const Type&);
 
 
-    // Friend functions
+    // IOstream operators
+
+        //- Read Matrix from Istream, discarding contents of existing Matrix.
+        friend Istream& operator>> <Form, Type>(Istream&, Matrix<Form, Type>&);
 
-        friend const T& max<T>(const Matrix<T>&);
-        friend const T& min<T>(const Matrix<T>&);
+        // Write Matrix to Ostream.
+        friend Ostream& operator<< <Form, Type>(Ostream&, const Matrix<Form, Type>&);
+};
 
 
-    // Friend operators
+// Global functions and operators
 
-        friend Matrix<T> operator-<T>(const Matrix<T>&);
-        friend Matrix<T> operator+<T>(const Matrix<T>&, const Matrix<T>&);
-        friend Matrix<T> operator-<T>(const Matrix<T>&, const Matrix<T>&);
-        friend Matrix<T> operator*<T>(const scalar, const Matrix<T>&);
+template<class Form, class Type> const Type& max(const Matrix<Form, Type>&);
+template<class Form, class Type> const Type& min(const Matrix<Form, Type>&);
 
+template<class Form, class Type> Form operator-(const Matrix<Form, Type>&);
 
-    // IOstream operators
+template<class Form, class Type> Form operator+
+(
+    const Matrix<Form, Type>&,
+    const Matrix<Form, Type>&
+);
 
-        //- Read Matrix from Istream, discarding contents of existing Matrix.
-        friend Istream& operator>> <T>(Istream&, Matrix<T>&);
+template<class Form, class Type> Form operator-
+(
+    const Matrix<Form, Type>&,
+    const Matrix<Form, Type>&
+);
 
-        // Write Matrix to Ostream.
-        friend Ostream& operator<< <T>(Ostream&, const Matrix<T>&);
-};
+template<class Form, class Type> Form operator*
+(
+    const scalar,
+    const Matrix<Form, Type>&
+);
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/containers/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H
similarity index 66%
rename from src/OpenFOAM/containers/Matrix/MatrixI.H
rename to src/OpenFOAM/matrices/Matrix/MatrixI.H
index d0e3fe8fdf36f457bd12336003d4e2659480470e..8d758cf5b168c6f07efba5ef9904fbeb350d8de7 100644
--- a/src/OpenFOAM/containers/Matrix/MatrixI.H
+++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H
@@ -26,8 +26,8 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class T>
-inline Foam::Matrix<T>::Matrix()
+template<class Form, class Type>
+inline Foam::Matrix<Form, Type>::Matrix()
 :
     n_(0),
     m_(0),
@@ -35,71 +35,67 @@ inline Foam::Matrix<T>::Matrix()
 {}
 
 
-template<class T>
-inline Foam::autoPtr<Foam::Matrix<T> > Foam::Matrix<T>::clone() const
+template<class Form, class Type>
+inline Foam::autoPtr<Foam::Matrix<Form, Type> > Foam::Matrix<Form, Type>::clone() const
 {
-    return autoPtr<Matrix<T> >(new Matrix<T>(*this));
+    return autoPtr<Matrix<Form, Type> >(new Matrix<Form, Type>(*this));
 }
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 //- Return the number of rows
-template<class T>
-inline Foam::label Foam::Matrix<T>::n() const
+template<class Form, class Type>
+inline Foam::label Foam::Matrix<Form, Type>::n() const
 {
     return n_;
 }
 
 
-//- Return the number of columns
-template<class T>
-inline Foam::label Foam::Matrix<T>::m() const
+template<class Form, class Type>
+inline Foam::label Foam::Matrix<Form, Type>::m() const
 {
     return m_;
 }
 
 
-//- Return the number of columns
-template<class T>
-inline Foam::label Foam::Matrix<T>::size() const
+template<class Form, class Type>
+inline Foam::label Foam::Matrix<Form, Type>::size() const
 {
     return n_*m_;
 }
 
 
-// Check index i is within valid range (0 ... n-1).
-template<class T>
-inline void Foam::Matrix<T>::checki(const label i) const
+template<class Form, class Type>
+inline void Foam::Matrix<Form, Type>::checki(const label i) const
 {
     if (!n_)
     {
-        FatalErrorIn("Matrix<T>::checki(const label)")
+        FatalErrorIn("Matrix<Form, Type>::checki(const label)")
             << "attempt to access element from zero sized row"
             << abort(FatalError);
     }
     else if (i<0 || i>=n_)
     {
-        FatalErrorIn("Matrix<T>::checki(const label)")
+        FatalErrorIn("Matrix<Form, Type>::checki(const label)")
             << "index " << i << " out of range 0 ... " << n_-1
             << abort(FatalError);
     }
 }
 
 
-// Check index j is within valid range (0 ... n-1).
-template<class T>
-inline void Foam::Matrix<T>::checkj(const label j) const
+template<class Form, class Type>
+inline void Foam::Matrix<Form, Type>::checkj(const label j) const
 {
     if (!m_)
     {
-        FatalErrorIn("Matrix<T>::checkj(const label)")
+        FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
             << "attempt to access element from zero sized column"
             << abort(FatalError);
     }
     else if (j<0 || j>=m_)
     {
-        FatalErrorIn("Matrix<T>::checkj(const label)")
+        FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
             << "index " << j << " out of range 0 ... " << m_-1
             << abort(FatalError);
     }
@@ -108,9 +104,8 @@ inline void Foam::Matrix<T>::checkj(const label j) const
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-// Return subscript-checked element access
-template<class T>
-inline T* Foam::Matrix<T>::operator[](const label i)
+template<class Form, class Type>
+inline Type* Foam::Matrix<Form, Type>::operator[](const label i)
 {
 #   ifdef FULLDEBUG
     checki(i);
@@ -119,9 +114,8 @@ inline T* Foam::Matrix<T>::operator[](const label i)
 }
 
 
-// Return subscript-checked const element access
-template<class T>
-inline const T* Foam::Matrix<T>::operator[](const label i) const
+template<class Form, class Type>
+inline const Type* Foam::Matrix<Form, Type>::operator[](const label i) const
 {
 #   ifdef FULLDEBUG
     checki(i);
diff --git a/src/OpenFOAM/containers/Matrix/MatrixIO.C b/src/OpenFOAM/matrices/Matrix/MatrixIO.C
similarity index 83%
rename from src/OpenFOAM/containers/Matrix/MatrixIO.C
rename to src/OpenFOAM/matrices/Matrix/MatrixIO.C
index 710e42876e68b86fa3fdfd3f4d41210505d8fa18..15f0d5345e848defdedae37439bc1e1adc419b86 100644
--- a/src/OpenFOAM/containers/Matrix/MatrixIO.C
+++ b/src/OpenFOAM/matrices/Matrix/MatrixIO.C
@@ -32,8 +32,8 @@ License
 
 // * * * * * * * * * * * * * * * Ostream Operator *  * * * * * * * * * * * * //
 
-template<class T>
-Foam::Matrix<T>::Matrix(Istream& is)
+template<class Form, class Type>
+Foam::Matrix<Form, Type>::Matrix(Istream& is)
 :
     n_(0),
     m_(0),
@@ -43,17 +43,17 @@ Foam::Matrix<T>::Matrix(Istream& is)
 }
 
 
-template<class T>
-Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
+template<class Form, class Type>
+Foam::Istream& Foam::operator>>(Istream& is, Matrix<Form, Type>& M)
 {
     // Anull matrix
     M.clear();
 
-    is.fatalCheck("operator>>(Istream&, Matrix<T>&)");
+    is.fatalCheck("operator>>(Istream&, Matrix<Form, Type>&)");
 
     token firstToken(is);
 
-    is.fatalCheck("operator>>(Istream&, Matrix<T>&) : reading first token");
+    is.fatalCheck("operator>>(Istream&, Matrix<Form, Type>&) : reading first token");
 
     if (firstToken.isLabel())
     {
@@ -63,7 +63,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
         label nm = M.n_*M.m_;
 
         // Read list contents depending on data format
-        if (is.format() == IOstream::ASCII || !contiguous<T>())
+        if (is.format() == IOstream::ASCII || !contiguous<Type>())
         {
             // Read beginning of contents
             char listDelimiter = is.readBeginList("Matrix");
@@ -71,7 +71,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
             if (nm)
             {
                 M.allocate();
-                T* v = M.v_[0];
+                Type* v = M.v_[0];
 
                 if (listDelimiter == token::BEGIN_LIST)
                 {
@@ -88,7 +88,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
 
                             is.fatalCheck
                             (
-                                "operator>>(Istream&, Matrix<T>&) : "
+                                "operator>>(Istream&, Matrix<Form, Type>&) : "
                                 "reading entry"
                             );
                         }
@@ -98,12 +98,12 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
                 }
                 else
                 {
-                    T element;
+                    Type element;
                     is >> element;
 
                     is.fatalCheck
                     (
-                        "operator>>(Istream&, Matrix<T>&) : "
+                        "operator>>(Istream&, Matrix<Form, Type>&) : "
                         "reading the single entry"
                     );
 
@@ -122,13 +122,13 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
             if (nm)
             {
                 M.allocate();
-                T* v = M.v_[0];
+                Type* v = M.v_[0];
 
-                is.read(reinterpret_cast<char*>(v), nm*sizeof(T));
+                is.read(reinterpret_cast<char*>(v), nm*sizeof(Type));
 
                 is.fatalCheck
                 (
-                    "operator>>(Istream&, Matrix<T>&) : "
+                    "operator>>(Istream&, Matrix<Form, Type>&) : "
                     "reading the binary block"
                 );
             }
@@ -136,7 +136,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
     }
     else
     {
-        FatalIOErrorIn("operator>>(Istream&, Matrix<T>&)", is)
+        FatalIOErrorIn("operator>>(Istream&, Matrix<Form, Type>&)", is)
             << "incorrect first token, expected <int>, found "
             << firstToken.info()
             << exit(FatalIOError);
@@ -146,23 +146,23 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<T>& M)
 }
 
 
-template<class T>
-Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<T>& M)
+template<class Form, class Type>
+Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
 {
     label nm = M.n_*M.m_;
 
     os  << M.n() << token::SPACE << M.m();
 
     // Write list contents depending on data format
-    if (os.format() == IOstream::ASCII || !contiguous<T>())
+    if (os.format() == IOstream::ASCII || !contiguous<Type>())
     {
         if (nm)
         {
             bool uniform = false;
 
-            const T* v = M.v_[0];
+            const Type* v = M.v_[0];
 
-            if (nm > 1 && contiguous<T>())
+            if (nm > 1 && contiguous<Type>())
             {
                 uniform = true;
 
@@ -187,7 +187,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<T>& M)
                 // Write end of contents delimiter
                 os << token::END_BLOCK;
             }
-            else if (nm < 10 && contiguous<T>())
+            else if (nm < 10 && contiguous<Type>())
             {
                 // Write size of list and start contents delimiter
                 os  << token::BEGIN_LIST;
@@ -246,7 +246,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<T>& M)
     {
         if (nm)
         {
-            os.write(reinterpret_cast<const char*>(M.v_[0]), nm*sizeof(T));
+            os.write(reinterpret_cast<const char*>(M.v_[0]), nm*sizeof(Type));
         }
     }
 
diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H
new file mode 100644
index 0000000000000000000000000000000000000000..e5e6b16777e8c0b8c699e1c68af51826188a1f4a
--- /dev/null
+++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H
@@ -0,0 +1,92 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::RectangularMatrix
+
+Description
+    A templated 2D rectangular matrix of objects of \<T\>, where the n x n matrix
+    dimension is known and used for subscript bounds checking, etc.
+
+SourceFiles
+    RectangularMatrixI.H
+    RectangularMatrix.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef RectangularMatrix_H
+#define RectangularMatrix_H
+
+#include "Matrix.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class Matrix Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class RectangularMatrix
+:
+    public Matrix<RectangularMatrix<Type>, Type>
+{
+
+public:
+
+    // Constructors
+
+        //- Null constructor.
+        inline RectangularMatrix();
+
+        //- Construct given number of rows and columns,
+        inline RectangularMatrix(const label m, const label n);
+
+        //- Construct with given number of rows and columns
+        //  and value for all elements.
+        inline RectangularMatrix(const label m, const label n, const Type&);
+
+        //- Construct from Istream.
+        inline RectangularMatrix(Istream&);
+
+        //- Clone
+        inline autoPtr<RectangularMatrix<Type> > clone() const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#   include "RectangularMatrixI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H
new file mode 100644
index 0000000000000000000000000000000000000000..1cacd2f11ae919b204d9091694521e7eeb3a58bf
--- /dev/null
+++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H
@@ -0,0 +1,70 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+inline Foam::RectangularMatrix<Type>::RectangularMatrix()
+:
+    Matrix<RectangularMatrix<Type>, Type>()
+{}
+
+template<class Type>
+inline Foam::RectangularMatrix<Type>::RectangularMatrix
+(
+    const label m,
+    const label n
+)
+:
+    Matrix<RectangularMatrix<Type>, Type>(m, n)
+{}
+
+template<class Type>
+inline Foam::RectangularMatrix<Type>::RectangularMatrix
+(
+    const label m,
+    const label n,
+    const Type& t
+)
+:
+    Matrix<RectangularMatrix<Type>, Type>(m, n, t)
+{}
+
+template<class Type>
+inline Foam::RectangularMatrix<Type>::RectangularMatrix(Istream& is)
+:
+    Matrix<RectangularMatrix<Type>, Type>(is)
+{}
+
+template<class Type>
+inline Foam::autoPtr<Foam::RectangularMatrix<Type> >
+Foam::RectangularMatrix<Type>::clone() const
+{
+    return autoPtr<RectangularMatrix<Type> >(new RectangularMatrix<Type>(*this));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H
new file mode 100644
index 0000000000000000000000000000000000000000..27160dc239ee876f9ee9260591bbcfd5e38e7da3
--- /dev/null
+++ b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H
@@ -0,0 +1,97 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::SquareMatrix
+
+Description
+    A templated 2D square matrix of objects of \<T\>, where the n x n matrix
+    dimension is known and used for subscript bounds checking, etc.
+
+SourceFiles
+    SquareMatrixI.H
+    SquareMatrix.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef SquareMatrix_H
+#define SquareMatrix_H
+
+#include "Matrix.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class Matrix Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class SquareMatrix
+:
+    public Matrix<SquareMatrix<Type>, Type>
+{
+
+public:
+
+    // Constructors
+
+        //- Null constructor.
+        inline SquareMatrix();
+
+        //- Construct given number of rows/columns.
+        inline SquareMatrix(const label n);
+
+        //- Construct given number of rows and columns,
+        //  It checks that m == n.
+        inline SquareMatrix(const label m, const label n);
+
+        //- Construct with given number of rows and rows
+        //  and value for all elements.
+        //  It checks that m == n.
+        inline SquareMatrix(const label m, const label n, const Type&);
+
+        //- Construct from Istream.
+        inline SquareMatrix(Istream&);
+
+        //- Clone
+        inline autoPtr<SquareMatrix<Type> > clone() const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#   include "SquareMatrixI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H
new file mode 100644
index 0000000000000000000000000000000000000000..d3ee1cd6bff848e6b64f17288167225f7121a300
--- /dev/null
+++ b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H
@@ -0,0 +1,89 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+inline Foam::SquareMatrix<Type>::SquareMatrix()
+:
+    Matrix<SquareMatrix<Type>, Type>()
+{}
+
+template<class Type>
+inline Foam::SquareMatrix<Type>::SquareMatrix(const label n)
+:
+    Matrix<SquareMatrix<Type>, Type>(n, n)
+{}
+
+template<class Type>
+inline Foam::SquareMatrix<Type>::SquareMatrix(const label m, const label n)
+:
+    Matrix<SquareMatrix<Type>, Type>(m, n)
+{
+    if (m != n)
+    {
+        FatalErrorIn
+        (
+            "SquareMatrix<Type>::SquareMatrix(const label m, const label n)"
+        ) << "m != n for constructing a square matrix" << exit(FatalError);
+    }
+}
+
+template<class Type>
+inline Foam::SquareMatrix<Type>::SquareMatrix
+(
+    const label m,
+    const label n,
+    const Type& t
+)
+:
+    Matrix<SquareMatrix<Type>, Type>(m, n, t)
+{
+    if (m != n)
+    {
+        FatalErrorIn
+        (
+            "SquareMatrix<Type>::SquareMatrix"
+            "(const label m, const label n, const Type&)"
+        ) << "m != n for constructing a square matrix" << exit(FatalError);
+    }
+}
+
+template<class Type>
+inline Foam::SquareMatrix<Type>::SquareMatrix(Istream& is)
+:
+    Matrix<SquareMatrix<Type>, Type>(is)
+{}
+
+template<class Type>
+inline Foam::autoPtr<Foam::SquareMatrix<Type> >
+Foam::SquareMatrix<Type>::clone() const
+{
+    return autoPtr<SquareMatrix<Type> >(new SquareMatrix<Type>(*this));
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C
new file mode 100644
index 0000000000000000000000000000000000000000..13ef29ed9bed12c9a330b939f42e92bce1a9547f
--- /dev/null
+++ b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C
@@ -0,0 +1,403 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2005 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 "SVD.H"
+#include "scalarList.H"
+#include "scalarMatrices.H"
+#include "ListOps.H"
+
+// * * * * * * * * * * * * * * * * Constructor  * * * * * * * * * * * * * * //
+
+Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
+:
+    U_(A),
+    V_(A.m(), A.m()),
+    S_(A.m()),
+    VSinvUt_(A.m(), A.n()),
+    nZeros_(0)
+{
+    // SVDcomp to find U_, V_ and S_ - the singular values
+
+    const label Um = U_.m();
+    const label Un = U_.n();
+
+    scalarList rv1(Um);
+    scalar g = 0;
+    scalar scale = 0;
+    scalar s = 0;
+    scalar anorm = 0;
+    label l = 0;
+
+    for (label i = 0; i < Um; i++)
+    {
+        l = i+2;
+        rv1[i] = scale*g;
+        g = s = scale = 0;
+
+        if (i < Un)
+        {
+            for (label k = i; k < Un; k++)
+            {
+                scale += mag(U_[k][i]);
+            }
+
+            if (scale != 0)
+            {
+                for (label k = i; k < Un; k++)
+                {
+                    U_[k][i] /= scale;
+                    s += U_[k][i]*U_[k][i];
+                }
+
+                scalar f = U_[i][i];
+                g = -sign(Foam::sqrt(s), f);
+                scalar h = f*g - s;
+                U_[i][i] = f - g;
+
+                for (label j = l-1; j < Um; j++)
+                {
+                    s = 0;
+                    for (label k = i; k < Un; k++)
+                    {
+                        s += U_[k][i]*U_[k][j];
+                    }
+
+                    f = s/h;
+                    for (label k = i; k < A.n(); k++)
+                    {
+                        U_[k][j] += f*U_[k][i];
+                    }
+                }
+
+                for (label k = i; k < Un; k++)
+                {
+                    U_[k][i] *= scale;
+                }
+            }
+        }
+
+        S_[i] = scale*g;
+
+        g = s = scale = 0;
+
+        if (i+1 <= Un && i != Um)
+        {
+            for (label k = l-1; k < Um; k++)
+            {
+                scale += mag(U_[i][k]);
+            }
+
+            if (scale != 0)
+            {
+                for (label k=l-1; k < Um; k++)
+                {
+                    U_[i][k] /= scale;
+                    s += U_[i][k]*U_[i][k];
+                }
+
+                scalar f = U_[i][l-1];
+                g = -sign(Foam::sqrt(s),f);
+                scalar h = f*g - s;
+                U_[i][l-1] = f - g;
+
+                for (label k = l-1; k < Um; k++)
+                {
+                    rv1[k] = U_[i][k]/h;
+                }
+
+                for (label j = l-1; j < Un; j++)
+                {
+                    s = 0;
+                    for (label k = l-1; k < Um; k++)
+                    {
+                        s += U_[j][k]*U_[i][k];
+                    }
+
+                    for (label k = l-1; k < Um; k++)
+                    {
+                        U_[j][k] += s*rv1[k];
+                    }
+                }
+                for (label k = l-1; k < Um; k++)
+                {
+                    U_[i][k] *= scale;
+                }
+            }
+        }
+
+        anorm = max(anorm, mag(S_[i]) + mag(rv1[i]));
+    }
+
+    for (label i = Um-1; i >= 0; i--)
+    {
+        if (i < Um-1)
+        {
+            if (g != 0)
+            {
+                for (label j = l; j < Um; j++)
+                {
+                    V_[j][i] = (U_[i][j]/U_[i][l])/g;
+                }
+
+                for (label j=l; j < Um; j++)
+                {
+                    s = 0;
+                    for (label k = l; k < Um; k++)
+                    {
+                        s += U_[i][k]*V_[k][j];
+                    }
+
+                    for (label k = l; k < Um; k++)
+                    {
+                        V_[k][j] += s*V_[k][i];
+                    }
+                }
+            }
+
+            for (label j = l; j < Um;j++)
+            {
+                V_[i][j] = V_[j][i] = 0.0;
+            }
+        }
+
+        V_[i][i] = 1;
+        g = rv1[i];
+        l = i;
+    }
+
+    for (label i = min(Um, Un) - 1; i >= 0; i--)
+    {
+        l = i+1;
+        g = S_[i];
+
+        for (label j = l; j < Um; j++)
+        {
+            U_[i][j] = 0.0;
+        }
+
+        if (g != 0)
+        {
+            g = 1.0/g;
+
+            for (label j = l; j < Um; j++)
+            {
+                s = 0;
+                for (label k = l; k < Un; k++)
+                {
+                    s += U_[k][i]*U_[k][j];
+                }
+
+                scalar f = (s/U_[i][i])*g;
+
+                for (label k = i; k < Un; k++)
+                {
+                    U_[k][j] += f*U_[k][i];
+                }
+            }
+
+            for (label j = i; j < Un; j++)
+            {
+                U_[j][i] *= g;
+            }
+        }
+        else
+        {
+            for (label j = i; j < Un; j++)
+            {
+                U_[j][i] = 0.0;
+            }
+        }
+
+        ++U_[i][i];
+    }
+
+    for (label k = Um-1; k >= 0; k--)
+    {
+        for (label its = 0; its < 35; its++)
+        {
+            bool flag = true;
+
+            label nm;
+            for (l = k; l >= 0; l--)
+            {
+                nm = l-1;
+                if (mag(rv1[l]) + anorm == anorm)
+                {
+                    flag = false;
+                    break;
+                }
+                if (mag(S_[nm]) + anorm == anorm) break;
+            }
+
+            if (flag)
+            {
+                scalar c = 0.0;
+                s = 1.0;
+                for (label i = l-1; i < k+1; i++)
+                {
+                    scalar f = s*rv1[i];
+                    rv1[i] = c*rv1[i];
+
+                    if (mag(f) + anorm == anorm) break;
+
+                    g = S_[i];
+                    scalar h = sqrtSumSqr(f, g);
+                    S_[i] = h;
+                    h = 1.0/h;
+                    c = g*h;
+                    s = -f*h;
+
+                    for (label j = 0; j < Un; j++)
+                    {
+                        scalar y = U_[j][nm];
+                        scalar z = U_[j][i];
+                        U_[j][nm] = y*c + z*s;
+                        U_[j][i] = z*c - y*s;
+                    }
+                }
+            }
+
+            scalar z = S_[k];
+
+            if (l == k)
+            {
+                if (z < 0.0)
+                {
+                    S_[k] = -z;
+
+                    for (label j = 0; j < Um; j++) V_[j][k] = -V_[j][k];
+                }
+                break;
+            }
+            if (its == 34)
+            {
+                WarningIn
+                (
+                    "SVD::SVD"
+                    "(scalarRectangularMatrix& A, const scalar minCondition)"
+                )   << "no convergence in 35 SVD iterations"
+                    << endl;
+            }
+
+            scalar x = S_[l];
+            nm = k-1;
+            scalar y = S_[nm];
+            g = rv1[nm];
+            scalar h = rv1[k];
+            scalar f = ((y - z)*(y + z) + (g - h)*(g + h))/(2.0*h*y);
+            g = sqrtSumSqr(f, 1.0);
+            f = ((x - z)*(x + z) + h*((y/(f + sign(g, f))) - h))/x;
+            scalar c = 1.0;
+            s = 1.0;
+
+            for (label j = l; j <= nm; j++)
+            {
+                label i = j + 1;
+                g = rv1[i];
+                y = S_[i];
+                h = s*g;
+                g = c*g;
+                scalar z = sqrtSumSqr(f, h);
+                rv1[j] = z;
+                c = f/z;
+                s = h/z;
+                f = x*c + g*s;
+                g = g*c - x*s;
+                h = y*s;
+                y *= c;
+
+                for (label jj = 0; jj < Um; jj++)
+                {
+                    x = V_[jj][j];
+                    z = V_[jj][i];
+                    V_[jj][j] = x*c + z*s;
+                    V_[jj][i] = z*c - x*s;
+                }
+
+                z = sqrtSumSqr(f, h);
+                S_[j] = z;
+                if (z)
+                {
+                    z = 1.0/z;
+                    c = f*z;
+                    s = h*z;
+                }
+                f = c*g + s*y;
+                x = c*y - s*g;
+
+                for (label jj=0; jj < Un; jj++)
+                {
+                    y = U_[jj][j];
+                    z = U_[jj][i];
+                    U_[jj][j] = y*c + z*s;
+                    U_[jj][i] = z*c - y*s;
+                }
+            }
+            rv1[l] = 0.0;
+            rv1[k] = f;
+            S_[k] = x;
+        }
+    }
+
+    // zero singular values that are less than minCondition*maxS
+    const scalar minS = minCondition*S_[findMax(S_)];
+    for (label i = 0; i < S_.size(); i++)
+    {
+        if (S_[i] <= minS)
+        {
+            //Info << "Removing " << S_[i] << " < " << minS << endl;
+            S_[i] = 0;
+            nZeros_++;
+        }
+    }
+
+    // now multiply out to find the pseudo inverse of A, VSinvUt_
+    multiply(VSinvUt_, V_, inv(S_), U_.T());
+
+    // test SVD
+    /*scalarRectangularMatrix SVDA(A.n(), A.m());
+    multiply(SVDA, U_, S_, transpose(V_));
+    scalar maxDiff = 0;
+    scalar diff = 0;
+    for(label i = 0; i < A.n(); i++)
+    {
+        for(label j = 0; j < A.m(); j++)
+        {
+            diff = mag(A[i][j] - SVDA[i][j]);
+            if (diff > maxDiff) maxDiff = diff;
+        }
+    }
+    Info << "Maximum discrepancy between A and svd(A) = " << maxDiff << endl;
+
+    if (maxDiff > 4)
+    {
+        Info << "singular values " << S_ << endl;
+    }
+    */
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H
new file mode 100644
index 0000000000000000000000000000000000000000..48e581198a39547089f4ae1b7a12a593e0f9de94
--- /dev/null
+++ b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H
@@ -0,0 +1,128 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2005 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::SVD
+
+Description
+    Singular value decomposition of a rectangular matrix.
+
+SourceFiles
+    SVDI.H
+    SVD.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef SVD_H
+#define SVD_H
+
+#include "scalarMatrices.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+/*---------------------------------------------------------------------------*\
+                      Class SVD Declaration
+\*---------------------------------------------------------------------------*/
+
+class SVD
+{
+    // Private data
+
+        //- Rectangular matrix with the same dimensions as the input
+        scalarRectangularMatrix U_;
+
+        //- square matrix V
+        scalarRectangularMatrix V_;
+
+        //- The singular values
+        DiagonalMatrix<scalar> S_;
+
+        //- The matrix product V S^(-1) U^T
+        scalarRectangularMatrix VSinvUt_;
+
+        //- The number of zero singular values
+        label nZeros_;
+
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        SVD(const SVD&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const SVD&);
+
+        template<class T>
+        inline const T sign(const T& a, const T& b);
+
+
+public:
+
+    // Constructors
+
+        //- Construct from a rectangular Matrix
+        SVD(const scalarRectangularMatrix& A, const scalar minCondition = 0);
+
+
+    // Access functions
+
+        //- Return U
+        inline const scalarRectangularMatrix& U() const;
+
+        //- Return the square matrix V
+        inline const scalarRectangularMatrix& V() const;
+
+        //- Return the singular values
+        inline const scalarDiagonalMatrix& S() const;
+
+        //- Return VSinvUt (the pseudo inverse)
+        inline const scalarRectangularMatrix& VSinvUt() const;
+
+        //- Return the number of zero singular values
+        inline label nZeros() const;
+
+        //- Return the minimum non-zero singular value
+        inline scalar minNonZeroS() const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "SVDI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVDI.H b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVDI.H
new file mode 100644
index 0000000000000000000000000000000000000000..298aac1aeb96cb3ef0374f979f5c8e5772565804
--- /dev/null
+++ b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVDI.H
@@ -0,0 +1,75 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * * //
+
+template<class T>
+inline const T Foam::SVD::sign(const T& a, const T& b)
+{
+    return b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a);
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline const Foam::scalarRectangularMatrix& Foam::SVD::U() const
+{
+    return U_;
+}
+
+inline const Foam::scalarRectangularMatrix& Foam::SVD::V() const
+{
+    return V_;
+}
+
+inline const Foam::scalarDiagonalMatrix& Foam::SVD::S() const
+{
+    return S_;
+}
+
+inline const Foam::scalarRectangularMatrix& Foam::SVD::VSinvUt() const
+{
+    return VSinvUt_;
+}
+
+inline Foam::label Foam::SVD::nZeros() const
+{
+    return nZeros_;
+}
+
+inline Foam::scalar Foam::SVD::minNonZeroS() const
+{
+    scalar minS = S_[0];
+    for(label i = 1; i < S_.size(); i++)
+    {
+        scalar s = S_[i];
+        if (s > VSMALL && s < minS) minS = s;
+    }
+    return minS;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C
new file mode 100644
index 0000000000000000000000000000000000000000..8ddd01a82c2d113565ca2be3f5f8f76565b27e1a
--- /dev/null
+++ b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C
@@ -0,0 +1,293 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "scalarMatrices.H"
+#include "SVD.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::LUDecompose
+(
+    scalarSquareMatrix& matrix,
+    labelList& pivotIndices
+)
+{
+    label n = matrix.n();
+    scalar vv[n];
+
+    for (register label i=0; i<n; i++)
+    {
+        scalar largestCoeff = 0.0;
+        scalar temp;
+        const scalar* __restrict__ matrixi = matrix[i];
+
+        for (register label j=0; j<n; j++)
+        {
+            if ((temp = mag(matrixi[j])) > largestCoeff)
+            {
+                largestCoeff = temp;
+            }
+        }
+
+        if (largestCoeff == 0.0)
+        {
+            FatalErrorIn
+            (
+                "LUdecompose"
+                "(scalarSquareMatrix& matrix, labelList& rowIndices)"
+            )   << "Singular matrix" << exit(FatalError);
+        }
+
+        vv[i] = 1.0/largestCoeff;
+    }
+
+    for (register label j=0; j<n; j++)
+    {
+        scalar* __restrict__ matrixj = matrix[j];
+
+        for (register label i=0; i<j; i++)
+        {
+            scalar* __restrict__ matrixi = matrix[i];
+
+            scalar sum = matrixi[j];
+            for (register label k=0; k<i; k++)
+            {
+                sum -= matrixi[k]*matrix[k][j];
+            }
+            matrixi[j] = sum;
+        }
+
+        label iMax = 0;
+
+        scalar largestCoeff = 0.0;
+        for (register label i=j; i<n; i++)
+        {
+            scalar* __restrict__ matrixi = matrix[i];
+            scalar sum = matrixi[j];
+
+            for (register label k=0; k<j; k++)
+            {
+                sum -= matrixi[k]*matrix[k][j];
+            }
+
+            matrixi[j] = sum;
+
+            scalar temp;
+            if ((temp = vv[i]*mag(sum)) >= largestCoeff)
+            {
+                largestCoeff = temp;
+                iMax = i;
+            }
+        }
+
+        pivotIndices[j] = iMax;
+
+        if (j != iMax)
+        {
+            scalar* __restrict__ matrixiMax = matrix[iMax];
+
+            for (register label k=0; k<n; k++)
+            {
+                Swap(matrixj[k], matrixiMax[k]);
+            }
+
+            vv[iMax] = vv[j];
+        }
+
+        if (matrixj[j] == 0.0)
+        {
+            matrixj[j] = SMALL;
+        }
+
+        if (j != n-1)
+        {
+            scalar rDiag = 1.0/matrixj[j];
+
+            for (register label i=j+1; i<n; i++)
+            {
+                matrix[i][j] *= rDiag;
+            }
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
+
+void Foam::multiply
+(
+    scalarRectangularMatrix& ans,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const scalarRectangularMatrix& B
+)
+{
+    if (A.m() != B.n())
+    {
+        FatalErrorIn
+        (
+            "multiply("
+            "scalarRectangularMatrix& answer "
+            "const scalarRectangularMatrix& A, "
+            "const scalarRectangularMatrix& B)"
+        )   << "A and B must have identical inner dimensions but A.m = "
+            << A.m() << " and B.n = " << B.n()
+            << abort(FatalError);
+    }
+
+    ans = scalarRectangularMatrix(A.n(), B.m(), scalar(0));
+
+    for(register label i = 0; i < A.n(); i++)
+    {
+        for(register label j = 0; j < B.m(); j++)
+        {
+            for(register label l = 0; l < B.n(); l++)
+            {
+                ans[i][j] += A[i][l]*B[l][j];
+            }
+        }
+    }
+}
+
+
+void Foam::multiply
+(
+    scalarRectangularMatrix& ans,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const scalarRectangularMatrix& B,
+    const scalarRectangularMatrix& C
+)
+{
+    if (A.m() != B.n())
+    {
+        FatalErrorIn
+        (
+            "multiply("
+            "const scalarRectangularMatrix& A, "
+            "const scalarRectangularMatrix& B, "
+            "const scalarRectangularMatrix& C, "
+            "scalarRectangularMatrix& answer)"
+        )   << "A and B must have identical inner dimensions but A.m = "
+            << A.m() << " and B.n = " << B.n()
+            << abort(FatalError);
+    }
+
+    if (B.m() != C.n())
+    {
+        FatalErrorIn
+        (
+            "multiply("
+            "const scalarRectangularMatrix& A, "
+            "const scalarRectangularMatrix& B, "
+            "const scalarRectangularMatrix& C, "
+            "scalarRectangularMatrix& answer)"
+        )   << "B and C must have identical inner dimensions but B.m = "
+            << B.m() << " and C.n = " << C.n()
+            << abort(FatalError);
+    }
+
+    ans = scalarRectangularMatrix(A.n(), C.m(), scalar(0));
+
+    for(register label i = 0; i < A.n(); i++)
+    {
+        for(register label g = 0; g < C.m(); g++)
+        {
+            for(register label l = 0; l < C.n(); l++)
+            {
+                scalar ab = 0;
+                for(register label j = 0; j < A.m(); j++)
+                {
+                    ab += A[i][j]*B[j][l];
+                }
+                ans[i][g] += C[l][g] * ab;
+            }
+        }
+    }
+}
+
+
+void Foam::multiply
+(
+    scalarRectangularMatrix& ans,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const DiagonalMatrix<scalar>& B,
+    const scalarRectangularMatrix& C
+)
+{
+    if (A.m() != B.size())
+    {
+        FatalErrorIn
+        (
+            "multiply("
+            "const scalarRectangularMatrix& A, "
+            "const DiagonalMatrix<scalar>& B, "
+            "const scalarRectangularMatrix& C, "
+            "scalarRectangularMatrix& answer)"
+        )   << "A and B must have identical inner dimensions but A.m = "
+            << A.m() << " and B.n = " << B.size()
+            << abort(FatalError);
+    }
+
+    if (B.size() != C.n())
+    {
+        FatalErrorIn
+        (
+            "multiply("
+            "const scalarRectangularMatrix& A, "
+            "const DiagonalMatrix<scalar>& B, "
+            "const scalarRectangularMatrix& C, "
+            "scalarRectangularMatrix& answer)"
+        )   << "B and C must have identical inner dimensions but B.m = "
+            << B.size() << " and C.n = " << C.n()
+            << abort(FatalError);
+    }
+
+    ans = scalarRectangularMatrix(A.n(), C.m(), scalar(0));
+
+    for(register label i = 0; i < A.n(); i++)
+    {
+        for(register label g = 0; g < C.m(); g++)
+        {
+            for(register label l = 0; l < C.n(); l++)
+            {
+                ans[i][g] += C[l][g] * A[i][l]*B[l];
+            }
+        }
+    }
+}
+
+
+Foam::RectangularMatrix<Foam::scalar> Foam::SVDinv
+(
+    const scalarRectangularMatrix& A,
+    scalar minCondition
+)
+{
+    SVD svd(A, minCondition);
+    return svd.VSinvUt();
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.H b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.H
new file mode 100644
index 0000000000000000000000000000000000000000..17d8727516922ad96b364a4cb60a20029fffcc00
--- /dev/null
+++ b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.H
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+    scalarMatrices
+
+Description
+    Scalar matrices
+
+SourceFiles
+    scalarMatrices.C
+    scalarMatricesTemplates.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef scalarMatrices_H
+#define scalarMatrices_H
+
+#include "RectangularMatrix.H"
+#include "SquareMatrix.H"
+#include "DiagonalMatrix.H"
+#include "scalarField.H"
+#include "labelList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+typedef RectangularMatrix<scalar> scalarRectangularMatrix;
+typedef SquareMatrix<scalar> scalarSquareMatrix;
+typedef DiagonalMatrix<scalar> scalarDiagonalMatrix;
+
+//- Solve the matrix using Gaussian elimination with pivoting,
+//  returning the solution in the source
+template<class Type>
+void solve(scalarSquareMatrix& matrix, Field<Type>& source);
+
+//- Solve the matrix using Gaussian elimination with pivoting
+//  and return the solution
+template<class Type>
+void solve
+(
+    Field<Type>& psi,
+    const scalarSquareMatrix& matrix,
+    const Field<Type>& source
+);
+
+//- LU decompose the matrix with pivoting
+void LUDecompose
+(
+    scalarSquareMatrix& matrix,
+    labelList& pivotIndices
+);
+
+//- LU back-substitution with given source, returning the solution
+//  in the source
+template<class Type>
+void LUBacksubstitute
+(
+    const scalarSquareMatrix& luMmatrix,
+    const labelList& pivotIndices,
+    Field<Type>& source
+);
+
+//- Solve the matrix using LU decomposition with pivoting
+//  returning the LU form of the matrix and the solution in the source
+template<class Type>
+void LUsolve(scalarSquareMatrix& matrix, Field<Type>& source);
+
+void multiply
+(
+    scalarRectangularMatrix& answer,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const scalarRectangularMatrix& B
+);
+
+void multiply
+(
+    scalarRectangularMatrix& answer,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const scalarRectangularMatrix& B,
+    const scalarRectangularMatrix& C
+);
+
+void multiply
+(
+    scalarRectangularMatrix& answer,         // value changed in return
+    const scalarRectangularMatrix& A,
+    const DiagonalMatrix<scalar>& B,
+    const scalarRectangularMatrix& C
+);
+
+//- Return the inverse of matrix A using SVD
+scalarRectangularMatrix SVDinv
+(
+    const scalarRectangularMatrix& A,
+    scalar minCondition = 0
+);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "scalarMatricesTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrixTemplates.C b/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C
similarity index 83%
rename from src/OpenFOAM/matrices/scalarMatrix/scalarMatrixTemplates.C
rename to src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C
index b729e32fcc77cf35c6e496f1ddd55622653a92a9..131856b3fcd3010e87251274ba44832e23136e37 100644
--- a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrixTemplates.C
+++ b/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C
@@ -24,16 +24,16 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "scalarMatrix.H"
+#include "scalarMatrices.H"
 #include "Swap.H"
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T>
-void Foam::scalarMatrix::solve
+template<class Type>
+void Foam::solve
 (
-    Matrix<scalar>& tmpMatrix,
-    Field<T>& sourceSol
+    scalarSquareMatrix& tmpMatrix,
+    Field<Type>& sourceSol
 )
 {
     label n = tmpMatrix.n();
@@ -68,7 +68,7 @@ void Foam::scalarMatrix::solve
         // Check that the system of equations isn't singular
         if (mag(tmpMatrix[i][i]) < 1e-20)
         {
-            FatalErrorIn("scalarMatrix::solve()")
+            FatalErrorIn("solve(scalarSquareMatrix&, Field<Type>& sourceSol)")
                 << "Singular Matrix"
                 << exit(FatalError);
         }
@@ -89,7 +89,7 @@ void Foam::scalarMatrix::solve
     // Back-substitution
     for (register label j=n-1; j>=0; j--)
     {
-        T ntempvec = pTraits<T>::zero;
+        Type ntempvec = pTraits<Type>::zero;
 
         for (register label k=j+1; k<n; k++)
         {
@@ -101,21 +101,26 @@ void Foam::scalarMatrix::solve
 }
 
 
-template<class T>
-void Foam::scalarMatrix::solve(Field<T>& psi, const Field<T>& source) const
+template<class Type>
+void Foam::solve
+(
+    Field<Type>& psi,
+    const scalarSquareMatrix& matrix,
+    const Field<Type>& source
+)
 {
-    Matrix<scalar> tmpMatrix = *this;
+    scalarSquareMatrix tmpMatrix = matrix;
     psi = source;
     solve(tmpMatrix, psi);
 }
 
 
-template<class T>
-void Foam::scalarMatrix::LUBacksubstitute
+template<class Type>
+void Foam::LUBacksubstitute
 (
-    const Matrix<scalar>& luMatrix,
+    const scalarSquareMatrix& luMatrix,
     const labelList& pivotIndices,
-    Field<T>& sourceSol
+    Field<Type>& sourceSol
 )
 {
     label n = luMatrix.n();
@@ -125,7 +130,7 @@ void Foam::scalarMatrix::LUBacksubstitute
     for (register label i=0; i<n; i++)
     {
         label ip = pivotIndices[i];
-        T sum = sourceSol[ip];
+        Type sum = sourceSol[ip];
         sourceSol[ip] = sourceSol[i];
         const scalar* __restrict__ luMatrixi = luMatrix[i];
 
@@ -136,7 +141,7 @@ void Foam::scalarMatrix::LUBacksubstitute
                 sum -= luMatrixi[j]*sourceSol[j];
             }
         }
-        else if (sum != pTraits<T>::zero)
+        else if (sum != pTraits<Type>::zero)
         {
             ii = i+1;
         }
@@ -146,11 +151,11 @@ void Foam::scalarMatrix::LUBacksubstitute
 
     for (register label i=n-1; i>=0; i--)
     {
-        T sum = sourceSol[i];
+        Type sum = sourceSol[i];
         const scalar* __restrict__ luMatrixi = luMatrix[i];
 
         for (register label j=i+1; j<n; j++)
-        { 
+        {
             sum -= luMatrixi[j]*sourceSol[j];
         }
 
@@ -159,11 +164,11 @@ void Foam::scalarMatrix::LUBacksubstitute
 }
 
 
-template<class T>
-void Foam::scalarMatrix::LUsolve
+template<class Type>
+void Foam::LUsolve
 (
-    Matrix<scalar>& matrix,
-    Field<T>& sourceSol
+    scalarSquareMatrix& matrix,
+    Field<Type>& sourceSol
 )
 {
     labelList pivotIndices(matrix.n());
diff --git a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.C b/src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.C
deleted file mode 100644
index 2ff9e39f18aeb7c259a9fa05b50ddf8916164d29..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.C
+++ /dev/null
@@ -1,161 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 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 "scalarMatrix.H"
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-Foam::scalarMatrix::scalarMatrix()
-{}
-
-
-Foam::scalarMatrix::scalarMatrix(const label mSize)
-:
-    Matrix<scalar>(mSize, mSize, 0.0)
-{}
-
-
-Foam::scalarMatrix::scalarMatrix(const Matrix<scalar>& matrix)
-:
-    Matrix<scalar>(matrix)
-{}
-
-
-Foam::scalarMatrix::scalarMatrix(Istream& is)
-:
-    Matrix<scalar>(is)
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-void Foam::scalarMatrix::LUDecompose
-(
-    Matrix<scalar>& matrix,
-    labelList& pivotIndices
-)
-{
-    label n = matrix.n();
-    scalar vv[n];
-
-    for (register label i=0; i<n; i++)
-    {
-        scalar largestCoeff = 0.0;
-        scalar temp;
-        const scalar* __restrict__ matrixi = matrix[i];
-
-        for (register label j=0; j<n; j++)
-        {
-            if ((temp = mag(matrixi[j])) > largestCoeff)
-            {
-                largestCoeff = temp;
-            }
-        }
-
-        if (largestCoeff == 0.0)
-        {
-            FatalErrorIn
-            (
-                "scalarMatrix::LUdecompose"
-                "(Matrix<scalar>& matrix, labelList& rowIndices)"
-            )   << "Singular matrix" << exit(FatalError);
-        }
-
-        vv[i] = 1.0/largestCoeff;
-    }
-
-    for (register label j=0; j<n; j++)
-    {
-        scalar* __restrict__ matrixj = matrix[j];
-
-        for (register label i=0; i<j; i++)
-        {
-            scalar* __restrict__ matrixi = matrix[i];
-
-            scalar sum = matrixi[j];
-            for (register label k=0; k<i; k++)
-            {
-                sum -= matrixi[k]*matrix[k][j];
-            }
-            matrixi[j] = sum;
-        }
-
-        label iMax = 0;
-
-        scalar largestCoeff = 0.0;
-        for (register label i=j; i<n; i++)
-        {
-            scalar* __restrict__ matrixi = matrix[i];
-            scalar sum = matrixi[j];
-
-            for (register label k=0; k<j; k++)
-            {
-                sum -= matrixi[k]*matrix[k][j];
-            }
-
-            matrixi[j] = sum;
-
-            scalar temp;
-            if ((temp = vv[i]*mag(sum)) >= largestCoeff)
-            {
-                largestCoeff = temp;
-                iMax = i;
-            }
-        }
-
-        pivotIndices[j] = iMax;
-
-        if (j != iMax)
-        {
-            scalar* __restrict__ matrixiMax = matrix[iMax];
-
-            for (register label k=0; k<n; k++)
-            {
-                Swap(matrixj[k], matrixiMax[k]);
-            }
-            
-            vv[iMax] = vv[j];
-        }
-
-        if (matrixj[j] == 0.0)
-        {
-            matrixj[j] = SMALL;
-        }
-
-        if (j != n-1)
-        {
-            scalar rDiag = 1.0/matrixj[j];
-
-            for (register label i=j+1; i<n; i++)
-            {
-                matrix[i][j] *= rDiag;
-            }
-        }
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C
index 22de758f3ac5edf4cdd82fd93523926c73c0e7e4..f0f80750a5e86caad64400e7276d77010502a05d 100644
--- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C
+++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C
@@ -28,55 +28,55 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class T>
-Foam::simpleMatrix<T>::simpleMatrix(const label mSize)
+template<class Type>
+Foam::simpleMatrix<Type>::simpleMatrix(const label mSize)
 :
-    scalarMatrix(mSize),
-    source_(mSize, pTraits<T>::zero)
+    scalarSquareMatrix(mSize),
+    source_(mSize, pTraits<Type>::zero)
 {}
 
 
-template<class T>
-Foam::simpleMatrix<T>::simpleMatrix
+template<class Type>
+Foam::simpleMatrix<Type>::simpleMatrix
 (
-    const scalarMatrix& matrix,
-    const Field<T>& source
+    const scalarSquareMatrix& matrix,
+    const Field<Type>& source
 )
 :
-    scalarMatrix(matrix),
+    scalarSquareMatrix(matrix),
     source_(source)
 {}
 
 
-template<class T>
-Foam::simpleMatrix<T>::simpleMatrix(Istream& is)
+template<class Type>
+Foam::simpleMatrix<Type>::simpleMatrix(Istream& is)
 :
-    scalarMatrix(is),
+    scalarSquareMatrix(is),
     source_(is)
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T>
-Foam::Field<T> Foam::simpleMatrix<T>::solve() const
+template<class Type>
+Foam::Field<Type> Foam::simpleMatrix<Type>::solve() const
 {
-    scalarMatrix tmpMatrix = *this;
-    Field<T> sourceSol = source_;
+    scalarSquareMatrix tmpMatrix = *this;
+    Field<Type> sourceSol = source_;
 
-    scalarMatrix::solve(tmpMatrix, sourceSol);
+    Foam::solve(tmpMatrix, sourceSol);
 
     return sourceSol;
 }
 
 
-template<class T>
-Foam::Field<T> Foam::simpleMatrix<T>::LUsolve() const
+template<class Type>
+Foam::Field<Type> Foam::simpleMatrix<Type>::LUsolve() const
 {
-    scalarMatrix luMatrix = *this;
-    Field<T> sourceSol = source_;
+    scalarSquareMatrix luMatrix = *this;
+    Field<Type> sourceSol = source_;
 
-    scalarMatrix::LUsolve(luMatrix, sourceSol);
+    Foam::LUsolve(luMatrix, sourceSol);
 
     return sourceSol;
 }
@@ -84,82 +84,82 @@ Foam::Field<T> Foam::simpleMatrix<T>::LUsolve() const
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-template<class T>
-void Foam::simpleMatrix<T>::operator=(const simpleMatrix<T>& m)
+template<class Type>
+void Foam::simpleMatrix<Type>::operator=(const simpleMatrix<Type>& m)
 {
     if (this == &m)
     {
-        FatalErrorIn("simpleMatrix<T>::operator=(const simpleMatrix<T>&)")
+        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
             << "Attempted assignment to self"
             << abort(FatalError);
     }
 
     if (n() != m.n())
     {
-        FatalErrorIn("simpleMatrix<T>::operator=(const simpleMatrix<T>&)")
+        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
             << "Different size matrices"
             << abort(FatalError);
     }
 
     if (source_.size() != m.source_.size())
     {
-        FatalErrorIn("simpleMatrix<T>::operator=(const simpleMatrix<T>&)")
+        FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
             << "Different size source vectors"
             << abort(FatalError);
     }
 
-    scalarMatrix::operator=(m);
+    scalarSquareMatrix::operator=(m);
     source_ = m.source_;
 }
 
 
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
-template<class T>
-Foam::simpleMatrix<T> Foam::operator+
+template<class Type>
+Foam::simpleMatrix<Type> Foam::operator+
 (
-    const simpleMatrix<T>& m1,
-    const simpleMatrix<T>& m2
+    const simpleMatrix<Type>& m1,
+    const simpleMatrix<Type>& m2
 )
 {
-    return simpleMatrix<T>
+    return simpleMatrix<Type>
     (
-        static_cast<const scalarMatrix&>(m1)
-      + static_cast<const scalarMatrix&>(m2),
+        static_cast<const scalarSquareMatrix&>(m1)
+      + static_cast<const scalarSquareMatrix&>(m2),
         m1.source_ + m2.source_
     );
 }
 
 
-template<class T>
-Foam::simpleMatrix<T> Foam::operator-
+template<class Type>
+Foam::simpleMatrix<Type> Foam::operator-
 (
-    const simpleMatrix<T>& m1,
-    const simpleMatrix<T>& m2
+    const simpleMatrix<Type>& m1,
+    const simpleMatrix<Type>& m2
 )
 {
-    return simpleMatrix<T>
+    return simpleMatrix<Type>
     (
-        static_cast<const scalarMatrix&>(m1)
-      - static_cast<const scalarMatrix&>(m2),
+        static_cast<const scalarSquareMatrix&>(m1)
+      - static_cast<const scalarSquareMatrix&>(m2),
         m1.source_ - m2.source_
     );
 }
 
 
-template<class T>
-Foam::simpleMatrix<T> Foam::operator*(const scalar s, const simpleMatrix<T>& m)
+template<class Type>
+Foam::simpleMatrix<Type> Foam::operator*(const scalar s, const simpleMatrix<Type>& m)
 {
-    return simpleMatrix<T>(s*m.matrix_, s*m.source_);
+    return simpleMatrix<Type>(s*m.matrix_, s*m.source_);
 }
 
 
 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
-template<class T>
-Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<T>& m)
+template<class Type>
+Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<Type>& m)
 {
-    os << static_cast<const scalarMatrix&>(m) << nl << m.source_;
+    os << static_cast<const scalarSquareMatrix&>(m) << nl << m.source_;
     return os;
 }
 
diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H
index d1c411452b887d126fafdcad26b3f7f36600f3db..a972c787c846ea3bd04003c5d7e7bb641139c150 100644
--- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H
+++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H
@@ -36,7 +36,7 @@ SourceFiles
 #ifndef simpleMatrix_H
 #define simpleMatrix_H
 
-#include "scalarMatrix.H"
+#include "scalarMatrices.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -45,35 +45,14 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 
-template<class T>
+template<class Type>
 class simpleMatrix;
 
-template<class T>
-simpleMatrix<T> operator+
-(
-    const simpleMatrix<T>&,
-    const simpleMatrix<T>&
-);
-
-template<class T>
-simpleMatrix<T> operator-
-(
-    const simpleMatrix<T>&,
-    const simpleMatrix<T>&
-);
-
-template<class T>
-simpleMatrix<T> operator*
-(
-    const scalar,
-    const simpleMatrix<T>&
-);
-
-template<class T>
+template<class Type>
 Ostream& operator<<
 (
     Ostream&,
-    const simpleMatrix<T>&
+    const simpleMatrix<Type>&
 );
 
 
@@ -81,14 +60,14 @@ Ostream& operator<<
                            Class simpleMatrix Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class T>
+template<class Type>
 class simpleMatrix
 :
-    public scalarMatrix
+    public scalarSquareMatrix
 {
     // Private data
 
-        Field<T> source_;
+        Field<Type> source_;
 
 
 public:
@@ -99,25 +78,25 @@ public:
         simpleMatrix(const label);
 
         //- Construct from components
-        simpleMatrix(const scalarMatrix&, const Field<T>&);
+        simpleMatrix(const scalarSquareMatrix&, const Field<Type>&);
 
         //- Construct from Istream
         simpleMatrix(Istream&);
 
         //- Construct as copy
-        simpleMatrix(const simpleMatrix<T>&);
+        simpleMatrix(const simpleMatrix<Type>&);
 
 
     // Member Functions
 
         // Access
 
-            Field<T>& source()
+            Field<Type>& source()
             {
                 return source_;
             }
 
-            const Field<T>& source() const
+            const Field<Type>& source() const
             {
                 return source_;
             }
@@ -125,47 +104,50 @@ public:
 
         //- Solve the matrix using Gaussian elimination with pivoting
         //  and return the solution
-        Field<T> solve() const;
+        Field<Type> solve() const;
 
         //- Solve the matrix using LU decomposition with pivoting
         //  and return the solution
-        Field<T> LUsolve() const;
+        Field<Type> LUsolve() const;
 
 
     // Member Operators
 
-        void operator=(const simpleMatrix<T>&);
+        void operator=(const simpleMatrix<Type>&);
 
 
-    // Friend Operators
+    // Ostream Operator
 
-        friend simpleMatrix<T> operator+ <T>
+        friend Ostream& operator<< <Type>
         (
-            const simpleMatrix<T>&,
-            const simpleMatrix<T>&
+            Ostream&,
+            const simpleMatrix<Type>&
         );
+};
 
-        friend simpleMatrix<T> operator- <T>
-        (
-            const simpleMatrix<T>&,
-            const simpleMatrix<T>&
-        );
 
-        friend simpleMatrix<T> operator* <T>
-        (
-            const scalar,
-            const simpleMatrix<T>&
-        );
+// Global operators
 
+template<class Type>
+simpleMatrix<Type> operator+
+(
+    const simpleMatrix<Type>&,
+    const simpleMatrix<Type>&
+);
 
-    // Ostream Operator
+template<class Type>
+simpleMatrix<Type> operator-
+(
+    const simpleMatrix<Type>&,
+    const simpleMatrix<Type>&
+);
 
-        friend Ostream& operator<< <T>
-        (
-            Ostream&,
-            const simpleMatrix<T>&
-        );
-};
+template<class Type>
+simpleMatrix<Type> operator*
+(
+    const scalar,
+    const simpleMatrix<Type>&
+);
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C
index bb0492735f586411d45b0dc480ba48c7512b76e0..502e3e3eec6c783f6d49998cdd1de04ba897383c 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.C
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.C
@@ -526,7 +526,7 @@ Foam::point Foam::face::centre(const pointField& meshPoints) const
 }
 
 
-Foam::vector Foam::face::normal(const pointField& meshPoints) const
+Foam::vector Foam::face::normal(const pointField& p) const
 {
     // Calculate the normal by summing the face triangle normals.
     // Changed to deal with small concavity by using a central decomposition
@@ -539,38 +539,43 @@ Foam::vector Foam::face::normal(const pointField& meshPoints) const
     {
         return triPointRef
         (
-            meshPoints[operator[](0)],
-            meshPoints[operator[](1)],
-            meshPoints[operator[](2)]
+            p[operator[](0)],
+            p[operator[](1)],
+            p[operator[](2)]
         ).normal();
     }
 
-    vector n = vector::zero;
+    label nPoints = size();
 
-    point centrePoint = Foam::average(points(meshPoints));
+    register label pI;
 
-    label nPoints = size();
+    point centrePoint = vector::zero;
+    for (pI = 0; pI < nPoints; pI++)
+    {
+        centrePoint += p[operator[](pI)];
+    }
+    centrePoint /= nPoints;
 
-    point nextPoint = centrePoint;
+    vector n = vector::zero;
 
-    register label pI;
+    point nextPoint = centrePoint;
 
     for (pI = 0; pI < nPoints; pI++)
     {
         if (pI < nPoints - 1)
         {
-            nextPoint = meshPoints[operator[](pI + 1)];
+            nextPoint = p[operator[](pI + 1)];
         }
         else
         {
-            nextPoint = meshPoints[operator[](0)];
+            nextPoint = p[operator[](0)];
         }
 
         // Note: for best accuracy, centre point always comes last
         //
         n += triPointRef
         (
-            meshPoints[operator[](pI)],
+            p[operator[](pI)],
             nextPoint,
             centrePoint
         ).normal();
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H
index 65888ea79e252fd916b8f40ac730297c758b37e5..748834ca4d28ef43dcab1816d451f43d4bfdacb7 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H
@@ -168,19 +168,50 @@ public:
                 List<T>&
             );
 
-            //- Distribute data using scheduling.
+            //- Distribute data using default commsType.
             template<class T>
             void distribute(List<T>& fld) const
             {
-                distribute
+                if
                 (
-                    Pstream::scheduled,
-                    schedule(),
-                    constructSize_,
-                    subMap_,
-                    constructMap_,
-                    fld
-                );
+                    Pstream::defaultCommsType == Pstream::nonBlocking
+                 && contiguous<T>()
+                )
+                {
+                    distribute
+                    (
+                        Pstream::nonBlocking,
+                        List<labelPair>(),
+                        constructSize_,
+                        subMap_,
+                        constructMap_,
+                        fld
+                    );
+                }
+                else if (Pstream::defaultCommsType == Pstream::scheduled)
+                {
+                    distribute
+                    (
+                        Pstream::scheduled,
+                        schedule(),
+                        constructSize_,
+                        subMap_,
+                        constructMap_,
+                        fld
+                    );
+                }
+                else
+                {
+                    distribute
+                    (
+                        Pstream::blocking,
+                        List<labelPair>(),
+                        constructSize_,
+                        subMap_,
+                        constructMap_,
+                        fld
+                    );
+                }
             }
 
             //- Correct for topo change.
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
index 86a0a618c18faf5215ac5a6b3b7bc3e038310cbd..5f16ad1335fb2eb58c07f2c38b5f05214dfaee4d 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
@@ -241,7 +241,7 @@ void Foam::mapDistribute::distribute
                     Pstream::nonBlocking,
                     domain,
                     reinterpret_cast<const char*>(subField.begin()),
-                    subField.size()
+                    subField.size()*sizeof(T)
                 );
             }
         }
@@ -262,7 +262,7 @@ void Foam::mapDistribute::distribute
                     Pstream::nonBlocking,
                     domain,
                     reinterpret_cast<char*>(recvFields[domain].begin()),
-                    recvFields[domain].size()
+                    recvFields[domain].size()*sizeof(T)
                 );
             }
         }
diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
index a74458fe9fce68936ec738ba775192f3f883fc5d..e7d7567a138da742b2eb21630b1b0866aad718ad 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
@@ -552,6 +552,8 @@ bool Foam::polyBoundaryMesh::checkDefinition(const bool report) const
         nextPatchStart += bm[patchI].size();
     }
 
+    reduce(boundaryError, orOp<bool>());
+
     if (boundaryError)
     {
         if (debug || report)
@@ -565,7 +567,7 @@ bool Foam::polyBoundaryMesh::checkDefinition(const bool report) const
     {
         if (debug || report)
         {
-            Pout << "    Boundary definition OK." << endl;
+            Info << "    Boundary definition OK." << endl;
         }
 
         return false;
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
index 4cf32e07a92fa70d59e137e25918b9b13fa74f23..b813aa7c685b6550a7a06d2de398184e44e8e4c4 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
@@ -214,7 +214,7 @@ public:
         //- Construct from IOobject
         explicit polyMesh(const IOobject& io);
 
-        //- Construct from components without boundary.
+        //- Construct without boundary from components.
         //  Boundary is added using addPatches() member function
         polyMesh
         (
@@ -226,8 +226,7 @@ public:
             const bool syncPar = true
         );
 
-        //- Construct from components with cells rather than owner
-        //  and neighbourwithout boundary.
+        //- Construct without boundary with cells rather than owner/neighbour.
         //  Boundary is added using addPatches() member function
         polyMesh
         (
@@ -263,8 +262,7 @@ public:
 
         // Database
 
-            //- Over-ride the objectRegistry dbDir
-            //  if this is single-region case
+            //- Override the objectRegistry dbDir for a single-region case
             virtual const fileName& dbDir() const;
 
             //- Return the local mesh directory (dbDir()/meshSubDir)
@@ -311,17 +309,17 @@ public:
                 return bounds_;
             }
 
-            //- Return the vector of valid directions in mesh
-            //  defined according to the presence of empty patches.
+            //- Return the vector of valid directions in mesh.
+            //  Defined according to the presence of empty patches.
             //  1 indicates valid direction and -1 an invalid direction.
             const Vector<label>& directions() const;
 
-            //- Return the number of valid geoemtric dimensions in the mesh
+            //- Return the number of valid geometric dimensions in the mesh
             label nGeometricD() const;
 
-            //- Return the number of valid solution dimensions in the mesh
+            //- Return the number of valid solution dimensions in the mesh.
             //  For wedge cases this includes the circumferential direction
-            //  in case of swirl
+            //  in case of swirl.
             label nSolutionD() const;
 
             //- Return point zone mesh
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C
index f4e073d4e14b1d46e12938234ac6616b9161e7db..73aff8a1fd2c711402e5ddd3a201583166df211b 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C
@@ -263,6 +263,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
         Pout<< "coupledPolyPatch::calcTransformTensors : " << name() << endl
             << "    (half)size:" << Cf.size() << nl
             << "    absTol:" << absTol << nl
+            //<< "    smallDist:" << smallDist << nl
             << "    sum(mag(nf & nr)):" << sum(mag(nf & nr)) << endl;
     }
 
@@ -316,6 +317,13 @@ void Foam::coupledPolyPatch::calcTransformTensors
             {
                 forwardT_.setSize(1);
                 reverseT_.setSize(1);
+
+                if (debug)
+                {
+                    Pout<< "    rotation " << sum(mag(forwardT_ - forwardT_[0]))
+                        << " more than local tolerance " << error
+                        << ". Assuming uniform rotation." << endl;
+                }
             }
         }
         else
@@ -384,7 +392,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
 
     if (debug)
     {
-        Pout<< "    separation_:" << separation_ << nl
+        Pout<< "    separation_:" << separation_.size() << nl
             << "    forwardT size:" << forwardT_.size() << endl;
     }
 }
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
index 31faea5669f6cb899fb41f8aaaa81180771ff215..171fb099f1a08ce774a19e2421c94ee83249cdb4 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
@@ -127,6 +127,22 @@ void Foam::cyclicPolyPatch::calcTransforms()
             Pout<< "cyclicPolyPatch::calcTransforms : Writing half1"
                 << " faces to OBJ file " << nm1 << endl;
             writeOBJ(nm1, half1, half1.points());
+
+            OFstream str(casePath/name()+"_half0_to_half1.obj");
+            label vertI = 0;
+            Pout<< "cyclicPolyPatch::calcTransforms :"
+                << " Writing coupled face centres as lines to " << str.name()
+                << endl;
+            forAll(half0Ctrs, i)
+            {
+                const point& p0 = half0Ctrs[i];
+                str << "v " << p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl;
+                vertI++;
+                const point& p1 = half1Ctrs[i];
+                str << "v " << p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl;
+                vertI++;
+                str << "l " << vertI-1 << ' ' << vertI << nl;
+            }
         }
 
         vectorField half0Normals(half0.size());
@@ -397,8 +413,6 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
     anchors0 = getAnchorPoints(half0Faces, pp.points());
     half1Ctrs = calcFaceCentres(half1Faces, pp.points());
 
-    vector n0 = vector::zero;
-    vector n1 = vector::zero;
     switch (transform_)
     {
         case ROTATIONAL:
@@ -406,12 +420,46 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
             label face0 = getConsistentRotationFace(half0Ctrs);
             label face1 = getConsistentRotationFace(half1Ctrs);
 
-            n0 = ((half0Ctrs[face0] - rotationCentre_) ^ rotationAxis_);
-            n1 = ((half1Ctrs[face1] - rotationCentre_) ^ -rotationAxis_);
+            vector n0 = ((half0Ctrs[face0] - rotationCentre_) ^ rotationAxis_);
+            vector n1 = ((half1Ctrs[face1] - rotationCentre_) ^ -rotationAxis_);
             n0 /= mag(n0) + VSMALL;
             n1 /= mag(n1) + VSMALL;
+
+            if (debug)
+            {
+                Pout<< "cyclicPolyPatch::getCentresAndAnchors :"
+                    << " Specified rotation :"
+                    << " n0:" << n0 << " n1:" << n1 << endl;
+            }
+
+            // Rotation (around origin)
+            const tensor reverseT(rotationTensor(n0, -n1));
+
+            // Rotation
+            forAll(half0Ctrs, faceI)
+            {
+                half0Ctrs[faceI] = Foam::transform(reverseT, half0Ctrs[faceI]);
+                anchors0[faceI] = Foam::transform(reverseT, anchors0[faceI]);
+            }
+
             break;
         }
+        //- Problem: usually specified translation is not accurate enough
+        //- to get proper match so keep automatic determination over here.
+        //case TRANSLATIONAL:
+        //{
+        //    // Transform 0 points.
+        //
+        //    if (debug)
+        //    {
+        //        Pout<< "cyclicPolyPatch::getCentresAndAnchors :"
+        //            << "Specified translation : " << separationVector_ << endl;
+        //    }
+        //
+        //    half0Ctrs += separationVector_;
+        //    anchors0 += separationVector_;
+        //    break;
+        //}
         default:
         {
             // Assumes that cyclic is planar. This is also the initial
@@ -420,56 +468,68 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
             // Determine the face with max area on both halves. These
             // two faces are used to determine the transformation tensors
             label max0I = findMaxArea(pp.points(), half0Faces);
-            n0 = half0Faces[max0I].normal(pp.points());
+            vector n0 = half0Faces[max0I].normal(pp.points());
             n0 /= mag(n0) + VSMALL;
 
             label max1I = findMaxArea(pp.points(), half1Faces);
-            n1 = half1Faces[max1I].normal(pp.points());
+            vector n1 = half1Faces[max1I].normal(pp.points());
             n1 /= mag(n1) + VSMALL;
-        }
-    }
 
-    if (mag(n0 & n1) < 1-coupledPolyPatch::matchTol)
-    {
-        if (debug)
-        {
-            Pout<< "cyclicPolyPatch::getCentresAndAnchors : Rotation :"
-                << " n0:" << n0 << " n1:" << n1 << endl;
-        }
+            if (mag(n0 & n1) < 1-coupledPolyPatch::matchTol)
+            {
+                if (debug)
+                {
+                    Pout<< "cyclicPolyPatch::getCentresAndAnchors :"
+                        << " Detected rotation :"
+                        << " n0:" << n0 << " n1:" << n1 << endl;
+                }
 
-        // Rotation (around origin)
-        const tensor reverseT(rotationTensor(n0, -n1));
+                // Rotation (around origin)
+                const tensor reverseT(rotationTensor(n0, -n1));
 
-        // Rotation
-        forAll(half0Ctrs, faceI)
-        {
-            half0Ctrs[faceI] = Foam::transform(reverseT, half0Ctrs[faceI]);
-            anchors0[faceI] = Foam::transform(reverseT, anchors0[faceI]);
-        }
-    }
-    else
-    {
-        // Parallel translation. Get average of all used points.
+                // Rotation
+                forAll(half0Ctrs, faceI)
+                {
+                    half0Ctrs[faceI] = Foam::transform
+                    (
+                        reverseT,
+                        half0Ctrs[faceI]
+                    );
+                    anchors0[faceI] = Foam::transform
+                    (
+                        reverseT,
+                        anchors0[faceI]
+                    );
+                }
+            }
+            else
+            {
+                // Parallel translation. Get average of all used points.
 
-        primitiveFacePatch half0(half0Faces, pp.points());
-        const pointField& half0Pts = half0.localPoints();
-        const point ctr0(sum(half0Pts)/half0Pts.size());
+                primitiveFacePatch half0(half0Faces, pp.points());
+                const pointField& half0Pts = half0.localPoints();
+                const point ctr0(sum(half0Pts)/half0Pts.size());
 
-        primitiveFacePatch half1(half1Faces, pp.points());
-        const pointField& half1Pts = half1.localPoints();
-        const point ctr1(sum(half1Pts)/half1Pts.size());
+                primitiveFacePatch half1(half1Faces, pp.points());
+                const pointField& half1Pts = half1.localPoints();
+                const point ctr1(sum(half1Pts)/half1Pts.size());
 
-        if (debug)
-        {
-            Pout<< "cyclicPolyPatch::getCentresAndAnchors : Translation :"
-                << " n0:" << n0 << " n1:" << n1
-                << " ctr0:" << ctr0 << " ctr1:" << ctr1 << endl;
-        }
+                if (debug)
+                {
+                    Pout<< "cyclicPolyPatch::getCentresAndAnchors :"
+                        << " Detected translation :"
+                        << " n0:" << n0 << " n1:" << n1
+                        << " ctr0:" << ctr0 << " ctr1:" << ctr1 << endl;
+                }
 
-        half0Ctrs += ctr1 - ctr0;
-        anchors0 += ctr1 - ctr0;
+                half0Ctrs += ctr1 - ctr0;
+                anchors0 += ctr1 - ctr0;
+            }
+            break;
+        }
     }
 
+
     // Calculate typical distance per face
     tols = calcFaceTol(half1Faces, pp.points(), half1Ctrs);
 }
@@ -615,7 +675,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
     featureCos_(0.9),
     transform_(UNKNOWN),
     rotationAxis_(vector::zero),
-    rotationCentre_(point::zero)
+    rotationCentre_(point::zero),
+    separationVector_(vector::zero)
 {
     calcTransforms();
 }
@@ -635,7 +696,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
     featureCos_(0.9),
     transform_(UNKNOWN),
     rotationAxis_(vector::zero),
-    rotationCentre_(point::zero)
+    rotationCentre_(point::zero),
+    separationVector_(vector::zero)
 {
     dict.readIfPresent("featureCos", featureCos_);
 
@@ -650,9 +712,14 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
                 dict.lookup("rotationCentre") >> rotationCentre_;
                 break;
             }
+            case TRANSLATIONAL:
+            {
+                dict.lookup("separationVector") >> separationVector_;
+                break;
+            }
             default:
             {
-                // no additioanl info required
+                // no additional info required
             }
         }
     }
@@ -673,7 +740,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
     featureCos_(pp.featureCos_),
     transform_(pp.transform_),
     rotationAxis_(pp.rotationAxis_),
-    rotationCentre_(pp.rotationCentre_)
+    rotationCentre_(pp.rotationCentre_),
+    separationVector_(pp.separationVector_)
 {
     calcTransforms();
 }
@@ -694,7 +762,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
     featureCos_(pp.featureCos_),
     transform_(pp.transform_),
     rotationAxis_(pp.rotationAxis_),
-    rotationCentre_(pp.rotationCentre_)
+    rotationCentre_(pp.rotationCentre_),
+    separationVector_(pp.separationVector_)
 {
     calcTransforms();
 }
@@ -1322,6 +1391,8 @@ void Foam::cyclicPolyPatch::write(Ostream& os) const
         {
             os.writeKeyword("transform") << transformTypeNames[TRANSLATIONAL]
                 << token::END_STATEMENT << nl;
+            os.writeKeyword("separationVector") << separationVector_
+                << token::END_STATEMENT << nl;
             break;
         }
         default:
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H
index f9c4e66dbb2c69cb6e2cdae369ae1c80f35b7bb4..7db828985fb8e37dcb78820e0d1dec0989484893 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H
@@ -101,11 +101,18 @@ private:
         //- Type of transformation - rotational or translational
         transformType transform_;
 
-        //- Axis of rotation for rotational cyclics
-        vector rotationAxis_;
+        // For rotation
 
-        //- point on axis of rotation for rotational cyclics
-        point rotationCentre_;
+            //- Axis of rotation for rotational cyclics
+            vector rotationAxis_;
+
+            //- point on axis of rotation for rotational cyclics
+            point rotationCentre_;
+
+        // For translation
+
+            //- Translation vector
+            vector separationVector_;
 
 
     // Private member functions
@@ -267,66 +274,94 @@ public:
         const edgeList& coupledEdges() const;
 
 
-        vector separation(const label facei) const
-        {
-            if (facei < size()/2)
-            {
-                return coupledPolyPatch::separation()[0];
-            }
-            else
+
+        // Transformation
+
+            vector separation(const label facei) const
             {
-                return -coupledPolyPatch::separation()[0];
+                if (facei < size()/2)
+                {
+                    return coupledPolyPatch::separation()[0];
+                }
+                else
+                {
+                    return -coupledPolyPatch::separation()[0];
+                }
             }
-        }
 
-        const tensor& transformT(const label facei) const
-        {
-            if (facei < size()/2)
+            const tensor& transformT(const label facei) const
             {
-                return reverseT()[0];
+                if (facei < size()/2)
+                {
+                    return reverseT()[0];
+                }
+                else
+                {
+                    return forwardT()[0];
+                }
             }
-            else
+
+            template<class T>
+            T transform(const T& t, const label facei) const
             {
-                return forwardT()[0];
+                if (parallel())
+                {
+                    return t;
+                }
+                else
+                {
+                    return Foam::transform(transformT(facei), t);
+                }
             }
-        }
 
-        template<class T>
-        T transform(const T& t, const label facei) const
-        {
-            if (parallel())
+            label transformLocalFace(const label facei) const
             {
-                return t;
+                if (facei < size()/2)
+                {
+                    return facei + size()/2;
+                }
+                else
+                {
+                    return facei - size()/2;
+                }
             }
-            else
+
+            label transformGlobalFace(const label facei) const
             {
-                return Foam::transform(transformT(facei), t);
+                if (facei - start() < size()/2)
+                {
+                    return facei + size()/2;
+                }
+                else
+                {
+                    return facei - size()/2;
+                }
             }
-        }
 
-        label transformLocalFace(const label facei) const
-        {
-            if (facei < size()/2)
+            //- Type of transform
+            transformType transform() const
             {
-                return facei + size()/2;
+                return transform_;
             }
-            else
+
+            //- Axis of rotation for rotational cyclics
+            const vector& rotationAxis() const
             {
-                return facei - size()/2;
+                return rotationAxis_;
             }
-        }
 
-        label transformGlobalFace(const label facei) const
-        {
-            if (facei - start() < size()/2)
+            //- point on axis of rotation for rotational cyclics
+            const point& rotationCentre() const
             {
-                return facei + size()/2;
+                return rotationCentre_;
             }
-            else
+
+            //- Translation vector for translational cyclics
+            const vector& separationVector() const
             {
-                return facei - size()/2;
+                return separationVector_;
             }
-        }
+
 
 
         //- Initialize ordering for primitivePatch. Does not
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
index d85cc939360ad265a6c01bec472822db7ad93533..ab3639362b693a4f9f7c697a3372bf810d39c1fb 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
@@ -114,6 +114,22 @@ Foam::cellZone::cellZone
 {}
 
 
+Foam::cellZone::cellZone
+(
+    const word& name,
+    const xfer<labelList>& addr,
+    const label index,
+    const cellZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(name),
+    index_(index),
+    zoneMesh_(zm),
+    cellLookupMapPtr_(NULL)
+{}
+
+
 // Construct from dictionary
 Foam::cellZone::cellZone
 (
@@ -148,6 +164,21 @@ Foam::cellZone::cellZone
     cellLookupMapPtr_(NULL)
 {}
 
+Foam::cellZone::cellZone
+(
+    const cellZone& cz,
+    const xfer<labelList>& addr,
+    const label index,
+    const cellZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(cz.name()),
+    index_(index),
+    zoneMesh_(zm),
+    cellLookupMapPtr_(NULL)
+{}
+
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
index 799e810e2a3454520721e3f26da7c14acd8e1091..a239992cde0ffbbfa45cb73fb2deb1d25e275960 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
@@ -128,26 +128,45 @@ public:
             const word& name,
             const labelList& addr,
             const label index,
-            const cellZoneMesh& zm
+            const cellZoneMesh&
+        );
+
+        //- Construct from components, transferring contents
+        cellZone
+        (
+            const word& name,
+            const xfer<labelList>& addr,
+            const label index,
+            const cellZoneMesh&
         );
 
         //- Construct from dictionary
         cellZone
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
-            const cellZoneMesh& zm
+            const cellZoneMesh&
         );
 
         //- Construct given the original zone and resetting the
         //  cell list and zone mesh information
         cellZone
         (
-            const cellZone& cz,
+            const cellZone&,
             const labelList& addr,
             const label index,
-            const cellZoneMesh& zm
+            const cellZoneMesh&
+        );
+
+        //- Construct given the original zone, resetting the
+        //  cell list and zone mesh information
+        cellZone
+        (
+            const cellZone&,
+            const xfer<labelList>& addr,
+            const label index,
+            const cellZoneMesh&
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -182,7 +201,7 @@ public:
         static autoPtr<cellZone> New
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
             const cellZoneMesh&
         );
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
index acc3b0dcf99574b49b3ab987bdaace28972a2208..0a478f8c88ec116c1936e4c681c76766b4ab7f96 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
@@ -242,6 +242,30 @@ Foam::faceZone::faceZone
 }
 
 
+Foam::faceZone::faceZone
+(
+    const word& name,
+    const xfer<labelList>& addr,
+    const xfer<boolList>& fm,
+    const label index,
+    const faceZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(name),
+    flipMap_(fm),
+    index_(index),
+    zoneMesh_(zm),
+    patchPtr_(NULL),
+    masterCellsPtr_(NULL),
+    slaveCellsPtr_(NULL),
+    mePtr_(NULL),
+    faceLookupMapPtr_(NULL)
+{
+    checkAddressing();
+}
+
+
 // Construct from dictionary
 Foam::faceZone::faceZone
 (
@@ -292,6 +316,30 @@ Foam::faceZone::faceZone
 }
 
 
+Foam::faceZone::faceZone
+(
+    const faceZone& fz,
+    const xfer<labelList>& addr,
+    const xfer<boolList>& fm,
+    const label index,
+    const faceZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(fz.name()),
+    flipMap_(fm),
+    index_(index),
+    zoneMesh_(zm),
+    patchPtr_(NULL),
+    masterCellsPtr_(NULL),
+    slaveCellsPtr_(NULL),
+    mePtr_(NULL),
+    faceLookupMapPtr_(NULL)
+{
+    checkAddressing();
+}
+
+
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 Foam::faceZone::~faceZone()
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
index c299361cf69b9827aacdb6629f370d1be2b12fe9..7d489da273cc5436369b997f6e0bf9e1be3aca75 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
@@ -163,24 +163,45 @@ public:
             const faceZoneMesh& zm
         );
 
+        //- Construct from components, transferring contents
+        faceZone
+        (
+            const word& name,
+            const xfer<labelList>& addr,
+            const xfer<boolList>& fm,
+            const label index,
+            const faceZoneMesh&
+        );
+
         //- Construct from dictionary
         faceZone
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
-            const faceZoneMesh& zm
+            const faceZoneMesh&
         );
 
         //- Construct given the original zone and resetting the
         //  face list and zone mesh information
         faceZone
         (
-            const faceZone& fz,
+            const faceZone&,
             const labelList& addr,
             const boolList& fm,
             const label index,
-            const faceZoneMesh& zm
+            const faceZoneMesh&
+        );
+
+        //- Construct given the original zone, resetting the
+        //  face list and zone mesh information
+        faceZone
+        (
+            const faceZone&,
+            const xfer<labelList>& addr,
+            const xfer<boolList>& fm,
+            const label index,
+            const faceZoneMesh&
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -216,9 +237,9 @@ public:
         static autoPtr<faceZone> New
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
-            const faceZoneMesh& zm
+            const faceZoneMesh&
         );
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
index 972588686d608bfb462003ff73730615c5b0618e..e93bb69ae6b8c168b832d263c9b7bef294c7d358 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
@@ -112,6 +112,22 @@ Foam::pointZone::pointZone
 {}
 
 
+Foam::pointZone::pointZone
+(
+    const word& name,
+    const xfer<labelList>& addr,
+    const label index,
+    const pointZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(name),
+    index_(index),
+    zoneMesh_(zm),
+    pointLookupMapPtr_(NULL)
+{}
+
+
 // Construct from dictionary
 Foam::pointZone::pointZone
 (
@@ -147,6 +163,22 @@ Foam::pointZone::pointZone
 {}
 
 
+Foam::pointZone::pointZone
+(
+    const pointZone& pz,
+    const xfer<labelList>& addr,
+    const label index,
+    const pointZoneMesh& zm
+)
+:
+    labelList(addr),
+    name_(pz.name()),
+    index_(index),
+    zoneMesh_(zm),
+    pointLookupMapPtr_(NULL)
+{}
+
+
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 Foam::pointZone::~pointZone()
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
index 18370e2672bf37b77b2e060855e948489447aec2..afc48da717d83ae0a26b61c754ffdf6fd2fc5b92 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
@@ -130,26 +130,45 @@ public:
             const word& name,
             const labelList& addr,
             const label index,
-            const pointZoneMesh& zm
+            const pointZoneMesh&
+        );
+
+        //- Construct from components, transferring contents
+        pointZone
+        (
+            const word& name,
+            const xfer<labelList>& addr,
+            const label index,
+            const pointZoneMesh&
         );
 
         //- Construct from dictionary
         pointZone
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
-            const pointZoneMesh& zm
+            const pointZoneMesh&
         );
 
         //- Construct given the original zone and resetting the
         //  point list and zone mesh information
         pointZone
         (
-            const pointZone& pz,
+            const pointZone&,
             const labelList& addr,
             const label index,
-            const pointZoneMesh& zm
+            const pointZoneMesh&
+        );
+
+        //- Construct given the original zone, resetting the
+        //  face list and zone mesh information
+        pointZone
+        (
+            const pointZone&,
+            const xfer<labelList>& addr,
+            const label index,
+            const pointZoneMesh&
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -184,7 +203,7 @@ public:
         static autoPtr<pointZone> New
         (
             const word& name,
-            const dictionary& dict,
+            const dictionary&,
             const label index,
             const pointZoneMesh&
         );
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
index 8c210172690c9e581f4997b11e3aa751aa2b4729..6bcc2af56f4758e63cf73044c2605e73c4f74d7a 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
@@ -66,7 +66,6 @@ primitiveMesh::primitiveMesh()
     ppPtr_(NULL),
     cpPtr_(NULL),
 
-    allocSize_(0),
     labels_(0),
 
     cellCentresPtr_(NULL),
@@ -109,7 +108,6 @@ primitiveMesh::primitiveMesh
     ppPtr_(NULL),
     cpPtr_(NULL),
 
-    allocSize_(0),
     labels_(0),
 
     cellCentresPtr_(NULL),
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
index 3868ba2b25bc638c6c656b6ea0d3d5ee0b0ad58b..6f24944cbc7e7df8258a11999f6755584066ecb7 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
@@ -54,6 +54,7 @@ SourceFiles
 #ifndef primitiveMesh_H
 #define primitiveMesh_H
 
+#include "DynamicList.H"
 #include "edgeList.H"
 #include "pointField.H"
 #include "SubField.H"
@@ -157,10 +158,8 @@ class primitiveMesh
 
         // On-the-fly edge addresing storage
 
-            //- Temporary storage for addressing. allocSize is the real size
-            //  of the labelList.
-            mutable label allocSize_;
-            mutable labelList labels_;
+            //- Temporary storage for addressing.
+            mutable DynamicList<label> labels_;
 
             //- Temporary storage for addressing
             mutable labelHashSet labelSet_;
@@ -705,31 +704,80 @@ public:
 
             // On-the-fly addressing calculation. These functions return either
             // a reference to the full addressing (if already calculated) or
-            // a reference to member data labels_ so be careful when not storing
+            // a reference to the supplied storage. The one-argument ones
+            // use member DynamicList labels_ so be careful when not storing
             // result.
 
-            //- cellCells using cells
+            //- cellCells using cells.
+            const labelList& cellCells
+            (
+                const label cellI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& cellCells(const label cellI) const;
 
             //- cellPoints using cells
+            const labelList& cellPoints
+            (
+                const label cellI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& cellPoints(const label cellI) const;
 
             //- pointCells using pointFaces
+            const labelList& pointCells
+            (
+                const label pointI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& pointCells(const label pointI) const;
 
             //- pointPoints using edges, pointEdges
+            const labelList& pointPoints
+            (
+                const label pointI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& pointPoints(const label pointI) const;
 
             //- faceEdges using pointFaces, edges, pointEdges
+            const labelList& faceEdges
+            (
+                const label faceI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& faceEdges(const label faceI) const;
 
             //- edgeFaces using pointFaces, edges, pointEdges
+            const labelList& edgeFaces
+            (
+                const label edgeI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& edgeFaces(const label edgeI) const;
 
             //- edgeCells using pointFaces, edges, pointEdges
+            const labelList& edgeCells
+            (
+                const label edgeI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& edgeCells(const label edgeI) const;
 
             //- cellEdges using cells, pointFaces, edges, pointEdges
+            const labelList& cellEdges
+            (
+                const label cellI,
+                DynamicList<label>&
+            ) const;
+
             const labelList& cellEdges(const label cellI) const;
 
 
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCells.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCells.C
index 3c8f896bbeb827f37f06a89046e77a7f28ab1c2e..e2eaf17a0f8f08f1fd795f2aafda47b8d3bbe544 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCells.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCells.C
@@ -41,6 +41,14 @@ void primitiveMesh::calcCellCells() const
     {
         Pout<< "primitiveMesh::calcCellCells() : calculating cellCells"
             << endl;
+
+        if (debug == -1)
+        {
+            // For checking calls:abort so we can quickly hunt down
+            // origin of call
+            FatalErrorIn("primitiveMesh::calcCellCells()")
+                << abort(FatalError);
+        }
     }
 
     // It is an error to attempt to recalculate cellCells
@@ -105,7 +113,11 @@ const labelListList& primitiveMesh::cellCells() const
 }
 
 
-const labelList& primitiveMesh::cellCells(const label cellI) const
+const labelList& primitiveMesh::cellCells
+(
+    const label cellI,
+    DynamicList<label>& storage
+) const
 {
     if (hasCellCells())
     {
@@ -117,16 +129,7 @@ const labelList& primitiveMesh::cellCells(const label cellI) const
         const labelList& nei = faceNeighbour();
         const cell& cFaces = cells()[cellI];
 
-        labels_.size() = allocSize_;
-
-        if (cFaces.size() > allocSize_)
-        {
-            labels_.clear();
-            allocSize_ = cFaces.size();
-            labels_.setSize(allocSize_);
-        }
-
-        label n = 0;
+        storage.clear();
 
         forAll(cFaces, i)
         {
@@ -136,22 +139,26 @@ const labelList& primitiveMesh::cellCells(const label cellI) const
             {
                 if (own[faceI] == cellI)
                 {
-                    labels_[n++] = nei[faceI];
+                    storage.append(nei[faceI]);
                 }
                 else
                 {
-                    labels_[n++] = own[faceI];
+                    storage.append(own[faceI]);
                 }
             }
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::cellCells(const label cellI) const
+{
+    return cellCells(cellI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
index 6588f4b7216d81b42d6ed4a8735a2d76b3ce4a67..47d6343f16e42639aa8f5bd9c1f277d73f773e13 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
@@ -40,6 +40,14 @@ void Foam::primitiveMesh::calcCellEdges() const
         Pout<< "primitiveMesh::calcCellEdges() : "
             << "calculating cellEdges"
             << endl;
+
+        if (debug == -1)
+        {
+            // For checking calls:abort so we can quickly hunt down
+            // origin of call
+            FatalErrorIn("primitiveMesh::calcCellEdges()")
+                << abort(FatalError);
+        }
     }
 
     // It is an error to attempt to recalculate cellEdges
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellPoints.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellPoints.C
index c8f63e1eef66b839ae0cd0dc99eff5dc80f0e5a8..f813c3b15ff456b0506bca8b79338a304d50409d 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellPoints.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellPoints.C
@@ -42,6 +42,14 @@ const labelListList& primitiveMesh::cellPoints() const
         {
             Pout<< "primitiveMesh::cellPoints() : "
                 << "calculating cellPoints" << endl;
+
+            if (debug == -1)
+            {
+                // For checking calls:abort so we can quickly hunt down
+                // origin of call
+                FatalErrorIn("primitiveMesh::cellPoints()")
+                    << abort(FatalError);
+            }
         }
 
         // Invert pointCells
@@ -53,7 +61,11 @@ const labelListList& primitiveMesh::cellPoints() const
 }
 
 
-const labelList& primitiveMesh::cellPoints(const label cellI) const
+const labelList& primitiveMesh::cellPoints
+(
+    const label cellI,
+    DynamicList<label>& storage
+) const
 {
     if (hasCellPoints())
     {
@@ -76,29 +88,28 @@ const labelList& primitiveMesh::cellPoints(const label cellI) const
             }
         }
 
-        labels_.size() = allocSize_;
-
-        if (labelSet_.size() > allocSize_)
+        storage.clear();
+        if (labelSet_.size() > storage.allocSize())
         {
-            labels_.clear();
-            allocSize_ = labelSet_.size();
-            labels_.setSize(allocSize_);
+            storage.setSize(labelSet_.size());
         }
 
-        label n = 0;
-
         forAllConstIter(labelHashSet, labelSet_, iter)
         {
-            labels_[n++] = iter.key();
+            storage.append(iter.key());
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::cellPoints(const label cellI) const
+{
+    return cellPoints(cellI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeCells.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeCells.C
index 6a2f309dd31bf7693c45ed9b32f94196e66e0f38..7b56c2e88f2c063ca70468987e54645f5b50fe9a 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeCells.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeCells.C
@@ -41,6 +41,14 @@ const labelListList& primitiveMesh::edgeCells() const
         if (debug)
         {
             Pout<< "primitiveMesh::edgeCells() : calculating edgeCells" << endl;
+
+            if (debug == -1)
+            {
+                // For checking calls:abort so we can quickly hunt down
+                // origin of call
+                FatalErrorIn("primitiveMesh::edgeCells()")
+                    << abort(FatalError);
+            }
         }
         // Invert cellEdges
         ecPtr_ = new labelListList(nEdges());
@@ -51,7 +59,11 @@ const labelListList& primitiveMesh::edgeCells() const
 }
 
 
-const labelList& primitiveMesh::edgeCells(const label edgeI) const
+const labelList& primitiveMesh::edgeCells
+(
+    const label edgeI,
+    DynamicList<label>& storage
+) const
 {
     if (hasEdgeCells())
     {
@@ -62,24 +74,11 @@ const labelList& primitiveMesh::edgeCells(const label edgeI) const
         const labelList& own = faceOwner();
         const labelList& nei = faceNeighbour();
 
-        // edge faces can either return labels_ or reference in edgeLabels.
-        labelList labelsCopy;
-        if (!hasEdgeFaces())
-        {
-            labelsCopy = edgeFaces(edgeI);
-        }
-
-        const labelList& eFaces =
-        (
-            hasEdgeFaces()
-          ? edgeFaces()[edgeI]
-          : labelsCopy
-        );
+        // Construct edgeFaces
+        DynamicList<label> eFacesStorage;
+        const labelList& eFaces = edgeFaces(edgeI, eFacesStorage);
 
-        labels_.size() = allocSize_;
-
-        // labels_ should certainly be big enough for edge cells.
-        label n = 0;
+        storage.clear();
 
         // Do quadratic insertion.
         forAll(eFaces, i)
@@ -89,10 +88,10 @@ const labelList& primitiveMesh::edgeCells(const label edgeI) const
             {
                 label ownCellI = own[faceI];
 
-                // Check if not already in labels_
-                for (label j = 0; j < n; j++)
+                // Check if not already in storage
+                forAll(storage, j)
                 {
-                    if (labels_[j] == ownCellI)
+                    if (storage[j] == ownCellI)
                     {
                         ownCellI = -1;
                         break;
@@ -101,7 +100,7 @@ const labelList& primitiveMesh::edgeCells(const label edgeI) const
 
                 if (ownCellI != -1)
                 {
-                    labels_[n++] = ownCellI;
+                    storage.append(ownCellI);
                 }
             }
 
@@ -109,9 +108,9 @@ const labelList& primitiveMesh::edgeCells(const label edgeI) const
             {
                 label neiCellI = nei[faceI];
 
-                for (label j = 0; j < n; j++)
+                forAll(storage, j)
                 {
-                    if (labels_[j] == neiCellI)
+                    if (storage[j] == neiCellI)
                     {
                         neiCellI = -1;
                         break;
@@ -120,18 +119,22 @@ const labelList& primitiveMesh::edgeCells(const label edgeI) const
 
                 if (neiCellI != -1)
                 {
-                    labels_[n++] = neiCellI;
+                    storage.append(neiCellI);
                 }
             }
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::edgeCells(const label edgeI) const
+{
+    return edgeCells(edgeI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeFaces.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeFaces.C
index 99536bcd335fe3cae6a3081aa48532adab9f3d8f..1281a713af9ee7424db0534613db3dda1cffad8b 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeFaces.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdgeFaces.C
@@ -41,6 +41,14 @@ const labelListList& primitiveMesh::edgeFaces() const
         if (debug)
         {
             Pout<< "primitiveMesh::edgeFaces() : calculating edgeFaces" << endl;
+
+            if (debug == -1)
+            {
+                // For checking calls:abort so we can quickly hunt down
+                // origin of call
+                FatalErrorIn("primitiveMesh::edgeFaces()")
+                    << abort(FatalError);
+            }
         }
 
         // Invert faceEdges
@@ -52,7 +60,11 @@ const labelListList& primitiveMesh::edgeFaces() const
 }
 
 
-const labelList& primitiveMesh::edgeFaces(const label edgeI) const
+const labelList& primitiveMesh::edgeFaces
+(
+    const label edgeI,
+    DynamicList<label>& storage
+) const
 {
     if (hasEdgeFaces())
     {
@@ -67,9 +79,8 @@ const labelList& primitiveMesh::edgeFaces(const label edgeI) const
 
         label i0 = 0;
         label i1 = 0;
-        label n = 0;
 
-        labels_.size() = allocSize_;
+        storage.clear();
 
         while (i0 < pFaces0.size() && i1 < pFaces1.size())
         {
@@ -84,26 +95,23 @@ const labelList& primitiveMesh::edgeFaces(const label edgeI) const
             else
             {
                 // Equal. Append.
-                if (n == allocSize_)
-                {
-                    // Have setSize copy contents so far
-                    labels_.size() = n;
-                    allocSize_ = allocSize_*2 + 1;
-                    labels_.setSize(allocSize_);
-                }
-                labels_[n++] = pFaces0[i0];
+                storage.append(pFaces0[i0]);
                 ++i0;
                 ++i1;
             }
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::edgeFaces(const label edgeI) const
+{
+    return edgeFaces(edgeI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
index b64eda72663185c99075f13cfe4ea2dac81e9cff..d7a79fb8feed128ce45d95cda64516c2799c117c 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
@@ -582,11 +582,15 @@ void primitiveMesh::clearOutEdges()
     deleteDemandDrivenData(pePtr_);
     deleteDemandDrivenData(fePtr_);
     labels_.clear();
-    allocSize_ = 0;
+    labelSet_.clear();
 }
 
 
-const labelList& primitiveMesh::faceEdges(const label faceI) const
+const labelList& primitiveMesh::faceEdges
+(
+    const label faceI,
+    DynamicList<label>& storage
+) const
 {
     if (hasFaceEdges())
     {
@@ -597,34 +601,40 @@ const labelList& primitiveMesh::faceEdges(const label faceI) const
         const labelListList& pointEs = pointEdges();
         const face& f = faces()[faceI];
 
-        labels_.size() = allocSize_;
-
-        if (f.size() > allocSize_)
+        storage.clear();
+        if (f.size() > storage.allocSize())
         {
-            labels_.clear();
-            allocSize_ = f.size();
-            labels_.setSize(allocSize_);
+            storage.setSize(f.size());
         }
 
-        label n = 0;
-
         forAll(f, fp)
         {
-            labels_[n++] = findFirstCommonElementFromSortedLists
+            storage.append
             (
-                pointEs[f[fp]],
-                pointEs[f.nextLabel(fp)]
+                findFirstCommonElementFromSortedLists
+                (
+                    pointEs[f[fp]],
+                    pointEs[f.nextLabel(fp)]
+                )
             );
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
-const labelList& primitiveMesh::cellEdges(const label cellI) const
+const labelList& primitiveMesh::faceEdges(const label faceI) const
+{
+    return faceEdges(faceI, labels_);
+}
+
+
+const labelList& primitiveMesh::cellEdges
+(
+    const label cellI,
+    DynamicList<label>& storage
+) const
 {
     if (hasCellEdges())
     {
@@ -646,29 +656,29 @@ const labelList& primitiveMesh::cellEdges(const label cellI) const
             }
         }
 
-        labels_.size() = allocSize_;
+        storage.clear();
 
-        if (labelSet_.size() > allocSize_)
+        if (labelSet_.size() > storage.allocSize())
         {
-            labels_.clear();
-            allocSize_ = labelSet_.size();
-            labels_.setSize(allocSize_);
+            storage.setSize(labelSet_.size());
         }
 
-        label n =0;
-
         forAllConstIter(labelHashSet, labelSet_, iter)
         {
-            labels_[n++] = iter.key();
+            storage.append(iter.key());
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::cellEdges(const label cellI) const
+{
+    return cellEdges(cellI, labels_);;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C
index 6d7af72e0b8e2c1553922f0ad5b617fe12fd7012..8a416eafaaf658137d0d4e322f8704b0fd887777 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C
@@ -43,6 +43,14 @@ void primitiveMesh::calcPointCells() const
         Pout<< "primitiveMesh::calcPointCells() : "
             << "calculating pointCells"
             << endl;
+
+        if (debug == -1)
+        {
+            // For checking calls:abort so we can quickly hunt down
+            // origin of call
+            FatalErrorIn("primitiveMesh::calcPointCells()")
+                << abort(FatalError);
+        }
     }
 
     // It is an error to attempt to recalculate pointCells
@@ -114,7 +122,11 @@ const labelListList& primitiveMesh::pointCells() const
 }
 
 
-const labelList& primitiveMesh::pointCells(const label pointI) const
+const labelList& primitiveMesh::pointCells
+(
+    const label pointI,
+    DynamicList<label>& storage
+) const
 {
     if (hasPointCells())
     {
@@ -126,58 +138,48 @@ const labelList& primitiveMesh::pointCells(const label pointI) const
         const labelList& nei = faceNeighbour();
         const labelList& pFaces = pointFaces()[pointI];
 
-        labels_.size() = allocSize_;
-
-        label n = 0;
+        storage.clear();
 
         forAll(pFaces, i)
         {
             const label faceI = pFaces[i];
 
             // Append owner
-            if (n == allocSize_)
-            {
-                labels_.size() = n;
-                allocSize_ = allocSize_*2 + 1;
-                labels_.setSize(allocSize_);
-            }
-            labels_[n++] = own[faceI];
+            storage.append(own[faceI]);
 
             // Append neighbour
             if (faceI < nInternalFaces())
             {
-                if (n == allocSize_)
-                {
-                    labels_.size() = n;
-                    allocSize_ = allocSize_*2 + 1;
-                    labels_.setSize(allocSize_);
-                }
-                labels_[n++] = nei[faceI];
+                storage.append(nei[faceI]);
             }
         }
-        labels_.size() = n;
-
 
         // Filter duplicates
-        sort(labels_);
+        sort(storage);
 
-        n = 1;
+        label n = 1;
 
-        for (label i = 1; i < labels_.size(); i++)
+        for (label i = 1; i < storage.size(); i++)
         {
-            if (labels_[i] != labels_[i-1])
+            if (storage[i] != storage[i-1])
             {
-                labels_[n++] = labels_[i];
+                storage[n++] = storage[i];
             }
         }
 
-        labels_.size() = n;
+        storage.setSize(n);
 
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::pointCells(const label pointI) const
+{
+    return pointCells(pointI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointPoints.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointPoints.C
index 099e2669418d7ed4310d673caeb7adb3e2f8003a..e1ffa07dff88201df77bcba1423a8bf7dba16950 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointPoints.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointPoints.C
@@ -40,6 +40,14 @@ void primitiveMesh::calcPointPoints() const
         Pout<< "primitiveMesh::calcPointPoints() : "
             << "calculating pointPoints"
             << endl;
+
+        if (debug == -1)
+        {
+            // For checking calls:abort so we can quickly hunt down
+            // origin of call
+            FatalErrorIn("primitiveMesh::calcPointPoints()")
+                << abort(FatalError);
+        }
     }
 
     // It is an error to attempt to recalculate pointPoints
@@ -97,7 +105,11 @@ const labelListList& primitiveMesh::pointPoints() const
 }
 
 
-const labelList& primitiveMesh::pointPoints(const label pointI) const
+const labelList& primitiveMesh::pointPoints
+(
+    const label pointI,
+    DynamicList<label>& storage
+) const
 {
     if (hasPointPoints())
     {
@@ -108,30 +120,29 @@ const labelList& primitiveMesh::pointPoints(const label pointI) const
         const edgeList& edges = this->edges();
         const labelList& pEdges = pointEdges()[pointI];
 
-        labels_.size() = allocSize_;
+        storage.clear();
 
-        if (pEdges.size() > allocSize_)
+        if (pEdges.size() > storage.allocSize())
         {
-            // Set size() so memory allocation behaves as normal.
-            labels_.clear();
-            allocSize_ = pEdges.size();
-            labels_.setSize(allocSize_);
+            storage.setSize(pEdges.size());
         }
 
-        label n = 0;
-
         forAll(pEdges, i)
         {
-            labels_[n++] = edges[pEdges[i]].otherVertex(pointI);
+            storage.append(edges[pEdges[i]].otherVertex(pointI));
         }
 
-        labels_.size() = n;
-
-        return labels_;
+        return storage;
     }
 }
 
 
+const labelList& primitiveMesh::pointPoints(const label pointI) const
+{
+    return pointPoints(pointI, labels_);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/primitives/Lists/stringListTemplates.C b/src/OpenFOAM/primitives/Lists/stringListTemplates.C
index f4fb22bdac75121c565c9631624db8aebb5ad0b4..a93c46e8ac2f0269d44a9577ff885189c6043495 100644
--- a/src/OpenFOAM/primitives/Lists/stringListTemplates.C
+++ b/src/OpenFOAM/primitives/Lists/stringListTemplates.C
@@ -25,9 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "labelList.H"
-
-#include <sys/types.h>
-#include <regex.h>
+#include "regularExpression.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -41,24 +39,12 @@ labelList findStrings(const string& regexp, const StringList& sl)
 {
     labelList matches(sl.size());
 
-    regex_t *preg = new regex_t;
-
-    if (regcomp(preg, regexp.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
-    {
-        WarningIn("findStrings(const string& regexp, const stringList& sl)")
-            << "Failed to compile regular expression " << regexp
-            << endl;
-
-        return matches;
-    }
-
-    size_t nmatch = 0;
-    regmatch_t *pmatch = NULL;
+    regularExpression re(regexp);
 
     label matchi = 0;
     forAll(sl, i)
     {
-        if (regexec(preg, sl[i].c_str(), nmatch, pmatch, 0) == 0)
+        if (re.matches(sl[i]))
         {
             matches[matchi++] = i;
         }
@@ -66,9 +52,6 @@ labelList findStrings(const string& regexp, const StringList& sl)
 
     matches.setSize(matchi);
 
-    regfree(preg);
-    delete preg;
-
     return matches;
 }
 
diff --git a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H
similarity index 52%
rename from src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.H
rename to src/OpenFOAM/primitives/strings/keyType/keyType.H
index f2b0764f1a5db0dcef42d37d9a0f0abe6d5a4b27..4d4c358d5d172f3cb831884246d9411872d0721c 100644
--- a/src/OpenFOAM/matrices/scalarMatrix/scalarMatrix.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H
@@ -23,88 +23,107 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::scalarMatrix
+    Foam::keyType
 
 Description
-    Foam::scalarMatrix
+    A class for handling keywords in dictionaries.
+
+    A keyType is the keyword of a dictionary. It differs from word in that
+    it accepts wildcards.
 
 SourceFiles
-    scalarMatrix.C
+    keyType.C
+    keyTypeIO.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef scalarMatrix_H
-#define scalarMatrix_H
+#ifndef keyType_H
+#define keyType_H
 
-#include "Matrix.H"
-#include "scalarField.H"
-#include "labelList.H"
+#include "word.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
 
+// Forward declaration of classes
+class Istream;
+class Ostream;
+
+
 /*---------------------------------------------------------------------------*\
-                           Class scalarMatrix Declaration
+                           Class keyType Declaration
 \*---------------------------------------------------------------------------*/
 
-class scalarMatrix
+class keyType
 :
-    public Matrix<scalar>
+    public word
 {
+    // Private member data
+
+        bool isWildCard_;
+
+    // Private Member Functions
+
+        //- Disallow assignments where we cannot determine string/word type
+        void operator=(const std::string&);
 
 public:
 
+
     // Constructors
 
         //- Construct null
-        scalarMatrix();
+        inline keyType();
 
-        //- Construct given size
-        scalarMatrix(const label);
+        //- Construct as copy
+        inline keyType(const keyType& s);
 
-        //- Construct from Matrix<scalar>
-        scalarMatrix(const Matrix<scalar>&);
+        //- Construct as copy of word
+        inline keyType(const word& s);
+
+        //- Construct as copy of string. Expect it to be regular expression.
+        inline keyType(const string& s);
+
+        //- Construct as copy of character array
+        inline keyType(const char* s);
+
+        //- Construct as copy of std::string
+        inline keyType(const std::string& s, const bool isWildCard);
 
         //- Construct from Istream
-        scalarMatrix(Istream&);
-
-
-    // Member Functions
-
-        //- Solve the matrix using Gaussian elimination with pivoting,
-        //  returning the solution in the source
-        template<class T>
-        static void solve(Matrix<scalar>& matrix, Field<T>& source);
-
-        //- Solve the matrix using Gaussian elimination with pivoting
-        //  and return the solution
-        template<class T>
-        void solve(Field<T>& psi, const Field<T>& source) const;
-
-
-        //- LU decompose the matrix with pivoting
-        static void LUDecompose
-        (
-            Matrix<scalar>& matrix,
-            labelList& pivotIndices
-        );
-
-        //- LU back-substitution with given source, returning the solution
-        //  in the source
-        template<class T>
-        static void LUBacksubstitute
-        (
-            const Matrix<scalar>& luMmatrix,
-            const labelList& pivotIndices,
-            Field<T>& source
-        );
-
-        //- Solve the matrix using LU decomposition with pivoting
-        //  returning the LU form of the matrix and the solution in the source
-        template<class T>
-        static void LUsolve(Matrix<scalar>& matrix, Field<T>& source);
+        keyType(Istream& is);
+
+
+    // Member functions
+
+        //- Is this character valid for a keyType
+        inline static bool valid(char c);
+
+        //- Is the type a wildcard?
+        inline bool isWildCard() const;
+
+
+    // Member operators
+
+        // Assignment
+
+            inline void operator=(const keyType& s);
+
+            //- Assign from regular expression.
+            inline void operator=(const string& s);
+
+            inline void operator=(const word& s);
+
+            inline void operator=(const char*);
+
+
+    // IOstream operators
+
+        friend Istream& operator>>(Istream& is, keyType& w);
+
+        friend Ostream& operator<<(Ostream& os, const keyType& w);
 };
 
 
@@ -114,9 +133,7 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-#ifdef NoRepository
-#   include "scalarMatrixTemplates.C"
-#endif
+#include "keyTypeI.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
new file mode 100644
index 0000000000000000000000000000000000000000..f3785ebbffe68b68d0093a79cc55f7e70d2e47c8
--- /dev/null
+++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
@@ -0,0 +1,132 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+
+\*---------------------------------------------------------------------------*/
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+//- Construct null
+inline Foam::keyType::keyType()
+:
+    word(),
+    isWildCard_(false)
+{}
+
+
+//- Construct as copy
+inline Foam::keyType::keyType(const keyType& s)
+:
+    word(s, false),
+    isWildCard_(s.isWildCard())
+{}
+
+
+//- Construct as copy of word
+inline Foam::keyType::keyType(const word& s)
+:
+    word(s, false),
+    isWildCard_(false)
+{}
+
+
+//- Construct as copy of string. Expect it to be regular expression
+inline Foam::keyType::keyType(const string& s)
+:
+    word(s, false),
+    isWildCard_(true)
+{}
+
+
+//- Construct as copy of character array
+inline Foam::keyType::keyType(const char* s)
+:
+    word(s, false),
+    isWildCard_(false)
+{}
+
+
+//- Construct as copy of std::string
+inline Foam::keyType::keyType
+(
+    const std::string& s,
+    const bool isWildCard
+)
+:
+    word(s, false),
+    isWildCard_(isWildCard)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline bool Foam::keyType::valid(char c)
+{
+    return c != '"';
+}
+
+
+bool Foam::keyType::isWildCard() const
+{
+    return isWildCard_;
+}
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+inline void Foam::keyType::operator=(const keyType& s)
+{
+    // Bypass checking
+    string::operator=(s);
+    isWildCard_ = s.isWildCard();
+}
+
+
+inline void Foam::keyType::operator=(const word& s)
+{
+    word::operator=(s);
+    isWildCard_ = false;
+}
+
+
+inline void Foam::keyType::operator=(const string& s)
+{
+    // Bypass checking
+    string::operator=(s);
+    isWildCard_ = true;
+}
+
+
+inline void Foam::keyType::operator=(const char* s)
+{
+    // Bypass checking
+    string::operator=(s);
+    isWildCard_ = false;
+}
+
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C
similarity index 55%
rename from src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H
rename to src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C
index 0f0571c93c77bf84874be0b3962144305c65fe02..11232282f912a2488fc1e21833ff3dd849e8c956 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C
@@ -22,48 +22,66 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    kOmegaWallViscosity
-
 Description
-    Calculate wall viscosity from wall-functions.
+    Istream constructor and IOstream operators for word.
 
 \*---------------------------------------------------------------------------*/
 
+#include "keyType.H"
+#include "IOstreams.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+Foam::keyType::keyType(Istream& is)
+:
+    word()
+{
+    is >> *this;
+}
+
+
+Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
 {
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
+    token t(is);
 
-    const fvPatchList& patches = mesh_.boundary();
+    if (!t.good())
+    {
+        is.setBad();
+        return is;
+    }
 
-    forAll(patches, patchi)
+    if (t.isWord())
+    {
+        w = t.wordToken();
+    }
+    else if (t.isString())
     {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            const scalarField& nuw = nu().boundaryField()[patchi];
-            scalarField& nutw = nut_.boundaryField()[patchi];
-
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[patchi][facei]*sqrt(k_[faceCelli])/nuw[facei];
-
-                if (yPlus > yPlusLam_)
-                {
-                    nutw[facei] =
-                         nuw[facei]
-                        *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1);
-                }
-                else
-                {
-                    nutw[facei] = 0.0;
-                }
-            }
-        }
+        // Assign from string. Sets regular expression.
+        w = t.stringToken();
     }
+    else
+    {
+        is.setBad();
+        FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
+            << "wrong token type - expected word or string found "
+            << t.info()
+            << exit(FatalIOError);
+
+        return is;
+    }
+
+    // Check state of IOstream
+    is.check("Istream& operator>>(Istream&, keyType&)");
+
+    return is;
+}
+
+
+Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& w)
+{
+    os.write(w);
+    os.check("Ostream& operator<<(Ostream&, const keyType&)");
+    return os;
 }
 
 
diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H
index 3e61275164b1fdc735ee9bd15c7cc73df84913db..6565c28b4f8ede3a084ac9c56fc67513e8ac6052 100644
--- a/src/OpenFOAM/primitives/strings/word/word.H
+++ b/src/OpenFOAM/primitives/strings/word/word.H
@@ -87,16 +87,21 @@ public:
         inline word(const word&);
 
         //- Construct as copy of character array
-        inline word(const char*);
+        inline word(const char*, const bool doStripInvalid = true);
 
         //- Construct as copy with a maximum number of characters
-        inline word(const char*, const size_type);
+        inline word
+        (
+            const char*,
+            const size_type,
+            const bool doStripInvalid
+        );
 
         //- Construct as copy of string
-        inline word(const string&);
+        inline word(const string&, const bool doStripInvalid = true);
 
         //- Construct as copy of std::string
-        inline word(const std::string&);
+        inline word(const std::string&, const bool doStripInvalid = true);
 
         //- Construct from Istream
         word(Istream&);
diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H
index c31208fd7b8584cc7ed27f8ccc7876f2b75ac7da..d71eff2f9aad9a1cc54b9a662b56fedc09be68f0 100644
--- a/src/OpenFOAM/primitives/strings/word/wordI.H
+++ b/src/OpenFOAM/primitives/strings/word/wordI.H
@@ -65,34 +65,51 @@ inline Foam::word::word()
 {}
 
 
-inline Foam::word::word(const string& s)
+inline Foam::word::word(const string& s, const bool doStripInvalid)
 :
     string(s)
 {
-    stripInvalid();
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
 }
 
 
-inline Foam::word::word(const std::string& s)
+inline Foam::word::word(const std::string& s, const bool doStripInvalid)
 :
     string(s)
 {
-    stripInvalid();
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
 }
 
 
-inline Foam::word::word(const char* s)
+inline Foam::word::word(const char* s, const bool doStripInvalid)
 :
     string(s)
 {
-    stripInvalid();
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
 }
 
-inline Foam::word::word(const char* s, const size_type n)
+inline Foam::word::word
+(
+    const char* s,
+    const size_type n,
+    const bool doStripInvalid
+)
 :
     string(s, n)
 {
-    stripInvalid();
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
 }
 
 
diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
index 520e6f69efc28dfc174b2a52e86b6773dfe75b1e..bd0825217a0458a66b6cec2bb86a0cebddf3df8a 100644
--- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
+++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
@@ -1059,6 +1059,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
         // Surfaces with zone information
         const wordList& faceZoneNames = surfaces.faceZoneNames();
 
+        scalarField minSnapDist(snapDist);
+
         forAll(zonedSurfaces, i)
         {
             label zoneSurfI = zonedSurfaces[i];
@@ -1075,31 +1077,33 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
                 )
             );
 
-            pointField zonePoints(zonePointIndices.size());
-            forAll(zonePointIndices, i)
-            {
-                zonePoints[i] = localPoints[zonePointIndices[i]];
-            }
-
             // Find nearest for points both on faceZone and pp.
             List<pointIndexHit> hitInfo;
             labelList hitSurface;
             surfaces.findNearest
             (
                 labelList(1, zoneSurfI),
-                zonePoints,
-                sqr(4*snapDist),
+                pointField(localPoints, zonePointIndices),
+                sqr(4*scalarField(minSnapDist, zonePointIndices)),
                 hitSurface,
                 hitInfo
             );
 
-            forAll(hitInfo, pointI)
+            forAll(hitInfo, i)
             {
-                if (hitInfo[pointI].hit())
+                label pointI = zonePointIndices[i]; 
+
+                if (hitInfo[i].hit())
                 {
                     patchDisp[pointI] =
-                        hitInfo[pointI].hitPoint()
+                        hitInfo[i].hitPoint()
                       - localPoints[pointI];
+
+                    minSnapDist[pointI] = min
+                    (
+                        minSnapDist[pointI],
+                        mag(patchDisp[pointI])
+                    );
                 }
                 else
                 {
@@ -1107,7 +1111,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
                         << "For point:" << pointI
                         << " coordinate:" << localPoints[pointI]
                         << " did not find any surface within:"
-                        << 4*snapDist[pointI]
+                        << 4*minSnapDist[pointI]
                         << " meter." << endl;
                 }
             }
diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
index 58c74d3fb4eb36f44e8f043c265751b1172d5a01..27366a7a7afbeab279290b8424f7e13c5deeddb4 100644
--- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
+++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
@@ -514,7 +514,7 @@ void Foam::meshRefinement::markBoundaryFace
 {
     isBoundaryFace[faceI] = true;
 
-    const labelList& fEdges = mesh_.faceEdges()[faceI];
+    const labelList& fEdges = mesh_.faceEdges(faceI);
 
     forAll(fEdges, fp)
     {
@@ -623,12 +623,16 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
     // If so what is the remaining non-boundary anchor point?
     labelHashSet nonBoundaryAnchors(mesh_.nCells()/10000);
 
+    // On-the-fly addressing storage.
+    DynamicList<label> dynFEdges;
+    DynamicList<label> dynCPoints;
+
     // Count of faces marked for baffling
     label nBaffleFaces = 0;
 
     forAll(cellLevel, cellI)
     {
-        const labelList cPoints(meshCutter_.cellPoints(cellI));
+        const labelList& cPoints = mesh_.cellPoints(cellI, dynCPoints);
 
         // Get number of anchor points (pointLevel == cellLevel)
 
@@ -714,11 +718,14 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
     // Loop over all points. If a point is connected to 4 or more cells
     // with 7 anchor points on the boundary set those cell's non-boundary faces
     // to baffles
+
+    DynamicList<label> dynPCells;
+
     forAllConstIter(labelHashSet, nonBoundaryAnchors, iter)
     {
         label pointI = iter.key();
 
-        const labelList& pCells = mesh_.pointCells()[pointI];
+        const labelList& pCells = mesh_.pointCells(pointI, dynPCells);
 
         // Count number of 'hasSevenBoundaryAnchorPoints' cells.
         label n = 0;
@@ -806,7 +813,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
     {
         if (facePatch[faceI] == -1)
         {
-            const labelList& fEdges = mesh_.faceEdges()[faceI];
+            const labelList& fEdges = mesh_.faceEdges(faceI, dynFEdges);
             label nFaceBoundaryEdges = 0;
 
             forAll(fEdges, fe)
@@ -840,7 +847,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
             {
                 if (facePatch[faceI] == -1)
                 {
-                    const labelList& fEdges = mesh_.faceEdges()[faceI];
+                    const labelList& fEdges = mesh_.faceEdges(faceI, dynFEdges);
                     label nFaceBoundaryEdges = 0;
 
                     forAll(fEdges, fe)
@@ -1239,6 +1246,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
     labelList nBafflesPerEdge(mesh_.nEdges(), 0);
 
 
+
     // Count number of boundary faces per edge
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -1255,7 +1263,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
 
             forAll(pp, i)
             {
-                const labelList& fEdges = mesh_.faceEdges()[faceI];
+                const labelList& fEdges = mesh_.faceEdges(faceI);
 
                 forAll(fEdges, fEdgeI)
                 {
@@ -1267,19 +1275,23 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
     }
 
 
+    DynamicList<label> fe0;
+    DynamicList<label> fe1;
+
+
     // Count number of duplicate boundary faces per edge
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     forAll(couples, i)
     {
-        const labelList& fEdges0 = mesh_.faceEdges()[couples[i].first()];
+        const labelList& fEdges0 = mesh_.faceEdges(couples[i].first(), fe0);
 
         forAll(fEdges0, fEdgeI)
         {
             nBafflesPerEdge[fEdges0[fEdgeI]] += 1000000;
         }
 
-        const labelList& fEdges1 = mesh_.faceEdges()[couples[i].second()];
+        const labelList& fEdges1 = mesh_.faceEdges(couples[i].second(), fe1);
 
         forAll(fEdges1, fEdgeI)
         {
@@ -1314,7 +1326,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
          == patches.whichPatch(couple.second())
         )
         {
-            const labelList& fEdges = mesh_.faceEdges()[couples[i].first()];
+            const labelList& fEdges = mesh_.faceEdges(couples[i].first());
 
             forAll(fEdges, fEdgeI)
             {
diff --git a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
index 9629b53bdc133c7d8f364f5e82af274b3e46771a..5f5d89c29a75b55c160584cc38607be77b50cab9 100644
--- a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
+++ b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
@@ -826,6 +826,19 @@ void Foam::refinementSurfaces::findNearestIntersection
             }
         }
     }
+
+
+    // Make sure that if hit1 has hit something, hit2 will have at least the
+    // same point (due to tolerances it might miss its end point)
+    forAll(hit1, pointI)
+    {
+        if (hit1[pointI].hit() && !hit2[pointI].hit())
+        {
+            hit2[pointI] = hit1[pointI];
+            surface2[pointI] = surface1[pointI];
+            region2[pointI] = region1[pointI];
+        }
+    }
 }
 
 
diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C
index 5b7dd0c3a736f095bbaf878717ef76b213afa3e0..e82103bdb935f31242bf5e0a191131ea8d1de836 100644
--- a/src/dynamicMesh/motionSmoother/motionSmoother.C
+++ b/src/dynamicMesh/motionSmoother/motionSmoother.C
@@ -343,7 +343,7 @@ void Foam::motionSmoother::getAffectedFacesAndPoints
 
         forAllConstIter(pointSet, nbrPoints, iter)
         {
-            const labelList& pCells = mesh_.pointCells()[iter.key()];  
+            const labelList& pCells = mesh_.pointCells(iter.key());
 
             forAll(pCells, pCellI)
             {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
index 0742fd44b50fd83ec1c3f03b563e08c17a6f0e6e..232e49e0e71441b5cdfe29cddbbac921318583a9 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
@@ -330,15 +330,14 @@ Foam::label Foam::addPatchCellLayer::addSideFace
     const label meshEdgeI,              // corresponding mesh edge
     const label layerI,                 // layer
     const label numEdgeFaces,           // number of layers for edge
+    const labelList& meshFaces,         // precalculated edgeFaces
     polyTopoChange& meshMod
 ) const
 {
     // Edge to 'inflate' from
     label inflateEdgeI = -1;
 
-    // Mesh faces using edge
-    const labelList& meshFaces = mesh_.edgeFaces()[meshEdgeI];
-
+    // Check mesh faces using edge
     forAll(meshFaces, i)
     {
         if (mesh_.isInternalFace(meshFaces[i]))
@@ -620,6 +619,9 @@ void Foam::addPatchCellLayer::setRefinement
 
     const labelList& meshPoints = pp.meshPoints();
 
+    // Some storage for edge-face-addressing.
+    DynamicList<label> ef;
+
     // Precalculate mesh edges for pp.edges.
     labelList meshEdges(calcMeshEdges(mesh_, pp));
 
@@ -777,7 +779,9 @@ void Foam::addPatchCellLayer::setRefinement
                 label meshEdgeI = meshEdges[edgeI];
 
                 // Mesh faces using edge
-                const labelList& meshFaces = mesh_.edgeFaces()[meshEdgeI];
+
+                // Mesh faces using edge
+                const labelList& meshFaces = mesh_.edgeFaces(meshEdgeI, ef);
 
                 // Check that there is only one patchface using edge.
                 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
@@ -1353,6 +1357,12 @@ void Foam::addPatchCellLayer::setRefinement
                             patchFaceI
                         );
 
+                        const labelList& meshFaces = mesh_.edgeFaces
+                        (
+                            meshEdgeI,
+                            ef
+                        );
+
                         addSideFace
                         (
                             pp,
@@ -1365,6 +1375,7 @@ void Foam::addPatchCellLayer::setRefinement
                             meshEdgeI,      // corresponding mesh edge
                             i,
                             numEdgeSideFaces,
+                            meshFaces,
                             meshMod
                         );
                     }
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
index 0b5caaba86f8d2b84c6f1605809ecb5925937d0b..d1a1162e9676c048869e351b0518dc4e7d6c4480 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
@@ -232,6 +232,7 @@ class addPatchCellLayer
             const label meshEdgeI,
             const label layerI,
             const label numEdgeFaces,
+            const labelList& meshFaces,
             polyTopoChange&
         ) const;
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
index ca059c2d1e0394789603f4ce69694206ec7ef752..74e21817d2a041ce838681b495e67e61e0f2335f 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
@@ -125,11 +125,11 @@ void Foam::combineFaces::regioniseFaces
 (
     const scalar minCos,
     const label cellI,
+    const labelList& cEdges,
     Map<label>& faceRegion
 ) const
 {
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
-    const labelList& cEdges = mesh_.cellEdges()[cellI];
 
     forAll(cEdges, i)
     {
@@ -220,9 +220,10 @@ bool Foam::combineFaces::faceNeighboursValid
         return true;
     }
 
-    const labelListList& faceEdges = mesh_.faceEdges();
     const cell& cFaces = mesh_.cells()[cellI];
 
+    DynamicList<label> storage;
+
     // Test for face collapsing to edge since too many neighbours merged.
     forAll(cFaces, cFaceI)
     {
@@ -230,7 +231,7 @@ bool Foam::combineFaces::faceNeighboursValid
 
         if (!faceRegion.found(faceI))
         {
-            const labelList& fEdges = faceEdges[faceI];
+            const labelList& fEdges = mesh_.faceEdges(faceI, storage);
 
             // Count number of remaining faces neighbouring faceI. This has
             // to be 3 or more.
@@ -299,6 +300,8 @@ Foam::labelListList Foam::combineFaces::getMergeSets
 {
     // Lists of faces that can be merged.
     DynamicList<labelList> allFaceSets(boundaryCells.size() / 10);
+    // Storage for on-the-fly cell-edge addressing.
+    DynamicList<label> storage;
 
     // On all cells regionise the faces
     forAllConstIter(labelHashSet, boundaryCells, iter)
@@ -307,9 +310,11 @@ Foam::labelListList Foam::combineFaces::getMergeSets
 
         const cell& cFaces = mesh_.cells()[cellI];
 
+        const labelList& cEdges = mesh_.cellEdges(cellI, storage);
+
         // Region per face
         Map<label> faceRegion(cFaces.size());
-        regioniseFaces(featureCos, cellI, faceRegion);
+        regioniseFaces(featureCos, cellI, cEdges, faceRegion);
 
         // Now we have in faceRegion for every face the region with planar
         // face sharing the same region. We now check whether the resulting
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.H
index 208407dff34b55f5463dfd68b8b8f9d4d5ce2289..a65db41e44f28ca5adfdbe50fa9cdf0d514aa4d7 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.H
@@ -103,6 +103,7 @@ class combineFaces
         (
             const scalar minCos,
             const label cellI,
+            const labelList& cEdges,
             Map<label>& faceRegion
         ) const;
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C
index 2a38afad1a19f4d50969bb38bc4918db9f444dcd..c69f6c4533f08784dacae285b1f2dfd7d838caee 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C
@@ -372,7 +372,7 @@ Foam::scalar Foam::hexRef8::getLevel0EdgeLength() const
         {
             const label cLevel = cellLevel_[cellI];
 
-            const labelList& cEdges = mesh_.cellEdges()[cellI];
+            const labelList& cEdges = mesh_.cellEdges(cellI);
 
             forAll(cEdges, i)
             {
@@ -447,7 +447,7 @@ Foam::scalar Foam::hexRef8::getLevel0EdgeLength() const
     {
         const label cLevel = cellLevel_[cellI];
 
-        const labelList& cEdges = mesh_.cellEdges()[cellI];
+        const labelList& cEdges = mesh_.cellEdges(cellI);
 
         forAll(cEdges, i)
         {
@@ -1190,6 +1190,10 @@ void Foam::hexRef8::createInternalFaces
     // From edge mid to face mids
     Map<edge> midPointToFaceMids(24);
 
+    // Storage for on-the-fly addressing
+    DynamicList<label> storage;
+
+
     // Running count of number of internal faces added so far.
     label nFacesAdded = 0;
 
@@ -1198,7 +1202,7 @@ void Foam::hexRef8::createInternalFaces
         label faceI = cFaces[i];
 
         const face& f = mesh_.faces()[faceI];
-        const labelList& fEdges = mesh_.faceEdges()[faceI];
+        const labelList& fEdges = mesh_.faceEdges(faceI, storage);
 
         // We are on the cellI side of face f. The face will have 1 or 4
         // cLevel points and lots of higher numbered ones.
@@ -1299,7 +1303,7 @@ void Foam::hexRef8::createInternalFaces
                     {
                         dumpCell(cellI);
 
-                        const labelList cPoints(cellPoints(cellI));
+                        const labelList& cPoints = mesh_.cellPoints(cellI);
 
                         FatalErrorIn("createInternalFaces(..)")
                             << "cell:" << cellI << " cLevel:" << cLevel
@@ -1372,7 +1376,7 @@ void Foam::hexRef8::createInternalFaces
                     {
                         dumpCell(cellI);
 
-                        const labelList cPoints(cellPoints(cellI));
+                        const labelList& cPoints = mesh_.cellPoints(cellI);
 
                         FatalErrorIn("createInternalFaces(..)")
                             << "cell:" << cellI << " cLevel:" << cLevel
@@ -1454,7 +1458,7 @@ void Foam::hexRef8::walkFaceToMid
 ) const
 {
     const face& f = mesh_.faces()[faceI];
-    const labelList& fEdges = mesh_.faceEdges()[faceI];
+    const labelList& fEdges = mesh_.faceEdges(faceI);
 
     label fp = startFp;
 
@@ -1503,7 +1507,7 @@ void Foam::hexRef8::walkFaceFromMid
 ) const
 {
     const face& f = mesh_.faces()[faceI];
-    const labelList& fEdges = mesh_.faceEdges()[faceI];
+    const labelList& fEdges = mesh_.faceEdges(faceI);
 
     label fp = f.rcIndex(startFp);
 
@@ -2013,27 +2017,6 @@ Foam::hexRef8::hexRef8
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-//- Get points of a cell (without using cellPoints addressing)
-Foam::labelList Foam::hexRef8::cellPoints(const label cellI) const
-{
-    // Pick up points of the cell
-    const cell& cFaces = mesh_.cells()[cellI];
-
-    labelHashSet cPoints(4*cFaces.size());
-
-    forAll(cFaces, i)
-    {
-        const face& f = mesh_.faces()[cFaces[i]];
-
-        forAll(f, fp)
-        {
-            cPoints.insert(f[fp]);
-        }
-    }
-    return cPoints.toc();
-}
-
-
 Foam::labelList Foam::hexRef8::consistentRefinement
 (
     const labelList& cellsToRefine,
@@ -2358,13 +2341,11 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
         // as cell level purely for ease)
         labelList maxPointCount(mesh_.nPoints(), 0);
 
-        const labelListList& pointCells = mesh_.pointCells();
-
-        forAll(pointCells, pointI)
+        forAll(maxPointCount, pointI)
         {
             label& pLevel = maxPointCount[pointI];
 
-            const labelList& pCells = pointCells[pointI];
+            const labelList& pCells = mesh_.pointCells(pointI);
 
             forAll(pCells, i)
             {
@@ -2395,7 +2376,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
             // Loop over all cells using the point and check whether their
             // refinement level is much less than the maximum.
 
-            const labelList& pCells = pointCells[pointI];
+            const labelList& pCells = mesh_.pointCells(pointI);
 
             forAll(pCells, pCellI)
             {
@@ -3121,7 +3102,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
     {
         if (cellMidPoint[cellI] >= 0)
         {
-            const labelList& cEdges = mesh_.cellEdges()[cellI];
+            const labelList& cEdges = mesh_.cellEdges(cellI);
 
             forAll(cEdges, i)
             {
@@ -3458,7 +3439,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
 
         forAll(pointLevel_, pointI)
         {
-            const labelList& pCells = mesh_.pointCells()[pointI];
+            const labelList& pCells = mesh_.pointCells(pointI);
 
             forAll(pCells, pCellI)
             {
@@ -3498,7 +3479,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
                 {
                     dumpCell(cellI);
 
-                    const labelList cPoints(cellPoints(cellI));
+                    const labelList& cPoints = mesh_.cellPoints(cellI);
 
                     FatalErrorIn
                     (
@@ -3610,7 +3591,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
         {
             if (edgeMidPoint[edgeI] >= 0)
             {
-                const labelList& eFaces = mesh_.edgeFaces()[edgeI];
+                const labelList& eFaces = mesh_.edgeFaces(edgeI);
 
                 forAll(eFaces, i)
                 {
@@ -3768,13 +3749,16 @@ Foam::labelListList Foam::hexRef8::setRefinement
             << endl;
     }
 
+    DynamicList<label> eFacesStorage;
+    DynamicList<label> fEdgesStorage;
+
     forAll(edgeMidPoint, edgeI)
     {
         if (edgeMidPoint[edgeI] >= 0)
         {
             // Split edge. Check that face not already handled above.
 
-            const labelList& eFaces = mesh_.edgeFaces()[edgeI];
+            const labelList& eFaces = mesh_.edgeFaces(edgeI, eFacesStorage);
 
             forAll(eFaces, i)
             {
@@ -3785,7 +3769,11 @@ Foam::labelListList Foam::hexRef8::setRefinement
                     // Unsplit face. Add edge splits to face.
 
                     const face& f = mesh_.faces()[faceI];
-                    const labelList& fEdges = mesh_.faceEdges()[faceI];
+                    const labelList& fEdges = mesh_.faceEdges
+                    (
+                        faceI,
+                        fEdgesStorage
+                    );
 
                     DynamicList<label> newFaceVerts(f.size());
 
@@ -4715,14 +4703,12 @@ void Foam::hexRef8::checkRefinementLevels
     // Check 2:1 across points (instead of faces)
     if (maxPointDiff != -1)
     {
-        const labelListList& pointCells = mesh_.pointCells();
-
         // Determine per point the max cell level.
         labelList maxPointLevel(mesh_.nPoints(), 0);
 
-        forAll(pointCells, pointI)
+        forAll(maxPointLevel, pointI)
         {
-            const labelList& pCells = pointCells[pointI];
+            const labelList& pCells = mesh_.pointCells(pointI);
 
             label& pLevel = maxPointLevel[pointI];
 
@@ -4747,7 +4733,7 @@ void Foam::hexRef8::checkRefinementLevels
         {
             label pointI = pointsToCheck[i];
 
-            const labelList& pCells = pointCells[pointI];
+            const labelList& pCells = mesh_.pointCells(pointI);
 
             forAll(pCells, i)
             {
@@ -4881,11 +4867,11 @@ Foam::labelList Foam::hexRef8::getSplitPoints() const
     labelList splitMasterLevel(mesh_.nPoints(), 0);
 
     // Unmark all with not 8 cells
-    const labelListList& pointCells = mesh_.pointCells();
+    //const labelListList& pointCells = mesh_.pointCells();
 
-    forAll(pointCells, pointI)
+    for (label pointI = 0; pointI < mesh_.nPoints(); pointI++)
     {
-        const labelList& pCells = pointCells[pointI];
+        const labelList& pCells = mesh_.pointCells(pointI);
 
         if (pCells.size() != 8)
         {
@@ -4898,8 +4884,7 @@ Foam::labelList Foam::hexRef8::getSplitPoints() const
 
     forAll(visibleCells, cellI)
     {
-        //const labelList& cPoints = mesh_.cellPoints()[cellI];
-        const labelList cPoints(cellPoints(cellI));
+        const labelList& cPoints = mesh_.cellPoints(cellI);
 
         if (visibleCells[cellI] != -1 && history_.parentIndex(cellI) >= 0)
         {
@@ -5104,7 +5089,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
         {
             if (unrefinePoint.get(pointI) == 1)
             {
-                const labelList& pCells = mesh_.pointCells()[pointI];
+                const labelList& pCells = mesh_.pointCells(pointI);
 
                 forAll(pCells, j)
                 {
@@ -5244,7 +5229,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
         {
             if (unrefinePoint.get(pointI) == 1)
             {
-                const labelList& pCells = mesh_.pointCells()[pointI];
+                const labelList& pCells = mesh_.pointCells(pointI);
 
                 forAll(pCells, j)
                 {
@@ -5329,7 +5314,7 @@ void Foam::hexRef8::setUnrefinement
 
         forAll(splitPointLabels, i)
         {
-            const labelList& pCells = mesh_.pointCells()[splitPointLabels[i]];
+            const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
 
             forAll(pCells, j)
             {
@@ -5395,7 +5380,7 @@ void Foam::hexRef8::setUnrefinement
 
         // Get original cell label
 
-        const labelList& pCells = mesh_.pointCells()[pointI];
+        const labelList& pCells = mesh_.pointCells(pointI);
 
         // Check
         if (pCells.size() != 8)
@@ -5463,7 +5448,7 @@ void Foam::hexRef8::setUnrefinement
     {
         label pointI = splitPointLabels[i];
 
-        const labelList& pCells = mesh_.pointCells()[pointI];
+        const labelList& pCells = mesh_.pointCells(pointI);
 
         label masterCellI = min(pCells);
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.H
index faccfdc27186e475f8cb8b94890711e90c963a85..ea67874474cecdf5715b784b67868fa2acff0dc7 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.H
@@ -370,9 +370,6 @@ public:
 
         // Refinement
 
-            //- Helper:get points of a cell without using cellPoints addressing
-            labelList cellPoints(const label cellI) const;
-
             //- Given valid mesh and current cell level and proposed
             //  cells to refine calculate any clashes (due to 2:1) and return
             //  ok list of cells to refine.
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
index fab2b746093631099a7a36c2c3217de21a4c2250..32cb3c5b823a0bb07da241ca8a62d4a733fe1ca2 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
@@ -83,6 +83,7 @@ Foam::label Foam::removeFaces::changeFaceRegion
     const labelList& nFacesPerEdge,
     const label faceI,
     const label newRegion,
+    const labelList& fEdges,
     labelList& faceRegion
 ) const
 {
@@ -94,27 +95,33 @@ Foam::label Foam::removeFaces::changeFaceRegion
 
         nChanged = 1;
 
-        // Step to neighbouring faces across edges that will get removed
-
-        const labelList& fEdges = mesh_.faceEdges()[faceI];
+        // Storage for on-the-fly addressing
+        DynamicList<label> fe;
+        DynamicList<label> ef;
 
+        // Step to neighbouring faces across edges that will get removed
         forAll(fEdges, i)
         {
             label edgeI = fEdges[i];
 
             if (nFacesPerEdge[edgeI] >= 0 && nFacesPerEdge[edgeI] <= 2)
             {
-                const labelList& eFaces = mesh_.edgeFaces()[edgeI];
+                const labelList& eFaces = mesh_.edgeFaces(edgeI, ef);
 
                 forAll(eFaces, j)
                 {
+                    label nbrFaceI = eFaces[j];
+
+                    const labelList& fEdges1 = mesh_.faceEdges(nbrFaceI, fe);
+
                     nChanged += changeFaceRegion
                     (
                         cellRegion,
                         removedFace,
                         nFacesPerEdge,
-                        eFaces[j],
+                        nbrFaceI,
                         newRegion,
+                        fEdges1,
                         faceRegion
                     );
                 }
@@ -166,7 +173,7 @@ Foam::boolList Foam::removeFaces::getFacesAffected
     //  Mark faces affected by removal of edges
     forAllConstIter(labelHashSet, edgesToRemove, iter)
     {
-        const labelList& eFaces = mesh_.edgeFaces()[iter.key()];
+        const labelList& eFaces = mesh_.edgeFaces(iter.key());
 
         forAll(eFaces, eFaceI)
         {
@@ -814,6 +821,10 @@ void Foam::removeFaces::setRefinement
     // Number of connected face regions
     label nRegions = 0;
 
+    // Storage for on-the-fly addressing
+    DynamicList<label> fe;
+    DynamicList<label> ef;
+
 
     {
         const polyBoundaryMesh& patches = mesh_.boundaryMesh();
@@ -827,7 +838,7 @@ void Foam::removeFaces::setRefinement
         {
             label faceI = faceLabels[i];
 
-            const labelList& fEdges = mesh_.faceEdges()[faceI];
+            const labelList& fEdges = mesh_.faceEdges(faceI, fe);
 
             forAll(fEdges, i)
             {
@@ -835,8 +846,7 @@ void Foam::removeFaces::setRefinement
 
                 if (nFacesPerEdge[edgeI] == -1)
                 {
-                    nFacesPerEdge[edgeI] =
-                        mesh_.edgeFaces()[edgeI].size()-1;
+                    nFacesPerEdge[edgeI] = mesh_.edgeFaces(edgeI, ef).size()-1;
                 }
                 else
                 {
@@ -849,16 +859,15 @@ void Foam::removeFaces::setRefinement
         // Note that this only needs to be done for possibly coupled edges
         // so we could choose to loop only over boundary faces and use faceEdges
         // of those.
-        const labelListList& edgeFaces = mesh_.edgeFaces();
 
-        forAll(edgeFaces, edgeI)
+        forAll(mesh_.edges(), edgeI)
         {
             if (nFacesPerEdge[edgeI] == -1)
             {
                 // Edge not yet handled in loop above so is not used by any
                 // face to be removed.
 
-                const labelList& eFaces = edgeFaces[edgeI];
+                const labelList& eFaces = mesh_.edgeFaces(edgeI, ef);
 
                 if (eFaces.size() > 2)
                 {
@@ -922,7 +931,7 @@ void Foam::removeFaces::setRefinement
                 label f0 = -1;
                 label f1 = -1;
 
-                const labelList& eFaces = mesh_.edgeFaces()[edgeI];
+                const labelList& eFaces = mesh_.edgeFaces(edgeI, ef);
 
                 forAll(eFaces, i)
                 {
@@ -1152,6 +1161,7 @@ void Foam::removeFaces::setRefinement
                 nFacesPerEdge,
                 startFaceI,
                 nRegions,
+                mesh_.faceEdges(startFaceI, fe),
                 faceRegion
             );
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.H
index 83186bed8bff88493a282d5b40d97465e587b4fb..48ac6169e8671f38058dce8359b384097702bcc0 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.H
@@ -93,6 +93,7 @@ class removeFaces
             const labelList& nFacesPerEdge,
             const label faceI,
             const label newRegion,
+            const labelList& fEdges,
             labelList& faceRegion
         ) const;
 
diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files
index 60b17f2a05330d1bc0a001f34af646ceba9b326c..25137c58c7d4199eb7579f5b6fc59114db7b231c 100644
--- a/src/finiteVolume/Make/files
+++ b/src/finiteVolume/Make/files
@@ -38,6 +38,9 @@ fvMeshMapper = fvMesh/fvMeshMapper
 $(fvMeshMapper)/fvPatchMapper.C
 $(fvMeshMapper)/fvSurfaceMapper.C
 
+extendedStencil = fvMesh/extendedStencil
+$(extendedStencil)/extendedStencil.C
+
 fvPatchFields = fields/fvPatchFields
 $(fvPatchFields)/fvPatchField/fvPatchFields.C
 
@@ -73,6 +76,7 @@ $(derivedFvPatchFields)/directMappedVelocityFluxFixedValue/directMappedVelocityF
 $(derivedFvPatchFields)/fan/fanFvPatchFields.C
 $(derivedFvPatchFields)/fixedFluxBuoyantPressure/fixedFluxBuoyantPressureFvPatchScalarField.C
 $(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
+$(derivedFvPatchFields)/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C
 $(derivedFvPatchFields)/fixedNormalSlip/fixedNormalSlipFvPatchFields.C
 $(derivedFvPatchFields)/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C
 $(derivedFvPatchFields)/freestream/freestreamFvPatchFields.C
@@ -108,8 +112,6 @@ $(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityK
 $(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C
 $(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C
 
-$(derivedFvPatchFields)/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C
-
 fvsPatchFields = fields/fvsPatchFields
 $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C
 
@@ -166,6 +168,8 @@ $(schemes)/harmonic/harmonic.C
 $(schemes)/localBlended/localBlended.C
 $(schemes)/localMax/localMax.C
 $(schemes)/localMin/localMin.C
+$(schemes)/quadraticFit/quadraticFit.C
+$(schemes)/quadraticFit/quadraticFitData.C
 
 limitedSchemes = $(surfaceInterpolation)/limitedSchemes
 $(limitedSchemes)/limitedSurfaceInterpolationScheme/limitedSurfaceInterpolationSchemes.C
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
index 33c6e2d98a8e07b877ca3c2d2c74591f0020e427..8b7ba7ddf156dc7d4d020591b608bf58a5a9df35 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
@@ -72,7 +72,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
     fixedGradientFvPatchScalarField(p, iF),
     UName_(dict.lookupOrDefault<word>("U", "U")),
     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
-    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
+    rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
     adjoint_(dict.lookup("adjoint"))
 {
     if (dict.found("gradient"))
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C
new file mode 100644
index 0000000000000000000000000000000000000000..eba3522e36ec98f0cc4f3447de0cdabf52b2ffc3
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C
@@ -0,0 +1,105 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "fixedInternalValueFvPatchField.H"
+#include "fvPatchFieldMapper.H"
+#include "fvMatrix.H"
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+Foam::fixedInternalValueFvPatchField<Type>::fixedInternalValueFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF)
+{}
+
+
+template<class Type>
+Foam::fixedInternalValueFvPatchField<Type>::fixedInternalValueFvPatchField
+(
+    const fixedInternalValueFvPatchField<Type>& ptf,
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    zeroGradientFvPatchField<Type>(ptf, p, iF, mapper)
+{}
+
+
+template<class Type>
+Foam::fixedInternalValueFvPatchField<Type>::fixedInternalValueFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF, dict)
+{
+    fvPatchField<Type>::operator=(this->patchInternalField());
+}
+
+
+template<class Type>
+Foam::fixedInternalValueFvPatchField<Type>::fixedInternalValueFvPatchField
+(
+    const fixedInternalValueFvPatchField& fivpf
+)
+:
+    zeroGradientFvPatchField<Type>(fivpf)
+{}
+
+
+template<class Type>
+Foam::fixedInternalValueFvPatchField<Type>::fixedInternalValueFvPatchField
+(
+    const fixedInternalValueFvPatchField& fivpf,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(fivpf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::fixedInternalValueFvPatchField<Type>::manipulateMatrix
+(
+    fvMatrix<Type>& matrix
+)
+{
+    // Apply the patch internal field as a constraint in the matrix
+    matrix.setValues(this->patch().faceCells(), this->patchInternalField());
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H
new file mode 100644
index 0000000000000000000000000000000000000000..99cfeb72f3fb90286851b3410d15bfb5d911cbfb
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::fixedInternalValueFvPatchField
+
+Description
+    Boundary condition providing mechanism to set boundary (cell) values
+    directly into a matrix, i.e. to set a constraint condition. Default
+    behaviour is to act as a zero gradient condition.
+
+SourceFiles
+    fixedInternalValueFvPatchField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef fixedInternalValueFvPatchField_H
+#define fixedInternalValueFvPatchField_H
+
+#include "zeroGradientFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+              Class fixedInternalValueFvPatchField Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class fixedInternalValueFvPatchField
+:
+    public zeroGradientFvPatchField<Type>
+{
+
+public:
+
+    //- Runtime type information
+    TypeName("fixedInternalValue");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        fixedInternalValueFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        fixedInternalValueFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping the given fixedInternalValueFvPatchField<Type>
+        //  onto a new patch
+        fixedInternalValueFvPatchField
+        (
+            const fixedInternalValueFvPatchField<Type>&,
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        fixedInternalValueFvPatchField
+        (
+            const fixedInternalValueFvPatchField<Type>&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchField<Type> > clone() const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new fixedInternalValueFvPatchField<Type>(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        fixedInternalValueFvPatchField
+        (
+            const fixedInternalValueFvPatchField<Type>&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchField<Type> > clone
+        (
+            const DimensionedField<Type, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new fixedInternalValueFvPatchField<Type>(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //-Manipulate a matrix
+            virtual void manipulateMatrix(fvMatrix<Type>& matrix);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "fixedInternalValueFvPatchField.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..cd6d5d490195b2d75dc9fd4c4bd53e6ae74d238c
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C
@@ -0,0 +1,45 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "fixedInternalValueFvPatchFields.H"
+#include "fvPatchFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+makePatchFields(fixedInternalValue);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..779339f443e2c862abad77e94d687084ddfc1de2
--- /dev/null
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H
@@ -0,0 +1,50 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 fixedInternalValueFvPatchFields_H
+#define fixedInternalValueFvPatchFields_H
+
+#include "fixedInternalValueFvPatchField.H"
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeFieldTypedefs(fixedInternalValue)
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C
deleted file mode 100644
index e950d8766308fae4895d9def4e81bbbd9c7dcec6..0000000000000000000000000000000000000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C
+++ /dev/null
@@ -1,196 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2006-2008 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 "massFlowRateInletVelocityFvPatchVectorField.H"
-#include "volFields.H"
-#include "addToRunTimeSelectionTable.H"
-#include "fvPatchFieldMapper.H"
-#include "surfaceFields.H"
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-Foam::
-massFlowRateInletVelocityFvPatchVectorField::
-massFlowRateInletVelocityFvPatchVectorField
-(
-    const fvPatch& p,
-    const DimensionedField<vector, volMesh>& iF
-)
-:
-    fixedValueFvPatchField<vector>(p, iF),
-    flowRate_(0),
-    phiName_("phi"),
-    rhoName_("rho")
-{}
-
-
-Foam::
-massFlowRateInletVelocityFvPatchVectorField::
-massFlowRateInletVelocityFvPatchVectorField
-(
-    const massFlowRateInletVelocityFvPatchVectorField& ptf,
-    const fvPatch& p,
-    const DimensionedField<vector, volMesh>& iF,
-    const fvPatchFieldMapper& mapper
-)
-:
-    fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
-    flowRate_(ptf.flowRate_),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-Foam::
-massFlowRateInletVelocityFvPatchVectorField::
-massFlowRateInletVelocityFvPatchVectorField
-(
-    const fvPatch& p,
-    const DimensionedField<vector, volMesh>& iF,
-    const dictionary& dict
-)
-:
-    fixedValueFvPatchField<vector>(p, iF, dict),
-    flowRate_(readScalar(dict.lookup("massFlowRate"))),
-    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
-    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
-{
-    WarningIn("massFlowRateInletVelocityFvPatchVectorField(..., dict)")
-        << "    changed to flowRateInletVelocityFvPatchVectorField"
-        << endl;
-
-}
-
-
-Foam::
-massFlowRateInletVelocityFvPatchVectorField::
-massFlowRateInletVelocityFvPatchVectorField
-(
-    const massFlowRateInletVelocityFvPatchVectorField& ptf
-)
-:
-    fixedValueFvPatchField<vector>(ptf),
-    flowRate_(ptf.flowRate_),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-Foam::
-massFlowRateInletVelocityFvPatchVectorField::
-massFlowRateInletVelocityFvPatchVectorField
-(
-    const massFlowRateInletVelocityFvPatchVectorField& ptf,
-    const DimensionedField<vector, volMesh>& iF
-)
-:
-    fixedValueFvPatchField<vector>(ptf, iF),
-    flowRate_(ptf.flowRate_),
-    phiName_(ptf.phiName_),
-    rhoName_(ptf.rhoName_)
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-void Foam::massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
-{
-    if (updated())
-    {
-        return;
-    }
-
-    // a simpler way of doing this would be nice
-    scalar avgU = -flowRate_/gSum(patch().magSf());
-
-    vectorField n = patch().nf();
-
-    const surfaceScalarField& phi =
-        db().lookupObject<surfaceScalarField>(phiName_);
-
-    if (phi.dimensions() == dimVelocity*dimArea)
-    {
-        // volumetric flow-rate
-        operator==(n*avgU);
-    }
-    else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
-    {
-        const fvPatchField<scalar>& rhop =
-            patch().lookupPatchField<volScalarField, scalar>(rhoName_);
-
-        // mass flow-rate
-        operator==(n*avgU/rhop);
-    }
-    else
-    {
-        FatalErrorIn
-        (
-            "massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()"
-        )   << "dimensions of " << phiName_ << " are incorrect" << nl
-            << "    on patch " << this->patch().name()
-            << " of field " << this->dimensionedInternalField().name()
-            << " in file " << this->dimensionedInternalField().objectPath()
-            << nl << exit(FatalError);
-    }
-
-    fixedValueFvPatchField<vector>::updateCoeffs();
-}
-
-
-void Foam::massFlowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
-{
-    os.writeKeyword("type") << "flowRateInletVelocity;" << nl;
-
-    os.writeKeyword("flowRate") << flowRate_
-        << token::END_STATEMENT << nl;
-
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
-
-    if (rhoName_ != "rho")
-    {
-        os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
-    }
-
-    writeEntry("value", os);
-}
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-   makePatchTypeField
-   (
-       fvPatchVectorField,
-       massFlowRateInletVelocityFvPatchVectorField
-   );
-}
-
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.H
deleted file mode 100644
index 86bd34771daa4abe4f4af3c4d9fb34e935e1541a..0000000000000000000000000000000000000000
--- a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.H
+++ /dev/null
@@ -1,175 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2006-2008 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::massFlowRateInletVelocityFvPatchVectorField
-
-Description
-    Compatibility boundary condition for upgrading from
-    massFlowRateInletVelocity to flowRateInletVelocity
-
-    Reads 'massFlowRate' and writes 'flowRate'
-
-Deprecated
-    This boundary condition is present for backward-compatibility only.
-    Use Foam::flowRateInletVelocityFvPatchVectorField
-
-SourceFiles
-    massFlowRateInletVelocityFvPatchVectorField.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef massFlowRateInletVelocityFvPatchVectorField_H
-#define massFlowRateInletVelocityFvPatchVectorField_H
-
-#include "fixedValueFvPatchFields.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-/*---------------------------------------------------------------------------*\
-               Class massFlowRateInletVelocityFvPatch Declaration
-\*---------------------------------------------------------------------------*/
-
-class massFlowRateInletVelocityFvPatchVectorField
-:
-    public fixedValueFvPatchVectorField
-{
-    // Private data
-
-        //- Inlet integral flow rate
-        scalar flowRate_;
-
-        //- Name of the flux transporting the field
-        word phiName_;
-
-        //- Name of the density field used to normalize the mass flux
-        word rhoName_;
-
-
-public:
-
-   //- Runtime type information
-   TypeName("massFlowRateInletVelocity");
-
-
-   // Constructors
-
-        //- Construct from patch and internal field
-        massFlowRateInletVelocityFvPatchVectorField
-        (
-            const fvPatch&,
-            const DimensionedField<vector, volMesh>&
-        );
-
-        //- Construct from patch, internal field and dictionary
-        massFlowRateInletVelocityFvPatchVectorField
-        (
-            const fvPatch&,
-            const DimensionedField<vector, volMesh>&,
-            const dictionary&
-        );
-
-        //- Construct by mapping given
-        //  massFlowRateInletVelocityFvPatchVectorField
-        //  onto a new patch
-        massFlowRateInletVelocityFvPatchVectorField
-        (
-            const massFlowRateInletVelocityFvPatchVectorField&,
-            const fvPatch&,
-            const DimensionedField<vector, volMesh>&,
-            const fvPatchFieldMapper&
-        );
-
-        //- Construct as copy
-        massFlowRateInletVelocityFvPatchVectorField
-        (
-            const massFlowRateInletVelocityFvPatchVectorField&
-        );
-
-        //- Construct and return a clone
-        virtual tmp<fvPatchVectorField> clone() const
-        {
-            return tmp<fvPatchVectorField>
-            (
-                new massFlowRateInletVelocityFvPatchVectorField(*this)
-            );
-        }
-
-        //- Construct as copy setting internal field reference
-        massFlowRateInletVelocityFvPatchVectorField
-        (
-            const massFlowRateInletVelocityFvPatchVectorField&,
-            const DimensionedField<vector, volMesh>&
-        );
-
-        //- Construct and return a clone setting internal field reference
-        virtual tmp<fvPatchVectorField> clone
-        (
-            const DimensionedField<vector, volMesh>& iF
-        ) const
-        {
-            return tmp<fvPatchVectorField>
-            (
-                new massFlowRateInletVelocityFvPatchVectorField(*this, iF)
-            );
-        }
-
-
-    // Member functions
-
-        // Access
-
-            //- Return the flux
-            scalar flowRate() const
-            {
-                return flowRate_;
-            }
-
-            //- Return reference to the flux to allow adjustment
-            scalar& flowRate()
-            {
-                return flowRate_;
-            }
-
-
-        //- Update the coefficients associated with the patch field
-        virtual void updateCoeffs();
-
-        //- Write
-        virtual void write(Ostream&) const;
-
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
index f4636e68a4255e2117b65a7e800f99a76d6389b6..8c4ee51e27d3d385bf14b5c11bd964d631e6c67f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
@@ -150,9 +150,9 @@ void pressureInletVelocityFvPatchVectorField::write(Ostream& os) const
     {
         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
     }
-    if (tangentialVelocity_.size())
+    if (rhoName_ != "rho")
     {
-        tangentialVelocity_.writeEntry("tangentialVelocity", os);
+        os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
     }
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H
index 53775789b00ae7a805ad77169a9011d233d30598..b7e65eee3db99114d602090d2e2f2331597d068c 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H
@@ -192,7 +192,7 @@ public:
             //- Return the time series used
             const interpolationTable<scalar>& totalPressureTimeSeries() const
             {
-                return totalPressureTimeSeries_;
+                return timeSeries_;
             }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
index 188e950b6d8d1a4c041a5fc50a720a58e2440898..90741d5843028afce1b9b765741879a8caf0a30c 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
@@ -28,6 +28,7 @@ License
 #include "dictionary.H"
 #include "fvMesh.H"
 #include "fvPatchFieldMapper.H"
+//#include "fvMatrices.H"
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
@@ -223,6 +224,13 @@ void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
 }
 
 
+template<class Type>
+void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
+{
+    // do nothing
+}
+
+
 template<class Type>
 void Foam::fvPatchField<Type>::write(Ostream& os) const
 {
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index 90cdb04a2024caacf2cb732297d8c7edb8f7eff6..40fd3ff818d99d2641c84046a2c87c15371fcdca 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
@@ -27,12 +27,12 @@ Class
 
 Description
     Abstract base class with a fat-interface to all derived classes
-    covering all possible ways in which they might be used. 
+    covering all possible ways in which they might be used.
 
     The first level of derivation is to basic patchFields which cover
     zero-gradient, fixed-gradient, fixed-value and mixed conditions.
 
-    The next level of derivation covers all the specialised typed with
+    The next level of derivation covers all the specialised types with
     specific evaluation proceedures, particularly with respect to specific
     fields.
 
@@ -66,6 +66,9 @@ class volMesh;
 template<class Type>
 class fvPatchField;
 
+template<class Type>
+class fvMatrix;
+
 template<class Type>
 Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
 
@@ -407,6 +410,10 @@ public:
             }
 
 
+            //- Manipulate matrix
+            virtual void manipulateMatrix(fvMatrix<Type>& matrix);
+
+
         //- Write
         virtual void write(Ostream&) const;
 
diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
index 31d557601b36b9602db220aa2318085ee9cbab2c..9dab83d168a4e57c7041331ca349b95dd1fdcf44 100644
--- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
+++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
@@ -592,6 +592,20 @@ void Foam::fvMatrix<Type>::relax()
 }
 
 
+template<class Type>
+void Foam::fvMatrix<Type>::boundaryManipulate
+(
+    typename GeometricField<Type, fvPatchField, volMesh>::
+        GeometricBoundaryField& bFields
+)
+{
+    forAll(bFields, patchI)
+    {
+        bFields[patchI].manipulateMatrix(*this);
+    }
+}
+
+
 template<class Type>
 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Type>::D() const
 {
diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H
index 5abb7ca0d61373083ab5c79c52b1793a781443ec..b7663db50f658d41783e1657f2ee401e134daa10 100644
--- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H
+++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H
@@ -351,6 +351,13 @@ public:
             //  alpha is read from controlDict
             void relax();
 
+            //- Manipulate based on a boundary field
+            void boundaryManipulate
+            (
+                typename GeometricField<Type, fvPatchField, volMesh>::
+                    GeometricBoundaryField& values
+            );
+
             //- Construct and return the solver
             //  Solver controls read from Istream
             autoPtr<fvSolver> solver(Istream&);
@@ -387,7 +394,7 @@ public:
 
             //- Return the face-flux field from the matrix
             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
-            flux() const;
+                flux() const;
 
 
     // Member operators
diff --git a/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.C b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.C
new file mode 100644
index 0000000000000000000000000000000000000000..bb4c6c1534c66c5f32911fd57bd62cd2acd040e5
--- /dev/null
+++ b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.C
@@ -0,0 +1,525 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "extendedStencil.H"
+#include "globalIndex.H"
+#include "syncTools.H"
+#include "SortableList.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+// Calculates per face a list of global cell/face indices.
+void Foam::extendedStencil::calcFaceStencils
+(
+    const polyMesh& mesh,
+    const globalIndex& globalNumbering
+)
+{
+    const polyBoundaryMesh& patches = mesh.boundaryMesh();
+    const label nBnd = mesh.nFaces()-mesh.nInternalFaces();
+    const labelList& own = mesh.faceOwner();
+    const labelList& nei = mesh.faceNeighbour();
+
+
+    // Determine neighbouring global cell or boundary face
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    labelList neiGlobal(nBnd);
+    forAll(patches, patchI)
+    {
+        const polyPatch& pp = patches[patchI];
+        label faceI = pp.start();
+
+        if (pp.coupled())
+        {
+            // For coupled faces get the cell on the other side
+            forAll(pp, i)
+            {
+                label bFaceI = faceI-mesh.nInternalFaces();
+                neiGlobal[bFaceI] = globalNumbering.toGlobal(own[faceI]);
+                faceI++;
+            }
+        }
+        else if (isA<emptyPolyPatch>(pp))
+        {
+            forAll(pp, i)
+            {
+                label bFaceI = faceI-mesh.nInternalFaces();
+                neiGlobal[bFaceI] = -1;
+                faceI++;
+            }
+        }
+        else
+        {
+            // For noncoupled faces get the boundary face.
+            forAll(pp, i)
+            {
+                label bFaceI = faceI-mesh.nInternalFaces();
+                neiGlobal[bFaceI] =
+                    globalNumbering.toGlobal(mesh.nCells()+bFaceI);
+                faceI++;
+            }
+        }
+    }
+    syncTools::swapBoundaryFaceList(mesh, neiGlobal, false);
+
+
+    // Determine cellCells in global numbering
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    labelListList globalCellCells(mesh.nCells());
+    forAll(globalCellCells, cellI)
+    {
+        const cell& cFaces = mesh.cells()[cellI];
+
+        labelList& cCells = globalCellCells[cellI];
+
+        cCells.setSize(cFaces.size());
+
+        // Collect neighbouring cells/faces
+        label nNbr = 0;
+        forAll(cFaces, i)
+        {
+            label faceI = cFaces[i];
+
+            if (mesh.isInternalFace(faceI))
+            {
+                label nbrCellI = own[faceI];
+                if (nbrCellI == cellI)
+                {
+                    nbrCellI = nei[faceI];
+                }
+                cCells[nNbr++] = globalNumbering.toGlobal(nbrCellI);
+            }
+            else
+            {
+                label nbrCellI = neiGlobal[faceI-mesh.nInternalFaces()];
+                if (nbrCellI != -1)
+                {
+                    cCells[nNbr++] = nbrCellI;
+                }
+            }
+        }
+        cCells.setSize(nNbr);
+    }
+
+
+    // Determine neighbouring global cell Cells
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    labelListList neiGlobalCellCells(nBnd);
+    for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
+    {
+        neiGlobalCellCells[faceI-mesh.nInternalFaces()] =
+            globalCellCells[own[faceI]];
+    }
+    syncTools::swapBoundaryFaceList(mesh, neiGlobalCellCells, false);
+
+
+
+    // Construct stencil in global numbering
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    stencil_.setSize(mesh.nFaces());
+
+    labelHashSet faceStencil;
+
+    for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
+    {
+        faceStencil.clear();
+        label globalOwn = globalNumbering.toGlobal(own[faceI]);
+        faceStencil.insert(globalOwn);
+        const labelList& ownCCells = globalCellCells[own[faceI]];
+        forAll(ownCCells, i)
+        {
+            faceStencil.insert(ownCCells[i]);
+        }
+
+        label globalNei = globalNumbering.toGlobal(nei[faceI]);
+        faceStencil.insert(globalNei);
+        const labelList& neiCCells = globalCellCells[nei[faceI]];
+        forAll(neiCCells, i)
+        {
+            faceStencil.insert(neiCCells[i]);
+        }
+
+        // Guarantee owner first, neighbour second.
+        stencil_[faceI].setSize(faceStencil.size());
+        label n = 0;
+        stencil_[faceI][n++] = globalOwn;
+        stencil_[faceI][n++] = globalNei;
+        forAllConstIter(labelHashSet, faceStencil, iter)
+        {
+            if (iter.key() != globalOwn && iter.key() != globalNei)
+            {
+                stencil_[faceI][n++] = iter.key();
+            }
+        }
+        //Pout<< "internalface:" << faceI << " toc:" << faceStencil.toc()
+        //    << " stencil:" << stencil_[faceI] << endl;
+    }
+    forAll(patches, patchI)
+    {
+        const polyPatch& pp = patches[patchI];
+        label faceI = pp.start();
+
+        if (pp.coupled())
+        {
+            forAll(pp, i)
+            {
+                faceStencil.clear();
+                label globalOwn = globalNumbering.toGlobal(own[faceI]);
+                faceStencil.insert(globalOwn);
+                const labelList& ownCCells = globalCellCells[own[faceI]];
+                forAll(ownCCells, i)
+                {
+                    faceStencil.insert(ownCCells[i]);
+                }
+                // Get the coupled cell
+                label globalNei = neiGlobal[faceI-mesh.nInternalFaces()];
+                faceStencil.insert(globalNei);
+                // And the neighbours of the coupled cell
+                const labelList& neiCCells =
+                    neiGlobalCellCells[faceI-mesh.nInternalFaces()];
+                forAll(neiCCells, i)
+                {
+                    faceStencil.insert(neiCCells[i]);
+                }
+
+                // Guarantee owner first, neighbour second.
+                stencil_[faceI].setSize(faceStencil.size());
+                label n = 0;
+                stencil_[faceI][n++] = globalOwn;
+                stencil_[faceI][n++] = globalNei;
+                forAllConstIter(labelHashSet, faceStencil, iter)
+                {
+                    if (iter.key() != globalOwn && iter.key() != globalNei)
+                    {
+                        stencil_[faceI][n++] = iter.key();
+                    }
+                }
+
+                //Pout<< "coupledface:" << faceI
+                //    << " toc:" << faceStencil.toc()
+                //    << " stencil:" << stencil_[faceI] << endl;
+
+                faceI++;
+            }
+        }
+        else if (!isA<emptyPolyPatch>(pp))
+        {
+            forAll(pp, i)
+            {
+                faceStencil.clear();
+                label globalOwn = globalNumbering.toGlobal(own[faceI]);
+                faceStencil.insert(globalOwn);
+                const labelList& ownCCells = globalCellCells[own[faceI]];
+                forAll(ownCCells, i)
+                {
+                    faceStencil.insert(ownCCells[i]);
+                }
+
+
+                // Guarantee owner first, neighbour second.
+                stencil_[faceI].setSize(faceStencil.size());
+                label n = 0;
+                stencil_[faceI][n++] = globalOwn;
+                forAllConstIter(labelHashSet, faceStencil, iter)
+                {
+                    if (iter.key() != globalOwn)
+                    {
+                        stencil_[faceI][n++] = iter.key();
+                    }
+                }
+
+                //Pout<< "boundaryface:" << faceI
+                //    << " toc:" << faceStencil.toc()
+                //    << " stencil:" << stencil_[faceI] << endl;
+
+                faceI++;
+            }
+        }
+    }
+}
+
+
+// Calculates extended stencil. This is per face
+// - owner
+// - cellCells of owner
+// - neighbour
+// - cellCells of neighbour
+// It comes in two parts:
+// - a map which collects/distributes all necessary data in a compact array
+// - the stencil (a labelList per face) which is a set of indices into this
+//   compact array.
+// The compact array is laid out as follows:
+// - first data for current processor (Pstream::myProcNo())
+//      - all cells
+//      - all boundary faces
+// - then per processor
+//      - all used cells and boundary faces
+void Foam::extendedStencil::calcExtendedFaceStencil(const polyMesh& mesh)
+{
+    const label nBnd = mesh.nFaces()-mesh.nInternalFaces();
+
+    // Global numbering for cells and boundary faces
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    globalIndex globalNumbering(mesh.nCells()+nBnd);
+
+
+    // Calculate stencil in global cell indices
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    calcFaceStencils(mesh, globalNumbering);
+
+
+    // Convert stencil to schedule
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    // We now know what information we need from other processors. This needs
+    // to be converted into what information I need to send as well
+    // (mapDistribute)
+
+
+    // 1. Construct per processor compact addressing of the global cells
+    //    needed. The ones from the local processor are not included since
+    //    these are always all needed.
+    List<Map<label> > globalToProc(Pstream::nProcs());
+    {
+        const labelList& procPatchMap = mesh.globalData().procPatchMap();
+        const polyBoundaryMesh& patches = mesh.boundaryMesh();
+
+        // Presize with (as estimate) size of patch to neighbour.
+        forAll(procPatchMap, procI)
+        {
+            if (procPatchMap[procI] != -1)
+            {
+                globalToProc[procI].resize
+                (
+                    patches[procPatchMap[procI]].size()
+                );
+            }
+        }
+
+        // Collect all (non-local) globalcells/faces needed.
+        forAll(stencil_, faceI)
+        {
+            const labelList& stencilCells = stencil_[faceI];
+
+            forAll(stencilCells, i)
+            {
+                label globalCellI = stencilCells[i];
+                label procI = globalNumbering.whichProcID(stencilCells[i]);
+
+                if (procI != Pstream::myProcNo())
+                {
+                    label nCompact = globalToProc[procI].size();
+                    globalToProc[procI].insert(globalCellI, nCompact);
+                }
+            }
+        }
+        // Sort global cells needed (not really necessary)
+        forAll(globalToProc, procI)
+        {
+            if (procI != Pstream::myProcNo())
+            {
+                Map<label>& globalMap = globalToProc[procI];
+
+                SortableList<label> sorted(globalMap.toc());
+
+                forAll(sorted, i)
+                {
+                    Map<label>::iterator iter = globalMap.find(sorted[i]);
+                    iter() = i;
+                }
+            }
+        }
+
+
+        // forAll(globalToProc, procI)
+        // {
+        //     Pout<< "From processor:" << procI << " want cells/faces:" << endl;
+        //     forAllConstIter(Map<label>, globalToProc[procI], iter)
+        //     {
+        //         Pout<< "    global:" << iter.key()
+        //             << " local:" << globalNumbering.toLocal(procI, iter.key())
+        //             << endl;
+        //     }
+        //     Pout<< endl;
+        // }
+    }
+
+
+    // 2. The overall compact addressing is
+    // - myProcNo first
+    // - all other processors consecutively
+
+    labelList compactStart(Pstream::nProcs());
+    compactStart[Pstream::myProcNo()] = 0;
+    label nCompact = mesh.nCells()+nBnd;
+    forAll(compactStart, procI)
+    {
+        if (procI != Pstream::myProcNo())
+        {
+            compactStart[procI] = nCompact;
+            nCompact += globalToProc[procI].size();
+
+            // Pout<< "Data wanted from " << procI << " starts at "
+            //     << compactStart[procI] << endl;
+        }
+    }
+    // Pout<< "Overall cells needed:" << nCompact << endl;
+
+
+    // 3. Find out what to receive/send in compact addressing.
+    labelListList recvCompact(Pstream::nProcs());
+    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    {
+        if (procI != Pstream::myProcNo())
+        {
+            labelList wantedGlobals(globalToProc[procI].size());
+            recvCompact[procI].setSize(globalToProc[procI].size());
+
+            label i = 0;
+            forAllConstIter(Map<label>, globalToProc[procI], iter)
+            {
+                wantedGlobals[i] = iter.key();
+                recvCompact[procI][i] = compactStart[procI]+iter();
+                i++;
+            }
+
+            // Pout<< "From proc:" << procI
+            //     << " I need (globalcells):" << wantedGlobals
+            //     << " which are my compact:" << recvCompact[procI]
+            //     << endl;
+
+            // Send the global cell numbers I need from procI
+            OPstream str(Pstream::blocking, procI);
+            str << wantedGlobals;
+        }
+        else
+        {
+            recvCompact[procI] =
+                compactStart[procI]
+              + identity(mesh.nCells()+nBnd);
+        }
+    }
+    labelListList sendCompact(Pstream::nProcs());
+    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    {
+        if (procI != Pstream::myProcNo())
+        {
+            // See what neighbour wants to receive (= what I need to send)
+
+            IPstream str(Pstream::blocking, procI);
+            labelList globalCells(str);
+
+            labelList& procCompact = sendCompact[procI];
+            procCompact.setSize(globalCells.size());
+
+            // Convert from globalCells (all on my processor!) into compact
+            // addressing
+            forAll(globalCells, i)
+            {
+                label cellI = globalNumbering.toLocal(globalCells[i]);
+                procCompact[i] = compactStart[Pstream::myProcNo()]+cellI;
+            }
+        }
+        else
+        {
+            sendCompact[procI] = recvCompact[procI];
+        }
+    }
+
+    // Convert stencil to compact numbering
+    forAll(stencil_, faceI)
+    {
+        labelList& stencilCells = stencil_[faceI];
+
+        forAll(stencilCells, i)
+        {
+            label globalCellI = stencilCells[i];
+            label procI = globalNumbering.whichProcID(globalCellI);
+            if (procI != Pstream::myProcNo())
+            {
+                label localCompact = globalToProc[procI][globalCellI];
+                stencilCells[i] = compactStart[procI]+localCompact;
+            }
+            else
+            {
+                label localCompact = globalNumbering.toLocal(globalCellI);
+                stencilCells[i] = compactStart[procI]+localCompact;
+            }
+
+        }
+    }
+    // Pout<< "***stencil_:" << stencil_ << endl;
+
+    // Constuct map for distribution of compact data.
+    mapPtr_.reset
+    (
+        new mapDistribute
+        (
+            nCompact,
+            sendCompact,
+            recvCompact,
+            true            // reuse send/recv maps.
+        )
+    );
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::extendedStencil::extendedStencil
+(
+    const mapDistribute& map,
+    const labelListList& stencil
+)
+:
+    mapPtr_
+    (
+        autoPtr<mapDistribute>
+        (
+            new mapDistribute
+            (
+                map.constructSize(),
+                map.subMap(),
+                map.constructMap()
+            )
+        )
+    ),
+    stencil_(stencil)
+{}
+
+
+Foam::extendedStencil::extendedStencil(const polyMesh& mesh)
+{
+    calcExtendedFaceStencil(mesh);
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H
new file mode 100644
index 0000000000000000000000000000000000000000..1d00972403ba61be4316d38f275300cd9eb190a0
--- /dev/null
+++ b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H
@@ -0,0 +1,151 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::extendedStencil
+
+Description
+    Calculates/constains the extended face stencil.
+
+    The stencil is a list of indices into either cells or boundary faces
+    in a compact way. (element 0 is owner, 1 is neighbour). The index numbering
+    is
+    - cells first
+    - then all (non-empty patch) boundary faces
+
+    When used in evaluation is a two stage process:
+    - collect the data (cell data and non-empty boundaries) into a
+    single field
+    - (parallel) distribute the field
+    - sum the weights*field.
+
+SourceFiles
+    extendedStencil.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef extendedStencil_H
+#define extendedStencil_H
+
+#include "mapDistribute.H"
+#include "volFields.H"
+#include "surfaceFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class globalIndex;
+
+/*---------------------------------------------------------------------------*\
+                           Class extendedStencil Declaration
+\*---------------------------------------------------------------------------*/
+
+class extendedStencil
+{
+    // Private data
+
+        //- Swap map for getting neigbouring data
+        autoPtr<mapDistribute> mapPtr_;
+
+        //- Per face the stencil.
+        labelListList stencil_;
+
+
+    // Private Member Functions
+
+        void calcFaceStencils(const polyMesh&, const globalIndex&);
+
+        //- Calculate the stencil (but not weights)
+        void calcExtendedFaceStencil(const polyMesh&);
+
+
+        //- Disallow default bitwise copy construct
+        extendedStencil(const extendedStencil&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const extendedStencil&);
+
+
+public:
+
+    // Constructors
+
+        //- Construct from components
+        extendedStencil(const mapDistribute& map, const labelListList&);
+
+        //- Construct from all cells and boundary faces
+        extendedStencil(const polyMesh&);
+
+
+
+    // Member Functions
+
+        //- Return reference to the parallel distribution map
+        const mapDistribute& map() const
+        {
+            return mapPtr_();
+        }
+
+        //- Return reference to the stencil
+        const labelListList& stencil() const
+        {
+            return stencil_;
+        }
+
+        //- Use map to get the data into stencil order
+        template<class T>
+        void collectData
+        (
+            const GeometricField<T, fvPatchField, volMesh>& fld,
+            List<List<T> >& stencilFld
+        ) const;
+
+        //- Given weights interpolate vol field
+        template<class Type>
+        tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > interpolate
+        (
+            const GeometricField<Type, fvPatchField, volMesh>& fld,
+            const List<List<scalar> >& stencilWeights
+        ) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "extendedStencilTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C b/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..a408621dc4c4fce2becbcc03eafa8ea82f2d62e5
--- /dev/null
+++ b/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "extendedStencil.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::extendedStencil::collectData
+(
+    const GeometricField<Type, fvPatchField, volMesh>& fld,
+    List<List<Type> >& stencilFld
+) const
+{
+    // 1. Construct cell data in compact addressing
+    List<Type> compactFld(map().constructSize(), pTraits<Type>::zero);
+
+    // Insert my internal values
+    forAll(fld, cellI)
+    {
+        compactFld[cellI] = fld[cellI];
+    }
+    // Insert my boundary values
+    label nCompact = fld.size();
+    forAll(fld.boundaryField(), patchI)
+    {
+        const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
+
+        forAll(pfld, i)
+        {
+            compactFld[nCompact++] = pfld[i];
+        }
+    }
+
+    // Do all swapping
+    map().distribute(compactFld);
+
+    // 2. Pull to stencil
+    stencilFld.setSize(stencil_.size());
+
+    forAll(stencil_, faceI)
+    {
+        const labelList& compactCells = stencil_[faceI];
+
+        stencilFld[faceI].setSize(compactCells.size());
+
+        forAll(compactCells, i)
+        {
+            stencilFld[faceI][i] = compactFld[compactCells[i]];
+        }
+    }
+}
+
+
+template<class Type>
+Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
+Foam::extendedStencil::interpolate
+(
+    const GeometricField<Type, fvPatchField, volMesh>& fld,
+    const List<List<scalar> >& stencilWeights
+) const
+{
+    const fvMesh& mesh = fld.mesh();
+
+    // Collect internal and boundary values
+    List<List<Type> > stencilFld;
+    collectData(fld, stencilFld);
+
+    tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
+    (
+        new GeometricField<Type, fvsPatchField, surfaceMesh>
+        (
+            IOobject
+            (
+                fld.name(),
+                mesh.time().timeName(),
+                mesh
+            ),
+            mesh,
+            dimensioned<Type>
+            (
+                fld.name(),
+                fld.dimensions(),
+                pTraits<Type>::zero
+            )
+        )
+    );
+    GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
+
+    for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
+    {
+        const List<Type>& stField = stencilFld[faceI];
+        const List<scalar>& stWeight = stencilWeights[faceI];
+
+        forAll(stField, i)
+        {
+            sf[faceI] += stField[i]*stWeight[i];
+        }
+    }
+    // And what for boundaries?
+
+    return tsfCorr;
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistData.C b/src/finiteVolume/fvMesh/wallDist/wallDistData.C
index c7b9debba84da83fd0b276a311103f490bc77cb7..ebe0aa16ee901a86bf863a3672f5cc5b52d5691c 100644
--- a/src/finiteVolume/fvMesh/wallDist/wallDistData.C
+++ b/src/finiteVolume/fvMesh/wallDist/wallDistData.C
@@ -83,11 +83,11 @@ void Foam::wallDistData<TransferType>::correct()
     labelHashSet wallPatchIDs(getPatchIDs(wallPolyPatch::typeName));
 
     // Collect pointers to data on patches
-    List<Field<Type>*> patchData(mesh.boundaryMesh().size());
+    UPtrList<Field<Type> > patchData(mesh.boundaryMesh().size());
 
     forAll(field_.boundaryField(), patchI)
     {
-        patchData[patchI] = &(field_.boundaryField()[patchI]);
+        patchData.set(patchI, &field_.boundaryField()[patchI]);
     }
 
     // Do mesh wave
diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.C
similarity index 87%
rename from src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C
rename to src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.C
index 60909d1891298d65c89c636814ab36fbf2ed7cef..a215576330b96524c911ddbcc13a622c877fc3d2 100644
--- a/src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.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-2007 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -24,16 +24,13 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "checkLock.H"
+#include "quadraticFit.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    globalCheckLock incompressibleTurbulenceModelsLock
-    (
-        "incompressibleTurbulenceModels"
-    );
+    makeSurfaceInterpolationScheme(quadraticFit);
 }
 
 // ************************************************************************* //
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H
new file mode 100644
index 0000000000000000000000000000000000000000..412b454015dfcbecdea2752b4394ae4abc457dd9
--- /dev/null
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H
@@ -0,0 +1,138 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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
+    quadraticFit
+
+Description
+    Quadratic fit interpolation scheme which applies an explicit correction to
+    linear.
+
+SourceFiles
+    quadraticFit.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef quadraticFit_H
+#define quadraticFit_H
+
+#include "linear.H"
+#include "quadraticFitData.H"
+#include "extendedStencil.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class quadraticFit Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class quadraticFit
+:
+    public linear<Type>
+{
+    // Private Data
+        const scalar centralWeight_;
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        quadraticFit(const quadraticFit&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const quadraticFit&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("quadraticFit");
+
+
+    // Constructors
+
+        //- Construct from mesh and Istream
+        quadraticFit(const fvMesh& mesh, Istream& is)
+        :
+            linear<Type>(mesh),
+            centralWeight_(readScalar(is))
+        {}
+
+
+        //- Construct from mesh, faceFlux and Istream
+        quadraticFit
+        (
+            const fvMesh& mesh,
+            const surfaceScalarField& faceFlux,
+            Istream& is
+        )
+        :
+            linear<Type>(mesh),
+            centralWeight_(readScalar(is))
+        {}
+
+
+    // Member Functions
+
+        //- Return true if this scheme uses an explicit correction
+        virtual bool corrected() const
+        {
+            return true;
+        }
+
+        //- Return the explicit correction to the face-interpolate
+        virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
+        correction
+        (
+            const GeometricField<Type, fvPatchField, volMesh>& vf
+        ) const
+        {
+            const fvMesh& mesh = this->mesh();
+
+            const quadraticFitData& cfd = quadraticFitData::New
+            (
+                mesh,
+                centralWeight_
+            );
+
+            const extendedStencil& stencil = cfd.stencil();
+            const List<scalarList>& f = cfd.fit();
+
+            return stencil.interpolate(vf, f);
+        }
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C
new file mode 100644
index 0000000000000000000000000000000000000000..79f9107e97f61b4b9f77a364256dca9c021f3620
--- /dev/null
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C
@@ -0,0 +1,362 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "quadraticFitData.H"
+#include "surfaceFields.H"
+#include "volFields.H"
+#include "SVD.H"
+#include "syncTools.H"
+
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(quadraticFitData, 0);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::quadraticFitData::quadraticFitData
+(
+    const fvMesh& mesh,
+    const scalar cWeight
+)
+:
+    MeshObject<fvMesh, quadraticFitData>(mesh),
+    centralWeight_(cWeight),
+#   ifdef SPHERICAL_GEOMETRY
+    dim_(2),
+#   else
+    dim_(mesh.nGeometricD()),
+#   endif
+    minSize_
+    (
+        dim_ == 1 ? 3 :
+        dim_ == 2 ? 6 :
+        dim_ == 3 ? 9 : 0
+    ),
+    stencil_(mesh),
+    fit_(mesh.nInternalFaces())
+{
+    if (debug)
+    {
+        Info << "Contructing quadraticFitData" << endl;
+    }
+
+    // check input
+    if (centralWeight_ < 1 - SMALL)
+    {
+        FatalErrorIn("quadraticFitData::quadraticFitData")
+            << "centralWeight requested = " << centralWeight_
+            << " should not be less than one"
+            << exit(FatalError);
+    }
+
+    if (minSize_ == 0)
+    {
+        FatalErrorIn("quadraticFitSnGradData")
+            << " dimension must be 1,2 or 3, not" << dim_ << exit(FatalError);
+    }
+
+    // store the polynomial size for each cell to write out
+    surfaceScalarField interpPolySize
+    (
+        IOobject
+        (
+            "quadraticFitInterpPolySize",
+            "constant",
+            mesh,
+            IOobject::NO_READ,
+            IOobject::NO_WRITE
+        ),
+        mesh,
+        dimensionedScalar("quadraticFitInterpPolySize", dimless, scalar(0))
+    );
+
+    // Get the cell/face centres in stencil order.
+    // Centred face stencils no good for triangles of tets. Need bigger stencils
+    List<List<point> > stencilPoints(stencil_.stencil().size());
+    stencil_.collectData
+    (
+        mesh.C(),
+        stencilPoints
+    );
+
+    // find the fit coefficients for every face in the mesh
+
+    for(label faci = 0; faci < mesh.nInternalFaces(); faci++)
+    {
+        interpPolySize[faci] = calcFit(stencilPoints[faci], faci);
+    }
+
+    interpPolySize.write();
+
+    if (debug)
+    {
+        Info<< "quadraticFitData::quadraticFitData() :"
+            << "Finished constructing polynomialFit data"
+            << endl;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::quadraticFitData::findFaceDirs
+(
+    vector& idir,        // value changed in return
+    vector& jdir,        // value changed in return
+    vector& kdir,        // value changed in return
+    const fvMesh& mesh,
+    const label faci
+)
+{
+    idir = mesh.Sf()[faci];
+    idir /= mag(idir);
+
+#   ifndef SPHERICAL_GEOMETRY
+    if (mesh.nGeometricD() <= 2) // find the normal direcion
+    {
+        if (mesh.directions()[0] == -1)
+        {
+            kdir = vector(1, 0, 0);
+        }
+        else if (mesh.directions()[1] == -1)
+        {
+            kdir = vector(0, 1, 0);
+        }
+        else
+        {
+            kdir = vector(0, 0, 1);
+        }
+    }
+    else // 3D so find a direction in the place of the face
+    {
+        const face& f = mesh.faces()[faci];
+        kdir = mesh.points()[f[0]] - mesh.points()[f[1]];
+    }
+#   else
+    // Spherical geometry so kdir is the radial direction
+    kdir = mesh.Cf()[faci];
+#   endif
+
+    if (mesh.nGeometricD() == 3)
+    {
+        // Remove the idir component from kdir and normalise
+        kdir -= (idir & kdir)*idir;
+
+        scalar magk = mag(kdir);
+
+        if (magk < SMALL)
+        {
+            FatalErrorIn("findFaceDirs") << " calculated kdir = zero"
+                << exit(FatalError);
+        }
+        else
+        {
+            kdir /= magk;
+        }
+    }
+
+    jdir = kdir ^ idir;
+}
+
+
+Foam::label Foam::quadraticFitData::calcFit
+(
+    const List<point>& C,
+    const label faci
+)
+{
+    vector idir(1,0,0);
+    vector jdir(0,1,0);
+    vector kdir(0,0,1);
+    findFaceDirs(idir, jdir, kdir, mesh(), faci);
+
+    scalarList wts(C.size(), scalar(1));
+    wts[0] = centralWeight_;
+    wts[1] = centralWeight_;
+
+    point p0 = mesh().faceCentres()[faci];
+    scalar scale = 0;
+
+    // calculate the matrix of the polynomial components
+    scalarRectangularMatrix B(C.size(), minSize_, scalar(0));
+
+    for(label ip = 0; ip < C.size(); ip++)
+    {
+        const point& p = C[ip];
+
+        scalar px = (p - p0)&idir;
+        scalar py = (p - p0)&jdir;
+#       ifndef SPHERICAL_GEOMETRY
+        scalar pz = (p - p0)&kdir;
+#       else
+        scalar pz = mag(p) - mag(p0);
+#       endif
+
+        if (ip == 0)
+        {
+            scale = max(max(mag(px), mag(py)), mag(pz));
+        }
+
+        px /= scale;
+        py /= scale;
+        pz /= scale;
+
+        label is = 0;
+
+        B[ip][is++] = wts[0]*wts[ip];
+        B[ip][is++] = wts[0]*wts[ip]*px;
+        B[ip][is++] = wts[ip]*sqr(px);
+
+        if (dim_ >= 2)
+        {
+            B[ip][is++] = wts[ip]*py;
+            B[ip][is++] = wts[ip]*px*py;
+            B[ip][is++] = wts[ip]*sqr(py);
+        }
+        if (dim_ == 3)
+        {
+            B[ip][is++] = wts[ip]*pz;
+            B[ip][is++] = wts[ip]*px*pz;
+            //B[ip][is++] = wts[ip]*py*pz;
+            B[ip][is++] = wts[ip]*sqr(pz);
+        }
+    }
+
+    // Set the fit
+    label stencilSize = C.size();
+    fit_[faci].setSize(stencilSize);
+    scalarList singVals(minSize_);
+    label nSVDzeros = 0;
+
+    const GeometricField<scalar, fvsPatchField, surfaceMesh>& w =
+        mesh().surfaceInterpolation::weights();
+
+    bool goodFit = false;
+    for(int iIt = 0; iIt < 10 && !goodFit; iIt++)
+    {
+        SVD svd(B, SMALL);
+
+        scalar fit0 = wts[0]*wts[0]*svd.VSinvUt()[0][0];
+        scalar fit1 = wts[0]*wts[1]*svd.VSinvUt()[0][1];
+
+        //goodFit = (fit0 > 0 && fit1 > 0);
+
+        goodFit =
+            (mag(fit0 - w[faci])/w[faci] < 0.5)
+         && (mag(fit1 - (1 - w[faci]))/(1 - w[faci]) < 0.5);
+
+        //scalar w0Err = fit0/w[faci];
+        //scalar w1Err = fit1/(1 - w[faci]);
+
+        //goodFit =
+        //    (w0Err > 0.5 && w0Err < 1.5)
+        // && (w1Err > 0.5 && w1Err < 1.5);
+
+        if (goodFit)
+        {
+            fit_[faci][0] = fit0;
+            fit_[faci][1] = fit1;
+
+            for(label i=2; i<stencilSize; i++)
+            {
+                fit_[faci][i] = wts[0]*wts[i]*svd.VSinvUt()[0][i];
+            }
+
+            singVals = svd.S();
+            nSVDzeros = svd.nZeros();
+        }
+        else // (not good fit so increase weight in the centre and for linear)
+        {
+            wts[0] *= 10;
+            wts[1] *= 10;
+
+            for(label i = 0; i < B.n(); i++)
+            {
+                B[i][0] *= 10;
+                B[i][1] *= 10;
+            }
+
+            for(label j = 0; j < B.m(); j++)
+            {
+                B[0][j] *= 10;
+                B[1][j] *= 10;
+            }
+        }
+    }
+
+    //static const scalar alpha = 1.5;
+    //static const scalar beta = alpha/0.5;
+
+    if (goodFit)
+    {
+        // scalar limiter =
+        // max
+        // (
+        //     min
+        //     (
+        //         min(alpha - beta*mag(fit_[faci][0] - w[faci])/w[faci], 1),
+        //         min(alpha - beta*mag(fit_[faci][1] - (1 - w[faci]))/(1 - w[faci]), 1)
+        //     ), 0
+        // );
+
+        // Remove the uncorrected linear coefficients
+        fit_[faci][0] -= w[faci];
+        fit_[faci][1] -= 1 - w[faci];
+
+        // if (limiter < 0.99)
+        // {
+        //     for(label i = 0; i < stencilSize; i++)
+        //     {
+        //         fit_[faci][i] *= limiter;
+        //     }
+        // }
+    }
+    else
+    {
+        Pout<< "Could not fit face " << faci
+            << " " << fit_[faci][0] << " " << w[faci]
+            << " " << fit_[faci][1] << " " << 1 - w[faci]<< endl;
+        fit_[faci] = 0;
+    }
+
+    return minSize_ - nSVDzeros;
+}
+
+
+bool Foam::quadraticFitData::movePoints()
+{
+    notImplemented("quadraticFitData::movePoints()");
+
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.H
new file mode 100644
index 0000000000000000000000000000000000000000..19859ea621cde6d18e6461f60aae6a7c49387d04
--- /dev/null
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.H
@@ -0,0 +1,140 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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
+    quadraticFitData
+
+Description
+    Data for the quadratic fit correction interpolation scheme
+
+SourceFiles
+    quadraticFitData.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef quadraticFitData_H
+#define quadraticFitData_H
+
+#include "MeshObject.H"
+#include "fvMesh.H"
+#include "extendedStencil.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class globalIndex;
+
+/*---------------------------------------------------------------------------*\
+                    Class quadraticFitData Declaration
+\*---------------------------------------------------------------------------*/
+
+class quadraticFitData
+:
+    public MeshObject<fvMesh, quadraticFitData>
+{
+    // Private data
+
+        //- weights for central stencil
+        const scalar centralWeight_;
+
+        //- dimensionality of the geometry
+        const label dim_;
+
+        //- minimum stencil size
+        const label minSize_;
+
+        //- Extended stencil addressing
+        extendedStencil stencil_;
+
+        //- For each cell in the mesh store the values which multiply the
+        //  values of the stencil to obtain the gradient for each direction
+        List<scalarList> fit_;
+
+
+    // Private member functions
+
+        //- Find the normal direction and i, j and k directions for face faci
+        static void findFaceDirs
+        (
+            vector& idir,        // value changed in return
+            vector& jdir,        // value changed in return
+            vector& kdir,        // value changed in return
+            const fvMesh& mesh,
+            const label faci
+        );
+
+        label calcFit(const List<point>&, const label faci);
+
+
+public:
+
+    TypeName("quadraticFitData");
+
+
+    // Constructors
+
+        explicit quadraticFitData
+        (
+            const fvMesh& mesh,
+            scalar cWeightDim
+        );
+
+
+    // Destructor
+
+        virtual ~quadraticFitData()
+        {}
+
+
+    // Member functions
+
+
+        //- Return reference to the stencil
+        const extendedStencil& stencil() const
+        {
+            return stencil_;
+        }
+
+        //- Return reference to fit coefficients
+        const List<scalarList>& fit() const
+        {
+            return fit_;
+        }
+
+        //- Delete the data when the mesh moves not implemented
+        virtual bool movePoints();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C
index dcf4730f7a42500e23d61e3ae48a76980719d59e..ffef30b10d4fe048eaa6b49ec22afec13951b43f 100644
--- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C
+++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C
@@ -86,7 +86,7 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
             (
                 IOobject
                 (
-                     this->name() + "rhoTrans" + name(i),
+                     this->name() + "rhoTrans" + Foam::name(i),
                      this->db().time().timeName(),
                      this->db(),
                      IOobject::NO_READ,
diff --git a/src/meshTools/cellDist/patchWave/patchDataWave.C b/src/meshTools/cellDist/patchWave/patchDataWave.C
index 4d196fb1e9f49bd085dbe8c81d3c7a9e7080a252..beb76631c5bbe7b7f8165902d077ff7590295edf 100644
--- a/src/meshTools/cellDist/patchWave/patchDataWave.C
+++ b/src/meshTools/cellDist/patchWave/patchDataWave.C
@@ -22,8 +22,6 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Description
-
 \*---------------------------------------------------------------------------*/
 
 #include "patchDataWave.H"
@@ -50,8 +48,7 @@ void Foam::patchDataWave<TransferType>::setChangedFaces
         {
             const polyPatch& patch = mesh.boundaryMesh()[patchI];
 
-            const Field<Type>& patchField =
-                *initialPatchValuePtrs_[patchI];
+            const Field<Type>& patchField = initialPatchValuePtrs_[patchI];
 
             forAll(patch.faceCentres(), patchFaceI)
             {
@@ -176,7 +173,7 @@ Foam::patchDataWave<TransferType>::patchDataWave
 (
     const polyMesh& mesh,
     const labelHashSet& patchIDs,
-    const List<Field<Type>*>& initialPatchValuePtrs,
+    const UPtrList<Field<Type> >& initialPatchValuePtrs,
     const bool correctWalls
 )
 :
diff --git a/src/meshTools/cellDist/patchWave/patchDataWave.H b/src/meshTools/cellDist/patchWave/patchDataWave.H
index be7aae205feb286e9b2a48f731f44597afd57ce1..241c378310960ba580b934e86195f2f262a520b2 100644
--- a/src/meshTools/cellDist/patchWave/patchDataWave.H
+++ b/src/meshTools/cellDist/patchWave/patchDataWave.H
@@ -45,7 +45,7 @@ SourceFiles
 
 #include "cellDistFuncs.H"
 #include "FieldField.H"
-
+#include "UPtrList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -78,7 +78,7 @@ private:
         labelHashSet patchIDs_;
 
         //- Reference to initial extra data at patch faces
-        const List<Field<Type>*>& initialPatchValuePtrs_;
+        const UPtrList<Field<Type> >& initialPatchValuePtrs_;
 
         //- Do accurate distance calculation for near-wall cells.
         bool correctWalls_;
@@ -129,7 +129,7 @@ public:
         (
             const polyMesh& mesh,
             const labelHashSet& patchIDs,
-            const List<Field<Type>*>& initialPatchValuePtrs,
+            const UPtrList<Field<Type> >& initialPatchValuePtrs,
             bool correctWalls = true
         );
 
diff --git a/src/meshTools/sets/topoSets/faceSet.C b/src/meshTools/sets/topoSets/faceSet.C
index 7c195ca0a976fbf3b492bf11dd2ff9696c8cb0a2..95d8dcefe9f8d9dcdbaa247c9abcd0f67ee2f67b 100644
--- a/src/meshTools/sets/topoSets/faceSet.C
+++ b/src/meshTools/sets/topoSets/faceSet.C
@@ -205,11 +205,12 @@ void faceSet::sync(const polyMesh& mesh)
 
     reduce(nAdded, sumOp<label>());
 
-    if (nAdded > 0)
-    {
-        Info<< "Added an additional " << nAdded << " faces on coupled patches. "
-            << "(processorPolyPatch, cyclicPolyPatch)" << endl;
-    }
+    //if (nAdded > 0)
+    //{
+    //    Info<< "Added an additional " << nAdded
+    //        << " faces on coupled patches. "
+    //        << "(processorPolyPatch, cyclicPolyPatch)" << endl;
+    //}
 }
 
 
diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake
index f67ba57aa1f70da1d1582a1db713c30f5337a204..1d889e8b76f7d90c636e8f8d7a6a1a6616925a48 100755
--- a/src/postProcessing/Allwmake
+++ b/src/postProcessing/Allwmake
@@ -6,5 +6,6 @@ wmake libo postCalc
 wmake libso forces
 wmake libso fieldAverage
 wmake libso foamCalcFunctions
+wmake libso minMaxFields
 
 # ----------------------------------------------------------------- end-of-file
diff --git a/src/postProcessing/fieldAverage/fieldAverageItem/fieldAverageItem.H b/src/postProcessing/fieldAverage/fieldAverageItem/fieldAverageItem.H
index 1bcb5689bbb45027b259e28d1a4274c08b5fa867..a8b8830016fc84d82b6d13b907582b80d96e3cac 100644
--- a/src/postProcessing/fieldAverage/fieldAverageItem/fieldAverageItem.H
+++ b/src/postProcessing/fieldAverage/fieldAverageItem/fieldAverageItem.H
@@ -102,15 +102,6 @@ private:
         baseType base_;
 
 
-    // Private Member Functions
-
-        //- Disallow default bitwise copy construct
-//        fieldAverageItem(const fieldAverageItem&);
-
-        //- Disallow default bitwise assignment
-//        void operator=(const fieldAverageItem&);
-
-
 public:
 
     // Constructors
@@ -175,6 +166,29 @@ public:
 
         void operator=(const fieldAverageItem&);
 
+    // Friend Operators
+
+        friend bool operator==
+        (
+            const fieldAverageItem& a,
+            const fieldAverageItem& b
+        )
+        {
+            return
+                a.fieldName_ == b.fieldName_
+             && a.mean_ == b.mean_
+             && a.prime2Mean_ == b.prime2Mean_
+             && a.base_ == b.base_;
+        }
+
+        friend bool operator!=
+        (
+            const fieldAverageItem& a,
+            const fieldAverageItem& b
+        )
+        {
+            return !(a == b);
+        }
 
     // IOstream Operators
 
diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H b/src/postProcessing/minMaxFields/IOminMaxFields.H
similarity index 74%
rename from src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H
rename to src/postProcessing/minMaxFields/IOminMaxFields.H
index eb1b3c59190d796207da478a265f3dfbdb0038b7..2c552e3742b0992d9a1194202a44370f09d389e3 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H
+++ b/src/postProcessing/minMaxFields/IOminMaxFields.H
@@ -22,30 +22,29 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    wallOmega
+Typedef
+    Foam::IOminMaxFields
 
 Description
-    Set wall dissipation in the omega matrix
+    Instance of the generic IOOutputFilter for minMaxFields.
 
 \*---------------------------------------------------------------------------*/
 
+#ifndef IOminMaxFields_H
+#define IOminMaxFields_H
+
+#include "minMaxFields.H"
+#include "IOOutputFilter.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
 {
-    const fvPatchList& patches = mesh_.boundary();
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& p = patches[patchi];
-
-        if (isType<wallFvPatch>(p))
-        {
-            omegaEqn().setValues
-            (
-                p.faceCells(),
-                omega_.boundaryField()[patchi].patchInternalField()
-            );
-        }
-    }
+    typedef IOOutputFilter<minMaxFields> IOminMaxFields;
 }
 
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
 // ************************************************************************* //
diff --git a/src/postProcessing/minMaxFields/Make/files b/src/postProcessing/minMaxFields/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..196026e838d0284033f114b2dcf5067df77c2cab
--- /dev/null
+++ b/src/postProcessing/minMaxFields/Make/files
@@ -0,0 +1,4 @@
+minMaxFields.C
+minMaxFieldsFunctionObject.C
+
+LIB = $(FOAM_LIBBIN)/libminMaxFields
diff --git a/src/postProcessing/minMaxFields/Make/options b/src/postProcessing/minMaxFields/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..0954a90689826c4634362b58d14d8a3c34d37a03
--- /dev/null
+++ b/src/postProcessing/minMaxFields/Make/options
@@ -0,0 +1,8 @@
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/sampling/lnInclude
+
+LIB_LIBS = \
+    -lfiniteVolume \
+    -lmeshTools
diff --git a/src/postProcessing/minMaxFields/minMaxFields.C b/src/postProcessing/minMaxFields/minMaxFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..0c9c5df645e42c3131f41d01988e91c832ac314a
--- /dev/null
+++ b/src/postProcessing/minMaxFields/minMaxFields.C
@@ -0,0 +1,203 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "minMaxFields.H"
+#include "volFields.H"
+#include "dictionary.H"
+#include "Time.H"
+
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(minMaxFields, 0);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::minMaxFields::minMaxFields
+(
+    const word& name,
+    const objectRegistry& obr,
+    const dictionary& dict,
+    const bool loadFromFiles
+)
+:
+    name_(name),
+    obr_(obr),
+    active_(true),
+    log_(false),
+    fieldSet_(),
+    minMaxFieldsFilePtr_(NULL)
+{
+    // Check if the available mesh is an fvMesh otherise deactivate
+    if (!isA<fvMesh>(obr_))
+    {
+        active_ = false;
+        WarningIn
+        (
+            "minMaxFields::minMaxFields"
+            "(const objectRegistry& obr, const dictionary& dict)"
+        )   << "No fvMesh available, deactivating."
+            << endl;
+    }
+
+    read(dict);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::minMaxFields::~minMaxFields()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::minMaxFields::read(const dictionary& dict)
+{
+    if (active_)
+    {
+        log_ = dict.lookupOrDefault<Switch>("log", false);
+
+        dict.lookup("fields") >> fieldSet_;
+    }
+}
+
+
+void Foam::minMaxFields::makeFile()
+{
+    // Create the minMaxFields file if not already created
+    if (!minMaxFieldsFilePtr_.valid())
+    {
+        if (debug)
+        {
+            Info<< "Creating minMaxFields file." << endl;
+        }
+
+        // File update
+        if (Pstream::master())
+        {
+            fileName minMaxFieldsDir;
+            if (Pstream::parRun())
+            {
+                // Put in undecomposed case (Note: gives problems for
+                // distributed data running)
+                minMaxFieldsDir =
+                    obr_.time().path()/".."/name_/obr_.time().timeName();
+            }
+            else
+            {
+                minMaxFieldsDir =
+                    obr_.time().path()/name_/obr_.time().timeName();
+            }
+
+            // Create directory if does not exist.
+            mkDir(minMaxFieldsDir);
+
+            // Open new file at start up
+            minMaxFieldsFilePtr_.reset
+            (
+                new OFstream(minMaxFieldsDir/(type() + ".dat"))
+            );
+
+            // Add headers to output data
+            writeFileHeader();
+        }
+    }
+}
+
+
+void Foam::minMaxFields::writeFileHeader()
+{
+    if (minMaxFieldsFilePtr_.valid())
+    {
+        minMaxFieldsFilePtr_()
+            << "# Time" << tab << "field" << tab << "min" << tab << "max"
+            << endl;
+    }
+}
+
+
+void Foam::minMaxFields::execute()
+{
+    // Do nothing - only valid on write
+}
+
+void Foam::minMaxFields::write()
+{
+    if (active_)
+    {
+        // Create the minMaxFields file if not already created
+        makeFile();
+
+        forAll(fieldSet_, fieldI)
+        {
+            calcMinMaxFields<scalar>(fieldSet_[fieldI]);
+            calcMinMaxFields<vector>(fieldSet_[fieldI]);
+            calcMinMaxFields<sphericalTensor>(fieldSet_[fieldI]);
+            calcMinMaxFields<symmTensor>(fieldSet_[fieldI]);
+            calcMinMaxFields<tensor>(fieldSet_[fieldI]);
+        }
+    }
+}
+
+
+template<>
+void Foam::minMaxFields::calcMinMaxFields<Foam::scalar>
+(
+    const word& fieldName
+)
+{
+    if (obr_.foundObject<volScalarField>(fieldName))
+    {
+        const scalarField& field = obr_.lookupObject<scalarField>(fieldName);
+        scalar minValue = min(field);
+        scalar maxValue = max(field);
+
+        reduce(minValue, minOp<scalar>());
+        reduce(maxValue, maxOp<scalar>());
+
+        if (Pstream::master())
+        {
+            minMaxFieldsFilePtr_() << obr_.time().value() << tab
+                << fieldName << tab << minValue << tab << maxValue << endl;
+
+            if (log_)
+            {
+                Info<< "minMaxFields output:" << nl
+                    << "    min(" << fieldName << ") = " << minValue << nl
+                    << "    max(" << fieldName << ") = " << maxValue << nl
+                    << endl;
+            }
+        }
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/postProcessing/minMaxFields/minMaxFields.H b/src/postProcessing/minMaxFields/minMaxFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..8a05ae3035005c2b05a8eefb2238a71b43548d47
--- /dev/null
+++ b/src/postProcessing/minMaxFields/minMaxFields.H
@@ -0,0 +1,182 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::minMaxFields
+
+Description
+    Calculates scalar minimim and maximum field values.
+
+    For variables with rank > 0, computes the magnitude of the min/max
+    values.
+
+    Data written to the file \<timeDir\>/minMaxFields.dat
+
+
+SourceFiles
+    minMaxFields.C
+    IOminMaxFields.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef minMaxFields_H
+#define minMaxFields_H
+
+#include "primitiveFieldsFwd.H"
+#include "volFieldsFwd.H"
+#include "labelHashSet.H"
+#include "OFstream.H"
+#include "Switch.H"
+#include "pointFieldFwd.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class objectRegistry;
+class dictionary;
+class mapPolyMesh;
+
+/*---------------------------------------------------------------------------*\
+                       Class minMaxFields Declaration
+\*---------------------------------------------------------------------------*/
+
+class minMaxFields
+{
+protected:
+
+    // Private data
+
+        //- Name of this set of forces,
+        //  Also used as the name of the probes directory.
+        word name_;
+
+        const objectRegistry& obr_;
+
+        //- on/off switch
+        bool active_;
+
+        //- Switch to send output to Info as well as to file
+        Switch log_;
+
+        //- Patches to integrate forces over
+        wordList fieldSet_;
+
+
+        //- Forces/moment file ptr
+        autoPtr<OFstream> minMaxFieldsFilePtr_;
+
+
+    // Private Member Functions
+
+        //- If the forces file has not been created create it
+        void makeFile();
+
+        //- Disallow default bitwise copy construct
+        minMaxFields(const minMaxFields&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const minMaxFields&);
+
+        //- Output file header information
+        virtual void writeFileHeader();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("minMaxFields");
+
+
+    // Constructors
+
+        //- Construct for given objectRegistry and dictionary.
+        //  Allow the possibility to load fields from files
+        minMaxFields
+        (
+            const word& name,
+            const objectRegistry&,
+            const dictionary&,
+            const bool loadFromFiles = false
+        );
+
+
+    // Destructor
+
+        virtual ~minMaxFields();
+
+
+    // Member Functions
+
+        //- Return name of the set of forces
+        virtual const word& name() const
+        {
+            return name_;
+        }
+
+        //- Read the forces data
+        virtual void read(const dictionary&);
+
+        //- Execute
+        virtual void execute();
+
+        //- Calculate the field min/max
+        template<class Type>
+        void calcMinMaxFields(const word& fieldName);
+
+        //- Write the minMaxFields
+        virtual void write();
+
+        //- Update for changes of mesh
+        virtual void updateMesh(const mapPolyMesh&)
+        {}
+
+        //- Update for changes of mesh
+        virtual void movePoints(const pointField&)
+        {}
+};
+
+
+// Template specialisation for scalar fields
+template<>
+void minMaxFields::calcMinMaxFields<scalar>(const word& fieldName);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "minMaxFieldsTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H b/src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.C
similarity index 75%
rename from src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H
rename to src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.C
index eb1b3c59190d796207da478a265f3dfbdb0038b7..454bb450c3645a69d3d043c15d7779b20c781f8b 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H
+++ b/src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.C
@@ -22,30 +22,22 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    wallOmega
+\*---------------------------------------------------------------------------*/
 
-Description
-    Set wall dissipation in the omega matrix
+#include "minMaxFieldsFunctionObject.H"
 
-\*---------------------------------------------------------------------------*/
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
+namespace Foam
 {
-    const fvPatchList& patches = mesh_.boundary();
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& p = patches[patchi];
-
-        if (isType<wallFvPatch>(p))
-        {
-            omegaEqn().setValues
-            (
-                p.faceCells(),
-                omega_.boundaryField()[patchi].patchInternalField()
-            );
-        }
-    }
+    defineNamedTemplateTypeNameAndDebug(minMaxFieldsFunctionObject, 0);
+
+    addToRunTimeSelectionTable
+    (
+        functionObject,
+        minMaxFieldsFunctionObject,
+        dictionary
+    );
 }
 
 // ************************************************************************* //
diff --git a/src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.H b/src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.H
new file mode 100644
index 0000000000000000000000000000000000000000..b414a0ff94b61d6d5be3ab262d5c463c55a3af71
--- /dev/null
+++ b/src/postProcessing/minMaxFields/minMaxFieldsFunctionObject.H
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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
+
+Typedef
+    Foam::minMaxFieldsFunctionObject
+
+Description
+    FunctionObject wrapper around minMaxFields to allow them to be created via
+    the functions list within controlDict.
+
+SourceFiles
+    minMaxFieldsFunctionObject.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef minMaxFieldsFunctionObject_H
+#define minMaxFieldsFunctionObject_H
+
+#include "minMaxFields.H"
+#include "OutputFilterFunctionObject.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef OutputFilterFunctionObject<minMaxFields>
+        minMaxFieldsFunctionObject;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H b/src/postProcessing/minMaxFields/minMaxFieldsTemplates.C
similarity index 56%
rename from src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H
rename to src/postProcessing/minMaxFields/minMaxFieldsTemplates.C
index 2cf371eedf6c42f0645c8c45b27f98d5974526ab..ea5947c1e26721f62afab57786d7aac127c0e6d2 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H
+++ b/src/postProcessing/minMaxFields/minMaxFieldsTemplates.C
@@ -22,45 +22,40 @@ License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Global
-    kOmegaWallViscosity
+\*---------------------------------------------------------------------------*/
 
-Description
-    Calculate wall viscosity from wall-functions.
+#include "minMaxFields.H"
+#include "volFields.H"
+#include "dictionary.H"
+#include "Time.H"
 
-\*---------------------------------------------------------------------------*/
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+template<class Type>
+void Foam::minMaxFields::calcMinMaxFields(const word& fieldName)
 {
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
-
-    const fvPatchList& patches = mesh_.boundary();
+    typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
 
-    forAll(patches, patchi)
+    if (obr_.foundObject<fieldType>(fieldName))
     {
-        const fvPatch& curPatch = patches[patchi];
+        const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
+        scalar minValue = min(mag(field)).value();
+        scalar maxValue = max(mag(field)).value();
 
-        if (isType<wallFvPatch>(curPatch))
+        reduce(minValue, minOp<scalar>());
+        reduce(maxValue, maxOp<scalar>());
+
+        if (Pstream::master())
         {
-            const scalarField& nuw = nu().boundaryField()[patchi];
-            scalarField& nutw = nut_.boundaryField()[patchi];
+            minMaxFieldsFilePtr_() << obr_.time().value() << tab
+                << fieldName << tab << minValue << tab << maxValue << endl;
 
-            forAll(curPatch, facei)
+            if (log_)
             {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[faceCelli]*sqrt(k_[faceCelli])/nuw[facei];
-
-                if (yPlus > yPlusLam_)
-                {
-                    nutw[facei] =
-                         nuw[facei]
-                        *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1);
-                }
-                else
-                {
-                    nutw[facei] = 0.0;
-                }
+                Info<< "minMaxFields output:" << nl
+                    << "    min(mag(" << fieldName << ")) = " << minValue << nl
+                    << "    max(mag(" << fieldName << ")) = " << maxValue << nl
+                    << endl;
             }
         }
     }
diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C
index eb31a2cabd7e4fbb81f6cf2419e7c0e0d106fd07..f9bb7a2067192a13769c2baf004b656ce3670687 100644
--- a/src/sampling/sampledSet/sampledSets/sampledSets.C
+++ b/src/sampling/sampledSet/sampledSets/sampledSets.C
@@ -269,7 +269,7 @@ void Foam::sampledSets::verbose(const bool verbosity)
 }
 
 
-void::Foam::sampledSets::execute()
+void Foam::sampledSets::execute()
 {
     // Do nothing - only valid on write
 }
diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C
index 059be188334b6db4e82e6f2d6deed1bae9e1e0f3..0de0bc1d862a9742ebd1279291a9218f664d12f7 100644
--- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C
+++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C
@@ -309,7 +309,7 @@ void Foam::sampledSurfaces::verbose(const bool verbosity)
 }
 
 
-void::Foam::sampledSurfaces::execute()
+void Foam::sampledSurfaces::execute()
 {
     // Do nothing - only valid on write
 }
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.C b/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.C
index 36df9e74005fa0e5ea7d9c52d28f515c4c26f4f6..7e6caf6ad94cd62a03752f0e241fc5311769a4f6 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.C
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.C
@@ -31,13 +31,16 @@ License
 
 namespace Foam
 {
-namespace compressibilityModels
-{
-
-defineTypeNameAndDebug(Chung, 0);
-addToRunTimeSelectionTable(barotropicCompressibilityModel, Chung, dictionary);
-
-}
+    namespace compressibilityModels
+    {
+        defineTypeNameAndDebug(Chung, 0);
+        addToRunTimeSelectionTable
+        (
+            barotropicCompressibilityModel,
+            Chung,
+            dictionary
+        );
+    }
 }
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -45,10 +48,11 @@ addToRunTimeSelectionTable(barotropicCompressibilityModel, Chung, dictionary);
 Foam::compressibilityModels::Chung::Chung
 (
     const dictionary& compressibilityProperties,
-    const volScalarField& gamma
+    const volScalarField& gamma,
+    const word& psiName
 )
 :
-    barotropicCompressibilityModel(compressibilityProperties, gamma),
+    barotropicCompressibilityModel(compressibilityProperties, gamma, psiName),
     psiv_(compressibilityProperties_.lookup("psiv")),
     psil_(compressibilityProperties_.lookup("psil")),
     rhovSat_(compressibilityProperties_.lookup("rhovSat")),
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.H b/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.H
index 56419ecbe991dea9362686938fa977c42a4b2521..97da534bcda62bf57f8a664f670b947edae5107d 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.H
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/Chung/Chung.H
@@ -75,7 +75,8 @@ public:
         Chung
         (
             const dictionary& compressibilityProperties,
-            const volScalarField& gamma
+            const volScalarField& gamma,
+            const word& psiName = "psi"
         );
 
 
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.C b/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.C
index 5c7e7f753f733a458ab5e8d7317ca9e336cd9c87..2e497b314c06ebae2a565073ae925a0ef46a2444 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.C
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.C
@@ -31,13 +31,16 @@ License
 
 namespace Foam
 {
-namespace compressibilityModels
-{
-
-defineTypeNameAndDebug(Wallis, 0);
-addToRunTimeSelectionTable(barotropicCompressibilityModel, Wallis, dictionary);
-
-}
+    namespace compressibilityModels
+    {
+        defineTypeNameAndDebug(Wallis, 0);
+        addToRunTimeSelectionTable
+        (
+            barotropicCompressibilityModel,
+            Wallis,
+            dictionary
+        );
+    }
 }
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -45,10 +48,11 @@ addToRunTimeSelectionTable(barotropicCompressibilityModel, Wallis, dictionary);
 Foam::compressibilityModels::Wallis::Wallis
 (
     const dictionary& compressibilityProperties,
-    const volScalarField& gamma
+    const volScalarField& gamma,
+    const word& psiName
 )
 :
-    barotropicCompressibilityModel(compressibilityProperties, gamma),
+    barotropicCompressibilityModel(compressibilityProperties, gamma, psiName),
     psiv_(compressibilityProperties_.lookup("psiv")),
     psil_(compressibilityProperties_.lookup("psil")),
     rhovSat_(compressibilityProperties_.lookup("rhovSat")),
@@ -62,8 +66,9 @@ Foam::compressibilityModels::Wallis::Wallis
 
 void Foam::compressibilityModels::Wallis::correct()
 {
-    psi_ = (gamma_*rhovSat_ + (scalar(1) - gamma_)*rholSat_)
-         *(gamma_*psiv_/rhovSat_ + (scalar(1) - gamma_)*psil_/rholSat_);
+    psi_ =
+        (gamma_*rhovSat_ + (scalar(1) - gamma_)*rholSat_)
+       *(gamma_*psiv_/rhovSat_ + (scalar(1) - gamma_)*psil_/rholSat_);
 }
 
 
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.H b/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.H
index 71f4db027428d6996c9383ecb6c4e7dd1d534d94..27c69c899f4cd19157f048f729a35cc2e0e8cd48 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.H
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/Wallis/Wallis.H
@@ -75,7 +75,8 @@ public:
         Wallis
         (
             const dictionary& compressibilityProperties,
-            const volScalarField& gamma
+            const volScalarField& gamma,
+            const word& psiName = "psi"
         );
 
 
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.C b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.C
index 21706f524a55b29ac26b94cc061a52537cd7155d..eeb7a8484d48c7dd2185d8d5de035a7c53c8a013 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.C
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.C
@@ -42,7 +42,8 @@ namespace Foam
 Foam::barotropicCompressibilityModel::barotropicCompressibilityModel
 (
     const dictionary& compressibilityProperties,
-    const volScalarField& gamma
+    const volScalarField& gamma,
+    const word& psiName
 )
 :
     compressibilityProperties_(compressibilityProperties),
@@ -50,12 +51,12 @@ Foam::barotropicCompressibilityModel::barotropicCompressibilityModel
     (
         IOobject
         (
-            "psi",
+            psiName,
             gamma.mesh().time().timeName(),
             gamma.mesh()
         ),
         gamma.mesh(),
-        dimensionedScalar("psi", dimensionSet(0, -2, 2, 0, 0), 0)
+        dimensionedScalar(psiName, dimensionSet(0, -2, 2, 0, 0), 0)
     ),
     gamma_(gamma)
 {}
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.H b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.H
index 71b5e5d423c9b872c9f619786ae96319413b8882..776df971d871085d7456c30c90481cd7f89f5125 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.H
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/barotropicCompressibilityModel.H
@@ -97,9 +97,10 @@ public:
             dictionary,
             (
                 const dictionary& compressibilityProperties,
-                const volScalarField& gamma
+                const volScalarField& gamma,
+                const word& psiName
             ),
-            (compressibilityProperties, gamma)
+            (compressibilityProperties, gamma, psiName)
         );
 
 
@@ -109,7 +110,8 @@ public:
         static autoPtr<barotropicCompressibilityModel> New
         (
             const dictionary& compressibilityProperties,
-            const volScalarField& gamma
+            const volScalarField& gamma,
+            const word& psiName = "psi"
         );
 
 
@@ -119,7 +121,8 @@ public:
         barotropicCompressibilityModel
         (
             const dictionary& compressibilityProperties,
-            const volScalarField& gamma
+            const volScalarField& gamma,
+            const word& psiName = "psi"
         );
 
 
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/newBarotropicCompressibilityModel.C b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/newBarotropicCompressibilityModel.C
index 83db0208f58d58f431ad2526c7d20c0d51f8931e..ea38016be6d20c8ac43cd55f6dac4d1aa4c7467b 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/newBarotropicCompressibilityModel.C
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/barotropicCompressibilityModel/newBarotropicCompressibilityModel.C
@@ -32,7 +32,8 @@ Foam::autoPtr<Foam::barotropicCompressibilityModel>
 Foam::barotropicCompressibilityModel::New
 (
     const dictionary& compressibilityProperties,
-    const volScalarField& gamma
+    const volScalarField& gamma,
+    const word& psiName
 )
 {
     word bcModelTypeName
@@ -60,7 +61,7 @@ Foam::barotropicCompressibilityModel::New
 
     return autoPtr<barotropicCompressibilityModel>
     (
-        cstrIter()(compressibilityProperties, gamma)
+        cstrIter()(compressibilityProperties, gamma, psiName)
     );
 }
 
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.C b/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.C
index dbf584d4c939a0928d7a46061031ccc99cfb35dd..3daf0dd37d9a1c425b30c81e53d3e461ead2459e 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.C
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.C
@@ -31,13 +31,16 @@ License
 
 namespace Foam
 {
-namespace compressibilityModels
-{
-
-defineTypeNameAndDebug(linear, 0);
-addToRunTimeSelectionTable(barotropicCompressibilityModel, linear, dictionary);
-
-}
+    namespace compressibilityModels
+    {
+        defineTypeNameAndDebug(linear, 0);
+        addToRunTimeSelectionTable
+        (
+            barotropicCompressibilityModel,
+            linear,
+            dictionary
+        );
+    }
 }
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -45,10 +48,11 @@ addToRunTimeSelectionTable(barotropicCompressibilityModel, linear, dictionary);
 Foam::compressibilityModels::linear::linear
 (
     const dictionary& compressibilityProperties,
-    const volScalarField& gamma
+    const volScalarField& gamma,
+    const word& psiName
 )
 :
-    barotropicCompressibilityModel(compressibilityProperties, gamma),
+    barotropicCompressibilityModel(compressibilityProperties, gamma, psiName),
     psiv_(compressibilityProperties_.lookup("psiv")),
     psil_(compressibilityProperties_.lookup("psil"))
 {
diff --git a/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.H b/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.H
index 2162f0b9fd46f3fb9390347685a3c3e11680f6b6..cc83a8cbe4c99ee4aba36484ec58f7be85a1f9ee 100644
--- a/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.H
+++ b/src/thermophysicalModels/barotropicCompressibilityModel/linear/linear.H
@@ -72,7 +72,8 @@ public:
         linear
         (
             const dictionary& compressibilityProperties,
-            const volScalarField& gamma
+            const volScalarField& gamma,
+            const word& psiName = "psi"
         );
 
 
diff --git a/src/thermophysicalModels/basic/hThermo/hThermo.C b/src/thermophysicalModels/basic/hThermo/hThermo.C
index 19e43d2410876416c43b7e93c1f3a546799b5cb6..7e32f7a0636288169e7bc36f02a3b9140c20efba 100644
--- a/src/thermophysicalModels/basic/hThermo/hThermo.C
+++ b/src/thermophysicalModels/basic/hThermo/hThermo.C
@@ -28,15 +28,10 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hThermo<MixtureType>::hThermo(const fvMesh& mesh)
+Foam::hThermo<MixtureType>::hThermo(const fvMesh& mesh)
 :
     basicThermo(mesh),
     MixtureType(*this, mesh),
@@ -56,9 +51,12 @@ hThermo<MixtureType>::hThermo(const fvMesh& mesh)
         hBoundaryTypes()
     )
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    const scalarField& TCells = T_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -76,25 +74,33 @@ hThermo<MixtureType>::hThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hThermo<MixtureType>::~hThermo()
+Foam::hThermo<MixtureType>::~hThermo()
 {}
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 template<class MixtureType>
-void hThermo<MixtureType>::calculate()
+void Foam::hThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
         const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -143,7 +149,7 @@ void hThermo<MixtureType>::calculate()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-void hThermo<MixtureType>::correct()
+void Foam::hThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -163,7 +169,7 @@ void hThermo<MixtureType>::correct()
 
 
 template<class MixtureType>
-tmp<scalarField>  hThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -182,7 +188,7 @@ tmp<scalarField>  hThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField>  hThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -201,7 +207,7 @@ tmp<scalarField>  hThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -220,7 +226,7 @@ tmp<scalarField> hThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -258,7 +264,7 @@ tmp<volScalarField> hThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hThermo<MixtureType>::Cv() const
+Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -303,7 +309,7 @@ tmp<volScalarField> hThermo<MixtureType>::Cv() const
 
 
 template<class MixtureType>
-bool hThermo<MixtureType>::read()
+bool Foam::hThermo<MixtureType>::read()
 {
     if (basicThermo::read())
     {
@@ -317,8 +323,4 @@ bool hThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.C
index 3dd49e126ea89ee00e0ca4d6ca3c3229c805792a..f2da51c746773199c302f071a3328ab351da568a 100644
--- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.C
+++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.C
@@ -114,7 +114,7 @@ Foam::scalarField Foam::chemistryModel::omega
     forAll(reactions_, i)
     {
         const reaction& R = reactions_[i];
-        
+
         scalar omegai = omega
         (
             R, c, T, p, pf, cf, lRef, pr, cr, rRef
@@ -164,13 +164,13 @@ Foam::scalar Foam::chemistryModel::omega
 
     pf = 1.0;
     pr = 1.0;
-    
+
     label Nl = R.lhs().size();
     label Nr = R.rhs().size();
-    
+
     label slRef = 0;
     lRef = R.lhs()[slRef].index;
-        
+
     pf = kf;
     for(label s=1; s<Nl; s++)
     {
@@ -212,7 +212,7 @@ Foam::scalar Foam::chemistryModel::omega
 
     label srRef = 0;
     rRef = R.rhs()[srRef].index;
-    
+
     // find the matrix element and element position for the rhs
     pr = kr;
     for(label s=1; s<Nr; s++)
@@ -250,7 +250,7 @@ Foam::scalar Foam::chemistryModel::omega
         {
             pr *= pow(cr, exp-1.0);
         }
-        
+
     }
 
     return pf*cf - pr*cr;
@@ -313,12 +313,12 @@ void Foam::chemistryModel::jacobian
     const scalar t,
     const scalarField& c,
     scalarField& dcdt,
-    Matrix<scalar>& dfdc
+    scalarSquareMatrix& dfdc
 ) const
 {
     scalar T = c[Ns_];
     scalar p = c[Ns_ + 1];
-    
+
     scalarField c2(Ns(), 0.0);
     for(label i=0; i<Ns(); i++)
     {
@@ -470,23 +470,23 @@ Foam::tmp<Foam::volScalarField> Foam::chemistryModel::tc() const
             scalar pi = thermo_.p()[celli];
             scalarField c(Ns_);
             scalar cSum = 0.0;
-            
+
             for(label i=0; i<Ns_; i++)
             {
                 scalar Yi = Y_[i][celli];
                 c[i] = rhoi*Yi/specieThermo_[i].W();
                 cSum += c[i];
             }
-            
+
             forAll(reactions_, i)
             {
                 const reaction& R = reactions_[i];
-                
+
                 omega
                 (
                     R, c, Ti, pi, pf, cf, lRef, pr, cr, rRef
                 );
-                
+
                 forAll(R.rhs(), s)
                 {
                     scalar sr = R.rhs()[s].stoichCoeff;
@@ -544,22 +544,22 @@ void Foam::chemistryModel::calculate()
             {
                 RR_[i][celli] = 0.0;
             }
-            
+
             scalar rhoi = rho_[celli];
             scalar Ti = thermo_.T()[celli];
             scalar pi = thermo_.p()[celli];
-            
+
             scalarField c(Ns_);
             scalarField dcdt(nEqns(), 0.0);
-            
+
             for(label i=0; i<Ns_; i++)
             {
                 scalar Yi = Y_[i][celli];
                 c[i] = rhoi*Yi/specieThermo_[i].W();
             }
-            
+
             dcdt = omega(c, Ti, pi);
-            
+
             for(label i=0; i<Ns_; i++)
             {
                 RR_[i][celli] = dcdt[i]*specieThermo_[i].W();
@@ -624,7 +624,7 @@ Foam::scalar Foam::chemistryModel::solve(const scalar t0, const scalar deltaT)
             for(label i=0; i<Ns_; i++)
             {
                 mixture += (c[i]/cTot)*specieThermo_[i];
-            }        
+            }
             Ti = mixture.TH(hi, Ti);
 
             timeLeft -= dt;
@@ -639,7 +639,7 @@ Foam::scalar Foam::chemistryModel::solve(const scalar t0, const scalar deltaT)
         for(label i=0; i<Ns_; i++)
         {
             WTot += c[i]*specieThermo_[i].W();
-        }        
+        }
         WTot /= cTot;
 
         for(label i=0; i<Ns_; i++)
diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.H
index 512f606e5f30a1af4e631f484f363499d0bbe7ee..354dd60b4ffce063d15f542104730b1b5eeb7d75 100644
--- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.H
+++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel.H
@@ -39,7 +39,6 @@ SourceFiles
 
 #include "hCombustionThermo.H"
 #include "reactingMixture.H"
-#include "Matrix.H"
 #include "ODE.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -251,7 +250,7 @@ public:
             const scalar t,
             const scalarField& c,
             scalarField& dcdt,
-            Matrix<scalar>& dfdc
+            scalarSquareMatrix& dfdc
         ) const;
 
         //- Calculates the reaction rates
diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
index 2d72a4f6887e5b03f7df977ed0ceb1bde5e9a8b9..064e7c3ebafeb0f67be03f7d547df9e1d2c31f55 100644
--- a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
+++ b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
@@ -28,22 +28,20 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
+Foam::hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
 :
     hCombustionThermo(mesh),
     MixtureType(*this, mesh)
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    const scalarField& TCells = T_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -61,25 +59,33 @@ hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hMixtureThermo<MixtureType>::~hMixtureThermo()
+Foam::hMixtureThermo<MixtureType>::~hMixtureThermo()
 {}
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 template<class MixtureType>
-void hMixtureThermo<MixtureType>::calculate()
+void Foam::hMixtureThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
         const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -128,7 +134,7 @@ void hMixtureThermo<MixtureType>::calculate()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -147,7 +153,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -166,7 +172,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -186,7 +192,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hMixtureThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hMixtureThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -224,7 +230,7 @@ tmp<volScalarField> hMixtureThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-void hMixtureThermo<MixtureType>::correct()
+void Foam::hMixtureThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -244,7 +250,7 @@ void hMixtureThermo<MixtureType>::correct()
 
 
 template<class MixtureType>
-bool hMixtureThermo<MixtureType>::read()
+bool Foam::hMixtureThermo<MixtureType>::read()
 {
     if (hCombustionThermo::read())
     {
@@ -258,8 +264,4 @@ bool hMixtureThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
index 04bf08e33027859a4b216fc6638cdf8465e40f0a..0086e8cd147c2824097599d087c7c6537e0787b3 100644
--- a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
+++ b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
@@ -28,23 +28,23 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
+Foam::hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
 :
     hhuCombustionThermo(mesh),
     MixtureType(*this, mesh)
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    scalarField& huCells = hu_.internalField();
+    const scalarField& TCells = T_.internalField();
+    const scalarField& TuCells = Tu_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
-        hu_[celli] = this->cellReactants(celli).H(Tu_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
+        huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -71,27 +71,38 @@ hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
+Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-void hhuMixtureThermo<MixtureType>::calculate()
+void Foam::hhuMixtureThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& huCells = hu_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& TuCells = Tu_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
-        const typename MixtureType::thermoType& mixture_ = 
+        const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
 
-        Tu_[celli] = this->cellReactants(celli).TH(hu_[celli], Tu_[celli]);
+        TuCells[celli] =
+            this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -144,7 +155,7 @@ void hhuMixtureThermo<MixtureType>::calculate()
 
 
 template<class MixtureType>
-void hhuMixtureThermo<MixtureType>::correct()
+void Foam::hhuMixtureThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -163,7 +174,7 @@ void hhuMixtureThermo<MixtureType>::correct()
 }
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -182,7 +193,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -201,7 +212,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -221,7 +232,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -260,7 +271,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::hu
 (
     const scalarField& Tu,
     const labelList& cells
@@ -279,7 +290,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::hu
 (
     const scalarField& Tu,
     const label patchi
@@ -298,7 +309,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::Tb() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::Tb() const
 {
     tmp<volScalarField> tTb
     (
@@ -342,7 +353,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::Tb() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::psiu() const
+Foam::tmp<Foam::volScalarField>
+Foam::hhuMixtureThermo<MixtureType>::psiu() const
 {
     tmp<volScalarField> tpsiu
     (
@@ -388,7 +400,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psiu() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
+Foam::tmp<Foam::volScalarField>
+Foam::hhuMixtureThermo<MixtureType>::psib() const
 {
     tmp<volScalarField> tpsib
     (
@@ -426,7 +439,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
         forAll(ppsib, facei)
         {
             ppsib[facei] =
-                this->patchFaceReactants(patchi, facei).psi(pp[facei], pTb[facei]);
+                this->patchFaceReactants
+                (patchi, facei).psi(pp[facei], pTb[facei]);
         }
     }
 
@@ -435,7 +449,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::muu() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::muu() const
 {
     tmp<volScalarField> tmuu
     (
@@ -478,7 +492,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::muu() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::mub() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::mub() const
 {
     tmp<volScalarField> tmub
     (
@@ -521,7 +535,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::mub() const
 
 
 template<class MixtureType>
-bool hhuMixtureThermo<MixtureType>::read()
+bool Foam::hhuMixtureThermo<MixtureType>::read()
 {
     if (hhuCombustionThermo::read())
     {
@@ -535,8 +549,4 @@ bool hhuMixtureThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/triSurface/triSurface/interfaces/NAS/readNAS.C b/src/triSurface/triSurface/interfaces/NAS/readNAS.C
index 2ec15c67067bddfd525aa049a08b5ac3d6271382..1440c2d15d3c0a632bfe776fc6d51729b586d445 100644
--- a/src/triSurface/triSurface/interfaces/NAS/readNAS.C
+++ b/src/triSurface/triSurface/interfaces/NAS/readNAS.C
@@ -23,10 +23,16 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Description
-    Nastran surface reader. Does Ansa $ANSA_NAME extension to get name
-    of patch. Handles Ansa coordinates like:
+    Nastran surface reader.
 
+    - Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
+      to obtain patch names.
+    - Handles Nastran short and long formats, but not free format.
+    - Properly handles the Nastran compact floating point notation: \n
+    @verbatim
         GRID          28        10.20269-.030265-2.358-8
+    @endverbatim
+
 
 \*---------------------------------------------------------------------------*/
 
@@ -49,13 +55,13 @@ static scalar parseNASCoord(const string& s)
     if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1]))
     {
         scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))());
-        scalar exp = readScalar(IStringStream(s.substr(expSign+1))());
+        scalar exponent = readScalar(IStringStream(s.substr(expSign+1))());
 
         if (s[expSign] == '-')
         {
-            exp = -exp;
+            exponent = -exponent;
         }
-        return mantissa*pow(10, exp);
+        return mantissa*pow(10, exponent);
     }
     else
     {
@@ -64,14 +70,14 @@ static scalar parseNASCoord(const string& s)
 }
 
 
-bool triSurface::readNAS(const fileName& OBJfileName)
+bool triSurface::readNAS(const fileName& fName)
 {
-    IFstream OBJfile(OBJfileName);
+    IFstream is(fName);
 
-    if (!OBJfile.good())
+    if (!is.good())
     {
         FatalErrorIn("triSurface::readNAS(const fileName&)")
-            << "Cannot read file " << OBJfileName
+            << "Cannot read file " << fName
             << exit(FatalError);
     }
 
@@ -90,17 +96,17 @@ bool triSurface::readNAS(const fileName& OBJfileName)
     // 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 patches.
-    label ansaID = -1;
+    label ansaId = -1;
     word ansaType;
     string ansaName;
 
-    // Done warnings per unrecognized command
+    // A single warning per unrecognized command
     HashSet<word> unhandledCmd;
 
-    while (OBJfile.good())
+    while (is.good())
     {
         string line;
-        OBJfile.getLine(line);
+        is.getLine(line);
 
         // Ansa extension
         if (line.substr(0, 10) == "$ANSA_NAME")
@@ -116,14 +122,14 @@ bool triSurface::readNAS(const fileName& OBJfileName)
              && sem2 != string::npos
             )
             {
-                ansaID = readLabel
+                ansaId = readLabel
                 (
                     IStringStream(line.substr(sem0+1, sem1-sem0-1))()
                 );
                 ansaType = line.substr(sem1+1, sem2-sem1-1);
 
                 string nameString;
-                OBJfile.getLine(ansaName);
+                is.getLine(ansaName);
                 if (ansaName[ansaName.size()-1] == '\r')
                 {
                     ansaName = ansaName.substr(1, ansaName.size()-2);
@@ -132,13 +138,37 @@ bool triSurface::readNAS(const fileName& OBJfileName)
                 {
                     ansaName = ansaName.substr(1, ansaName.size()-1);
                 }
-                //Pout<< "ANSA tag for NastranID:" << ansaID
-                //    << " of type " << ansaType
-                //    << " name " << ansaName << endl;
+
+                // Info<< "ANSA tag for NastranID:" << ansaId
+                //     << " of type " << ansaType
+                //     << " name " << ansaName << endl;
             }
         }
 
 
+        // Hypermesh extension
+        // $HMNAME COMP                   1"partName"
+        if
+        (
+            line.substr(0, 12) == "$HMNAME COMP"
+         && line.find ('"') != string::npos
+        )
+        {
+            label groupId = readLabel
+            (
+                IStringStream(line.substr(16, 16))()
+            );
+
+            IStringStream lineStream(line.substr(32));
+
+            string rawName;
+            lineStream >> rawName;
+
+            groupToName.insert(groupId, string::validate<word>(rawName));
+            Info<< "group " << groupId << " => " << rawName << endl;
+        }
+
+
         if (line.size() == 0 || line[0] == '$')
         {
             // Skip empty or comment
@@ -153,7 +183,7 @@ bool triSurface::readNAS(const fileName& OBJfileName)
             while (true)
             {
                 string buf;
-                OBJfile.getLine(buf);
+                is.getLine(buf);
 
                 if (buf.size() > 72 && buf[72]=='+')
                 {
@@ -174,26 +204,21 @@ bool triSurface::readNAS(const fileName& OBJfileName)
 
         if (cmd == "CTRIA3")
         {
-            //label index, group, a, b, c;
-            //lineStream >> index >> group >> a >> b >> c;
-            label group = readLabel(IStringStream(line.substr(16,8))());
+            label groupId = readLabel(IStringStream(line.substr(16,8))());
             label a = readLabel(IStringStream(line.substr(24,8))());
             label b = readLabel(IStringStream(line.substr(32,8))());
             label c = readLabel(IStringStream(line.substr(40,8))());
 
 
             // Convert group into patch
-            Map<label>::const_iterator iter = groupToPatch.find(group);
+            Map<label>::const_iterator iter = groupToPatch.find(groupId);
 
             label patchI;
             if (iter == groupToPatch.end())
             {
                 patchI = nPatches++;
-
-                Pout<< "Allocating Foam patch " << patchI
-                    << " for group " << group << endl;
-
-                groupToPatch.insert(group, patchI);
+                groupToPatch.insert(groupId, patchI);
+                Info<< "patch " << patchI << " => group " << groupId << endl;
             }
             else
             {
@@ -204,26 +229,21 @@ bool triSurface::readNAS(const fileName& OBJfileName)
         }
         else if (cmd == "CQUAD4")
         {
-            //label index, group, a, b, c, d;
-            //lineStream >> index >> group >> a >> b >> c >> d;
-            label group = readLabel(IStringStream(line.substr(16,8))());
+            label groupId = readLabel(IStringStream(line.substr(16,8))());
             label a = readLabel(IStringStream(line.substr(24,8))());
             label b = readLabel(IStringStream(line.substr(32,8))());
             label c = readLabel(IStringStream(line.substr(40,8))());
             label d = readLabel(IStringStream(line.substr(48,8))());
 
             // Convert group into patch
-            Map<label>::const_iterator iter = groupToPatch.find(group);
+            Map<label>::const_iterator iter = groupToPatch.find(groupId);
 
             label patchI;
             if (iter == groupToPatch.end())
             {
                 patchI = nPatches++;
-
-                Pout<< "Allocating Foam patch " << patchI
-                    << " for group " << group << endl;
-
-                groupToPatch.insert(group, patchI);
+                groupToPatch.insert(groupId, patchI);
+                Info<< "patch " << patchI << " => group " << groupId << endl;
             }
             else
             {
@@ -235,66 +255,56 @@ bool triSurface::readNAS(const fileName& OBJfileName)
         }
         else if (cmd == "PSHELL")
         {
-            // Read shell type since gives patchnames.
-            //label group;
-            //lineStream >> group;
-            label group = readLabel(IStringStream(line.substr(8,8))());
-
-            if (group == ansaID && ansaType == "PSHELL")
+            // Read shell type since group gives patchnames
+            label groupId = readLabel(IStringStream(line.substr(8,8))());
+            if (groupId == ansaId && ansaType == "PSHELL")
             {
-                Pout<< "Found name " << ansaName << " for group "
-                    << group << endl;
-                groupToName.insert(group, string::validate<word>(ansaName));
+                groupToName.insert(groupId, string::validate<word>(ansaName));
+                Info<< "group " << groupId << " => " << ansaName << endl;
             }
         }
         else if (cmd == "GRID")
         {
-            //label index;
-            //lineStream >> index;
             label index = readLabel(IStringStream(line.substr(8,8))());
-            indices.append(index);
-
             scalar x = parseNASCoord(line.substr(24, 8));
             scalar y = parseNASCoord(line.substr(32, 8));
             scalar z = parseNASCoord(line.substr(40, 8));
+
+            indices.append(index);
             points.append(point(x, y, z));
         }
         else if (cmd == "GRID*")
         {
-            // Assume on two lines with '*' continuation symbol on start of
-            // second line. (comes out of Tgrid. Typical line (spaces truncated)
+            // Long format is on two lines with '*' continuation symbol
+            // on start of second line.
+            // Typical line (spaces compacted)
             // GRID*      126   0 -5.55999875E+02 -5.68730474E+02
             // *         2.14897901E+02
-            string line2;
-            OBJfile.getLine(line2);
-            if (line2[0] != '*')
+
+            label index = readLabel(IStringStream(line.substr(8,16))());
+            scalar x = parseNASCoord(line.substr(40, 16));
+            scalar y = parseNASCoord(line.substr(56, 16));
+
+            is.getLine(line);
+            if (line[0] != '*')
             {
                 FatalErrorIn("triSurface::readNAS(const fileName&)")
                     << "Expected continuation symbol '*' when reading GRID*"
-                    << " (double precision coordinate) output by Tgrid" << nl
-                    << "Read:" << line2 << nl
-                    << "File:" << OBJfile.name()
-                    << " line:" << OBJfile.lineNumber()
+                    << " (double precision coordinate) output" << nl
+                    << "Read:" << line << nl
+                    << "File:" << is.name()
+                    << " line:" << is.lineNumber()
                     << exit(FatalError);
             }
-            IStringStream lineStream(line.substr(10) + line2.substr(1));
+            scalar z = parseNASCoord(line.substr(8, 16));
 
-            label index;
-            lineStream >> index;
             indices.append(index);
-
-            readScalar(lineStream); // What is this field?
-            scalar x = readScalar(lineStream);
-            scalar y = readScalar(lineStream);
-            scalar z = readScalar(lineStream);
             points.append(point(x, y, z));
         }
         else if (unhandledCmd.insert(cmd))
         {
             Info<< "Unhandled Nastran command " << line << nl
-                << "File:" << OBJfile.name()
-                << " line:" << OBJfile.lineNumber()
-                << endl;
+                << "File:" << is.name() << " line:" << is.lineNumber() << endl;
         }
     }
 
@@ -303,7 +313,7 @@ bool triSurface::readNAS(const fileName& OBJfileName)
     faces.shrink();
 
 
-    Pout<< "Read triangles:" << faces.size() << " points:" << points.size()
+    Info<< "Read triangles:" << faces.size() << " points:" << points.size()
         << endl;
 
     {
@@ -314,7 +324,7 @@ bool triSurface::readNAS(const fileName& OBJfileName)
             indexToPoint.insert(indices[i], i);
         }
 
-        // Relabel triangles
+        // Relabel faces
         forAll(faces, i)
         {
             labelledTri& f = faces[i];
@@ -341,7 +351,7 @@ bool triSurface::readNAS(const fileName& OBJfileName)
         );
     }
 
-    Pout<< "patches:" << patches << endl;
+    Info<< "patches:" << patches << endl;
 
 
     // Transfer DynamicLists to straight ones.
diff --git a/src/turbulenceModels/LES/Allwmake b/src/turbulenceModels/LES/Allwmake
index bd99dd1f4e26d091ca717a42973af7e8b148c184..a2521d21f07c66194ead15877ae830e00df91be7 100755
--- a/src/turbulenceModels/LES/Allwmake
+++ b/src/turbulenceModels/LES/Allwmake
@@ -2,8 +2,9 @@
 cd ${0%/*} || exit 1    # run from this directory
 set -x
 
+wmakeLnInclude -f incompressible
+
 wmake libso LESfilters
-wmakeLnInclude incompressible
 wmake libso LESdeltas
 wmake libso incompressible
 wmake libso compressible
diff --git a/src/turbulenceModels/LES/compressible/Make/files b/src/turbulenceModels/LES/compressible/Make/files
index 59ced1fae21556825e9154eb56abd763a2bb93e3..dc31f55cae3e86d6e502de718939006c26372208 100644
--- a/src/turbulenceModels/LES/compressible/Make/files
+++ b/src/turbulenceModels/LES/compressible/Make/files
@@ -1,5 +1,3 @@
-wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C
-
 LESModel/LESModel.C
 LESModel/newLESModel.C
 GenEddyVisc/GenEddyVisc.C
@@ -12,4 +10,10 @@ dynOneEqEddy/dynOneEqEddy.C
 DeardorffDiffStress/DeardorffDiffStress.C
 SpalartAllmaras/SpalartAllmaras.C
 
+/* Wall functions */
+wallFunctions=derivedFvPatchFields/wallFunctions
+
+muSgsWallFunctions=$(wallFunctions)/muSgsWallFunctions
+$(muSgsWallFunctions)/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
+
 LIB = $(FOAM_LIBBIN)/libcompressibleLESModels
diff --git a/src/turbulenceModels/LES/compressible/Make/options b/src/turbulenceModels/LES/compressible/Make/options
index 9f0da00e30d472756c59e2307c5ee43cab56f948..c148a902e054bdb040c68332e8813a12d06eb6d4 100644
--- a/src/turbulenceModels/LES/compressible/Make/options
+++ b/src/turbulenceModels/LES/compressible/Make/options
@@ -1,6 +1,6 @@
 EXE_INC = \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
-	-I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
     -I../LESdeltas/lnInclude \
     -I../LESfilters/lnInclude \
     -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
diff --git a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
similarity index 81%
rename from src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
index fb493237bf529a236192d40faa990b7aefd8a642..e210c32c730e46e1c51eafe64f9b67d9287d96d4 100644
--- a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "muSgsWallFunctionFvPatchScalarField.H"
+#include "muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H"
 #include "LESModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,7 +41,8 @@ namespace LESModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -51,9 +52,10 @@ muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
 {}
 
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const muSgsWallFunctionFvPatchScalarField& ptf,
+    const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -63,7 +65,8 @@ muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
 {}
 
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -74,7 +77,8 @@ muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
 {}
 
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -85,18 +89,20 @@ muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
 {}
 
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const muSgsWallFunctionFvPatchScalarField& tppsf
+    const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf)
 {}
 
 
-muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+muSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const muSgsWallFunctionFvPatchScalarField& tppsf,
+    const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -106,7 +112,7 @@ muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void muSgsWallFunctionFvPatchScalarField::evaluate
+void muSgsSpalartAllmarasWallFunctionFvPatchScalarField::evaluate
 (
     const Pstream::commsTypes
 )
@@ -184,7 +190,11 @@ void muSgsWallFunctionFvPatchScalarField::evaluate
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-makePatchTypeField(fvPatchScalarField, muSgsWallFunctionFvPatchScalarField);
+makePatchTypeField
+(
+    fvPatchScalarField,
+    muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..9d3210c1d41d280cd2a4b0022f8e92de8786dd6b
--- /dev/null
+++ b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H
@@ -0,0 +1,165 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible::LESModels::
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+
+Description
+    Spalart Allmaas wall function boundary condition for compressible flows
+
+SourceFiles
+    muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef muSgsSpalartAllmarasWallFunctionFvPatchScalarField_H
+#define muSgsSpalartAllmarasWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace LESModels
+{
+
+/*---------------------------------------------------------------------------*\
+     Class muSgsSpalartAllmarasWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+    // Private data
+
+
+public:
+
+    //- Runtime type information
+    TypeName("muSgsSpalartAllmarasWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and Istream
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            Istream&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        //  onto a new patch
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new muSgsSpalartAllmarasWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+        (
+            const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new muSgsSpalartAllmarasWallFunctionFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Evaluate the patchField
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::blocking
+            );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace LESModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/LES/incompressible/Make/files b/src/turbulenceModels/LES/incompressible/Make/files
index ed45e8ffbc58f27e523ffad567f7c2f2acf0e2d2..796bbee6a0070d16a9464befb7a318d71a676899 100644
--- a/src/turbulenceModels/LES/incompressible/Make/files
+++ b/src/turbulenceModels/LES/incompressible/Make/files
@@ -1,5 +1,4 @@
 vanDriestDelta/vanDriestDelta.C
-wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C
 
 LESModel/LESModel.C
 LESModel/newLESModel.C
@@ -25,4 +24,12 @@ dynMixedSmagorinsky/dynMixedSmagorinsky.C
 
 /*Smagorinsky2/Smagorinsky2.C*/
 
+
+/* Wall functions */
+wallFunctions=derivedFvPatchFields/wallFunctions
+
+nuSgsWallFunctions=$(wallFunctions)/nuSgsWallFunctions
+$(nuSgsWallFunctions)/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
+
+
 LIB = $(FOAM_LIBBIN)/libincompressibleLESModels
diff --git a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
similarity index 81%
rename from src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
index d7be3cf9f0dd75170373026df325589bf7f6a88c..ab02061c5d29eb93dd1953fde247ef48e313a8d2 100644
--- a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "nuSgsWallFunctionFvPatchScalarField.H"
+#include "nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.H"
 #include "LESModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,7 +41,8 @@ namespace LESModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -51,9 +52,10 @@ nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
 {}
 
 
-nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nuSgsWallFunctionFvPatchScalarField& ptf,
+    const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -63,7 +65,8 @@ nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
 {}
 
 
-nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -74,18 +77,20 @@ nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
 {}
 
 
-nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nuSgsWallFunctionFvPatchScalarField& tppsf
+    const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf)
 {}
 
 
-nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::
+nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nuSgsWallFunctionFvPatchScalarField& tppsf,
+    const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -95,7 +100,7 @@ nuSgsWallFunctionFvPatchScalarField::nuSgsWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void nuSgsWallFunctionFvPatchScalarField::evaluate
+void nuSgsSpalartAllmarasWallFunctionFvPatchScalarField::evaluate
 (
     const Pstream::commsTypes
 )
@@ -166,7 +171,11 @@ void nuSgsWallFunctionFvPatchScalarField::evaluate
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-makePatchTypeField(fvPatchScalarField, nuSgsWallFunctionFvPatchScalarField);
+makePatchTypeField
+(
+    fvPatchScalarField,
+    nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
+);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.H
similarity index 71%
rename from src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.H
index 687e30a6a6f36781eab3ae033ec1f7925aa3be76..ecb1830757e6d5ba29993a4c6480472734813593 100644
--- a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.H
@@ -23,18 +23,19 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::incompressible::LESModels::nuSgsWallFunctionFvPatchScalarField
+    Foam::incompressible::LESModels::
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 
 Description
-    wall function boundary condition for incompressible flows
+    Spalart Allmaras wall function boundary condition for incompressible flows
 
 SourceFiles
-    nuSgsWallFunctionFvPatchScalarField.C
+    nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef nuSgsWallFunctionFvPatchScalarField_H
-#define nuSgsWallFunctionFvPatchScalarField_H
+#ifndef nuSgsSpalartAllmarasWallFunctionFvPatchScalarField_H
+#define nuSgsSpalartAllmarasWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
@@ -48,10 +49,10 @@ namespace LESModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class nuSgsWallFunctionFvPatch Declaration
+     Class nuSgsSpalartAllmarasWallFunctionFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
-class nuSgsWallFunctionFvPatchScalarField
+class nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
@@ -61,40 +62,41 @@ class nuSgsWallFunctionFvPatchScalarField
 public:
 
     //- Runtime type information
-    TypeName("nuSgsWallFunction");
+    TypeName("nuSgsSpalartAllmarasWallFunction");
 
 
     // Constructors
 
         //- Construct from patch and internal field
-        nuSgsWallFunctionFvPatchScalarField
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&
         );
 
         //- Construct from patch, internal field and dictionary
-        nuSgsWallFunctionFvPatchScalarField
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const dictionary&
         );
 
-        //- Construct by mapping given nuSgsWallFunctionFvPatchScalarField
+        //- Construct by mapping given
+        //  nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         //  onto a new patch
-        nuSgsWallFunctionFvPatchScalarField
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nuSgsWallFunctionFvPatchScalarField&,
+            const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const fvPatchFieldMapper&
         );
 
         //- Construct as copy
-        nuSgsWallFunctionFvPatchScalarField
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nuSgsWallFunctionFvPatchScalarField&
+            const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField&
         );
 
         //- Construct and return a clone
@@ -102,14 +104,14 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nuSgsWallFunctionFvPatchScalarField(*this)
+                new nuSgsSpalartAllmarasWallFunctionFvPatchScalarField(*this)
             );
         }
 
         //- Construct as copy setting internal field reference
-        nuSgsWallFunctionFvPatchScalarField
+        nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nuSgsWallFunctionFvPatchScalarField&,
+            const nuSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
             const DimensionedField<scalar, volMesh>&
         );
 
@@ -121,7 +123,11 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nuSgsWallFunctionFvPatchScalarField(*this, iF)
+                new nuSgsSpalartAllmarasWallFunctionFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C
index 4a703d2c8ff29ac62e55a91081162eb0ea7c9afa..a22d495249797b6a0876abeff8b59422ab2a06e5 100644
--- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C
+++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -165,9 +167,8 @@ LRR::LRR
             IOobject::MUST_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateR("R", mesh_)
     ),
-
     k_
     (
         IOobject
@@ -175,12 +176,11 @@ LRR::LRR
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -188,12 +188,11 @@ LRR::LRR
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -202,13 +201,23 @@ LRR::LRR
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
         ),
-        Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateAlphat("alphat", mesh_)
     )
 {
-#   include "wallViscosityI.H"
-
     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
     {
         FatalErrorIn
@@ -221,6 +230,12 @@ LRR::LRR
             << exit(FatalError);
     }
 
+    mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
+
     printCoeffs();
 }
 
@@ -310,16 +325,23 @@ void LRR::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
     RASModel::correct();
 
     volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
-    volScalarField G = 0.5*tr(P);
+    volScalarField G("G", 0.5*tr(P));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -335,7 +357,7 @@ void LRR::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -397,9 +419,12 @@ void LRR::correct()
 
 
     // Re-calculate viscosity
-    mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
+    mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
+    mut_.correctBoundaryConditions();
 
-#   include "wallViscosityI.H"
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
 
     // Correct wall shear stresses
diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.H b/src/turbulenceModels/RAS/compressible/LRR/LRR.H
index 553b11be96e5b338f4b42fe59aabc03e40f4c5ca..0dc2ed2ad855323a71ef29572e200e06cb15e243 100644
--- a/src/turbulenceModels/RAS/compressible/LRR/LRR.H
+++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.H
@@ -97,6 +97,7 @@ class LRR
         volScalarField k_;
         volScalarField epsilon_;
         volScalarField mut_;
+        volScalarField alphat_;
 
 
 public:
@@ -152,7 +153,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
index 4b977f0809c893cd13c93c5fe8e1351ace6bf039..0181605fb1987101f180e70f951b005e7553b137 100644
--- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
+++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
@@ -30,6 +30,8 @@ License
 #include "wallDist.H"
 #include "wallDistReflection.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -187,9 +189,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             IOobject::MUST_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateR("R", mesh_)
     ),
-
     k_
     (
         IOobject
@@ -197,12 +198,11 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -210,12 +210,11 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -224,13 +223,23 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
         ),
-        Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateAlphat("alphat", mesh_)
     )
 {
-#   include "wallViscosityI.H"
-
     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
     {
         FatalErrorIn
@@ -243,6 +252,12 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             << exit(FatalError);
     }
 
+    mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
+
     printCoeffs();
 }
 
@@ -335,7 +350,13 @@ void LaunderGibsonRSTM::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
@@ -347,9 +368,10 @@ void LaunderGibsonRSTM::correct()
     }
 
     volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
-    volScalarField G = 0.5*tr(P);
+    volScalarField G("G", 0.5*tr(P));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -365,7 +387,7 @@ void LaunderGibsonRSTM::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -436,11 +458,12 @@ void LaunderGibsonRSTM::correct()
 
 
     // Re-calculate turbulent viscosity
-    mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
-
-
-#   include "wallViscosityI.H"
+    mut_ == Cmu_*rho_*sqr(k_)/epsilon_;
+    mut_.correctBoundaryConditions();
 
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
     // Correct wall shear stresses
 
diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H
index 2be69e96b5be6497406a8f07d8d1ed1a3964f327..4fa0e9315eadda5ac40784eac438db14b947e9fb 100644
--- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H
+++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H
@@ -104,6 +104,7 @@ class LaunderGibsonRSTM
         volScalarField k_;
         volScalarField epsilon_;
         volScalarField mut_;
+        volScalarField alphat_;
 
 
 public:
@@ -161,7 +162,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files
index aab9098c3db7310d01990abe8ef0a78ef3d7c0e1..0598d06a00e639b222b13f2a8c3cb48f4dd31040 100644
--- a/src/turbulenceModels/RAS/compressible/Make/files
+++ b/src/turbulenceModels/RAS/compressible/Make/files
@@ -12,10 +12,32 @@ SpalartAllmaras/SpalartAllmaras.C
 kOmegaSST/kOmegaSST.C
 
 /* Wall functions */
-wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C
+wallFunctions = derivedFvPatchFields/wallFunctions
+
+alphatWallFunctions = $(wallFunctions)/alphatWallFunctions
+$(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
+
+mutWallFunctions = $(wallFunctions)/mutWallFunctions
+$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
+$(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C
+$(mutWallFunctions)/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C
+$(mutWallFunctions)/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
+$(mutWallFunctions)/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
+
+epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
+$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
+
+omegaWallFunctions = $(wallFunctions)/omegaWallFunctions
+$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
+
+kQRWallFunctions = $(wallFunctions)/kQRWallFunctions
+$(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C
 
 /* Patch fields */
+derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
 derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
 derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
 
+backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
+
 LIB = $(FOAM_LIBBIN)/libcompressibleRASModels
diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C
index 38d6266d7b047c76c725ba02c8ec622021268bb5..c1bbdc1684e330283676325ce9cd798ea5802324 100644
--- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C
+++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C
@@ -47,7 +47,8 @@ void RASModel::printCoeffs()
 {
     if (printCoeffs_)
     {
-        Info<< type() << "Coeffs" << coeffDict_ << endl;
+        Info<< type() << "Coeffs" << coeffDict_ << nl
+            << "wallFunctionCoeffs" << wallFunctionDict_ << endl;
     }
 }
 
@@ -87,6 +88,7 @@ RASModel::RASModel
     printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
     coeffDict_(subDict(type + "Coeffs")),
 
+    wallFunctionDict_(subDict("wallFunctionCoeffs")),
     kappa_
     (
         dimensioned<scalar>::lookupOrAddToDict
@@ -105,6 +107,24 @@ RASModel::RASModel
             9.0
         )
     ),
+    Cmu_
+    (
+        dimensioned<scalar>::lookupOrAddToDict
+        (
+            "Cmu",
+            wallFunctionDict_,
+            0.09
+        )
+    ),
+    Prt_
+    (
+        dimensioned<scalar>::lookupOrAddToDict
+        (
+            "Prt",
+            wallFunctionDict_,
+            0.85
+        )
+    ),
 
     yPlusLam_(yPlusLam(kappa_.value(), E_.value())),
 
@@ -118,7 +138,7 @@ RASModel::RASModel
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-scalar RASModel::yPlusLam(const scalar kappa, const scalar E)
+scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
 {
     scalar ypl = 11.0;
 
@@ -138,11 +158,9 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
     tmp<scalarField> tYp(new scalarField(curPatch.size()));
     scalarField& Yp = tYp();
 
-    if (typeid(curPatch) == typeid(wallFvPatch))
+    if (isType<wallFvPatch>(curPatch))
     {
-        scalar Cmu(readScalar(coeffDict_.lookup("Cmu")));
-
-        Yp = pow(Cmu, 0.25)
+        Yp = pow(Cmu_.value(), 0.25)
             *y_[patchNo]
             *sqrt(k()().boundaryField()[patchNo].patchInternalField())
            /(
@@ -155,8 +173,8 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
         WarningIn
         (
             "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
-        )   << "Patch " << patchNo << " is not a wall.  Returning blank field"
-            << endl;
+        )   << "Patch " << patchNo << " is not a wall. Returning null field"
+            << nl << endl;
 
         Yp.setSize(0);
     }
@@ -181,8 +199,11 @@ bool RASModel::read()
         lookup("turbulence") >> turbulence_;
         coeffDict_ = subDict(type() + "Coeffs");
 
-        kappa_.readIfPresent(subDict("wallFunctionCoeffs"));
-        E_.readIfPresent(subDict("wallFunctionCoeffs"));
+        wallFunctionDict_ = subDict("wallFunctionCoeffs");
+        kappa_.readIfPresent(wallFunctionDict_);
+        E_.readIfPresent(wallFunctionDict_);
+        Cmu_.readIfPresent(wallFunctionDict_);
+        Prt_.readIfPresent(wallFunctionDict_);
 
         yPlusLam_ = yPlusLam(kappa_.value(), E_.value());
 
diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H
index 47feaebe18b19c66781f0bdace398c40386be4ad..1be29e6e7926cb347cbd25913460d990246eed57 100644
--- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H
+++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H
@@ -91,10 +91,12 @@ protected:
         Switch printCoeffs_;
         dictionary coeffDict_;
 
+        dictionary wallFunctionDict_;
         dimensionedScalar kappa_;
         dimensionedScalar E_;
+        dimensionedScalar Cmu_;
+        dimensionedScalar Prt_;
 
-        scalar yPlusLam(const scalar kappa, const scalar E);
         scalar yPlusLam_;
 
         dimensionedScalar k0_;
@@ -237,6 +239,27 @@ public:
                 return E_;
             }
 
+            //- Return Cmu for use in wall-functions
+            dimensionedScalar Cmu() const
+            {
+                return Cmu_;
+            }
+
+            //- Return turbulent Prandtl number for use in wall-functions
+            dimensionedScalar Prt() const
+            {
+                return Prt_;
+            }
+
+            //- Return the near wall distances
+            const nearWallDist& y() const
+            {
+                return y_;
+            }
+
+            //- Calculate y+ at the edge of the laminar sublayer
+            scalar yPlusLam(const scalar kappa, const scalar E) const;
+
             //- Return y+ at the edge of the laminar sublayer
             //  for use in wall-functions
             scalar yPlusLam() const
@@ -250,6 +273,12 @@ public:
                 return coeffDict_;
             }
 
+            //- Const access to the wall functions coefficients dictionary
+            const dictionary& walLFunctionDict() const
+            {
+                return wallFunctionDict_;
+            }
+
 
         //- Return the laminar viscosity
         const volScalarField& mu() const
diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C
index f2a3562365cd6064fddb9402f210a29bd78436e3..8f6ba82321333b72f9c751c70a95d33269ba7e6d 100644
--- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C
+++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -144,12 +146,11 @@ RNGkEpsilon::RNGkEpsilon
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -157,12 +158,11 @@ RNGkEpsilon::RNGkEpsilon
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -171,12 +171,28 @@ RNGkEpsilon::RNGkEpsilon
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
         ),
-        Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateAlphat("alphat", mesh_)
     )
 {
-#   include "wallViscosityI.H"
+    mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -262,7 +278,13 @@ void RNGkEpsilon::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
@@ -279,7 +301,7 @@ void RNGkEpsilon::correct()
     volScalarField S2 = (tgradU() && dev(twoSymm(tgradU())));
     tgradU.clear();
 
-    volScalarField G = mut_*S2;
+    volScalarField G("G", mut_*S2);
 
     volScalarField eta = sqrt(mag(S2))*k_/epsilon_;
     volScalarField eta3 = eta*sqr(eta);
@@ -287,7 +309,8 @@ void RNGkEpsilon::correct()
     volScalarField R =
         ((eta*(-eta/eta0_ + scalar(1)))/(beta_*eta3 + scalar(1)));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -303,7 +326,7 @@ void RNGkEpsilon::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -327,10 +350,12 @@ void RNGkEpsilon::correct()
 
 
     // Re-calculate viscosity
-    mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
+    mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
+    mut_.correctBoundaryConditions();
 
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H
index 5063615ccbe5a19fe87b52f8dda97713d8fc03be..98445ced1db5b2462fb63460c0fc6f1e83f69247 100644
--- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H
+++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H
@@ -87,6 +87,7 @@ class RNGkEpsilon
         volScalarField k_;
         volScalarField epsilon_;
         volScalarField mut_;
+        volScalarField alphat_;
 
 
 public:
@@ -142,7 +143,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
new file mode 100644
index 0000000000000000000000000000000000000000..19df95a3d5bc706b627cae9206bb0b6124718041
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
@@ -0,0 +1,286 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "backwardsCompatibilityWallFunctions.H"
+
+#include "calculatedFvPatchField.H"
+#include "alphatWallFunctionFvPatchScalarField.H"
+#include "mutWallFunctionFvPatchScalarField.H"
+#include "epsilonWallFunctionFvPatchScalarField.H"
+#include "kQRWallFunctionFvPatchField.H"
+#include "omegaWallFunctionFvPatchScalarField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+tmp<volScalarField> autoCreateAlphat
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    IOobject alphatHeader
+    (
+        fieldName,
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE,
+        false
+    );
+
+    if (alphatHeader.headerOk())
+    {
+        return tmp<volScalarField>(new volScalarField(alphatHeader, mesh));
+    }
+    else
+    {
+        Info<< "--> Upgrading " << fieldName << " to employ run-time "
+            << "selectable wall functions" << endl;
+
+        const fvBoundaryMesh& bm = mesh.boundary();
+
+        wordList alphatBoundaryTypes(bm.size());
+
+        forAll(bm, patchI)
+        {
+            if (isType<wallFvPatch>(bm[patchI]))
+            {
+                alphatBoundaryTypes[patchI] =
+                    RASModels::alphatWallFunctionFvPatchScalarField::typeName;
+            }
+            else
+            {
+                alphatBoundaryTypes[patchI] =
+                    calculatedFvPatchField<scalar>::typeName;
+            }
+        }
+
+        tmp<volScalarField> alphat
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh,
+                dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0),
+                alphatBoundaryTypes
+            )
+        );
+
+        Info<< "    Writing updated " << fieldName << endl;
+        alphat().write();
+
+        return alphat;
+    }
+}
+
+
+tmp<volScalarField> autoCreateMut
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    IOobject mutHeader
+    (
+        fieldName,
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE,
+        false
+    );
+
+    if (mutHeader.headerOk())
+    {
+        return tmp<volScalarField>(new volScalarField(mutHeader, mesh));
+    }
+    else
+    {
+        Info<< "--> Upgrading " << fieldName << " to employ run-time "
+            << "selectable wall functions" << endl;
+
+        const fvBoundaryMesh& bm = mesh.boundary();
+
+        wordList mutBoundaryTypes(bm.size());
+
+        forAll(bm, patchI)
+        {
+            if (isType<wallFvPatch>(bm[patchI]))
+            {
+                mutBoundaryTypes[patchI] =
+                    RASModels::mutWallFunctionFvPatchScalarField::typeName;
+            }
+            else
+            {
+                mutBoundaryTypes[patchI] =
+                    calculatedFvPatchField<scalar>::typeName;
+            }
+        }
+
+        tmp<volScalarField> mut
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh,
+                dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0),
+                mutBoundaryTypes
+            )
+        );
+
+        Info<< "    Writing updated " << fieldName << endl;
+        mut().write();
+
+        return mut;
+    }
+}
+
+
+tmp<volScalarField> autoCreateEpsilon
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::epsilonWallFunctionFvPatchScalarField
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateOmega
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::omegaWallFunctionFvPatchScalarField
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateK
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::kQRWallFunctionFvPatchField<scalar>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateQ
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::kQRWallFunctionFvPatchField<scalar>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volSymmTensorField> autoCreateR
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            symmTensor,
+            RASModels::kQRWallFunctionFvPatchField<symmTensor>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
+
diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H
new file mode 100644
index 0000000000000000000000000000000000000000..bcc812a6b4d228d02fcd3b12004b71dc96b71226
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H
@@ -0,0 +1,123 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible
+
+Description
+    Auto creation of fields to provide backwards compatibility with
+    runtime selectable wall functions
+
+SourceFiles
+    backwardsCompatibilityWallFunctions.C
+    backwardsCompatibilityWallFunctionsTemplates.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef backwardsCompatibilityWallFunctions_H
+#define backwardsCompatibilityWallFunctions_H
+
+#include "fvMesh.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+    //- mut
+    tmp<volScalarField> autoCreateMut
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- alphat
+    tmp<volScalarField> autoCreateAlphat
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- epsilon
+    tmp<volScalarField> autoCreateEpsilon
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- omega
+    tmp<volScalarField> autoCreateOmega
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- k
+    tmp<volScalarField> autoCreateK
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- Q
+    tmp<volScalarField> autoCreateQ
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- R
+    tmp<volSymmTensorField> autoCreateR
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- Helper function to create the new field
+    template<class Type, class PatchType>
+    tmp<GeometricField<Type, fvPatchField, volMesh> >
+    autoCreateWallFunctionField
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "backwardsCompatibilityWallFunctionsTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..d6b489ffeab5c5fc7912bd0764ca421631c5fb01
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C
@@ -0,0 +1,166 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "backwardsCompatibilityWallFunctions.H"
+#include "Time.H"
+
+#include "wallPolyPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template<class Type, class PatchType>
+tmp<GeometricField<Type, fvPatchField, volMesh> >
+autoCreateWallFunctionField
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    IOobject mutHeader
+    (
+        "mut",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
+
+    if (mutHeader.headerOk())
+    {
+        return tmp<fieldType>
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh
+            )
+        );
+    }
+    else
+    {
+        Info<< "--> Upgrading " << fieldName << " to employ run-time "
+            << "selectable wall functions" << endl;
+
+        // Read existing epsilon field
+        tmp<fieldType> fieldOrig
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh
+            )
+        );
+
+        PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
+
+        forAll(newPatchFields, patchI)
+        {
+            if (isType<wallPolyPatch>(mesh.boundaryMesh()[patchI]))
+            {
+                newPatchFields.set
+                (
+                    patchI,
+                    new PatchType
+                    (
+                        mesh.boundary()[patchI],
+                        fieldOrig().dimensionedInternalField()
+                    )
+                );
+                newPatchFields[patchI] == fieldOrig().boundaryField()[patchI];
+            }
+            else
+            {
+                newPatchFields.set
+                (
+                    patchI,
+                    fieldOrig().boundaryField()[patchI].clone()
+                );
+            }
+        }
+
+        tmp<fieldType> fieldNew
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh,
+                fieldOrig().dimensions(),
+                fieldOrig().internalField(),
+                newPatchFields
+            )
+        );
+
+        Info<< "    Writing backup of original " << fieldName << " to "
+            << fieldName << ".old" << endl;
+        fieldOrig().rename(fieldName + ".old");
+        fieldOrig().write();
+
+        Info<< "    Writing updated " << fieldName << endl;
+        fieldNew().write();
+
+        return fieldNew;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..9cd3901fe3d323791cb2307475c78dbe9e38498e
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
@@ -0,0 +1,203 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "turbulentHeatFluxTemperatureFvPatchScalarField.H"
+#include "addToRunTimeSelectionTable.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "RASModel.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedGradientFvPatchScalarField(p, iF),
+    q_(p.size(), 0.0),
+    rhoName_("undefinedRho")
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
+    q_(ptf.q_, mapper),
+    rhoName_(ptf.rhoName_)
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedGradientFvPatchScalarField(p, iF),
+    q_("q", dict, p.size()),
+    rhoName_(dict.lookup("rho"))
+{
+    fvPatchField<scalar>::operator=(patchInternalField());
+    gradient() = 0.0;
+}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf
+)
+:
+    fixedGradientFvPatchScalarField(thftpsf),
+    q_(thftpsf.q_),
+    rhoName_(thftpsf.rhoName_)
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedGradientFvPatchScalarField(thftpsf, iF),
+    q_(thftpsf.q_),
+    rhoName_(thftpsf.rhoName_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap
+(
+    const fvPatchFieldMapper& m
+)
+{
+    fixedGradientFvPatchScalarField::autoMap(m);
+    q_.autoMap(m);
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::rmap
+(
+    const fvPatchScalarField& ptf,
+    const labelList& addr
+)
+{
+    fixedGradientFvPatchScalarField::rmap(ptf, addr);
+
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf =
+        refCast<const turbulentHeatFluxTemperatureFvPatchScalarField>
+        (
+            ptf
+        );
+
+    q_.rmap(thftptf.q_, addr);
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
+{
+    if (updated())
+    {
+        return;
+    }
+
+    const label patchI = patch().index();
+
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalarField alphaEffp = ras.alphaEff()().boundaryField()[patchI];
+
+    const basicThermo& thermo =
+        db().lookupObject<basicThermo>("thermophysicalProperties");
+
+//    const scalarField& Tp = thermo.T().boundaryField()[patchI];
+    const scalarField& Tp = *this;
+
+    const scalarField Cpp = thermo.Cp(Tp, patchI);
+
+    const scalarField& rhop =
+        patch().lookupPatchField<volScalarField, scalar>(rhoName_);
+
+    const scalar Ap = gSum(patch().magSf());
+
+    gradient() = q_/(Ap*rhop*Cpp*alphaEffp);
+
+    fixedGradientFvPatchScalarField::updateCoeffs();
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::write
+(
+    Ostream& os
+) const
+{
+    fvPatchScalarField::write(os);
+    q_.writeEntry("q", os);
+    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
+    gradient().writeEntry("gradient", os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    turbulentHeatFluxTemperatureFvPatchScalarField
+);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace compressible
+} // End namespace Foam
+
+
+// ************************************************************************* //
+
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..c2ee7be012558b958acdc6e29e30f6f47701f4b3
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
@@ -0,0 +1,176 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::turbulentHeatFluxTemperatureFvPatchScalarField
+
+Description
+    Fixed heat flux boundary condition for temperature.
+
+SourceFiles
+    turbulentHeatFluxTemperatureFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H
+#define turbulentHeatFluxTemperatureFvPatchScalarFields_H
+
+#include "fvPatchFields.H"
+#include "fixedGradientFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+
+/*---------------------------------------------------------------------------*\
+     Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class turbulentHeatFluxTemperatureFvPatchScalarField
+:
+    public fixedGradientFvPatchScalarField
+{
+// Private data
+
+    //- Heat flux [W]
+    scalarField q_;
+
+    //- Name of density field
+    word rhoName_;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("turbulentHeatFluxTemperature");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  turbulentHeatFluxTemperatureFvPatchScalarField onto
+        //  a new patch
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new turbulentHeatFluxTemperatureFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new turbulentHeatFluxTemperatureFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+
+    // Member functions
+
+        // Mapping functions
+
+            //- Map (and resize as needed) from self given a mapping object
+            virtual void autoMap(const fvPatchFieldMapper&);
+
+            //- Reverse map the given fvPatchField onto this fvPatchField
+            virtual void rmap
+            (
+                const fvPatchScalarField&,
+                const labelList&
+            );
+
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..a34631cc3c2f8de8d2db7617fe629e55ba2e10e3
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
@@ -0,0 +1,132 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "alphatWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+alphatWallFunctionFvPatchScalarField::
+alphatWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF)
+{}
+
+
+alphatWallFunctionFvPatchScalarField::
+alphatWallFunctionFvPatchScalarField
+(
+    const alphatWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper)
+{}
+
+
+alphatWallFunctionFvPatchScalarField::
+alphatWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict)
+{}
+
+
+alphatWallFunctionFvPatchScalarField::
+alphatWallFunctionFvPatchScalarField
+(
+    const alphatWallFunctionFvPatchScalarField& awfpsf
+)
+:
+    fixedValueFvPatchScalarField(awfpsf)
+{}
+
+
+alphatWallFunctionFvPatchScalarField::
+alphatWallFunctionFvPatchScalarField
+(
+    const alphatWallFunctionFvPatchScalarField& awfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(awfpsf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void alphatWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+    const scalar Prt = ras.Prt().value();
+
+    const scalarField& mutw =
+        patch().lookupPatchField<volScalarField, scalar>("mut");
+
+    operator==(mutw/Prt);
+}
+
+
+void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, alphatWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..d94775a342e71899bd09fdc6af74b86e65ad6ba4
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible::RASModels::alphatWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for turbulent thermal diffusivity when using wall
+    functions
+    - replicates OpenFOAM v1.5 (and earlier) behaviour
+
+SourceFiles
+    alphatWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef alphatWallFunctionFvPatchScalarField_H
+#define alphatWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+            Class alphatWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class alphatWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+
+public:
+
+    //- Runtime type information
+    TypeName("alphatWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        alphatWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        alphatWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  alphatWallFunctionFvPatchScalarField
+        //  onto a new patch
+        alphatWallFunctionFvPatchScalarField
+        (
+            const alphatWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        alphatWallFunctionFvPatchScalarField
+        (
+            const alphatWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new alphatWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        alphatWallFunctionFvPatchScalarField
+        (
+            const alphatWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new alphatWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..b22c101340d0e5c2dfd0bb2d577f4b3ffe840bd9
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
@@ -0,0 +1,218 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "epsilonWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void epsilonWallFunctionFvPatchScalarField::checkType()
+{
+    if (!isA<wallFvPatch>(patch()))
+    {
+        FatalErrorIn("epsilonWallFunctionFvPatchScalarField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << patch().type() << nl << endl
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF, dict)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ewfpsf
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ewfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar Cmu75 = pow(Cmu, 0.75);
+    const scalar kappa = ras.kappa().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    volScalarField& G = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("G"));
+
+    volScalarField& epsilon = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("epsilon"));
+
+    const volScalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+
+    const scalarField& mutw =
+        patch().lookupPatchField<volScalarField, scalar>("mut");
+
+    const fvPatchVectorField& Uw =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    const scalarField magGradUw = mag(Uw.snGrad());
+
+    // Set epsilon and G
+    forAll(mutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus =
+            Cmu25*y[faceI]*sqrt(k[faceCellI])
+           /(muw[faceI]/rhow[faceI]);
+
+        epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]);
+
+        if (yPlus > yPlusLam)
+        {
+            G[faceCellI] =
+                (mutw[faceI] + muw[faceI])
+               *magGradUw[faceI]
+               *Cmu25*sqrt(k[faceCellI])
+               /(kappa*y[faceI]);
+        }
+        else
+        {
+            G[faceCellI] = 0.0;
+        }
+    }
+
+    // TODO: perform averaging for cells sharing more than one boundary face
+}
+
+
+void epsilonWallFunctionFvPatchScalarField::evaluate
+(
+    const Pstream::commsTypes commsType
+)
+{
+    fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
+}
+
+
+void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fixedInternalValueFvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    epsilonWallFunctionFvPatchScalarField
+);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..2cb6b336bfb85a8767f0958350fac2b76300a997
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
@@ -0,0 +1,164 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::compressible::RASModels::epsilonWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for epsilon when using wall functions
+    - calculates epsilon and G
+    - epsilon values added directly into the matrix to act as a constraint
+
+SourceFiles
+    epsilonWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef epsilonWallFunctionFvPatchScalarField_H
+#define epsilonWallFunctionFvPatchScalarField_H
+
+#include "fixedInternalValueFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+           Class epsilonWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class epsilonWallFunctionFvPatchScalarField
+:
+    public fixedInternalValueFvPatchField<scalar>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("epsilonWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  epsilonWallFunctionFvPatchScalarField
+        //  onto a new patch
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new epsilonWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new epsilonWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+            //- Evaluate the patchField
+            virtual void evaluate(const Pstream::commsTypes);
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C
new file mode 100644
index 0000000000000000000000000000000000000000..9f6a7d71f991304f540191bda89f5575246aa381
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "kQRWallFunctionFvPatchField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::checkType()
+{
+    if (!isA<wallFvPatch>(this->patch()))
+    {
+        FatalErrorIn("kQRWallFunctionFvPatchField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << this->patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << this->patch().type()
+            << nl << endl << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& ptf,
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    zeroGradientFvPatchField<Type>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF, dict)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& tkqrwfpf
+)
+:
+    zeroGradientFvPatchField<Type>(tkqrwfpf)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& tkqrwfpf,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(tkqrwfpf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::evaluate
+(
+    const Pstream::commsTypes commsType
+)
+{
+    zeroGradientFvPatchField<Type>::evaluate(commsType);
+}
+
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::write(Ostream& os) const
+{
+    zeroGradientFvPatchField<Type>::write(os);
+    this->writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H
new file mode 100644
index 0000000000000000000000000000000000000000..05ed2fbcb81d08f9d21ca1ba104f4649c7057c43
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H
@@ -0,0 +1,170 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::compressible::RASModels::kQRWallFunctionFvPatchField
+
+Description
+    Boundary condition for turbulence k, Q, and R when using wall functions.
+    Simply acts as a zero gradient condition.
+
+SourceFiles
+    kQRWallFunctionFvPatchField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef kQRWallFunctionFvPatchField_H
+#define kQRWallFunctionFvPatchField_H
+
+#include "zeroGradientFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+                Class kQRWallFunctionFvPatchField Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class kQRWallFunctionFvPatchField
+:
+    public zeroGradientFvPatchField<Type>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("kQRWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        kQRWallFunctionFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        kQRWallFunctionFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        // kQRWallFunctionFvPatchField
+        //  onto a new patch
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&,
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchField<Type> > clone() const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new kQRWallFunctionFvPatchField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchField<Type> > clone
+        (
+            const DimensionedField<Type, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new kQRWallFunctionFvPatchField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Evaluate the patchField
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::Pstream::blocking
+            );
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "kQRWallFunctionFvPatchField.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..6942ba56b129e1fb217aad49627500f01e95d434
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "kQRWallFunctionFvPatchFields.H"
+#include "fvPatchFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+makePatchFields(kQRWallFunction);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..e1297548beeb0451f88f733a9c3ee91e70d1a300
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H
@@ -0,0 +1,56 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 kQRWallFunctionFvPatchFields_H
+#define kQRWallFunctionFvPatchFields_H
+
+#include "kQRWallFunctionFvPatchField.H"
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeFieldTypedefs(kQRWallFunction)
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..67ad5536df50e0a8a3bac9543bc6ae70ec2d4026
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C
@@ -0,0 +1,248 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "mutRoughWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+scalar mutRoughWallFunctionFvPatchScalarField::fnRough
+(
+    const scalar KsPlus,
+    const scalar Cs,
+    const scalar kappa
+) const
+{
+    // Set deltaB based on non-dimensional roughness height
+    scalar deltaB = 0.0;
+    if (KsPlus < 90.0)
+    {
+        deltaB =
+            1.0/kappa
+            *log((KsPlus - 2.25)/87.75 + Cs*KsPlus)
+            *sin(0.4258*(log(KsPlus) - 0.811));
+    }
+    else
+    {
+        deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus);
+    }
+
+    return exp(min(deltaB*kappa, 50.0));
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+mutRoughWallFunctionFvPatchScalarField::
+mutRoughWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF),
+    Ks_(p.size(), 0.0),
+    Cs_(p.size(), 0.0)
+{}
+
+
+mutRoughWallFunctionFvPatchScalarField::
+mutRoughWallFunctionFvPatchScalarField
+(
+    const mutRoughWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper),
+    Ks_(ptf.Ks_, mapper),
+    Cs_(ptf.Cs_, mapper)
+{}
+
+
+mutRoughWallFunctionFvPatchScalarField::
+mutRoughWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict),
+    Ks_("Ks", dict, p.size()),
+    Cs_("Cs", dict, p.size())
+{}
+
+
+mutRoughWallFunctionFvPatchScalarField::
+mutRoughWallFunctionFvPatchScalarField
+(
+    const mutRoughWallFunctionFvPatchScalarField& nrwfpsf
+)
+:
+    fixedValueFvPatchScalarField(nrwfpsf),
+    Ks_(nrwfpsf.Ks_),
+    Cs_(nrwfpsf.Cs_)
+{}
+
+
+mutRoughWallFunctionFvPatchScalarField::
+mutRoughWallFunctionFvPatchScalarField
+(
+    const mutRoughWallFunctionFvPatchScalarField& nrwfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(nrwfpsf, iF),
+    Ks_(nrwfpsf.Ks_),
+    Cs_(nrwfpsf.Cs_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void mutRoughWallFunctionFvPatchScalarField::autoMap
+(
+    const fvPatchFieldMapper& m
+)
+{
+    fixedValueFvPatchScalarField::autoMap(m);
+    Ks_.autoMap(m);
+    Cs_.autoMap(m);
+}
+
+
+void mutRoughWallFunctionFvPatchScalarField::rmap
+(
+    const fvPatchScalarField& ptf,
+    const labelList& addr
+)
+{
+    fixedValueFvPatchScalarField::rmap(ptf, addr);
+
+    const mutRoughWallFunctionFvPatchScalarField& nrwfpsf =
+        refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf);
+
+    Cs_.rmap(nrwfpsf.Cs_, addr);
+    Ks_.rmap(nrwfpsf.Ks_, addr);
+}
+
+
+void mutRoughWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar kappa = ras.kappa().value();
+    const scalar E = ras.E().value();
+    scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const scalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+
+    scalarField& mutw = *this;
+
+    forAll(mutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar uStar = Cmu25*sqrt(k[faceCellI]);
+
+        scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
+
+        scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
+
+        scalar Edash = E;
+        scalar yPlusLamNew = yPlusLam;
+        if (KsPlus > 2.25)
+        {
+            Edash = E/fnRough(KsPlus, Cs_[faceI], kappa);
+            yPlusLam = ras.yPlusLam(kappa, Edash);
+        }
+
+        if (debug)
+        {
+            Info<< "yPlus = " << yPlus
+                << ", KsPlus = " << KsPlus
+                << ", Edash = " << Edash
+                << ", yPlusLam = " << yPlusLam
+                << endl;
+        }
+
+        if (yPlus > yPlusLamNew)
+        {
+            mutw[faceI] = muw[faceI]*(yPlus*kappa/log(Edash*yPlus) - 1);
+        }
+        else
+        {
+            mutw[faceI] = 0.0;
+        }
+    }
+}
+
+
+void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fvPatchField<scalar>::write(os);
+    Cs_.writeEntry("Cs", os);
+    Ks_.writeEntry("Ks", os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..830e320646c1d71db0375ffff04939ca7e0b9024
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H
@@ -0,0 +1,194 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible::RASModels::nutRoughWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for turbulent (kinematic) viscosity when using wall
+    functions for rough walls.
+
+    Manipulates the E parameter to account for roughness effects, based on
+    KsPlus.
+
+    - roughness height = sand-grain roughness (0 for smooth walls)
+    - roughness constant = 0.5-1.0 (0.5 default)
+
+SourceFiles
+    mutRoughWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef mutRoughWallFunctionFvPatchScalarField_H
+#define mutRoughWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+          Class mutRoughWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class mutRoughWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+    // Private data
+
+        //- Roughness height
+        scalarField Ks_;
+
+        //- Roughness constant
+        scalarField Cs_;
+
+
+    // Private member functions
+
+        //- Compute the roughness function
+        scalar fnRough
+        (
+            const scalar KsPlus,
+            const scalar Cs,
+            const scalar kappa
+        ) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("mutRoughWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        mutRoughWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        mutRoughWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  mutRoughWallFunctionFvPatchScalarField
+        //  onto a new patch
+        mutRoughWallFunctionFvPatchScalarField
+        (
+            const mutRoughWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        mutRoughWallFunctionFvPatchScalarField
+        (
+            const mutRoughWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutRoughWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        mutRoughWallFunctionFvPatchScalarField
+        (
+            const mutRoughWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutRoughWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Mapping functions
+
+            //- Map (and resize as needed) from self given a mapping object
+            virtual void autoMap
+            (
+                const fvPatchFieldMapper&
+            );
+
+            //- Reverse map the given fvPatchField onto this fvPatchField
+            virtual void rmap
+            (
+                const fvPatchScalarField&,
+                const labelList&
+            );
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
similarity index 88%
rename from src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
index d712e56bd9faf04f17fd051d398a2247c27cfe15..8cff5793be33fbac5b698ed0a5d9bd928684c2e1 100644
--- a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "mutStandardRoughWallFunctionFvPatchScalarField.H"
+#include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H"
 #include "RASModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,8 +41,8 @@ namespace RASModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-mutStandardRoughWallFunctionFvPatchScalarField::
-mutStandardRoughWallFunctionFvPatchScalarField
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -55,10 +55,10 @@ mutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-mutStandardRoughWallFunctionFvPatchScalarField::
-mutStandardRoughWallFunctionFvPatchScalarField
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const mutStandardRoughWallFunctionFvPatchScalarField& ptf,
+    const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -71,8 +71,8 @@ mutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-mutStandardRoughWallFunctionFvPatchScalarField::
-mutStandardRoughWallFunctionFvPatchScalarField
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -86,10 +86,10 @@ mutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-mutStandardRoughWallFunctionFvPatchScalarField::
-mutStandardRoughWallFunctionFvPatchScalarField
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const mutStandardRoughWallFunctionFvPatchScalarField& tppsf
+    const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf),
@@ -99,10 +99,10 @@ mutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-mutStandardRoughWallFunctionFvPatchScalarField::
-mutStandardRoughWallFunctionFvPatchScalarField
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const mutStandardRoughWallFunctionFvPatchScalarField& tppsf,
+    const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -115,7 +115,7 @@ mutStandardRoughWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void mutStandardRoughWallFunctionFvPatchScalarField::evaluate
+void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
 (
     const Pstream::commsTypes
 )
@@ -282,7 +282,10 @@ void mutStandardRoughWallFunctionFvPatchScalarField::evaluate
 }
 
 
-void mutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
+void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write
+(
+    Ostream& os
+) const
 {
     fixedValueFvPatchScalarField::write(os);
     os.writeKeyword("roughnessHeight")
@@ -299,7 +302,7 @@ void mutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
 makePatchTypeField
 (
     fvPatchScalarField,
-    mutStandardRoughWallFunctionFvPatchScalarField
+    mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 );
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
similarity index 76%
rename from src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
index 7c8e5617934d4bc886069c5cf4fa7a6425fe3ecb..7341cea2417b3bdd6d4bd0f19e6f9a3239befa4c 100644
--- a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
@@ -23,18 +23,19 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::compressible::RASModels::mutStandardRoughWallFunctionFvPatchScalarField
+    Foam::compressible::RASModels::
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 
 Description
     Wall function boundary condition for rough walls
 
 SourceFiles
-    mutStandardWallFunctionFvPatchScalarField.C
+    mutSpalartAllamarasStandardWallFunctionFvPatchScalarField.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef mutStandardRoughWallFunctionFvPatchScalarField_H
-#define mutStandardRoughWallFunctionFvPatchScalarField_H
+#ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
+#define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
@@ -48,10 +49,10 @@ namespace RASModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class mutWallFunctionFvPatch Declaration
+Class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
-class mutStandardRoughWallFunctionFvPatchScalarField
+class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
@@ -65,41 +66,41 @@ class mutStandardRoughWallFunctionFvPatchScalarField
 public:
 
     //- Runtime type information
-    TypeName("mutStandardRoughWallFunction");
+    TypeName("mutSpalartAllmarasStandardRoughWallFunction");
 
 
     // Constructors
 
         //- Construct from patch and internal field
-        mutStandardRoughWallFunctionFvPatchScalarField
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&
         );
 
         //- Construct from patch, internal field and dictionary
-        mutStandardRoughWallFunctionFvPatchScalarField
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const dictionary&
         );
 
-        //- Construct by mapping given 
-        //  mutStandardRoughWallFunctionFvPatchScalarField
+        //- Construct by mapping given
+        //  mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         //  onto a new patch
-        mutStandardRoughWallFunctionFvPatchScalarField
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const mutStandardRoughWallFunctionFvPatchScalarField&,
+            const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&,
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const fvPatchFieldMapper&
         );
 
         //- Construct as copy
-        mutStandardRoughWallFunctionFvPatchScalarField
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const mutStandardRoughWallFunctionFvPatchScalarField&
+            const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&
         );
 
         //- Construct and return a clone
@@ -107,14 +108,17 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new mutStandardRoughWallFunctionFvPatchScalarField(*this)
+                new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
+                (
+                    *this
+                )
             );
         }
 
         //- Construct as copy setting internal field reference
-        mutStandardRoughWallFunctionFvPatchScalarField
+        mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const mutStandardRoughWallFunctionFvPatchScalarField&,
+            const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&,
             const DimensionedField<scalar, volMesh>&
         );
 
@@ -126,7 +130,11 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new mutStandardRoughWallFunctionFvPatchScalarField(*this, iF)
+                new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
+                (
+                   *this,
+                    iF
+                )
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..669d0e72f8466cb40cc163ed849e760573d1d3cf
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
@@ -0,0 +1,175 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF)
+{}
+
+
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper)
+{}
+
+
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict)
+{}
+
+
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf
+)
+:
+    fixedValueFvPatchScalarField(tppsf)
+{}
+
+
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(tppsf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate
+(
+    const Pstream::commsTypes
+)
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    scalar kappa = ras.kappa().value();
+    scalar E = ras.E().value();
+    scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& ry = patch().deltaCoeffs();
+
+    const fvPatchVectorField& U =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    scalarField magUp = mag(U.patchInternalField() - U);
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+    scalarField& mutw = *this;
+
+    scalarField magFaceGradU = mag(U.snGrad());
+
+    forAll(mutw, faceI)
+    {
+        scalar magUpara = magUp[faceI];
+
+        scalar kappaRe = kappa*magUpara/((muw[faceI]/rhow[faceI])*ry[faceI]);
+
+        scalar yPlus = yPlusLam;
+        scalar ryPlusLam = 1.0/yPlus;
+
+        int iter = 0;
+        scalar yPlusLast = 0.0;
+
+        do
+        {
+            yPlusLast = yPlus;
+            yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus));
+
+        } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 );
+
+        if (yPlus > yPlusLam)
+        {
+            mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1);
+        }
+        else
+        {
+            mutw[faceI] = 0.0;
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..c55a1fb0c6a7045e494ce640c1dc6e9cffcf69a3
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H
@@ -0,0 +1,158 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible::RASModels::
+    mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+
+Description
+    Wall function boundary condition for walls
+
+SourceFiles
+    mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
+#define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+  Class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+
+public:
+
+    //- Runtime type information
+    TypeName("mutSpalartAllmarasStandardWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        //  onto a new patch
+        mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+                (
+                    *this
+                )
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Evaluate the patchField
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::blocking
+            );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..f9e92d19baee0ec1405070cf9031c21df3213d62
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C
@@ -0,0 +1,187 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+mutSpalartAllmarasWallFunctionFvPatchScalarField::
+mutSpalartAllmarasWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF)
+{}
+
+
+mutSpalartAllmarasWallFunctionFvPatchScalarField::
+mutSpalartAllmarasWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper)
+{}
+
+
+mutSpalartAllmarasWallFunctionFvPatchScalarField::
+mutSpalartAllmarasWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict)
+{}
+
+
+mutSpalartAllmarasWallFunctionFvPatchScalarField::
+mutSpalartAllmarasWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf
+)
+:
+    fixedValueFvPatchScalarField(tppsf)
+{}
+
+
+mutSpalartAllmarasWallFunctionFvPatchScalarField::
+mutSpalartAllmarasWallFunctionFvPatchScalarField
+(
+    const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(tppsf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void mutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate
+(
+    const Pstream::commsTypes
+)
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    scalar kappa = ras.kappa().value();
+    scalar E = ras.E().value();
+
+    const scalarField& ry = patch().deltaCoeffs();
+
+    const fvPatchVectorField& U =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    scalarField magUp = mag(U.patchInternalField() - U);
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+
+    scalarField& mutw = *this;
+
+    scalarField magFaceGradU = mag(U.snGrad());
+
+    forAll(mutw, faceI)
+    {
+        scalar magUpara = magUp[faceI];
+
+        scalar utau =
+            sqrt((mutw[faceI] + muw[faceI])*magFaceGradU[faceI]/rhow[faceI]);
+
+        if (utau > VSMALL)
+        {
+            int iter = 0;
+            scalar err = GREAT;
+
+            do
+            {
+                scalar kUu = min(kappa*magUpara/utau, 50);
+                scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
+
+                scalar f =
+                    - utau/(ry[faceI]*(muw[faceI]/rhow[faceI]))
+                    + magUpara/utau
+                    + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu));
+
+                scalar df =
+                    1.0/(ry[faceI]*(muw[faceI]/rhow[faceI]))
+                  + magUpara/sqr(utau)
+                  + 1/E*kUu*fkUu/utau;
+
+                scalar utauNew = utau + f/df;
+                err = mag((utau - utauNew)/utau);
+                utau = utauNew;
+
+            } while (utau > VSMALL && err > 0.01 && ++iter < 10);
+
+            mutw[faceI] = max
+            (
+                rhow[faceI]*sqr(max(utau, 0))/magFaceGradU[faceI]- muw[faceI],
+                0.0
+            );
+        }
+        else
+        {
+            mutw[faceI] = 0;
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H
similarity index 72%
rename from src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H
index 76f6aca405667ac3527f7fb28cebf54d2cdf5f4d..8967a243c2a9093cf21cb7e2ff587cddcfc4802f 100644
--- a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H
@@ -23,18 +23,19 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::compressible::LESModels::muSgsWallFunctionFvPatchScalarField
+    Foam::compressible::RASModels::
+    mutSpalartAllmarasWallFunctionFvPatchScalarField
 
 Description
-    wall function boundary condition for compressible flows
+    Wall function boundary condition for walls
 
 SourceFiles
-    muSgsWallFunctionFvPatchScalarField.C
+    mutSpalartAllmarasWallFunctionFvPatchScalarField.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef muSgsWallFunctionFvPatchScalarField_H
-#define muSgsWallFunctionFvPatchScalarField_H
+#ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H
+#define mutSpalartAllmarasWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
@@ -44,65 +45,55 @@ namespace Foam
 {
 namespace compressible
 {
-namespace LESModels
+namespace RASModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class muSgsWallFunctionFvPatch Declaration
+      Class mutSpalartAllmarasWallFunctionFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
-class muSgsWallFunctionFvPatchScalarField
+class mutSpalartAllmarasWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
-    // Private data
-
-
 public:
 
     //- Runtime type information
-    TypeName("muSgsWallFunction");
+    TypeName("mutSpalartAllmarasWallFunction");
 
 
     // Constructors
 
         //- Construct from patch and internal field
-        muSgsWallFunctionFvPatchScalarField
+        mutSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&
         );
 
-        //- Construct from patch, internal field and Istream
-        muSgsWallFunctionFvPatchScalarField
-        (
-            const fvPatch&,
-            const DimensionedField<scalar, volMesh>&,
-            Istream&
-        );
-
         //- Construct from patch, internal field and dictionary
-        muSgsWallFunctionFvPatchScalarField
+        mutSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const dictionary&
         );
 
-        //- Construct by mapping given muSgsWallFunctionFvPatchScalarField
+        //- Construct by mapping given
+        //  mutSpalartAllmarasWallFunctionFvPatchScalarField
         //  onto a new patch
-        muSgsWallFunctionFvPatchScalarField
+        mutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const muSgsWallFunctionFvPatchScalarField&,
+            const mutSpalartAllmarasWallFunctionFvPatchScalarField&,
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const fvPatchFieldMapper&
         );
 
         //- Construct as copy
-        muSgsWallFunctionFvPatchScalarField
+        mutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const muSgsWallFunctionFvPatchScalarField&
+            const mutSpalartAllmarasWallFunctionFvPatchScalarField&
         );
 
         //- Construct and return a clone
@@ -110,14 +101,14 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new muSgsWallFunctionFvPatchScalarField(*this)
+                new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this)
             );
         }
 
         //- Construct as copy setting internal field reference
-        muSgsWallFunctionFvPatchScalarField
+        mutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const muSgsWallFunctionFvPatchScalarField&,
+            const mutSpalartAllmarasWallFunctionFvPatchScalarField&,
             const DimensionedField<scalar, volMesh>&
         );
 
@@ -129,7 +120,7 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new muSgsWallFunctionFvPatchScalarField(*this, iF)
+                new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this, iF)
             );
         }
 
@@ -148,7 +139,7 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace LESModels
+} // End namespace RASModels
 } // End namespace compressible
 } // End namespace Foam
 
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..f73e5b2a899b85110f610f5c39b50a052596956d
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C
@@ -0,0 +1,162 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "mutWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+mutWallFunctionFvPatchScalarField::
+mutWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF)
+{}
+
+
+mutWallFunctionFvPatchScalarField::
+mutWallFunctionFvPatchScalarField
+(
+    const mutWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper)
+{}
+
+
+mutWallFunctionFvPatchScalarField::
+mutWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict)
+{}
+
+
+mutWallFunctionFvPatchScalarField::
+mutWallFunctionFvPatchScalarField
+(
+    const mutWallFunctionFvPatchScalarField& tppsf
+)
+:
+    fixedValueFvPatchScalarField(tppsf)
+{}
+
+
+mutWallFunctionFvPatchScalarField::
+mutWallFunctionFvPatchScalarField
+(
+    const mutWallFunctionFvPatchScalarField& tppsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(tppsf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void mutWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar kappa = ras.kappa().value();
+    const scalar E = ras.E().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const volScalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+
+    scalarField& mutw = *this;
+
+    forAll(mutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus =
+            Cmu25*y[faceI]*sqrt(k[faceCellI])
+           /(muw[faceI]/rhow[faceI]);
+
+        if (yPlus > yPlusLam)
+        {
+            mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1);
+        }
+        else
+        {
+            mutw[faceI] = 0.0;
+        }
+    }
+}
+
+
+void mutWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..815e50ca700d58904cad4abe0d7b9e93861f16bd
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::compressible::RASModels::mutWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for turbulent (kinematic) viscosity when using wall
+    functions
+    - replicates OpenFOAM v1.5 (and earlier) behaviour
+
+SourceFiles
+    mutWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef mutWallFunctionFvPatchScalarField_H
+#define mutWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+             Class mutWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class mutWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+
+public:
+
+    //- Runtime type information
+    TypeName("mutWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        mutWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        mutWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  mutWallFunctionFvPatchScalarField
+        //  onto a new patch
+        mutWallFunctionFvPatchScalarField
+        (
+            const mutWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        mutWallFunctionFvPatchScalarField
+        (
+            const mutWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        mutWallFunctionFvPatchScalarField
+        (
+            const mutWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new mutWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..5b0ee67630fa909764d9965fb3f9d49ed2c01af3
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
@@ -0,0 +1,209 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "omegaWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void omegaWallFunctionFvPatchScalarField::checkType()
+{
+    if (!isA<wallFvPatch>(patch()))
+    {
+        FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << patch().type() << nl << endl
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF, dict)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ewfpsf
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ewfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void omegaWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+
+    const scalar kappa = ras.kappa().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    volScalarField& G = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("G"));
+
+    volScalarField& omega = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("omega"));
+
+    const scalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& rhow =
+        patch().lookupPatchField<volScalarField, scalar>("rho");
+
+    const scalarField& muw =
+        patch().lookupPatchField<volScalarField, scalar>("mu");
+
+    const scalarField& mutw =
+        patch().lookupPatchField<volScalarField, scalar>("mut");
+
+    const fvPatchVectorField& Uw =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    const scalarField magGradUw = mag(Uw.snGrad());
+
+    // Set epsilon and G
+    forAll(mutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus =
+            Cmu25*y[faceI]*sqrt(k[faceCellI])
+           /(muw[faceI]/rhow[faceI]);
+
+        omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceI]);
+
+        if (yPlus > yPlusLam)
+        {
+            G[faceCellI] =
+                (mutw[faceI] + muw[faceI])
+               *magGradUw[faceI]
+               *Cmu25*sqrt(k[faceCellI])
+               /(kappa*y[faceI]);
+        }
+        else
+        {
+            G[faceCellI] = 0.0;
+        }
+    }
+
+    // TODO: perform averaging for cells sharing more than one boundary face
+}
+
+
+void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fixedInternalValueFvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    omegaWallFunctionFvPatchScalarField
+);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..266e7987d54f8d50b0b33712e483066808240d4f
--- /dev/null
+++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
@@ -0,0 +1,159 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::compressible::RASModels::omegaWallFunctionFvPatchScalarField
+
+Description
+    Replaces functionality in wallFunctionsI.H
+
+SourceFiles
+    omegaWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef omegaWallFunctionFvPatchScalarField_H
+#define omegaWallFunctionFvPatchScalarField_H
+
+#include "fixedInternalValueFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace compressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+           Class omegaWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class omegaWallFunctionFvPatchScalarField
+:
+    public fixedInternalValueFvPatchField<scalar>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("omegaWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        omegaWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        omegaWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        // omegaWallFunctionFvPatchScalarField
+        //  onto a new patch
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new omegaWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new omegaWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace compressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallDissipationI.H b/src/turbulenceModels/RAS/compressible/include/wallDissipationI.H
similarity index 100%
rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallDissipationI.H
rename to src/turbulenceModels/RAS/compressible/include/wallDissipationI.H
diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallFunctionsI.H b/src/turbulenceModels/RAS/compressible/include/wallFunctionsI.H
similarity index 100%
rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallFunctionsI.H
rename to src/turbulenceModels/RAS/compressible/include/wallFunctionsI.H
diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallViscosityI.H b/src/turbulenceModels/RAS/compressible/include/wallViscosityI.H
similarity index 100%
rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallViscosityI.H
rename to src/turbulenceModels/RAS/compressible/include/wallViscosityI.H
diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C
index 60bd1c3fa240565de6567c7e855e044b6426bf75..cb0fecc03dcbb3db26ce8a55b1f10d2dddd54036 100644
--- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C
+++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -125,12 +127,11 @@ kEpsilon::kEpsilon
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -138,12 +139,11 @@ kEpsilon::kEpsilon
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -152,12 +152,28 @@ kEpsilon::kEpsilon
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
         ),
-        Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateAlphat("alphat", mesh_)
     )
 {
-#   include "wallViscosityI.H"
+    mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -242,8 +258,13 @@ void kEpsilon::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
-#       include "wallViscosityI.H"
+        mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
@@ -257,10 +278,11 @@ void kEpsilon::correct()
     }
 
     tmp<volTensorField> tgradU = fvc::grad(U_);
-    volScalarField G = mut_*(tgradU() && dev(twoSymm(tgradU())));
+    volScalarField G("G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
     tgradU.clear();
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -274,10 +296,10 @@ void kEpsilon::correct()
       - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
     );
 
-#   include "wallDissipationI.H"
-
     epsEqn().relax();
 
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
+
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
 
@@ -301,10 +323,12 @@ void kEpsilon::correct()
 
 
     // Re-calculate viscosity
-    mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
+    mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
+    mut_.correctBoundaryConditions();
 
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H
index d42bc73a6666767d0bb9ebc67765b7fe8cd21315..76d952d40da37d80720f923b2675ca4825679ec4 100644
--- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H
+++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H
@@ -74,7 +74,6 @@ class kEpsilon
 
         // Model coefficients
 
-//            dimensionedScalar Cmu;
             dimensionedScalar Cmu_;
             dimensionedScalar C1_;
             dimensionedScalar C2_;
@@ -88,6 +87,7 @@ class kEpsilon
             volScalarField k_;
             volScalarField epsilon_;
             volScalarField mut_;
+            volScalarField alphat_;
 
 
 public:
@@ -144,7 +144,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H
deleted file mode 100644
index 025c06bb9c9a373cc579aff60a75f824346850db..0000000000000000000000000000000000000000
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H
+++ /dev/null
@@ -1,19 +0,0 @@
-if (!isType<zeroGradientFvPatchScalarField>(k_.boundaryField()[patchi]))
-{
-    FatalErrorIn("wall-function evaluation")
-        << k_.boundaryField()[patchi].type()
-        << " is the wrong k patchField type for wall-functions on patch "
-        << curPatch.name() << nl
-        << "    should be zeroGradient"
-        << exit(FatalError);
-}
-
-if (!isType<zeroGradientFvPatchScalarField>(omega_.boundaryField()[patchi]))
-{
-    FatalErrorIn("wall-function evaluation")
-        << omega_.boundaryField()[patchi].type()
-        << " is the wrong omega patchField type for wall-functions on patch "
-        << curPatch.name() << nl
-        << "    should be zeroGradient"
-        << exit(FatalError);
-}
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C
index ad9e49a858846cb3c84ff4b6bbe98f9897dd0482..1181169f87915b806ff7a95ef558a567d083fd19 100644
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C
+++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -228,12 +230,11 @@ kOmegaSST::kOmegaSST
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     omega_
     (
         IOobject
@@ -241,12 +242,11 @@ kOmegaSST::kOmegaSST
             "omega",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateOmega("omega", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -255,12 +255,28 @@ kOmegaSST::kOmegaSST
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
         ),
-        a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))))
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateAlphat("alphat", mesh_)
     )
 {
-#   include "kOmegaWallViscosityI.H"
+    mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -350,10 +366,15 @@ void kOmegaSST::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ =
+        mut_ ==
             a1_*rho_*k_
            /max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
-#       include "kOmegaWallViscosityI.H"
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
@@ -374,10 +395,11 @@ void kOmegaSST::correct()
     tmp<volTensorField> tgradU = fvc::grad(U_);
     volScalarField S2 = magSqr(symm(tgradU()));
     volScalarField GbyMu = (tgradU() && dev(twoSymm(tgradU())));
-    volScalarField G = mut_*GbyMu;
+    volScalarField G("G", mut_*GbyMu);
     tgradU.clear();
 
-#   include "kOmegaWallFunctionsI.H"
+    // Update omega and G at the wall
+    omega_.boundaryField().updateCoeffs();
 
     volScalarField CDkOmega =
         (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_;
@@ -404,7 +426,7 @@ void kOmegaSST::correct()
 
     omegaEqn().relax();
 
-#   include "wallOmegaI.H"
+    omegaEqn().boundaryManipulate(omega_.boundaryField());
 
     solve(omegaEqn);
     bound(omega_, omega0_);
@@ -427,10 +449,12 @@ void kOmegaSST::correct()
 
 
     // Re-calculate viscosity
-    mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2));
-
-#   include "kOmegaWallViscosityI.H"
+    mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2));
+    mut_.correctBoundaryConditions();
 
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H
index 4836d02611c1fc0853d1bf3a086803ecf227a0b8..3f9c1486d3e41361a447fb77f69f64a106fdfb00 100644
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H
+++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H
@@ -134,6 +134,7 @@ class kOmegaSST
         volScalarField k_;
         volScalarField omega_;
         volScalarField mut_;
+        volScalarField alphat_;
 
 
     // Private member functions
@@ -238,7 +239,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H
deleted file mode 100644
index ff5cdf4514f175d5b216b2e1814215ba060d0253..0000000000000000000000000000000000000000
--- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H
+++ /dev/null
@@ -1,127 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 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
-
-Global
-    kOmegaWallFunctions
-
-Description
-    Calculate wall generation and frequency omega from wall-functions.
-
-\*---------------------------------------------------------------------------*/
-
-{
-    labelList cellBoundaryFaceCount(omega_.size(), 0);
-
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
-
-    const fvPatchList& patches = mesh_.boundary();
-
-    //- Initialise the near-wall omega and G fields to zero
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] = 0.0;
-                G[faceCelli] = 0.0;
-            }
-        }
-    }
-
-    //- Accumulate the wall face contributions to omega and G
-    //  Increment cellBoundaryFaceCount for each face for averaging
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-#           include "checkkOmegaPatchFieldTypes.H"
-
-            const scalarField& rhow = rho_.boundaryField()[patchi];
-
-            const scalarField& muw = mu().boundaryField()[patchi];
-            const scalarField& mutw = mut_.boundaryField()[patchi];
-
-            scalarField magFaceGradU =
-                mag(U_.boundaryField()[patchi].snGrad());
-
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[faceCelli]
-                    *sqrt(k_[faceCelli])
-                    /(muw[facei]/rhow[facei]);
-
-                // For corner cells (with two boundary or more faces),
-                // omega and G in the near-wall cell are calculated
-                // as an average
-
-                cellBoundaryFaceCount[faceCelli]++;
-
-                omega_[faceCelli] +=
-                    sqrt(k_[faceCelli])
-                   /(Cmu25*kappa_.value()*y_[faceCelli]);
-
-                if (yPlus > yPlusLam_)
-                {
-                    G[faceCelli] +=
-                        (mutw[facei] + muw[facei])
-                       *magFaceGradU[facei]
-                       *Cmu25*sqrt(k_[faceCelli])
-                       /(kappa_.value()*y_[faceCelli]);
-                }
-            }
-        }
-    }
-
-
-    // Perform the averaging
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-                G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-            }
-        }
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C
index 405667906c5447b5d9aa8c7e5f76d1609a2763e4..1e762433f3efbc13193f682a57941e0a4fad15f5 100644
--- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C
+++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -157,12 +159,11 @@ realizableKE::realizableKE
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -170,12 +171,11 @@ realizableKE::realizableKE
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
     mut_
     (
         IOobject
@@ -184,14 +184,31 @@ realizableKE::realizableKE
             runTime_.timeName(),
             mesh_,
             IOobject::NO_READ,
-            IOobject::NO_WRITE
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateMut("mut", mesh_)
+    ),
+    alphat_
+    (
+        IOobject
+        (
+            "alphat",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
         ),
-        rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
+        autoCreateAlphat("alphat", mesh_)
     )
 {
     bound(k_, k0_);
     bound(epsilon_, epsilon0_);
-#   include "wallViscosityI.H"
+
+    mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    mut_.correctBoundaryConditions();
+
+    alphat_ == mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -274,7 +291,13 @@ void realizableKE::correct()
     if (!turbulence_)
     {
         // Re-calculate viscosity
-        mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
+        mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
+        mut_.correctBoundaryConditions();
+
+        // Re-calculate thermal diffusivity
+        alphat_ = mut_/Prt_;
+        alphat_.correctBoundaryConditions();
+
         return;
     }
 
@@ -294,9 +317,10 @@ void realizableKE::correct()
     volScalarField eta = magS*k_/epsilon_;
     volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
 
-    volScalarField G = mut_*(gradU && dev(twoSymm(gradU)));
+    volScalarField G("G", mut_*(gradU && dev(twoSymm(gradU))));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -315,7 +339,7 @@ void realizableKE::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -338,10 +362,12 @@ void realizableKE::correct()
     bound(k_, k0_);
 
     // Re-calculate viscosity
-    mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
+    mut_ == rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
+    mut_.correctBoundaryConditions();
 
+    // Re-calculate thermal diffusivity
+    alphat_ = mut_/Prt_;
+    alphat_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H
index 0eb770f0832b6ca8462551cab38f0d69a901aedc..f997efdd5f8f77aa6eb78125d9e8d2d64eb7c31d 100644
--- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H
+++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H
@@ -91,6 +91,7 @@ class realizableKE
         volScalarField k_;
         volScalarField epsilon_;
         volScalarField mut_;
+        volScalarField alphat_;
 
         tmp<volScalarField> rCmu
         (
@@ -157,7 +158,7 @@ public:
         {
             return tmp<volScalarField>
             (
-                new volScalarField("alphaEff", alphah_*mut_ + alpha())
+                new volScalarField("alphaEff", alphah_*alphat_ + alpha())
             );
         }
 
diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C
index 45384f361236dd4b56b08327be148e5cbb708c21..7bf38a998257449e293f7c5f21013b6315034e58 100644
--- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C
+++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -143,12 +145,11 @@ LRR::LRR
             "R",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateR("R", mesh_)
     ),
-
     k_
     (
         IOobject
@@ -156,12 +157,11 @@ LRR::LRR
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -169,15 +169,26 @@ LRR::LRR
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
-    nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    nut_.correctBoundaryConditions();
 
     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
     {
@@ -289,9 +300,10 @@ void LRR::correct()
     RASModel::correct();
 
     volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
-    volScalarField G = 0.5*tr(P);
+    volScalarField G("G", 0.5*tr(P));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -307,7 +319,7 @@ void LRR::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -369,9 +381,8 @@ void LRR::correct()
 
 
     // Re-calculate viscosity
-    nut_ = Cmu_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/epsilon_;
+    nut_.correctBoundaryConditions();
 
 
     // Correct wall shear stresses
diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
index 47d7773c85d5b1abb75a97759736bfc5c6550743..d67c91a227d7e1f9f58aeed397c53b4cd5d74575 100644
--- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
+++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -172,12 +174,11 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             "R",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateR("R", mesh_)
     ),
-
     k_
     (
         IOobject
@@ -185,12 +186,11 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -198,15 +198,26 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
-    nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    nut_.correctBoundaryConditions();
 
     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
     {
@@ -321,9 +332,10 @@ void LaunderGibsonRSTM::correct()
     }
 
     volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
-    volScalarField G = 0.5*tr(P);
+    volScalarField G("G", 0.5*tr(P));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -339,7 +351,7 @@ void LaunderGibsonRSTM::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -410,10 +422,8 @@ void LaunderGibsonRSTM::correct()
 
 
     // Re-calculate turbulent viscosity
-    nut_ = Cmu_*sqr(k_)/epsilon_;
-
-
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/epsilon_;
+    nut_.correctBoundaryConditions();
 
 
     // Correct wall shear stresses
diff --git a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C
index 5a64ab127caac320a595dfe4dd2f34a782dae714..b347693adc4ce0421a65dc115f2f40e260e123f4 100644
--- a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C
+++ b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -152,12 +154,11 @@ LienCubicKE::LienCubicKE
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -165,10 +166,10 @@ LienCubicKE::LienCubicKE
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
 
     gradU_(fvc::grad(U)),
@@ -179,13 +180,25 @@ LienCubicKE::LienCubicKE
 
     C5viscosity_
     (
-        -2.0*pow(Cmu_, 3.0)*pow(k_, 4.0)/pow(epsilon_, 3.0)*
-        (magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T()))
+      - 2.0*pow3(Cmu_)*pow4(k_)/pow3(epsilon_)
+       *(
+            magSqr(gradU_ + gradU_.T())
+          - magSqr(gradU_ - gradU_.T())
+        )
     ),
 
-    // C5 term, implicit
-    nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_),
-    // turbulent viscosity, with implicit part of C5
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    ),
 
     nonlinearStress_
     (
@@ -215,7 +228,8 @@ LienCubicKE::LienCubicKE
         )
     )
 {
-#   include "wallNonlinearViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_;
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -315,9 +329,14 @@ void LienCubicKE::correct()
     // generation term
     volScalarField S2 = symm(gradU_) && gradU_;
 
-    volScalarField G = Cmu_*sqr(k_)/epsilon_*S2 - (nonlinearStress_ && gradU_);
+    volScalarField G
+    (
+        "G",
+        Cmu_*sqr(k_)/epsilon_*S2 - (nonlinearStress_ && gradU_)
+    );
 
-#   include "nonLinearWallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -332,7 +351,7 @@ void LienCubicKE::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -366,9 +385,8 @@ void LienCubicKE::correct()
         - 2.0*pow(Cmu_, 3.0)*pow(k_, 4.0)/pow(epsilon_, 3.0)
        *(magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T()));
 
-    nut_ = Cmu_*sqr(k_)/epsilon_ + C5viscosity_;
-
-#   include "wallNonlinearViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/epsilon_ + C5viscosity_;
+    nut_.correctBoundaryConditions();
 
     nonlinearStress_ = symm
     (
diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files
index 6584fc611340767ff6d9d63b7d24cbed89ec9047..32b29db2fe88badc50821f82a22538e4341687ed 100644
--- a/src/turbulenceModels/RAS/incompressible/Make/files
+++ b/src/turbulenceModels/RAS/incompressible/Make/files
@@ -19,12 +19,30 @@ LienLeschzinerLowRe/LienLeschzinerLowRe.C
 LamBremhorstKE/LamBremhorstKE.C
 
 /* Wall functions */
-wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
-wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C
-wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C
+wallFunctions = derivedFvPatchFields/wallFunctions
+
+nutWallFunctions = $(wallFunctions)/nutWallFunctions
+$(nutWallFunctions)/nutWallFunction/nutWallFunctionFvPatchScalarField.C
+$(nutWallFunctions)/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C
+$(nutWallFunctions)/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C
+$(nutWallFunctions)/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
+$(nutWallFunctions)/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
+
+epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
+$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
+
+omegaWallFunctions = $(wallFunctions)/omegaWallFunctions
+$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
+
+kQRWallFunctions = $(wallFunctions)/kQRWallFunctions
+$(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C
+
 
 /* Patch fields */
+derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
 derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
 derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
 
+backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
+
 LIB = $(FOAM_LIBBIN)/libincompressibleRASModels
diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C
index b33dcb752f903b3fb235495bd02e98d28b27d7df..46236828f231c127211565fb271596fe04dbcc34 100644
--- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C
+++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C
@@ -45,7 +45,8 @@ void RASModel::printCoeffs()
 {
     if (printCoeffs_)
     {
-        Info<< type() << "Coeffs" << coeffDict_ << endl;;
+        Info<< type() << "Coeffs" << coeffDict_ << nl
+            << "wallFunctionCoeffs" << wallFunctionDict_ << endl;
     }
 }
 
@@ -83,12 +84,13 @@ RASModel::RASModel
     printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
     coeffDict_(subDict(type + "Coeffs")),
 
+    wallFunctionDict_(subDict("wallFunctionCoeffs")),
     kappa_
     (
         dimensioned<scalar>::lookupOrAddToDict
         (
             "kappa",
-            subDict("wallFunctionCoeffs"),
+            wallFunctionDict_,
             0.4187
         )
     ),
@@ -97,10 +99,19 @@ RASModel::RASModel
         dimensioned<scalar>::lookupOrAddToDict
         (
             "E",
-            subDict("wallFunctionCoeffs"),
+            wallFunctionDict_,
             9.0
         )
     ),
+    Cmu_
+    (
+        dimensioned<scalar>::lookupOrAddToDict
+        (
+            "Cmu",
+            wallFunctionDict_,
+            0.09
+        )
+    ),
 
     yPlusLam_(yPlusLam(kappa_.value(), E_.value())),
 
@@ -118,13 +129,13 @@ RASModel::~RASModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-scalar RASModel::yPlusLam(const scalar kappa, const scalar E)
+scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
 {
     scalar ypl = 11.0;
 
     for (int i=0; i<10; i++)
     {
-        ypl = log(E*ypl)/kappa;
+        ypl = log(max(E*ypl, 1))/kappa;
     }
 
     return ypl;
@@ -138,11 +149,10 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
     tmp<scalarField> tYp(new scalarField(curPatch.size()));
     scalarField& Yp = tYp();
 
-    if (typeid(curPatch) == typeid(wallFvPatch))
+    if (isType<wallFvPatch>(curPatch))
     {
-        scalar Cmu(readScalar(coeffDict_.lookup("Cmu")));
-
-        Yp = pow(Cmu, 0.25)*y_[patchNo]
+        Yp = pow(Cmu_.value(), 0.25)
+            *y_[patchNo]
             *sqrt(k()().boundaryField()[patchNo].patchInternalField())
             /nu().boundaryField()[patchNo];
     }
@@ -150,10 +160,9 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
     {
         WarningIn
         (
-            "tmp<scalarField> RASModel::yPlus(const label patchNo)"
-        )   << "const : " << endl
-            << "Patch " << patchNo << " is not a wall.  Returning blank field"
-            << endl;
+            "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
+        )   << "Patch " << patchNo << " is not a wall. Returning null field"
+            << nl << endl;
 
         Yp.setSize(0);
     }
@@ -178,8 +187,10 @@ bool RASModel::read()
         lookup("turbulence") >> turbulence_;
         coeffDict_ = subDict(type() + "Coeffs");
 
-        kappa_.readIfPresent(subDict("wallFunctionCoeffs"));
-        E_.readIfPresent(subDict("wallFunctionCoeffs"));
+        wallFunctionDict_ = subDict("wallFunctionCoeffs");
+        kappa_.readIfPresent(wallFunctionDict_);
+        E_.readIfPresent(wallFunctionDict_);
+        Cmu_.readIfPresent(wallFunctionDict_);
 
         yPlusLam_ = yPlusLam(kappa_.value(), E_.value());
 
diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H
index 345565fbab458a5437791e18680d3f17f8f32685..b5edce3ea3137fd99de9f58072812b7d4204e91f 100644
--- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H
+++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H
@@ -88,10 +88,11 @@ protected:
         Switch printCoeffs_;
         dictionary coeffDict_;
 
+        dictionary wallFunctionDict_;
         dimensionedScalar kappa_;
         dimensionedScalar E_;
+        dimensionedScalar Cmu_;
 
-        scalar yPlusLam(const scalar kappa, const scalar E);
         scalar yPlusLam_;
 
         dimensionedScalar k0_;
@@ -192,7 +193,6 @@ public:
                 return epsilonSmall_;
             }
 
-
             //- Allow k0 to be changed
             dimensionedScalar& k0()
             {
@@ -211,7 +211,6 @@ public:
                 return epsilonSmall_;
             }
 
-
             //- Return kappa for use in wall-functions
             dimensionedScalar kappa() const
             {
@@ -224,6 +223,21 @@ public:
                 return E_;
             }
 
+            //- Return Cmu for use in wall-functions
+            dimensionedScalar Cmu() const
+            {
+                return Cmu_;
+            }
+
+            //- Return the near wall distances
+            const nearWallDist& y() const
+            {
+                return y_;
+            }
+
+            //- Calculate y+ at the edge of the laminar sublayer
+            scalar yPlusLam(const scalar kappa, const scalar E) const;
+
             //- Return y+ at the edge of the laminar sublayer
             //  for use in wall-functions
             scalar yPlusLam() const
@@ -237,6 +251,12 @@ public:
                 return coeffDict_;
             }
 
+            //- Const access to the wall functions coefficients dictionary
+            const dictionary& walLFunctionDict() const
+            {
+                return wallFunctionDict_;
+            }
+
 
         //- Return the laminar viscosity
         const volScalarField& nu() const
diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C
index 602adee89bf61f1792cfe21b353068b6633daf15..3c98bfec9e3e856bea4b7e9b83e013488d60fc6e 100644
--- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C
+++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -124,12 +126,11 @@ RNGkEpsilon::RNGkEpsilon
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -137,15 +138,26 @@ RNGkEpsilon::RNGkEpsilon
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
-    nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -239,13 +251,14 @@ void RNGkEpsilon::correct()
 
     volScalarField S2 = 2*magSqr(symm(fvc::grad(U_)));
 
-    volScalarField G = nut_*S2;
+    volScalarField G("G", nut_*S2);
 
     volScalarField eta = sqrt(S2)*k_/epsilon_;
     volScalarField R =
         ((eta*(scalar(1) - eta/eta0_))/(scalar(1) + beta_*eta*sqr(eta)));
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -261,7 +274,7 @@ void RNGkEpsilon::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -284,10 +297,8 @@ void RNGkEpsilon::correct()
 
 
     // Re-calculate viscosity
-    nut_ = Cmu_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
-
+    nut_ == Cmu_*sqr(k_)/epsilon_;
+    nut_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
new file mode 100644
index 0000000000000000000000000000000000000000..4e8352414df2d65f8d188d18170323e17237f5f6
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C
@@ -0,0 +1,215 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "backwardsCompatibilityWallFunctions.H"
+
+#include "calculatedFvPatchField.H"
+#include "nutWallFunctionFvPatchScalarField.H"
+#include "epsilonWallFunctionFvPatchScalarField.H"
+#include "kQRWallFunctionFvPatchField.H"
+#include "omegaWallFunctionFvPatchScalarField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+tmp<volScalarField> autoCreateNut
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    IOobject nutHeader
+    (
+        fieldName,
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE,
+        false
+    );
+
+    if (nutHeader.headerOk())
+    {
+        return tmp<volScalarField>(new volScalarField(nutHeader, mesh));
+    }
+    else
+    {
+        Info<< "--> Upgrading " << fieldName << " to employ run-time "
+            << "selectable wall functions" << endl;
+
+        const fvBoundaryMesh& bm = mesh.boundary();
+
+        wordList nutBoundaryTypes(bm.size());
+
+        forAll(bm, patchI)
+        {
+            if (isType<wallFvPatch>(bm[patchI]))
+            {
+                nutBoundaryTypes[patchI] =
+                    RASModels::nutWallFunctionFvPatchScalarField::typeName;
+            }
+            else
+            {
+                nutBoundaryTypes[patchI] =
+                    calculatedFvPatchField<scalar>::typeName;
+            }
+        }
+
+        tmp<volScalarField> nut
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh,
+                dimensionedScalar("zero", dimArea/dimTime, 0.0),
+                nutBoundaryTypes
+            )
+        );
+
+        Info<< "    Writing updated " << fieldName << endl;
+        nut().write();
+
+        return nut;
+    }
+}
+
+
+tmp<volScalarField> autoCreateEpsilon
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::epsilonWallFunctionFvPatchScalarField
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateOmega
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::omegaWallFunctionFvPatchScalarField
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateK
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::kQRWallFunctionFvPatchField<scalar>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volScalarField> autoCreateQ
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            scalar,
+            RASModels::kQRWallFunctionFvPatchField<scalar>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+tmp<volSymmTensorField> autoCreateR
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    return
+        autoCreateWallFunctionField
+        <
+            symmTensor,
+            RASModels::kQRWallFunctionFvPatchField<symmTensor>
+        >
+        (
+            fieldName,
+            mesh
+        );
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
+
diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H
new file mode 100644
index 0000000000000000000000000000000000000000..28ba0652143650b932d22ebf356e144caf3c99cc
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H
@@ -0,0 +1,116 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::incompressible
+
+Description
+    Auto creation of fields to provide backwards compatibility with
+    runtime selectable wall functions
+
+SourceFiles
+    backwardsCompatibilityWallFunctions.C
+    backwardsCompatibilityWallFunctionsTemplates.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef backwardsCompatibilityWallFunctions_H
+#define backwardsCompatibilityWallFunctions_H
+
+#include "fvMesh.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+    //- nut
+    tmp<volScalarField> autoCreateNut
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- epsilon
+    tmp<volScalarField> autoCreateEpsilon
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- omega
+    tmp<volScalarField> autoCreateOmega
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- k
+    tmp<volScalarField> autoCreateK
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- Q
+    tmp<volScalarField> autoCreateQ
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- R
+    tmp<volSymmTensorField> autoCreateR
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+    //- Helper function to create the new field
+    template<class Type, class PatchType>
+    tmp<GeometricField<Type, fvPatchField, volMesh> >
+    autoCreateWallFunctionField
+    (
+        const word& fieldName,
+        const fvMesh& mesh
+    );
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "backwardsCompatibilityWallFunctionsTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..9b6850bc9464d86f52a3cc3288ea7185e8578c22
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C
@@ -0,0 +1,166 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "backwardsCompatibilityWallFunctions.H"
+#include "Time.H"
+
+#include "wallPolyPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template<class Type, class PatchType>
+tmp<GeometricField<Type, fvPatchField, volMesh> >
+autoCreateWallFunctionField
+(
+    const word& fieldName,
+    const fvMesh& mesh
+)
+{
+    IOobject nutHeader
+    (
+        "nut",
+        mesh.time().timeName(),
+        mesh,
+        IOobject::MUST_READ
+    );
+
+    typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
+
+    if (nutHeader.headerOk())
+    {
+        return tmp<fieldType>
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh
+            )
+        );
+    }
+    else
+    {
+        Info<< "--> Upgrading " << fieldName << " to employ run-time "
+            << "selectable wall functions" << endl;
+
+        // Read existing epsilon field
+        tmp<fieldType> fieldOrig
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh
+            )
+        );
+
+        PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
+
+        forAll(newPatchFields, patchI)
+        {
+            if (isType<wallPolyPatch>(mesh.boundaryMesh()[patchI]))
+            {
+                newPatchFields.set
+                (
+                    patchI,
+                    new PatchType
+                    (
+                        mesh.boundary()[patchI],
+                        fieldOrig().dimensionedInternalField()
+                    )
+                );
+                newPatchFields[patchI] == fieldOrig().boundaryField()[patchI];
+            }
+            else
+            {
+                newPatchFields.set
+                (
+                    patchI,
+                    fieldOrig().boundaryField()[patchI].clone()
+                );
+            }
+        }
+
+        tmp<fieldType> fieldNew
+        (
+            new fieldType
+            (
+                IOobject
+                (
+                    fieldName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE,
+                    false
+                ),
+                mesh,
+                fieldOrig().dimensions(),
+                fieldOrig().internalField(),
+                newPatchFields
+            )
+        );
+
+        Info<< "    Writing backup of original " << fieldName << " to "
+            << fieldName << ".old" << endl;
+        fieldOrig().rename(fieldName + ".old");
+        fieldOrig().write();
+
+        Info<< "    Writing updated " << fieldName << endl;
+        fieldNew().write();
+
+        return fieldNew;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..f51ccb7251d24134dcee605d64d3d4c4c32455ac
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
@@ -0,0 +1,191 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "turbulentHeatFluxTemperatureFvPatchScalarField.H"
+#include "addToRunTimeSelectionTable.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedGradientFvPatchScalarField(p, iF),
+    q_(p.size(), 0.0),
+    alphaEffName_("undefinedAlphaEff"),
+    CpName_("undefinedCp")
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
+    q_(ptf.q_, mapper),
+    alphaEffName_(ptf.alphaEffName_),
+    CpName_(ptf.CpName_)
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedGradientFvPatchScalarField(p, iF),
+    q_("q", dict, p.size()),
+    alphaEffName_(dict.lookup("alphaEff")),
+    CpName_(dict.lookup("Cp"))
+{
+    fvPatchField<scalar>::operator=(patchInternalField());
+    gradient() = 0.0;
+}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf
+)
+:
+    fixedGradientFvPatchScalarField(thftpsf),
+    q_(thftpsf.q_),
+    alphaEffName_(thftpsf.alphaEffName_),
+    CpName_(thftpsf.CpName_)
+{}
+
+
+turbulentHeatFluxTemperatureFvPatchScalarField::
+turbulentHeatFluxTemperatureFvPatchScalarField
+(
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedGradientFvPatchScalarField(thftpsf, iF),
+    q_(thftpsf.q_),
+    alphaEffName_(thftpsf.alphaEffName_),
+    CpName_(thftpsf.CpName_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap
+(
+    const fvPatchFieldMapper& m
+)
+{
+    scalarField::autoMap(m);
+    q_.autoMap(m);
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::rmap
+(
+    const fvPatchScalarField& ptf,
+    const labelList& addr
+)
+{
+    fixedGradientFvPatchScalarField::rmap(ptf, addr);
+
+    const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf =
+        refCast<const turbulentHeatFluxTemperatureFvPatchScalarField>
+        (
+            ptf
+        );
+
+    q_.rmap(thftptf.q_, addr);
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
+{
+    if (updated())
+    {
+        return;
+    }
+
+    const scalarField& alphaEffp =
+        patch().lookupPatchField<volScalarField, scalar>(alphaEffName_);
+
+    const scalarField& Cpp =
+        patch().lookupPatchField<volScalarField, scalar>(CpName_);
+
+    gradient() = q_/(Cpp*alphaEffp);
+
+    fixedGradientFvPatchScalarField::updateCoeffs();
+}
+
+
+void turbulentHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const
+{
+    fixedGradientFvPatchScalarField::write(os);
+    q_.writeEntry("q", os);
+    os.writeKeyword("alphaEff") << alphaEffName_ << token::END_STATEMENT << nl;
+    os.writeKeyword("Cp") << CpName_ << token::END_STATEMENT << nl;
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    turbulentHeatFluxTemperatureFvPatchScalarField
+);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace incompressible
+} // End namespace Foam
+
+
+// ************************************************************************* //
+
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..de677f0e91b0ac91a0c72e978e1f3158a034f2d5
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H
@@ -0,0 +1,179 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::turbulentHeatFluxTemperatureFvPatchScalarField
+
+Description
+    Fixed heat flux boundary condition for temperature.
+
+SourceFiles
+    turbulentHeatFluxTemperatureFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H
+#define turbulentHeatFluxTemperatureFvPatchScalarFields_H
+
+#include "fvPatchFields.H"
+#include "fixedGradientFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+
+/*---------------------------------------------------------------------------*\
+       Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class turbulentHeatFluxTemperatureFvPatchScalarField
+:
+    public fixedGradientFvPatchScalarField
+{
+// Private data
+
+    //- Heat flux [W/m2]
+    scalarField q_;
+
+    //- Name of effective thermal diffusivity field
+    word alphaEffName_;
+
+    //- Name of specific heat capacity field
+    word CpName_;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("turbulentHeatFluxTemperature");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  turbulentHeatFluxTemperatureFvPatchScalarField onto
+        //  a new patch
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new turbulentHeatFluxTemperatureFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        turbulentHeatFluxTemperatureFvPatchScalarField
+        (
+            const turbulentHeatFluxTemperatureFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new turbulentHeatFluxTemperatureFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+
+    // Member functions
+
+        // Mapping functions
+
+            //- Map (and resize as needed) from self given a mapping object
+            virtual void autoMap(const fvPatchFieldMapper&);
+
+            //- Reverse map the given fvPatchField onto this fvPatchField
+            virtual void rmap
+            (
+                const fvPatchScalarField&,
+                const labelList&
+            );
+
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..a4f0bd13f751fb797a6d1668f901b6c179f19db6
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
@@ -0,0 +1,213 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "epsilonWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void epsilonWallFunctionFvPatchScalarField::checkType()
+{
+    if (!isA<wallFvPatch>(patch()))
+    {
+        FatalErrorIn("epsilonWallFunctionFvPatchScalarField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << patch().type() << nl << endl
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF, dict)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ewfpsf
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf)
+{
+    checkType();
+}
+
+
+epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
+(
+    const epsilonWallFunctionFvPatchScalarField& ewfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar Cmu75 = pow(Cmu, 0.75);
+    const scalar kappa = ras.kappa().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    volScalarField& G = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("G"));
+
+    volScalarField& epsilon = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("epsilon"));
+
+    const volScalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& nuw =
+        patch().lookupPatchField<volScalarField, scalar>("nu");
+
+    const scalarField& nutw =
+        patch().lookupPatchField<volScalarField, scalar>("nut");
+
+    const fvPatchVectorField& Uw =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    const scalarField magGradUw = mag(Uw.snGrad());
+
+    // Set epsilon and G
+    forAll(nutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
+
+        epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]);
+
+        if (yPlus > yPlusLam)
+        {
+            G[faceCellI] =
+                (nutw[faceI] + nuw[faceI])
+               *magGradUw[faceI]
+               *Cmu25*sqrt(k[faceCellI])
+               /(kappa*y[faceI]);
+        }
+        else
+        {
+            G[faceCellI] = 0.0;
+        }
+    }
+
+    // TODO: perform averaging for cells sharing more than one boundary face
+}
+
+
+void epsilonWallFunctionFvPatchScalarField::evaluate
+(
+    const Pstream::commsTypes commsType
+)
+{
+    fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
+}
+
+
+void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fixedInternalValueFvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    epsilonWallFunctionFvPatchScalarField
+);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..7e81a50a342a6029ecff4673fcc9c4ed4c687ebc
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
@@ -0,0 +1,164 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::incompressible::RASModels::epsilonWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for epsilon when using wall functions
+    - calculates epsilon and G
+    - epsilon values added directly into the matrix to act as a constraint
+
+SourceFiles
+    epsilonWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef epsilonWallFunctionFvPatchScalarField_H
+#define epsilonWallFunctionFvPatchScalarField_H
+
+#include "fixedInternalValueFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+           Class epsilonWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class epsilonWallFunctionFvPatchScalarField
+:
+    public fixedInternalValueFvPatchField<scalar>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("epsilonWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  epsilonWallFunctionFvPatchScalarField
+        //  onto a new patch
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new epsilonWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        epsilonWallFunctionFvPatchScalarField
+        (
+            const epsilonWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new epsilonWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+            //- Evaluate the patchField
+            virtual void evaluate(const Pstream::commsTypes);
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C
new file mode 100644
index 0000000000000000000000000000000000000000..afe0cd24c84a613b77c31de4188382e0fb228c73
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C
@@ -0,0 +1,155 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "kQRWallFunctionFvPatchField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::checkType()
+{
+    if (!isA<wallFvPatch>(this->patch()))
+    {
+        FatalErrorIn("kQRWallFunctionFvPatchField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << this->patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << this->patch().type() << nl << endl
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& ptf,
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    zeroGradientFvPatchField<Type>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    zeroGradientFvPatchField<Type>(p, iF, dict)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& tkqrwfpf
+)
+:
+    zeroGradientFvPatchField<Type>(tkqrwfpf)
+{
+    checkType();
+}
+
+
+template<class Type>
+kQRWallFunctionFvPatchField<Type>::kQRWallFunctionFvPatchField
+(
+    const kQRWallFunctionFvPatchField& tkqrwfpf,
+    const DimensionedField<Type, volMesh>& iF
+)
+:
+    zeroGradientFvPatchField<Type>(tkqrwfpf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::evaluate
+(
+    const Pstream::commsTypes commsType
+)
+{
+    zeroGradientFvPatchField<Type>::evaluate(commsType);
+}
+
+
+template<class Type>
+void kQRWallFunctionFvPatchField<Type>::write(Ostream& os) const
+{
+    zeroGradientFvPatchField<Type>::write(os);
+    this->writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H
new file mode 100644
index 0000000000000000000000000000000000000000..719836cf8ff11d1a0a30889e2026a266637ffef9
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H
@@ -0,0 +1,170 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::incompressible::RASModels::kQRWallFunctionFvPatchField
+
+Description
+    Boundary condition for turbulence k, Q, and R when using wall functions.
+    Simply acts as a zero gradient condition.
+
+SourceFiles
+    kQRWallFunctionFvPatchField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef kQRWallFunctionFvPatchField_H
+#define kQRWallFunctionFvPatchField_H
+
+#include "zeroGradientFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+                Class kQRWallFunctionFvPatchField Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class Type>
+class kQRWallFunctionFvPatchField
+:
+    public zeroGradientFvPatchField<Type>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("kQRWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        kQRWallFunctionFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        kQRWallFunctionFvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        // kQRWallFunctionFvPatchField
+        //  onto a new patch
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&,
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchField<Type> > clone() const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new kQRWallFunctionFvPatchField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        kQRWallFunctionFvPatchField
+        (
+            const kQRWallFunctionFvPatchField&,
+            const DimensionedField<Type, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchField<Type> > clone
+        (
+            const DimensionedField<Type, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchField<Type> >
+            (
+                new kQRWallFunctionFvPatchField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Evaluate the patchField
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::Pstream::blocking
+            );
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "kQRWallFunctionFvPatchField.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C
new file mode 100644
index 0000000000000000000000000000000000000000..4378e877235628d538e0574c6cba6558064320d1
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "kQRWallFunctionFvPatchFields.H"
+#include "fvPatchFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+makePatchFields(kQRWallFunction);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H
new file mode 100644
index 0000000000000000000000000000000000000000..f7a312a78053f9d606e510c08fcc552fc4629107
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H
@@ -0,0 +1,56 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 kQRWallFunctionFvPatchFields_H
+#define kQRWallFunctionFvPatchFields_H
+
+#include "kQRWallFunctionFvPatchField.H"
+#include "fieldTypes.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeFieldTypedefs(kQRWallFunction)
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..b4fd633432bfe6976dfaf4a824391a67223ddf38
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C
@@ -0,0 +1,245 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "nutRoughWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+scalar nutRoughWallFunctionFvPatchScalarField::fnRough
+(
+    const scalar KsPlus,
+    const scalar Cs,
+    const scalar kappa
+) const
+{
+    // Set deltaB based on non-dimensional roughness height
+    scalar deltaB = 0.0;
+    if (KsPlus < 90.0)
+    {
+        deltaB =
+            1.0/kappa
+            *log((KsPlus - 2.25)/87.75 + Cs*KsPlus)
+            *sin(0.4258*(log(KsPlus) - 0.811));
+    }
+    else
+    {
+        deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus);
+    }
+
+    return exp(min(deltaB*kappa, 50.0));
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+nutRoughWallFunctionFvPatchScalarField::
+nutRoughWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF),
+    Ks_(p.size(), 0.0),
+    Cs_(p.size(), 0.0)
+{}
+
+
+nutRoughWallFunctionFvPatchScalarField::
+nutRoughWallFunctionFvPatchScalarField
+(
+    const nutRoughWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper),
+    Ks_(ptf.Ks_, mapper),
+    Cs_(ptf.Cs_, mapper)
+{}
+
+
+nutRoughWallFunctionFvPatchScalarField::
+nutRoughWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict),
+    Ks_("Ks", dict, p.size()),
+    Cs_("Cs", dict, p.size())
+{}
+
+
+nutRoughWallFunctionFvPatchScalarField::
+nutRoughWallFunctionFvPatchScalarField
+(
+    const nutRoughWallFunctionFvPatchScalarField& nrwfpsf
+)
+:
+    fixedValueFvPatchScalarField(nrwfpsf),
+    Ks_(nrwfpsf.Ks_),
+    Cs_(nrwfpsf.Cs_)
+{}
+
+
+nutRoughWallFunctionFvPatchScalarField::
+nutRoughWallFunctionFvPatchScalarField
+(
+    const nutRoughWallFunctionFvPatchScalarField& nrwfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(nrwfpsf, iF),
+    Ks_(nrwfpsf.Ks_),
+    Cs_(nrwfpsf.Cs_)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void nutRoughWallFunctionFvPatchScalarField::autoMap
+(
+    const fvPatchFieldMapper& m
+)
+{
+    fixedValueFvPatchScalarField::autoMap(m);
+    Ks_.autoMap(m);
+    Cs_.autoMap(m);
+}
+
+
+void nutRoughWallFunctionFvPatchScalarField::rmap
+(
+    const fvPatchScalarField& ptf,
+    const labelList& addr
+)
+{
+    fixedValueFvPatchScalarField::rmap(ptf, addr);
+
+    const nutRoughWallFunctionFvPatchScalarField& nrwfpsf =
+        refCast<const nutRoughWallFunctionFvPatchScalarField>(ptf);
+
+    Cs_.rmap(nrwfpsf.Cs_, addr);
+    Ks_.rmap(nrwfpsf.Ks_, addr);
+}
+
+
+void nutRoughWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar kappa = ras.kappa().value();
+    const scalar E = ras.E().value();
+    scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    const scalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& nuw =
+        patch().lookupPatchField<volScalarField, scalar>("nu");
+
+    scalarField& nutw = *this;
+
+    forAll(nutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar uStar = Cmu25*sqrt(k[faceCellI]);
+
+        scalar yPlus = uStar*y[faceI]/nuw[faceI];
+
+        scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI];
+
+        scalar Edash = E;
+        scalar yPlusLamNew = yPlusLam;
+        if (KsPlus > 2.25)
+        {
+            Edash = E/fnRough(KsPlus, Cs_[faceI], kappa);
+            yPlusLam = ras.yPlusLam(kappa, Edash);
+        }
+
+        if (debug)
+        {
+            Info<< "yPlus = " << yPlus
+                << ", KsPlus = " << KsPlus
+                << ", Edash = " << Edash
+                << ", yPlusLam = " << yPlusLam
+                << endl;
+        }
+
+        if (yPlus > yPlusLamNew)
+        {
+            nutw[faceI] = nuw[faceI]*(yPlus*kappa/log(Edash*yPlus) - 1);
+        }
+        else
+        {
+            nutw[faceI] = 0.0;
+        }
+    }
+}
+
+
+void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fvPatchField<scalar>::write(os);
+    Cs_.writeEntry("Cs", os);
+    Ks_.writeEntry("Ks", os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, nutRoughWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..299e55cc03c7e55028bf78bc5764f09cdf3764c3
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H
@@ -0,0 +1,194 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::incompressible::RASModels::nutRoughWallFunctionFvPatchScalarField
+
+Description
+    Boundary condition for turbulent (kinematic) viscosity when using wall
+    functions for rough walls.
+
+    Manipulates the E parameter to account for roughness effects, based on
+    KsPlus.
+
+    - roughness height = sand-grain roughness (0 for smooth walls)
+    - roughness constant = 0.5-1.0 (0.5 default)
+
+SourceFiles
+    nutRoughWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef nutRoughWallFunctionFvPatchScalarField_H
+#define nutRoughWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+           Class nutRoughWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class nutRoughWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+    // Private data
+
+        //- Roughness height
+        scalarField Ks_;
+
+        //- Roughness constant
+        scalarField Cs_;
+
+
+    // Private member functions
+
+        //- Compute the roughness function
+        scalar fnRough
+        (
+            const scalar KsPlus,
+            const scalar Cs,
+            const scalar kappa
+        ) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("nutRoughWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        nutRoughWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        nutRoughWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  nutRoughWallFunctionFvPatchScalarField
+        //  onto a new patch
+        nutRoughWallFunctionFvPatchScalarField
+        (
+            const nutRoughWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        nutRoughWallFunctionFvPatchScalarField
+        (
+            const nutRoughWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new nutRoughWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        nutRoughWallFunctionFvPatchScalarField
+        (
+            const nutRoughWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new nutRoughWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Mapping functions
+
+            //- Map (and resize as needed) from self given a mapping object
+            virtual void autoMap
+            (
+                const fvPatchFieldMapper&
+            );
+
+            //- Reverse map the given fvPatchField onto this fvPatchField
+            virtual void rmap
+            (
+                const fvPatchScalarField&,
+                const labelList&
+            );
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
similarity index 85%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
index cf74e31813342c26ce18c73a0050b083a9b9a929..0455576df4d6d3331d0de5e49468b99b5b630b24 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "nutStandardRoughWallFunctionFvPatchScalarField.H"
+#include "nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H"
 #include "RASModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,8 +41,8 @@ namespace RASModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-nutStandardRoughWallFunctionFvPatchScalarField::
-nutStandardRoughWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -55,10 +55,10 @@ nutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardRoughWallFunctionFvPatchScalarField::
-nutStandardRoughWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const nutStandardRoughWallFunctionFvPatchScalarField& ptf,
+    const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -71,8 +71,8 @@ nutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardRoughWallFunctionFvPatchScalarField::
-nutStandardRoughWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -86,10 +86,10 @@ nutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardRoughWallFunctionFvPatchScalarField::
-nutStandardRoughWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const nutStandardRoughWallFunctionFvPatchScalarField& tppsf
+    const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf),
@@ -99,10 +99,10 @@ nutStandardRoughWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardRoughWallFunctionFvPatchScalarField::
-nutStandardRoughWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 (
-    const nutStandardRoughWallFunctionFvPatchScalarField& tppsf,
+    const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -115,16 +115,15 @@ nutStandardRoughWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void nutStandardRoughWallFunctionFvPatchScalarField::evaluate
+void nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
 (
     const Pstream::commsTypes
 )
 {
-    const RASModel& rasModel
-        = db().lookupObject<RASModel>("RASProperties");
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
 
-    const scalar kappa = rasModel.kappa().value();
-    const scalar E = rasModel.E().value();
+    const scalar kappa = ras.kappa().value();
+    const scalar E = ras.E().value();
     const scalar yPlusLam = 11.225;
 
     // The reciprical of the distance to the adjacent cell centre.
@@ -142,7 +141,7 @@ void nutStandardRoughWallFunctionFvPatchScalarField::evaluate
 
     scalarField magFaceGradU = mag(U.snGrad());
 
-    if(roughnessHeight_ > 0.0)
+    if (roughnessHeight_ > 0.0)
     {
         // Rough Walls.
         const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_;
@@ -208,7 +207,7 @@ void nutStandardRoughWallFunctionFvPatchScalarField::evaluate
                     }
 
                     scalar denom = 1.0 + log(E* yPlus) - G - yPlusGPrime;
-                    if(mag(denom) > VSMALL)
+                    if (mag(denom) > VSMALL)
                     {
                         yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom;
                     }
@@ -271,7 +270,10 @@ void nutStandardRoughWallFunctionFvPatchScalarField::evaluate
 }
 
 
-void nutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
+void nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write
+(
+    Ostream& os
+) const
 {
     fixedValueFvPatchScalarField::write(os);
     os.writeKeyword("roughnessHeight")
@@ -288,7 +290,7 @@ void nutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
 makePatchTypeField
 (
     fvPatchScalarField,
-    nutStandardRoughWallFunctionFvPatchScalarField
+    nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 );
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
similarity index 76%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
index df3007b10f14a6d4fe7932c755b82861cae7687f..2806288b2a9c0493eff31f3774dfd4ce0676fbce 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H
@@ -23,18 +23,19 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::incompressible::RASModels::nutStandardRoughWallFunctionFvPatchScalarField
+    Foam::incompressible::RASModels::
+    nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 
 Description
     Wall function boundary condition for rough walls
 
 SourceFiles
-    nutStandardWallFunctionFvPatchScalarField.C
+    nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef nutStandardRoughWallFunctionFvPatchScalarField_H
-#define nutStandardRoughWallFunctionFvPatchScalarField_H
+#ifndef nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
+#define nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
@@ -48,10 +49,10 @@ namespace RASModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class nutWallFunctionFvPatch Declaration
+Class nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
-class nutStandardRoughWallFunctionFvPatchScalarField
+class nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
@@ -65,20 +66,20 @@ class nutStandardRoughWallFunctionFvPatchScalarField
 public:
 
     //- Runtime type information
-    TypeName("nutStandardRoughWallFunction");
+    TypeName("nutSpalartAllmarasStandardRoughWallFunction");
 
 
     // Constructors
 
         //- Construct from patch and internal field
-        nutStandardRoughWallFunctionFvPatchScalarField
+        nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&
         );
 
         //- Construct from patch, internal field and dictionary
-        nutStandardRoughWallFunctionFvPatchScalarField
+        nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
@@ -86,20 +87,20 @@ public:
         );
 
         //- Construct by mapping given
-        //  nutStandardRoughWallFunctionFvPatchScalarField
+        //  nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         //  onto a new patch
-        nutStandardRoughWallFunctionFvPatchScalarField
+        nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const nutStandardRoughWallFunctionFvPatchScalarField&,
+            const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&,
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const fvPatchFieldMapper&
         );
 
         //- Construct as copy
-        nutStandardRoughWallFunctionFvPatchScalarField
+        nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const nutStandardRoughWallFunctionFvPatchScalarField&
+            const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&
         );
 
         //- Construct and return a clone
@@ -107,14 +108,17 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nutStandardRoughWallFunctionFvPatchScalarField(*this)
+                new nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
+                (
+                    *this
+                )
             );
         }
 
         //- Construct as copy setting internal field reference
-        nutStandardRoughWallFunctionFvPatchScalarField
+        nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
         (
-            const nutStandardRoughWallFunctionFvPatchScalarField&,
+            const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&,
             const DimensionedField<scalar, volMesh>&
         );
 
@@ -126,7 +130,11 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nutStandardRoughWallFunctionFvPatchScalarField(*this, iF)
+                new nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
             );
         }
 
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
similarity index 74%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
index ddbb42425577a9a6fff83ca009bc940ad956efcf..c60e065f0522d6e668495d83cd3c4d9a02b4f901 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "nutStandardWallFunctionFvPatchScalarField.H"
+#include "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
 #include "RASModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,8 +41,8 @@ namespace RASModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-nutStandardWallFunctionFvPatchScalarField::
-nutStandardWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -52,10 +52,10 @@ nutStandardWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardWallFunctionFvPatchScalarField::
-nutStandardWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
 (
-    const nutStandardWallFunctionFvPatchScalarField& ptf,
+    const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -65,8 +65,8 @@ nutStandardWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardWallFunctionFvPatchScalarField::
-nutStandardWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -77,20 +77,20 @@ nutStandardWallFunctionFvPatchScalarField
 {}
 
 
-nutStandardWallFunctionFvPatchScalarField::
-nutStandardWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
 (
-    const nutStandardWallFunctionFvPatchScalarField& tppsf
+    const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf)
 {}
 
 
-nutStandardWallFunctionFvPatchScalarField::
-nutStandardWallFunctionFvPatchScalarField
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
+nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
 (
-    const nutStandardWallFunctionFvPatchScalarField& tppsf,
+    const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -100,17 +100,16 @@ nutStandardWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void nutStandardWallFunctionFvPatchScalarField::evaluate
+void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate
 (
     const Pstream::commsTypes
 )
 {
-    const RASModel& rasModel
-        = db().lookupObject<RASModel>("RASProperties");
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
 
-    scalar kappa = rasModel.kappa().value();
-    scalar E = rasModel.E().value();
-    scalar yPlusLam = rasModel.yPlusLam();
+    scalar kappa = ras.kappa().value();
+    scalar E = ras.E().value();
+    scalar yPlusLam = ras.yPlusLam();
 
     const scalarField& ry = patch().deltaCoeffs();
 
@@ -158,7 +157,11 @@ void nutStandardWallFunctionFvPatchScalarField::evaluate
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-makePatchTypeField(fvPatchScalarField, nutStandardWallFunctionFvPatchScalarField);
+makePatchTypeField
+(
+    fvPatchScalarField,
+    nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..51ecc156f762bd97379361eea4332d575d01083e
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H
@@ -0,0 +1,160 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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::incompressible::RASModels::
+    nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+
+Description
+    Wall function boundary condition for walls
+
+SourceFiles
+    nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
+#define nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
+
+#include "fixedValueFvPatchFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+  Class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+:
+    public fixedValueFvPatchScalarField
+{
+    // Private data
+
+
+public:
+
+    //- Runtime type information
+    TypeName("nutSpalartAllmarasStandardWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        //  nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        //  onto a new patch
+        nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+                (
+                    *this
+                )
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+        (
+            const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
+                (
+                    *this,
+                    iF
+                )
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Evaluate the patchField
+            virtual void evaluate
+            (
+                const Pstream::commsTypes commsType=Pstream::blocking
+            );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C
similarity index 78%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C
index 2fab6a7429d55883449c07959d6aa965ee9d1e57..6e37a19949af017f24d2be670c507b0448efd309 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C
@@ -24,7 +24,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "nutWallFunctionFvPatchScalarField.H"
+#include "nutSpalartAllmarasWallFunctionFvPatchScalarField.H"
 #include "RASModel.H"
 #include "fvPatchFieldMapper.H"
 #include "volFields.H"
@@ -41,7 +41,8 @@ namespace RASModels
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
+nutSpalartAllmarasWallFunctionFvPatchScalarField::
+nutSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -51,9 +52,10 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
 {}
 
 
-nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
+nutSpalartAllmarasWallFunctionFvPatchScalarField::
+nutSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nutWallFunctionFvPatchScalarField& ptf,
+    const nutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
@@ -63,7 +65,8 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
 {}
 
 
-nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
+nutSpalartAllmarasWallFunctionFvPatchScalarField::
+nutSpalartAllmarasWallFunctionFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -74,18 +77,20 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
 {}
 
 
-nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
+nutSpalartAllmarasWallFunctionFvPatchScalarField::
+nutSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nutWallFunctionFvPatchScalarField& tppsf
+    const nutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf
 )
 :
     fixedValueFvPatchScalarField(tppsf)
 {}
 
 
-nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
+nutSpalartAllmarasWallFunctionFvPatchScalarField::
+nutSpalartAllmarasWallFunctionFvPatchScalarField
 (
-    const nutWallFunctionFvPatchScalarField& tppsf,
+    const nutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
@@ -95,13 +100,15 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void nutWallFunctionFvPatchScalarField::evaluate(const Pstream::commsTypes)
+void nutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate
+(
+    const Pstream::commsTypes
+)
 {
-    const RASModel& rasModel
-        = db().lookupObject<RASModel>("RASProperties");
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
 
-    scalar kappa = rasModel.kappa().value();
-    scalar E = rasModel.E().value();
+    scalar kappa = ras.kappa().value();
+    scalar E = ras.E().value();
 
     const scalarField& ry = patch().deltaCoeffs();
 
@@ -162,7 +169,7 @@ void nutWallFunctionFvPatchScalarField::evaluate(const Pstream::commsTypes)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField);
+makePatchTypeField(fvPatchScalarField, nutSpalartAllmarasWallFunctionFvPatchScalarField);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H
similarity index 75%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H
index f4042e7f5f03a02de54d1184ae940a47c4065a18..70f1107de3de0eaf0e6f273fafe30c6c5367afa9 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H
@@ -23,18 +23,19 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Class
-    Foam::incompressible::RASModels::nutStandardWallFunctionFvPatchScalarField
+    Foam::incompressible::RASModels::
+    nutSpalartAllmarasWallFunctionFvPatchScalarField
 
 Description
     Wall function boundary condition for walls
 
 SourceFiles
-    nutStandardWallFunctionFvPatchScalarField.C
+    nutSpalartAllmarasWallFunctionFvPatchScalarField.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef nutStandardWallFunctionFvPatchScalarField_H
-#define nutStandardWallFunctionFvPatchScalarField_H
+#ifndef nutSpalartAllmarasWallFunctionFvPatchScalarField_H
+#define nutSpalartAllmarasWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
@@ -48,10 +49,10 @@ namespace RASModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class nutWallFunctionFvPatch Declaration
+           Class nutSpalartAllmarasWallFunctionFvPatch Declaration
 \*---------------------------------------------------------------------------*/
 
-class nutStandardWallFunctionFvPatchScalarField
+class nutSpalartAllmarasWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
@@ -61,40 +62,41 @@ class nutStandardWallFunctionFvPatchScalarField
 public:
 
     //- Runtime type information
-    TypeName("nutStandardWallFunction");
+    TypeName("nutSpalartAllmarasWallFunction");
 
 
     // Constructors
 
         //- Construct from patch and internal field
-        nutStandardWallFunctionFvPatchScalarField
+        nutSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&
         );
 
         //- Construct from patch, internal field and dictionary
-        nutStandardWallFunctionFvPatchScalarField
+        nutSpalartAllmarasWallFunctionFvPatchScalarField
         (
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const dictionary&
         );
 
-        //- Construct by mapping given nutStandardWallFunctionFvPatchScalarField
+        //- Construct by mapping given
+        //  nutSpalartAllmarasWallFunctionFvPatchScalarField
         //  onto a new patch
-        nutStandardWallFunctionFvPatchScalarField
+        nutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nutStandardWallFunctionFvPatchScalarField&,
+            const nutSpalartAllmarasWallFunctionFvPatchScalarField&,
             const fvPatch&,
             const DimensionedField<scalar, volMesh>&,
             const fvPatchFieldMapper&
         );
 
         //- Construct as copy
-        nutStandardWallFunctionFvPatchScalarField
+        nutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nutStandardWallFunctionFvPatchScalarField&
+            const nutSpalartAllmarasWallFunctionFvPatchScalarField&
         );
 
         //- Construct and return a clone
@@ -102,14 +104,14 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nutStandardWallFunctionFvPatchScalarField(*this)
+                new nutSpalartAllmarasWallFunctionFvPatchScalarField(*this)
             );
         }
 
         //- Construct as copy setting internal field reference
-        nutStandardWallFunctionFvPatchScalarField
+        nutSpalartAllmarasWallFunctionFvPatchScalarField
         (
-            const nutStandardWallFunctionFvPatchScalarField&,
+            const nutSpalartAllmarasWallFunctionFvPatchScalarField&,
             const DimensionedField<scalar, volMesh>&
         );
 
@@ -121,7 +123,7 @@ public:
         {
             return tmp<fvPatchScalarField>
             (
-                new nutStandardWallFunctionFvPatchScalarField(*this, iF)
+                new nutSpalartAllmarasWallFunctionFvPatchScalarField(*this, iF)
             );
         }
 
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..d86963a792161e82a7f2b234fb946ce29db3a706
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
@@ -0,0 +1,157 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 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 "nutWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+nutWallFunctionFvPatchScalarField::
+nutWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(p, iF)
+{}
+
+
+nutWallFunctionFvPatchScalarField::
+nutWallFunctionFvPatchScalarField
+(
+    const nutWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedValueFvPatchScalarField(ptf, p, iF, mapper)
+{}
+
+
+nutWallFunctionFvPatchScalarField::
+nutWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedValueFvPatchScalarField(p, iF, dict)
+{}
+
+
+nutWallFunctionFvPatchScalarField::
+nutWallFunctionFvPatchScalarField
+(
+    const nutWallFunctionFvPatchScalarField& tppsf
+)
+:
+    fixedValueFvPatchScalarField(tppsf)
+{}
+
+
+nutWallFunctionFvPatchScalarField::
+nutWallFunctionFvPatchScalarField
+(
+    const nutWallFunctionFvPatchScalarField& tppsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedValueFvPatchScalarField(tppsf, iF)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void nutWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+    const scalar kappa = ras.kappa().value();
+    const scalar E = ras.E().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    const volScalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& nuw =
+        patch().lookupPatchField<volScalarField, scalar>("nu");
+
+    scalarField& nutw = *this;
+
+    forAll(nutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
+
+        if (yPlus > yPlusLam)
+        {
+            nutw[faceI] = nuw[faceI]*(yPlus*kappa/log(E*yPlus) - 1);
+        }
+        else
+        {
+            nutw[faceI] = 0.0;
+        }
+    }
+}
+
+
+void nutWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H
similarity index 89%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H
rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H
index 218599b59c0ea2fb757b182bde2df7aa75ee03e1..ffb370608ab99c343edd46b774854cd2688ac704 100644
--- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H
@@ -26,7 +26,9 @@ Class
     Foam::incompressible::RASModels::nutWallFunctionFvPatchScalarField
 
 Description
-    Wall function boundary condition for walls
+    Boundary condition for turbulent (kinematic) viscosity when using wall
+    functions
+    - replicates OpenFOAM v1.5 (and earlier) behaviour
 
 SourceFiles
     nutWallFunctionFvPatchScalarField.C
@@ -48,15 +50,13 @@ namespace RASModels
 {
 
 /*---------------------------------------------------------------------------*\
-                    Class nutWallFunctionFvPatch Declaration
+             Class nutWallFunctionFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
 class nutWallFunctionFvPatchScalarField
 :
     public fixedValueFvPatchScalarField
 {
-    // Private data
-
 
 public:
 
@@ -81,7 +81,8 @@ public:
             const dictionary&
         );
 
-        //- Construct by mapping given nutWallFunctionFvPatchScalarField
+        //- Construct by mapping given
+        //  nutWallFunctionFvPatchScalarField
         //  onto a new patch
         nutWallFunctionFvPatchScalarField
         (
@@ -130,11 +131,14 @@ public:
 
         // Evaluation functions
 
-            //- Evaluate the patchField
-            virtual void evaluate
-            (
-                const Pstream::commsTypes commsType=Pstream::blocking
-            );
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
 };
 
 
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
new file mode 100644
index 0000000000000000000000000000000000000000..84793a2c4208e2d33e42be64826b625ba8658da1
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
@@ -0,0 +1,204 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 "omegaWallFunctionFvPatchScalarField.H"
+#include "RASModel.H"
+#include "fvPatchFieldMapper.H"
+#include "volFields.H"
+#include "addToRunTimeSelectionTable.H"
+#include "wallFvPatch.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void omegaWallFunctionFvPatchScalarField::checkType()
+{
+    if (!isA<wallFvPatch>(patch()))
+    {
+        FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
+            << "Invalid wall function specification" << nl
+            << "    Patch type for patch " << patch().name()
+            << " must be wall" << nl
+            << "    Current patch type is " << patch().type() << nl << endl
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ptf,
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const fvPatchFieldMapper& mapper
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const fvPatch& p,
+    const DimensionedField<scalar, volMesh>& iF,
+    const dictionary& dict
+)
+:
+    fixedInternalValueFvPatchField<scalar>(p, iF, dict)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ewfpsf
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf)
+{
+    checkType();
+}
+
+
+omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
+(
+    const omegaWallFunctionFvPatchScalarField& ewfpsf,
+    const DimensionedField<scalar, volMesh>& iF
+)
+:
+    fixedInternalValueFvPatchField<scalar>(ewfpsf, iF)
+{
+    checkType();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void omegaWallFunctionFvPatchScalarField::updateCoeffs()
+{
+    const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
+
+    const scalar Cmu = ras.Cmu().value();
+    const scalar Cmu25 = pow(Cmu, 0.25);
+
+    const scalar kappa = ras.kappa().value();
+    const scalar yPlusLam = ras.yPlusLam();
+
+    const scalarField& y = ras.y()[patch().index()];
+
+    volScalarField& G = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("G"));
+
+    volScalarField& omega = const_cast<volScalarField&>
+        (db().lookupObject<volScalarField>("omega"));
+
+    const scalarField& k = db().lookupObject<volScalarField>("k");
+
+    const scalarField& nuw =
+        patch().lookupPatchField<volScalarField, scalar>("nu");
+
+    const scalarField& nutw =
+        patch().lookupPatchField<volScalarField, scalar>("nut");
+
+    const fvPatchVectorField& Uw =
+        patch().lookupPatchField<volVectorField, vector>("U");
+
+    const scalarField magGradUw = mag(Uw.snGrad());
+
+    // Set epsilon and G
+    forAll(nutw, faceI)
+    {
+        label faceCellI = patch().faceCells()[faceI];
+
+        scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
+
+        omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceI]);
+
+        if (yPlus > yPlusLam)
+        {
+            G[faceCellI] =
+                (nutw[faceI] + nuw[faceI])
+               *magGradUw[faceI]
+               *Cmu25*sqrt(k[faceCellI])
+               /(kappa*y[faceI]);
+        }
+        else
+        {
+            G[faceCellI] = 0.0;
+        }
+    }
+
+    // TODO: perform averaging for cells sharing more than one boundary face
+}
+
+
+void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
+{
+    fixedInternalValueFvPatchField<scalar>::write(os);
+    writeEntry("value", os);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makePatchTypeField
+(
+    fvPatchScalarField,
+    omegaWallFunctionFvPatchScalarField
+);
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
new file mode 100644
index 0000000000000000000000000000000000000000..37c8d90188a9e913c6e5c13795e83cda5ac53308
--- /dev/null
+++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
@@ -0,0 +1,159 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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::incompressible::RASModels::omegaWallFunctionFvPatchScalarField
+
+Description
+    Replaces functionality in wallFunctionsI.H
+
+SourceFiles
+    omegaWallFunctionFvPatchScalarField.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef omegaWallFunctionFvPatchScalarField_H
+#define omegaWallFunctionFvPatchScalarField_H
+
+#include "fixedInternalValueFvPatchField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace incompressible
+{
+namespace RASModels
+{
+
+/*---------------------------------------------------------------------------*\
+           Class omegaWallFunctionFvPatchScalarField Declaration
+\*---------------------------------------------------------------------------*/
+
+class omegaWallFunctionFvPatchScalarField
+:
+    public fixedInternalValueFvPatchField<scalar>
+{
+
+    // Private member functions
+
+        //- Check the type of the patch
+        void checkType();
+
+
+public:
+
+    //- Runtime type information
+    TypeName("omegaWallFunction");
+
+
+    // Constructors
+
+        //- Construct from patch and internal field
+        omegaWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct from patch, internal field and dictionary
+        omegaWallFunctionFvPatchScalarField
+        (
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const dictionary&
+        );
+
+        //- Construct by mapping given
+        // omegaWallFunctionFvPatchScalarField
+        //  onto a new patch
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&,
+            const fvPatch&,
+            const DimensionedField<scalar, volMesh>&,
+            const fvPatchFieldMapper&
+        );
+
+        //- Construct as copy
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&
+        );
+
+        //- Construct and return a clone
+        virtual tmp<fvPatchScalarField> clone() const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new omegaWallFunctionFvPatchScalarField(*this)
+            );
+        }
+
+        //- Construct as copy setting internal field reference
+        omegaWallFunctionFvPatchScalarField
+        (
+            const omegaWallFunctionFvPatchScalarField&,
+            const DimensionedField<scalar, volMesh>&
+        );
+
+        //- Construct and return a clone setting internal field reference
+        virtual tmp<fvPatchScalarField> clone
+        (
+            const DimensionedField<scalar, volMesh>& iF
+        ) const
+        {
+            return tmp<fvPatchScalarField>
+            (
+                new omegaWallFunctionFvPatchScalarField(*this, iF)
+            );
+        }
+
+
+    // Member functions
+
+        // Evaluation functions
+
+            //- Update the coefficients associated with the patch field
+            virtual void updateCoeffs();
+
+
+        // I-O
+
+            //- Write
+            void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace RASModels
+} // End namespace incompressible
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nonLinearWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/include/nonLinearWallFunctionsI.H
similarity index 100%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nonLinearWallFunctionsI.H
rename to src/turbulenceModels/RAS/incompressible/include/nonLinearWallFunctionsI.H
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallDissipationI.H b/src/turbulenceModels/RAS/incompressible/include/wallDissipationI.H
similarity index 100%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallDissipationI.H
rename to src/turbulenceModels/RAS/incompressible/include/wallDissipationI.H
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/include/wallFunctionsI.H.old
similarity index 100%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H
rename to src/turbulenceModels/RAS/incompressible/include/wallFunctionsI.H.old
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallNonlinearViscosityI.H b/src/turbulenceModels/RAS/incompressible/include/wallNonlinearViscosityI.H
similarity index 100%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallNonlinearViscosityI.H
rename to src/turbulenceModels/RAS/incompressible/include/wallNonlinearViscosityI.H
diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H b/src/turbulenceModels/RAS/incompressible/include/wallViscosityI.H.old
similarity index 100%
rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H
rename to src/turbulenceModels/RAS/incompressible/include/wallViscosityI.H.old
diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C
index 0f4e20df045cabfcf0b7213b1970e9beee6ad1d9..c38760430152764c40b3bdaa80491a6920cfb9a5 100644
--- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C
+++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -98,12 +100,11 @@ kEpsilon::kEpsilon
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -111,15 +112,26 @@ kEpsilon::kEpsilon
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
-    nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "wallViscosityI.H"
+    nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -207,9 +219,15 @@ void kEpsilon::correct()
 
     RASModel::correct();
 
-    volScalarField G = nut_*2*magSqr(symm(fvc::grad(U_)));
+    if (mesh_.changing())
+    {
+        y_.correct();
+    }
 
-#   include "wallFunctionsI.H"
+    volScalarField G("G", nut_*2*magSqr(symm(fvc::grad(U_))));
+
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
     // Dissipation equation
     tmp<fvScalarMatrix> epsEqn
@@ -225,7 +243,7 @@ void kEpsilon::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -249,10 +267,8 @@ void kEpsilon::correct()
 
 
     // Re-calculate viscosity
-    nut_ = Cmu_*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
-
+    nut_ == Cmu_*sqr(k_)/epsilon_;
+    nut_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C
index 179e694261eb3d6c560ac8805f1c8ebb19cc6967..ff2dceca5adc5915198148246d56b762b9de0cde 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C
+++ b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -109,12 +111,11 @@ kOmega::kOmega
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     omega_
     (
         IOobject
@@ -122,15 +123,26 @@ kOmega::kOmega
             "omega",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateOmega("omega", mesh_)
     ),
-
-    nut_(k_/(omega_ + omegaSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "kOmegaWallViscosityI.H"
+    nut_ == k_/(omega_ + omegaSmall_);
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -218,9 +230,10 @@ void kOmega::correct()
 
     RASModel::correct();
 
-    volScalarField G = nut_*2*magSqr(symm(fvc::grad(U_)));
+    volScalarField G("G", nut_*2*magSqr(symm(fvc::grad(U_))));
 
-#   include "kOmegaWallFunctionsI.H"
+    // Update omega and G at the wall
+    omega_.boundaryField().updateCoeffs();
 
     // Turbulence specific dissipation rate equation
     tmp<fvScalarMatrix> omegaEqn
@@ -236,7 +249,7 @@ void kOmega::correct()
 
     omegaEqn().relax();
 
-#   include "wallOmegaI.H"
+    omegaEqn().boundaryManipulate(omega_.boundaryField());
 
     solve(omegaEqn);
     bound(omega_, omega0_);
@@ -260,10 +273,8 @@ void kOmega::correct()
 
 
     // Re-calculate viscosity
-    nut_ = k_/omega_;
-
-#   include "kOmegaWallViscosityI.H"
-
+    nut_ == k_/omega_;
+    nut_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H
deleted file mode 100644
index aca757443e3937ecc2001e370b5a73befa5f0f32..0000000000000000000000000000000000000000
--- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H
+++ /dev/null
@@ -1,125 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 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
-
-Global
-    kOmegaWallFunctions
-
-Description
-    Calculate wall generation and frequency omega from wall-functions.
-
-\*---------------------------------------------------------------------------*/
-
-{
-    labelList cellBoundaryFaceCount(omega_.size(), 0);
-
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
-
-    const fvPatchList& patches = mesh_.boundary();
-
-    //- Initialise the near-wall omega and G fields to zero
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] = 0.0;
-                G[faceCelli] = 0.0;
-            }
-        }
-    }
-
-    //- Accumulate the wall face contributions to omega and G
-    //  Increment cellBoundaryFaceCount for each face for averaging
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-#           include "checkkOmegaPatchFieldTypes.H"
-
-            const scalarField& nuw = nu().boundaryField()[patchi];
-            const scalarField& nutw = nut_.boundaryField()[patchi];
-
-            scalarField magFaceGradU =
-                mag(U_.boundaryField()[patchi].snGrad());
-
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[patchi][facei]
-                    *sqrt(k_[faceCelli])
-                    /nuw[facei];
-
-                // For corner cells (with two boundary or more faces),
-                // omega and G in the near-wall cell are calculated
-                // as an average
-
-                cellBoundaryFaceCount[faceCelli]++;
-
-                omega_[faceCelli] +=
-                    sqrt(k_[faceCelli])
-                   /(Cmu25*kappa_.value()*y_[patchi][facei]);
-
-                if (yPlus > yPlusLam_)
-                {
-                    G[faceCelli] +=
-                        (nutw[facei] + nuw[facei])
-                       *magFaceGradU[facei]
-                       *Cmu25*sqrt(k_[faceCelli])
-                       /(kappa_.value()*y_[patchi][facei]);
-                }
-            }
-        }
-    }
-
-
-    // Perform the averaging
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-                G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-            }
-        }
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H
deleted file mode 100644
index 025c06bb9c9a373cc579aff60a75f824346850db..0000000000000000000000000000000000000000
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H
+++ /dev/null
@@ -1,19 +0,0 @@
-if (!isType<zeroGradientFvPatchScalarField>(k_.boundaryField()[patchi]))
-{
-    FatalErrorIn("wall-function evaluation")
-        << k_.boundaryField()[patchi].type()
-        << " is the wrong k patchField type for wall-functions on patch "
-        << curPatch.name() << nl
-        << "    should be zeroGradient"
-        << exit(FatalError);
-}
-
-if (!isType<zeroGradientFvPatchScalarField>(omega_.boundaryField()[patchi]))
-{
-    FatalErrorIn("wall-function evaluation")
-        << omega_.boundaryField()[patchi].type()
-        << " is the wrong omega patchField type for wall-functions on patch "
-        << curPatch.name() << nl
-        << "    should be zeroGradient"
-        << exit(FatalError);
-}
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C
index 1cf4a5c6d7ca94ad93a33477d9265a561dc7f243..4760c17152ec8f4ce64408ac98ee41492a07c478 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C
+++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -218,12 +220,11 @@ kOmegaSST::kOmegaSST
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     omega_
     (
         IOobject
@@ -231,15 +232,32 @@ kOmegaSST::kOmegaSST
             "omega",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateOmega("omega", mesh_)
     ),
-
-    nut_(a1_*k_/max(a1_*(omega_ + omegaSmall_), F2()*mag(symm(fvc::grad(U_)))))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
-#   include "kOmegaWallViscosityI.H"
+    nut_ ==
+        a1_*k_
+       /max
+        (
+            a1_*(omega_ + omegaSmall_),
+            F2()*mag(symm(fvc::grad(U_)))
+        );
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -341,9 +359,10 @@ void kOmegaSST::correct()
     }
 
     volScalarField S2 = magSqr(symm(fvc::grad(U_)));
-    volScalarField G = nut_*2*S2;
+    volScalarField G("G", nut_*2*S2);
 
-#   include "kOmegaWallFunctionsI.H"
+    // Update omega and G at the wall
+    omega_.boundaryField().updateCoeffs();
 
     volScalarField CDkOmega =
         (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_;
@@ -369,7 +388,7 @@ void kOmegaSST::correct()
 
     omegaEqn().relax();
 
-#   include "wallOmegaI.H"
+    omegaEqn().boundaryManipulate(omega_.boundaryField());
 
     solve(omegaEqn);
     bound(omega_, omega0_);
@@ -392,10 +411,8 @@ void kOmegaSST::correct()
 
 
     // Re-calculate viscosity
-    nut_ = a1_*k_/max(a1_*omega_, F2()*sqrt(S2));
-
-#   include "kOmegaWallViscosityI.H"
-
+    nut_ == a1_*k_/max(a1_*omega_, F2()*sqrt(S2));
+    nut_.correctBoundaryConditions();
 }
 
 
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H
index 5564d84555b9d378468e5532d8aaa9ba0d9ab013..8b406d6ea74ba657c5c488cca0dca0f1a55ce276 100644
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H
+++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H
@@ -75,9 +75,6 @@ Description
 
 SourceFiles
     kOmegaSST.C
-    kOmegaWallFunctionsI.H
-    kOmegaWallViscosityI.H
-    wallOmegaI.H
 
 \*---------------------------------------------------------------------------*/
 
diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H
deleted file mode 100644
index 82d8b933c36bd8838a5195531e7ef981ec604c23..0000000000000000000000000000000000000000
--- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H
+++ /dev/null
@@ -1,125 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2008 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
-
-Global
-    kOmegaWallFunctions
-
-Description
-    Calculate wall generation and frequency omega from wall-functions.
-
-\*---------------------------------------------------------------------------*/
-
-{
-    labelList cellBoundaryFaceCount(omega_.size(), 0);
-
-    scalar Cmu25 = pow(Cmu_.value(), 0.25);
-
-    const fvPatchList& patches = mesh_.boundary();
-
-    //- Initialise the near-wall omega and G fields to zero
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] = 0.0;
-                G[faceCelli] = 0.0;
-            }
-        }
-    }
-
-    //- Accumulate the wall face contributions to omega and G
-    //  Increment cellBoundaryFaceCount for each face for averaging
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-#           include "checkkOmegaPatchFieldTypes.H"
-
-            const scalarField& nuw = nu().boundaryField()[patchi];
-            const scalarField& nutw = nut_.boundaryField()[patchi];
-
-            scalarField magFaceGradU =
-                mag(U_.boundaryField()[patchi].snGrad());
-
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                scalar yPlus =
-                    Cmu25*y_[faceCelli]
-                    *sqrt(k_[faceCelli])
-                    /nuw[facei];
-
-                // For corner cells (with two boundary or more faces),
-                // omega and G in the near-wall cell are calculated
-                // as an average
-
-                cellBoundaryFaceCount[faceCelli]++;
-
-                omega_[faceCelli] +=
-                    sqrt(k_[faceCelli])
-                   /(Cmu25*kappa_.value()*y_[faceCelli]);
-
-                if (yPlus > yPlusLam_)
-                {
-                    G[faceCelli] +=
-                        (nutw[facei] + nuw[facei])
-                       *magFaceGradU[facei]
-                       *Cmu25*sqrt(k_[faceCelli])
-                       /(kappa_.value()*y_[faceCelli]);
-                }
-            }
-        }
-    }
-
-
-    // Perform the averaging
-
-    forAll(patches, patchi)
-    {
-        const fvPatch& curPatch = patches[patchi];
-
-        if (isType<wallFvPatch>(curPatch))
-        {
-            forAll(curPatch, facei)
-            {
-                label faceCelli = curPatch.faceCells()[facei];
-
-                omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-                G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
-            }
-        }
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C
index a9d2cbc601cfcd6911e956309486e5ca58de8069..ffeba065d7576a3dfe869f05d3f5c34d6c67a5a5 100644
--- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C
+++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C
@@ -28,6 +28,8 @@ License
 #include "addToRunTimeSelectionTable.H"
 #include "wallFvPatch.H"
 
+#include "backwardsCompatibilityWallFunctions.H"
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -147,12 +149,11 @@ realizableKE::realizableKE
             "k",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateK("k", mesh_)
     ),
-
     epsilon_
     (
         IOobject
@@ -160,17 +161,29 @@ realizableKE::realizableKE
             "epsilon",
             runTime_.timeName(),
             mesh_,
-            IOobject::MUST_READ,
+            IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        mesh_
+        autoCreateEpsilon("epsilon", mesh_)
     ),
-
-    nut_(rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_))
+    nut_
+    (
+        IOobject
+        (
+            "nut",
+            runTime_.timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::AUTO_WRITE
+        ),
+        autoCreateNut("nut", mesh_)
+    )
 {
     bound(k_, k0_);
     bound(epsilon_, epsilon0_);
-#   include "wallViscosityI.H"
+
+    nut_ == rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_);
+    nut_.correctBoundaryConditions();
 
     printCoeffs();
 }
@@ -266,9 +279,10 @@ void realizableKE::correct()
     volScalarField eta = magS*k_/epsilon_;
     volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43));
 
-    volScalarField G = nut_*S2;
+    volScalarField G("G", nut_*S2);
 
-#   include "wallFunctionsI.H"
+    // Update espsilon and G at the wall
+    epsilon_.boundaryField().updateCoeffs();
 
 
     // Dissipation equation
@@ -289,7 +303,7 @@ void realizableKE::correct()
 
     epsEqn().relax();
 
-#   include "wallDissipationI.H"
+    epsEqn().boundaryManipulate(epsilon_.boundaryField());
 
     solve(epsEqn);
     bound(epsilon_, epsilon0_);
@@ -312,10 +326,8 @@ void realizableKE::correct()
 
 
     // Re-calculate viscosity
-    nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
-
-#   include "wallViscosityI.H"
-
+    nut_ == rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
+    nut_.correctBoundaryConditions();
 }
 
 
diff --git a/tutorials/Allclean b/tutorials/Allclean
index c72811f9fae68642d7f48847ec2d44515da5a89b..2a79bb7ec44f9a5caa5964c6574447d15c7d49f2 100755
--- a/tutorials/Allclean
+++ b/tutorials/Allclean
@@ -32,15 +32,15 @@
 
 cd ${0%/*} || exit 1    # run from this directory
 
-echo "Cleaning backup files"
+echo "--------"
+echo "Cleaning tutorials ..."
+echo "Removing backup files"
 find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \;
 find . \( -name 'core' -o -name 'core.[1-9]*' \) -exec rm {} \;
 find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \;
-rm logs > /dev/null 2>&1
-rm testLoopReport > /dev/null 2>&1
-
-echo ""
+rm logs testLoopReport > /dev/null 2>&1
 
 foamCleanTutorials cases
 
+echo "--------"
 # ----------------------------------------------------------------- end-of-file
diff --git a/tutorials/XiFoam/Allrun b/tutorials/XiFoam/Allrun
index c32a0b032edb5ecdfa90aa78bce3064eba52c4f4..a07a780037c220bfb5401419e5693671bedf4ec7 100755
--- a/tutorials/XiFoam/Allrun
+++ b/tutorials/XiFoam/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 setControlDict () {
     controlDict="system/controlDict"
diff --git a/tutorials/channelOodles/channel395/constant/postChannelDict b/tutorials/channelOodles/channel395/constant/postChannelDict
index b8f3c3e0480747bdb4e53b09cb2ccbbd72e899b4..d63cd656675c6ebe4aecf1608dca9b561a5a3fe8 100644
--- a/tutorials/channelOodles/channel395/constant/postChannelDict
+++ b/tutorials/channelOodles/channel395/constant/postChannelDict
@@ -12,11 +12,17 @@ FoamFile
     class       dictionary;
     object      postChannelDict;
 }
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-Nx    40;
-Ny    (50);
-Nz    30;
+// Seed patches to start layering from
+patches (bottomWall);
+
+// Direction in which the layers are
+component y;
+
+// Is the mesh symmetric? If so average(symmetric fields) or
+// subtract(asymmetric) contributions from both halves
 symmetric true;
 
 // ************************************************************************* //
diff --git a/tutorials/icoFoam/Allrun b/tutorials/icoFoam/Allrun
index fcea17d98e2001b2f2eff9570382ffa96710caa5..914e53d07de0af8907cc8a5b56f88778f02a1a76 100755
--- a/tutorials/icoFoam/Allrun
+++ b/tutorials/icoFoam/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 cavityCases="cavity cavityFine cavityGrade cavityHighRe cavityClipped"
 
diff --git a/tutorials/interDyMFoam/sloshingTank2D/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank2D/constant/polyMesh/blockMeshDict.m4
index 0473efbc150bdb78effeaae893d913d81be2fc5b..b6c1cdd4ad9b1d6ba5fd81e26deeeb626cee8b8f 100644
--- a/tutorials/interDyMFoam/sloshingTank2D/constant/polyMesh/blockMeshDict.m4
+++ b/tutorials/interDyMFoam/sloshingTank2D/constant/polyMesh/blockMeshDict.m4
@@ -15,8 +15,8 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // General m4 macros
 
-changecom(//)changequote([,])
-define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; printf ($1)')])
+changecom(//)changequote([,]) dnl>
+define(calc, [esyscmd(perl -e 'use Math::Trig; print ($1)')]) dnl>
 define(VCOUNT, 0)
 define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
 
diff --git a/tutorials/interDyMFoam/sloshingTank2D3DoF/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank2D3DoF/constant/polyMesh/blockMeshDict.m4
index 5f286a9a6bc642bbb0b92f586a0ecc76fe67bcc8..b6c1cdd4ad9b1d6ba5fd81e26deeeb626cee8b8f 100644
--- a/tutorials/interDyMFoam/sloshingTank2D3DoF/constant/polyMesh/blockMeshDict.m4
+++ b/tutorials/interDyMFoam/sloshingTank2D3DoF/constant/polyMesh/blockMeshDict.m4
@@ -15,8 +15,8 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // General m4 macros
 
-changecom(//)changequote([,])
-define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; print ($1)')])
+changecom(//)changequote([,]) dnl>
+define(calc, [esyscmd(perl -e 'use Math::Trig; print ($1)')]) dnl>
 define(VCOUNT, 0)
 define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4
index d00110499198e0a49652f9797f09c7baff05a112..f97859e6bffaa7c864e14cd5f5c62968652fc03f 100644
--- a/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4
+++ b/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4
@@ -15,8 +15,8 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // General m4 macros
 
-changecom(//)changequote([,])
-define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; printf ($1)')])
+changecom(//)changequote([,]) dnl>
+define(calc, [esyscmd(perl -e 'use Math::Trig; print ($1)')]) dnl>
 define(VCOUNT, 0)
 define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D3DoF/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank3D3DoF/constant/polyMesh/blockMeshDict.m4
index 0b91b83dd263a10bcc2c7ba94513c8076109fae1..f97859e6bffaa7c864e14cd5f5c62968652fc03f 100644
--- a/tutorials/interDyMFoam/sloshingTank3D3DoF/constant/polyMesh/blockMeshDict.m4
+++ b/tutorials/interDyMFoam/sloshingTank3D3DoF/constant/polyMesh/blockMeshDict.m4
@@ -15,8 +15,8 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // General m4 macros
 
-changecom(//)changequote([,])
-define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; print ($1)')])
+changecom(//)changequote([,]) dnl>
+define(calc, [esyscmd(perl -e 'use Math::Trig; print ($1)')]) dnl>
 define(VCOUNT, 0)
 define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
 
diff --git a/tutorials/interDyMFoam/sloshingTank3D6DoF/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank3D6DoF/constant/polyMesh/blockMeshDict.m4
index 0b91b83dd263a10bcc2c7ba94513c8076109fae1..f97859e6bffaa7c864e14cd5f5c62968652fc03f 100644
--- a/tutorials/interDyMFoam/sloshingTank3D6DoF/constant/polyMesh/blockMeshDict.m4
+++ b/tutorials/interDyMFoam/sloshingTank3D6DoF/constant/polyMesh/blockMeshDict.m4
@@ -15,8 +15,8 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // General m4 macros
 
-changecom(//)changequote([,])
-define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; print ($1)')])
+changecom(//)changequote([,]) dnl>
+define(calc, [esyscmd(perl -e 'use Math::Trig; print ($1)')]) dnl>
 define(VCOUNT, 0)
 define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
 
diff --git a/tutorials/interFoam/Allrun b/tutorials/interFoam/Allrun
index 3e7961c94b8266035c8420985ef5b7e3ddabd4f8..4adf8e9374f634d277f886f7272de6083b7d5276 100755
--- a/tutorials/interFoam/Allrun
+++ b/tutorials/interFoam/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 setDamBreakFine ()
 {
diff --git a/tutorials/laplacianFoam/flange/Allrun b/tutorials/laplacianFoam/flange/Allrun
index 6e3250d8c66c1a3fb5cac6a4bd12d67770439509..497eed73f83ef1065ecb5f01f75f107fff090ffa 100755
--- a/tutorials/laplacianFoam/flange/Allrun
+++ b/tutorials/laplacianFoam/flange/Allrun
@@ -5,9 +5,10 @@
 # Get application directory
 application="laplacianFoam"
 
-runIdeasToFoam ()
+runAnsysToFoam()
 {
-    if [ -f log.ideasToFoam ] ; then
+    if [ -f log.ansysToFoam ]
+    then
         echo "ansysToFoam already run on $PWD: remove log file to run"
     else
         echo "ansysToFoam: converting mesh $1"
@@ -15,7 +16,7 @@ runIdeasToFoam ()
     fi
 }
 
-runIdeasToFoam flange.ans 0.001
+runAnsysToFoam flange.ans 0.001
 runApplication $application
 runApplication foamToFieldview9
 runApplication foamToEnsight
diff --git a/tutorials/lesCavitatingFoam/Allrun b/tutorials/lesCavitatingFoam/Allrun
index 33517002c0787a16cfdd6ccff70fd2621b7633c7..af563a0512000ff37ed97fc0787df58c686c66eb 100755
--- a/tutorials/lesCavitatingFoam/Allrun
+++ b/tutorials/lesCavitatingFoam/Allrun
@@ -7,21 +7,21 @@ application="lesCavitatingFoam"
 
 refineMeshByCellSet()
 {
-    echo "creating cell set for primary zone - $1"
-    cp system/cellSetDict.$1 system/cellSetDict
-    cellSet >& log.cellSet.$1
-
-    echo "refining primary zone - $1"
-    refineMesh -dict -overwrite >& log.refineMesh.$1
+   while [ $# -ge 1 ]
+   do
+      echo "creating cell set for primary zone - $1"
+      cp system/cellSetDict.$1 system/cellSetDict
+      cellSet > log.cellSet.$1 2>&1
+
+      echo "refining primary zone - $1"
+      refineMesh -dict -overwrite > log.refineMesh.$1 2>&1
+      shift
+   done
 }
 
 cd throttle
     runApplication blockMesh
-
-    refineMeshByCellSet 1
-    refineMeshByCellSet 2
-    refineMeshByCellSet 3
-
+    refineMeshByCellSet 1 2 3
     runApplication $application
 cd ..
 
@@ -29,10 +29,7 @@ cd throttle3D
     cp -r 0.org 0
 
     runApplication blockMesh
-
-    refineMeshByCellSet 1
-    refineMeshByCellSet 2
-    refineMeshByCellSet 3
+    refineMeshByCellSet 1 2 3
 
     echo "mapping fields from 2D throttle case"
     mapFields ../throttle -sourceTime latestTime >& log.mapFields
diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary b/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary
index c67eadf3856621ce53fc53ab72fb32465cfd0496..3f70c82e6755e02de59c615fbabcd399dfcec25c 100644
--- a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary
+++ b/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  1.5                                   |
+|  \\    /   O peration     | Version:  dev                                   |
 |   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -10,19 +10,22 @@ FoamFile
     version     2.0;
     format      ascii;
     class       polyBoundaryMesh;
+    location    "constant/polyMesh";
     object      boundary;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+
 5
 (
 inlet           
 {
+    type            directMappedPatch;
     nFaces          30;
     startFace       27238;
-    offset          ( 0.0495 0 0 );
     sampleMode      nearestCell;
     samplePatch     none;
+    offset          ( 0.0495 0 0 );
 }
 
 outlet          
@@ -55,4 +58,5 @@ frontAndBack
 
 )
 
+
 // ************************************************************************* //
diff --git a/tutorials/rasCavitatingFoam/throttle/Allrun b/tutorials/rasCavitatingFoam/throttle/Allrun
index 972d1f37c9d1c49a54823f46b8ae14a204f9c44b..83a53ae761330db16c885c6bf750580dff30cebd 100755
--- a/tutorials/rasCavitatingFoam/throttle/Allrun
+++ b/tutorials/rasCavitatingFoam/throttle/Allrun
@@ -7,20 +7,19 @@ application="rasCavitatingFoam"
 
 refineMeshByCellSet()
 {
-    echo "creating cell set for primary zone - $1"
-    cp system/cellSetDict.$1 system/cellSetDict
-    cellSet >& log.cellSet.$1
-
-    echo "refining primary zone - $1"
-    refineMesh -dict -overwrite >& log.refineMesh.$1
+   while [ $# -ge 1 ]
+   do
+      echo "creating cell set for primary zone - $1"
+      cp system/cellSetDict.$1 system/cellSetDict
+      cellSet > log.cellSet.$1 2>&1
+
+      echo "refining primary zone - $1"
+      refineMesh -dict -overwrite > log.refineMesh.$1 2>&1
+      shift
+   done
 }
 
 runApplication blockMesh
-
-refineMeshByCellSet 1
-
-refineMeshByCellSet 2
-
-refineMeshByCellSet 3
-
+refineMeshByCellSet 1 2 3
 runApplication $application
+
diff --git a/tutorials/rhoCentralFoam/Allrun b/tutorials/rhoCentralFoam/Allrun
index e41004597b2e32473c15083e72c0624df6c613bc..dbd8b7758fa6264d533d75ffd5a1758a8484ba72 100755
--- a/tutorials/rhoCentralFoam/Allrun
+++ b/tutorials/rhoCentralFoam/Allrun
@@ -1,10 +1,9 @@
 #!/bin/sh
-
 # Source tutorial run functions
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 cases=" \
 shockTube \
@@ -15,12 +14,13 @@ LadenburgJet60psi \
 biconic25-55Run35 \
 "
 
-moveTimeMeshToConstant () {
-DT=`foamInfoExec -times | tail -1`
-if [ $DT != 0 ] ; then
-    mv ${DT}/polyMesh/* constant/polyMesh
-    rm -rf ${DT}
-fi
+moveTimeMeshToConstant ()
+{
+   DT=`foamInfoExec -times | tail -1`
+   if [ "$DT" != 0 ] ; then
+       mv ${DT}/polyMesh/* constant/polyMesh
+       rm -rf ${DT}
+   fi
 }
 
 for case in $cases
@@ -51,4 +51,4 @@ do
     fi
 #
     (cd $case && runApplication $application)
-done
\ No newline at end of file
+done
diff --git a/tutorials/sonicLiquidFoam/Allrun b/tutorials/sonicLiquidFoam/Allrun
index 4afc525e8b810275e671d74e80bd0aa4bc819b26..db8cdfa08aa3785e92d4fdc271670055628eefb0 100755
--- a/tutorials/sonicLiquidFoam/Allrun
+++ b/tutorials/sonicLiquidFoam/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 setDecompressionTankFine ()
 {
diff --git a/tutorials/sonicTurbFoam/Allrun b/tutorials/sonicTurbFoam/Allrun
index cb60b8cc068eab826bb581e62b57e7b578a553fb..810c6525ebd3dbad0a9f01b21f7edff079bae876 100755
--- a/tutorials/sonicTurbFoam/Allrun
+++ b/tutorials/sonicTurbFoam/Allrun
@@ -3,7 +3,7 @@
 . $WM_PROJECT_DIR/bin/tools/RunFunctions
 
 # Get application name from directory
-application=`basename $PWD`
+application=${PWD##*/}
 
 runStarToFoam ()
 {
diff --git a/wmake/wcleanAll b/wmake/wcleanAll
index e7d3477cb7d65cb6252a2a285ed786d89e14f1e1..e9b36bc375639f473af76cd2501812a5038b2387 100755
--- a/wmake/wcleanAll
+++ b/wmake/wcleanAll
@@ -39,20 +39,27 @@
 
 for dir in lib applications/bin
 do
+   echo "Removing $dir/"
    [ -d $dir ] && rm -rf $dir/*
 done
 
-( cd tutorials && ./Allclean )
-
+echo "Removing *~ backup files"
 find . -name '*~' -exec rm {} \;
+
+echo "Removing .dep files"
 find . -name '*.dep' -exec rm {} \;
 
+echo "Cleaning Make subdirectories"
 find `find . -depth \( -name "Make.[A-Za-z]*" -o -name "Make" \) -type d -print` -depth \( -type d ! -name "*Make.[A-Za-z]*" ! -name "*Make" \) -exec rm -rf {} \;
 
+echo "Removing lnInclude and intermediate directories"
 find . -depth -type d \( -name lnInclude -o -name ii_files -o -name Templates.DB \) -exec rm -rf {} \;
 
+echo "Removing misc files"
 find . \( -name exe -o -name log -o -name so_locations \) -exec rm {} \;
 
 # rm -rf src/mpich-${MPICH_VERSION}/platforms
 
+( cd tutorials && ./Allclean )
+
 #------------------------------------------------------------------------------
diff --git a/wmake/wcleanAlmostAll b/wmake/wcleanAlmostAll
index 515c3110d856507686bddbc0fc60f687cb5c5396..8bd52916008b40ea5475065b101641f811044d4d 100755
--- a/wmake/wcleanAlmostAll
+++ b/wmake/wcleanAlmostAll
@@ -24,11 +24,10 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     wmakeAlmostAll
+#     wcleanAlmostAll
 #
 # Description
-#     script that searches all the directories below the current for the
-#     object file directories of all machines and then deletes them.
+#     as per wcleanAll, but retains "*~" backup files
 #
 #------------------------------------------------------------------------------
 
@@ -39,18 +38,25 @@
 
 for dir in lib applications/bin
 do
+   echo "Removing $dir/"
    [ -d $dir ] && rm -rf $dir/*
 done
 
-( cd tutorials && ./Allclean )
+echo "Retaining *~ backup files"
+## find . -name '*~' -exec rm {} \;
 
-# find . -name '*~' -exec rm {} \;
+echo "Removing .dep files"
 find . -name '*.dep' -exec rm {} \;
 
-find `find . -depth \( -name "Make[.A-Za-z]*" -o -name "Make" \) -type d -print` -depth \( -type d ! -name "*Make[.A-Za-z]*" ! -name "*Make" \) -exec rm -r {} \;
+echo "Cleaning Make subdirectories"
+find `find . -depth \( -name "Make.[A-Za-z]*" -o -name "Make" \) -type d -print` -depth \( -type d ! -name "*Make.[A-Za-z]*" ! -name "*Make" \) -exec rm -rf {} \;
 
+echo "Removing lnInclude and intermediate directories"
 find . -depth -type d \( -name lnInclude -o -name ii_files -o -name Templates.DB \) -exec rm -rf {} \;
 
+echo "Removing misc files"
 find . \( -name exe -o -name log -o -name so_locations \) -exec rm {} \;
 
+( cd tutorials && ./Allclean )
+
 #------------------------------------------------------------------------------
diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll
index 7d7d0059c1e922c2b594b36b62c7f312135883d7..67da4d0bb0c078eff288f0320a7dfca34bcdbdc3 100755
--- a/wmake/wcleanLnIncludeAll
+++ b/wmake/wcleanLnIncludeAll
@@ -24,7 +24,7 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     wmakeLnInclude
+#     wcleanLnIncludeAll
 #
 # Description
 #     Delete all the lnInclude directories in the tree.
diff --git a/wmake/wmakeLnInclude b/wmake/wmakeLnInclude
index fcf3bfbf50acab0a0399ab1f2cc197e36151cfc1..ad63d6bca945f743e88e06591c3025c6d3110d88 100755
--- a/wmake/wmakeLnInclude
+++ b/wmake/wmakeLnInclude
@@ -80,8 +80,18 @@ do
 done
 
 baseDir=$1
+# convert incorrect path/dir/lnInclude to something sensible
+while [ "${baseDir##*/}" = lnInclude ]
+do
+   baseDir="${baseDir%/*}"
+   if [ "$baseDir" = lnInclude ]
+   then
+      baseDir="."
+   fi
+done
 incDir=$baseDir/lnInclude
 
+
 if [ $# -eq 1 ]
 then
    lnOpt="-s"
@@ -89,7 +99,7 @@ elif [ $# -eq 2 ]
 then
    lnOpt="$2"
 else
-   usage "ERROR: wrong number of arguments"
+   usage "ERROR: incorrect number of arguments"
 fi
 
 
@@ -101,7 +111,6 @@ fi
 
 if [ -d $incDir ]
 then
-   # could change force to remove lnInclude first
    if [ ! "$forceUpdate" ]
    then
       # echo $Script: include directory $incDir already exists, exiting.
@@ -117,24 +126,34 @@ then
    exit 0
 fi
 
+cd $incDir || exit 1
+
 
 # Link include files
 # ~~~~~~~~~~~~~~~~~~
 echo $Script: linking include files to $incDir
-echo
-
-cd $incDir
-
-find .. $findOpt \
-    \( -name lnInclude -o -name -Make -o -name config \) -prune  \
- -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \)  \
- -a ! -name ".#*"     \
- -exec ln $lnOpt {} . \;
-
 
 #
-# remove any broken links
+# remove any broken links first (this helps when file locations have moved)
 #
 find -L . -type l -exec rm \{\} \;
 
+#
+# create links, avoid recreating links unless necessary
+#
+find .. $findOpt \
+    \( -name lnInclude -o -name Make -o -name config \) -prune \
+ -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \)  \
+ -a ! -name ".#*" \
+ -print | \
+   while read src
+   do
+      link=$(readlink ${src##*/})
+      if [ "$link" != "$src" ]
+      then
+         rm $link 2>/dev/null
+         ln $lnOpt $src .
+      fi
+   done
+
 #------------------------------------------------------------------------------
diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler
index bf9bfc914bdc4568cd013194526046879303c70f..a4c88624abc084a43117dee136e609f75a72c9fd 100755
--- a/wmake/wmakeScheduler
+++ b/wmake/wmakeScheduler
@@ -57,14 +57,15 @@ lockDir=$HOME/.wmakeScheduler
 # count the total number of slots available and exit
 if [ "$1" = "-count" ]
 then
-    expr $(
-        for slotGroup in $WM_HOSTS
-        do
-            n=${slotGroup##*:}
-            if [ "$n" = "${slotGroup%%:*}" ]; then n=1; fi # missing ':'
-            echo "+ ${n:-1}"
-        done)
-    exit 0
+   expr $(
+      for slotGroup in $WM_HOSTS
+      do
+         n=${slotGroup##*:}
+         [ "$n" = "${slotGroup%%:*}" ] && n=1  # missing ':'
+         echo "+ ${n:-1}"
+      done
+   )
+   exit 0
 fi
 
 # where to source WM_PROJECT settings in a remote shell
@@ -75,25 +76,26 @@ fi
 sourceFoam=false    # fallback command
 case $SHELL in
 */csh | */tcsh )    # [t]csh vs bash|ksh|sh
-    shellRc=cshrc
-    ;;
+   shellRc=cshrc
+   ;;
 *)
-    shellRc=bashrc
-    ;;
+   shellRc=bashrc
+   ;;
 esac
 
 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # check ~/.$WM_PROJECT/
 # check <installedProject>/etc/
-if [ "$WM_PROJECT" ]; then
-
+if [ "$WM_PROJECT" ]
+then
    for i in \
       $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
       $HOME/.$WM_PROJECT \
       $WM_PROJECT_DIR/etc \
       ;
    do
-      if [ -f "$i/$shellRc" ]; then
+      if [ -f "$i/$shellRc" ]
+      then
          sourceFoam="$i/$shellRc"
          break
       fi
@@ -105,7 +107,8 @@ fi
 # attempt to preserve the installation directory 'FOAM_INST_DIR'
 case $sourceFoam in
 */bashrc)
-   if [ "$FOAM_INST_DIR" ]; then
+   if [ "$FOAM_INST_DIR" ]
+   then
       sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam"
    else
       sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam"
@@ -125,77 +128,111 @@ rcmd=$(echo $* | sed -e s/\"/\'\"\'/g)
 
 
 # Convert WM_COLOURS into an array
-declare colours
+declare colourList
 nColours=0
 for col in $WM_COLOURS
 do
-    colours[$nColours]=$col
-    ((nColours = $nColours + 1))
+   colourList[$nColours]=$col
+   ((nColours = $nColours + 1))
 done
 
-# Bashism: make pipe fail early. This make sure return value of compilation
-# is returned and not of colouring pipe.
+# Bashism: make pipe fail early.
+# This ensures the return value of the command is returned and not of the
+# colouring pipe etc.
 set -o pipefail
 
+
+#
+# colour output by argument 1
+#
+colourPipe()
+{
+   if [ "$1" ]
+   then
+   (
+      while read line
+      do
+         setterm -foreground $1
+         echo "$line"
+      done
+      setterm -foreground default
+   )
+   else
+      cat
+   fi
+}
+
+
+#
+# prefix message with [HOSTNAME]
+#
+prefixPipe()
+{
+   while read line
+   do
+      echo "[$@] $line"
+   done
+}
+
+
 colourIndex=0
 
 while :
 do
-    for slotGroup in $WM_HOSTS
-    do
-        # split 'host:N', but catch 'host:' and 'host' too
-        host=${slotGroup%%:*}
-        n=${slotGroup##*:}
-        if [ "$n" = "$host" ]; then n=1; fi # missing ':'
-        : ${n:=1}
-
-        i=0
-        while [ "$i" -lt "$n" ]
-        do
-            lockFile="$lockDir/$host:$i"
-            if lockfile -r0 "$lockFile" 2>/dev/null; then
-                if [ "$WM_COLOURS" ]; then
-                    # Set colour
-                    colourString=`setterm -foreground ${colours[$colourIndex]}`
-
-                    if [ "$host" = "$HOST" ]; then
-                        eval $* 2>&1 | sed -e "s/^/$colourString/"
-                    elif [ -n "$JOB_ID" ]; then
-                        qrsh -inherit -v PWD $host "$rcmd"
-                    else
-                        ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | sed -e "s/^/$colourString/"
-                    fi
-                    retval=$?
-                else
-                    if [ "$host" = "$HOST" ]; then
-                        eval $*
-                    elif [ -n "$JOB_ID" ]; then
-                        qrsh -inherit -v PWD $host "$rcmd"
-                    else
-                        ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd"
-                    fi
-                    retval=$?
-                fi
-
-                # Release lock
-                rm -f "$lockFile" 2>/dev/null
-                exit $retval
+   for slotGroup in $WM_HOSTS
+   do
+      # split 'host:N', but catch 'host:' and 'host' too
+      host=${slotGroup%%:*}
+      n=${slotGroup##*:}
+      [ "$n" = "$host" ] && n=1  # missing ':'
+      : ${n:=1}
+
+      i=0
+      while [ "$i" -lt "$n" ]
+      do
+         lockFile="$lockDir/$host:$i"
+         if lockfile -r0 "$lockFile" 2>/dev/null
+         then
+            if [ "$nColours" -gt 0 ]
+            then
+               # Set colour and index to next colour
+               colour="${colourList[$colourIndex]}"
+               colourIndex=$(expr $colourIndex + 1)
+               [ "$colourIndex" -lt "$nColours" ] || colourIndex=0
+
+               if [ "$host" = "$HOST" ]; then
+                  eval $* 2>&1 | colourPipe "$colour"
+               elif [ -n "$JOB_ID" ]; then
+                  qrsh -inherit -v PWD $host "$rcmd"
+               else
+                  ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour"
+               fi
+               retval=$?
+            else
+               if [ "$host" = "$HOST" ]; then
+                  eval $* 2>&1 | prefixPipe "$host"
+               elif [ -n "$JOB_ID" ]; then
+                  qrsh -inherit -v PWD $host "$rcmd" | prefixPipe "$host"
+               else
+                  ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | prefixPipe "$host"
+               fi
+               retval=$?
             fi
-            i=$(expr $i + 1)
 
-            # Cycle through colours
-            colourIndex=$(expr $colourIndex + 1)
-            if (( $colourIndex >= $nColours )); then
-                colourIndex=0
-            fi
-        done
-    done
-    # Did not find any free slots. Rest a bit.
-    sleep 1
+            # Release lock
+            rm -f "$lockFile" 2>/dev/null
+            exit $retval
+         fi
+         i=$(expr $i + 1)
+      done
+   done
+   # Did not find any free slots. Rest a bit.
+   sleep 1
 done
 
-if [ "$WM_COLOURS" ]; then
-    setterm -foreground default
+if [ "$nColours" -gt 0 ]
+then
+   setterm -foreground default
 fi
 
 #------------------------------------------------------------------------------