diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C index d6b0163349f8d364ea2679a719f04057e8343731..69eb579d70578be5f2d6a4e13f8329186d0a2bd2 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,6 +37,10 @@ Description Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and pseudo-transient simulations. +Note + The motion frequency of this solver can be influenced by the presence + of "updateControl" and "updateInterval" in the dynamicMeshDict. + \*---------------------------------------------------------------------------*/ #include "fvCFD.H" @@ -131,7 +136,7 @@ int main(int argc, char *argv[]) } // Do any mesh changes - mesh.update(); + mesh.controlledUpdate(); if (mesh.changing()) { diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C index 9c9fb3bb2bdd8558275cff38f59becae15e1f1ac..282c75e9544bb8a214873b381b01fb74dd1fae7a 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,6 +68,10 @@ Description \<turbulence fields\> | As required by user selection \endplaintable +Note + The motion frequency of this solver can be influenced by the presence + of "updateControl" and "updateInterval" in the dynamicMeshDict. + \*---------------------------------------------------------------------------*/ #include "fvCFD.H" @@ -121,7 +126,8 @@ int main(int argc, char *argv[]) { if (pimple.firstIter() || moveMeshOuterCorrectors) { - mesh.update(); + // Do any mesh changes + mesh.controlledUpdate(); if (mesh.changing()) { diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.C index d19c8691afd4f0e5c09df32963181c0d4cf5473a..b0cbbbc3a99bb0615c65651aa78f1fffa53ebe15 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.C +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,12 +37,36 @@ namespace Foam } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::dynamicFvMesh::readDict() +{ + IOdictionary dict + ( + IOobject + ( + "dynamicMeshDict", + thisDb().time().constant(), + thisDb(), + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false // Do not register + ) + ); + + timeControl_.read(dict); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dynamicFvMesh::dynamicFvMesh(const IOobject& io) : - fvMesh(io) -{} + fvMesh(io), + timeControl_(io.time(), "update") +{ + readDict(); +} Foam::dynamicFvMesh::dynamicFvMesh @@ -52,8 +76,11 @@ Foam::dynamicFvMesh::dynamicFvMesh const bool syncPar ) : - fvMesh(io, Zero, syncPar) -{} + fvMesh(io, Zero, syncPar), + timeControl_(io.time(), "update") +{ + readDict(); +} Foam::dynamicFvMesh::dynamicFvMesh @@ -74,8 +101,11 @@ Foam::dynamicFvMesh::dynamicFvMesh std::move(allOwner), std::move(allNeighbour), syncPar - ) -{} + ), + timeControl_(io.time(), "update") +{ + readDict(); +} Foam::dynamicFvMesh::dynamicFvMesh @@ -94,8 +124,28 @@ Foam::dynamicFvMesh::dynamicFvMesh std::move(faces), std::move(cells), syncPar - ) -{} + ), + timeControl_(io.time(), "update") +{ + readDict(); +} + + +bool Foam::dynamicFvMesh::controlledUpdate() +{ + if (timeControl_.execute()) + { + if (!timeControl_.always()) + { + // Feedback that update has been triggered + Info<< "Mesh update triggered based on " << timeControl_.name() << nl; + } + + return this->update(); + } + + return false; +} // ************************************************************************* // diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H index 666fe89471546c30e1caddb50b1db1c79a876b47..8a0a7e3563600a7c0d8c36d426af563708efa4cd 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,16 @@ Class Description Abstract base class for geometry and/or topology changing fvMesh. + Supports optional update controls that may be used by custom solvers: + \table + Property | Description | Required | Default + updateControl | See time controls below | no | timeStep + updateInterval | Steps/time between update phases | no | 1 + \endtable + +See also + Foam::timeControl + SourceFiles dynamicFvMesh.C dynamicFvMeshNew.C @@ -40,6 +50,7 @@ SourceFiles #define dynamicFvMesh_H #include "fvMesh.H" +#include "timeControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,15 +58,24 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class dynamicFvMesh Declaration + Class dynamicFvMesh Declaration \*---------------------------------------------------------------------------*/ class dynamicFvMesh : public fvMesh { + // Private Data + + //- Optional update control + timeControl timeControl_; + + // Private Member Functions + //- Read the updateControl/updateInterval from dynamicMeshDict + void readDict(); + //- No copy construct dynamicFvMesh(const dynamicFvMesh&) = delete; @@ -83,7 +103,7 @@ public: // Constructors - //- Construct from objectRegistry, and read/write options + //- Construct from an IOobject explicit dynamicFvMesh(const IOobject& io); //- Construct from components without boundary. @@ -144,6 +164,9 @@ public: return true; } + //- Update the mesh if controller permits + virtual bool controlledUpdate(); + //- Update the mesh for both mesh motion and topology change virtual bool update() = 0; }; diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C index ae5a9afb9fa8322a925235d70707c4909cd20e9a..8b85cbb172773e95a425ca68bde34cd093ec2d98 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C @@ -88,7 +88,6 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io) return autoPtr<dynamicFvMesh>(cstrIter()(io)); } - return autoPtr<dynamicFvMesh>(new staticFvMesh(io)); }