diff --git a/applications/solvers/incompressible/pimpleFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pEqn.H
index c8d02ed281..1c3eb66259 100644
--- a/applications/solvers/incompressible/pimpleFoam/pEqn.H
+++ b/applications/solvers/incompressible/pimpleFoam/pEqn.H
@@ -53,6 +53,6 @@ while (pimple.correctNonOrthogonal())
// Explicitly relax pressure for momentum corrector
p.relax();
-U = HbyA - rAtU()*fvc::grad(p);
+U = HbyA - rAtU*fvc::grad(p);
U.correctBoundaryConditions();
fvOptions.correct(U);
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createUf.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createUf.H
new file mode 100644
index 0000000000..523a04b502
--- /dev/null
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createUf.H
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Global
+ createUf
+
+Description
+ Creates and initialises the velocity field Uf if present.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+autoPtr UfPtr;
+
+IOobject UfHeader
+(
+ "Uf",
+ runTime.timeName(),
+ mesh,
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+);
+
+if (UfHeader.typeHeaderOk(true))
+{
+ Info<< "Reading face velocity Uf\n" << endl;
+ UfPtr = new surfaceVectorField(UfHeader, mesh);
+}
+
+// ************************************************************************* //
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
index a53391a90b..df19741c50 100644
--- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
@@ -4,7 +4,7 @@ surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
- + fvc::interpolate(rAU)*fvc::ddtCorr(U, Uf)
+ + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi, Uf)
);
MRF.makeRelative(phiHbyA);
@@ -61,11 +61,8 @@ U = HbyA - rAtU*fvc::grad(p);
U.correctBoundaryConditions();
fvOptions.correct(U);
-{
- Uf = fvc::interpolate(U);
- surfaceVectorField n(mesh.Sf()/mesh.magSf());
- Uf += n*(phi/mesh.magSf() - (n & Uf));
-}
+// Correct Uf if the mesh is moving
+fvc::correctUf(Uf, U, phi);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C
index d016fb18e7..468c017380 100644
--- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pimpleDyMFoam.C
@@ -74,6 +74,8 @@ int main(int argc, char *argv[])
mesh.update();
+ #include "updateUf.H"
+
if (mesh.changing())
{
MRF.update();
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/updateUf.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/updateUf.H
new file mode 100644
index 0000000000..a38c30ac9b
--- /dev/null
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/updateUf.H
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Global
+ updateUf
+
+Description
+ Constructs the velocity field Uf if not already constructed.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+if (mesh.changing())
+{
+ if (!UfPtr.valid())
+ {
+ Info<< "Constructing face velocity Uf" << endl;
+
+ UfPtr = new surfaceVectorField
+ (
+ IOobject
+ (
+ "Uf",
+ runTime.timeName(),
+ mesh,
+ IOobject::READ_IF_PRESENT,
+ IOobject::AUTO_WRITE
+ ),
+ fvc::interpolate(U)
+ );
+ }
+}
+
+surfaceVectorField& Uf = *UfPtr;
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H
index 76afd531c0..5b76c18114 100644
--- a/src/OpenFOAM/memory/autoPtr/autoPtr.H
+++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H
@@ -116,6 +116,12 @@ public:
//- Return const reference to the object data
inline const T& operator()() const;
+ //- Return reference to the object data
+ inline T& operator*();
+
+ //- Return const reference to the object data
+ inline const T& operator*() const;
+
//- Const cast to the underlying type reference
inline operator const T&() const;
diff --git a/src/OpenFOAM/memory/autoPtr/autoPtrI.H b/src/OpenFOAM/memory/autoPtr/autoPtrI.H
index 7eaa605a8f..7f07ccc188 100644
--- a/src/OpenFOAM/memory/autoPtr/autoPtrI.H
+++ b/src/OpenFOAM/memory/autoPtr/autoPtrI.H
@@ -161,6 +161,36 @@ inline const T& Foam::autoPtr::operator()() const
}
+template
+inline T& Foam::autoPtr::operator*()
+{
+ if (!ptr_)
+ {
+ FatalErrorInFunction
+ << "object of type " << typeid(T).name()
+ << " is not allocated"
+ << abort(FatalError);
+ }
+
+ return *ptr_;
+}
+
+
+template
+inline const T& Foam::autoPtr::operator*() const
+{
+ if (!ptr_)
+ {
+ FatalErrorInFunction
+ << "object of type " << typeid(T).name()
+ << " is not allocated"
+ << abort(FatalError);
+ }
+
+ return *ptr_;
+}
+
+
template
inline Foam::autoPtr::operator const T&() const
{
diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H
index 6447ba5240..56dc4be0d1 100644
--- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H
+++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
+ \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -37,8 +37,6 @@ SourceFiles
#define dynamicFvMesh_H
#include "fvMesh.H"
-#include "autoPtr.H"
-#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -111,7 +109,9 @@ public:
// Selectors
- //- Select null constructed
+ //- Select, construct and return the dynamicFvMesh
+ // If the constant/dynamicMeshDict does not exist
+ // a staticFvMesh is returned
static autoPtr New(const IOobject& io);
diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C
index fa05cc2a59..10fc73e15e 100644
--- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C
+++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
+ \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -23,9 +23,7 @@ License
\*---------------------------------------------------------------------------*/
-#include "dynamicFvMesh.H"
-#include "Time.H"
-#include "dlLibraryTable.H"
+#include "staticFvMesh.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
@@ -36,52 +34,58 @@ Foam::autoPtr Foam::dynamicFvMesh::New(const IOobject& io)
// - defaultRegion (region0) gets loaded from constant, other ones
// get loaded from constant/. Normally we'd use
// polyMesh::dbDir() but we haven't got a polyMesh yet ...
- IOdictionary dict
+ IOobject dictHeader
(
- IOobject
+ "dynamicMeshDict",
+ io.time().constant(),
+ (io.name() == polyMesh::defaultRegion ? "" : io.name()),
+ io.db(),
+ IOobject::MUST_READ_IF_MODIFIED,
+ IOobject::NO_WRITE,
+ false
+ );
+
+ if (dictHeader.typeHeaderOk(true))
+ {
+ IOdictionary dict(dictHeader);
+
+ const word dynamicFvMeshTypeName(dict.lookup("dynamicFvMesh"));
+
+ Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
+
+ const_cast