Skip to content
Snippets Groups Projects
Commit 55c880b7 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

Merge branch 'feature-mesh-update-controls' into 'develop'

Feature mesh update controls

See merge request !306
parents 280be631 87bba9ae
Branches
Tags
1 merge request!306Feature mesh update controls
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -36,6 +37,10 @@ Description ...@@ -36,6 +37,10 @@ Description
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
pseudo-transient simulations. 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" #include "fvCFD.H"
...@@ -131,7 +136,7 @@ int main(int argc, char *argv[]) ...@@ -131,7 +136,7 @@ int main(int argc, char *argv[])
} }
// Do any mesh changes // Do any mesh changes
mesh.update(); mesh.controlledUpdate();
if (mesh.changing()) if (mesh.changing())
{ {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -67,6 +68,10 @@ Description ...@@ -67,6 +68,10 @@ Description
\<turbulence fields\> | As required by user selection \<turbulence fields\> | As required by user selection
\endplaintable \endplaintable
Note
The motion frequency of this solver can be influenced by the presence
of "updateControl" and "updateInterval" in the dynamicMeshDict.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "fvCFD.H"
...@@ -121,7 +126,8 @@ int main(int argc, char *argv[]) ...@@ -121,7 +126,8 @@ int main(int argc, char *argv[])
{ {
if (pimple.firstIter() || moveMeshOuterCorrectors) if (pimple.firstIter() || moveMeshOuterCorrectors)
{ {
mesh.update(); // Do any mesh changes
mesh.controlledUpdate();
if (mesh.changing()) if (mesh.changing())
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -37,12 +37,36 @@ namespace Foam ...@@ -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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dynamicFvMesh::dynamicFvMesh(const IOobject& io) Foam::dynamicFvMesh::dynamicFvMesh(const IOobject& io)
: :
fvMesh(io) fvMesh(io),
{} timeControl_(io.time(), "update")
{
readDict();
}
Foam::dynamicFvMesh::dynamicFvMesh Foam::dynamicFvMesh::dynamicFvMesh
...@@ -52,8 +76,11 @@ Foam::dynamicFvMesh::dynamicFvMesh ...@@ -52,8 +76,11 @@ Foam::dynamicFvMesh::dynamicFvMesh
const bool syncPar const bool syncPar
) )
: :
fvMesh(io, Zero, syncPar) fvMesh(io, Zero, syncPar),
{} timeControl_(io.time(), "update")
{
readDict();
}
Foam::dynamicFvMesh::dynamicFvMesh Foam::dynamicFvMesh::dynamicFvMesh
...@@ -74,8 +101,11 @@ Foam::dynamicFvMesh::dynamicFvMesh ...@@ -74,8 +101,11 @@ Foam::dynamicFvMesh::dynamicFvMesh
std::move(allOwner), std::move(allOwner),
std::move(allNeighbour), std::move(allNeighbour),
syncPar syncPar
) ),
{} timeControl_(io.time(), "update")
{
readDict();
}
Foam::dynamicFvMesh::dynamicFvMesh Foam::dynamicFvMesh::dynamicFvMesh
...@@ -94,8 +124,28 @@ Foam::dynamicFvMesh::dynamicFvMesh ...@@ -94,8 +124,28 @@ Foam::dynamicFvMesh::dynamicFvMesh
std::move(faces), std::move(faces),
std::move(cells), std::move(cells),
syncPar 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;
}
// ************************************************************************* // // ************************************************************************* //
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -30,6 +30,16 @@ Class ...@@ -30,6 +30,16 @@ Class
Description Description
Abstract base class for geometry and/or topology changing fvMesh. 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 SourceFiles
dynamicFvMesh.C dynamicFvMesh.C
dynamicFvMeshNew.C dynamicFvMeshNew.C
...@@ -40,6 +50,7 @@ SourceFiles ...@@ -40,6 +50,7 @@ SourceFiles
#define dynamicFvMesh_H #define dynamicFvMesh_H
#include "fvMesh.H" #include "fvMesh.H"
#include "timeControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -47,15 +58,24 @@ namespace Foam ...@@ -47,15 +58,24 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class dynamicFvMesh Declaration Class dynamicFvMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class dynamicFvMesh class dynamicFvMesh
: :
public fvMesh public fvMesh
{ {
// Private Data
//- Optional update control
timeControl timeControl_;
// Private Member Functions // Private Member Functions
//- Read the updateControl/updateInterval from dynamicMeshDict
void readDict();
//- No copy construct //- No copy construct
dynamicFvMesh(const dynamicFvMesh&) = delete; dynamicFvMesh(const dynamicFvMesh&) = delete;
...@@ -83,7 +103,7 @@ public: ...@@ -83,7 +103,7 @@ public:
// Constructors // Constructors
//- Construct from objectRegistry, and read/write options //- Construct from an IOobject
explicit dynamicFvMesh(const IOobject& io); explicit dynamicFvMesh(const IOobject& io);
//- Construct from components without boundary. //- Construct from components without boundary.
...@@ -144,6 +164,9 @@ public: ...@@ -144,6 +164,9 @@ public:
return true; return true;
} }
//- Update the mesh if controller permits
virtual bool controlledUpdate();
//- Update the mesh for both mesh motion and topology change //- Update the mesh for both mesh motion and topology change
virtual bool update() = 0; virtual bool update() = 0;
}; };
......
...@@ -88,7 +88,6 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io) ...@@ -88,7 +88,6 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
return autoPtr<dynamicFvMesh>(cstrIter()(io)); return autoPtr<dynamicFvMesh>(cstrIter()(io));
} }
return autoPtr<dynamicFvMesh>(new staticFvMesh(io)); return autoPtr<dynamicFvMesh>(new staticFvMesh(io));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment