pimpleDyMFoam: Improved efficiency and consistency when running on a static mesh

Now pimpleDyMFoam is exactly equivalent to pimpleFoam when running on a
staticFvMesh.  Also when the constant/dynamicMeshDict is not present a
staticFvMesh is automatically constructed so that the pimpleDyMFoam solver can
run any pimpleFoam case without change.
This commit is contained in:
Henry Weller
2017-11-18 01:13:48 +00:00
parent 16ba55100a
commit 9c48042e85
13 changed files with 275 additions and 56 deletions

View File

@ -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;

View File

@ -161,6 +161,36 @@ inline const T& Foam::autoPtr<T>::operator()() const
}
template<class T>
inline T& Foam::autoPtr<T>::operator*()
{
if (!ptr_)
{
FatalErrorInFunction
<< "object of type " << typeid(T).name()
<< " is not allocated"
<< abort(FatalError);
}
return *ptr_;
}
template<class T>
inline const T& Foam::autoPtr<T>::operator*() const
{
if (!ptr_)
{
FatalErrorInFunction
<< "object of type " << typeid(T).name()
<< " is not allocated"
<< abort(FatalError);
}
return *ptr_;
}
template<class T>
inline Foam::autoPtr<T>::operator const T&() const
{

View File

@ -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<dynamicFvMesh> New(const IOobject& io);

View File

@ -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> Foam::dynamicFvMesh::New(const IOobject& io)
// - defaultRegion (region0) gets loaded from constant, other ones
// get loaded from constant/<regionname>. 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<IOdictionary>(true))
{
IOdictionary dict(dictHeader);
const word dynamicFvMeshTypeName(dict.lookup("dynamicFvMesh"));
Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
const_cast<Time&>(io.time()).libs().open
(
"dynamicMeshDict",
io.time().constant(),
(io.name() == polyMesh::defaultRegion ? "" : io.name()),
io.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
dict,
"dynamicFvMeshLibs",
IOobjectConstructorTablePtr_
);
const word dynamicFvMeshTypeName(dict.lookup("dynamicFvMesh"));
if (!IOobjectConstructorTablePtr_)
{
FatalErrorInFunction
<< "dynamicFvMesh table is empty"
<< exit(FatalError);
}
Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
IOobjectConstructorTable::iterator cstrIter =
IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);
const_cast<Time&>(io.time()).libs().open
(
dict,
"dynamicFvMeshLibs",
IOobjectConstructorTablePtr_
);
if (cstrIter == IOobjectConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown dynamicFvMesh type "
<< dynamicFvMeshTypeName << nl << nl
<< "Valid dynamicFvMesh types are :" << endl
<< IOobjectConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
if (!IOobjectConstructorTablePtr_)
{
FatalErrorInFunction
<< "dynamicFvMesh table is empty"
<< exit(FatalError);
return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
IOobjectConstructorTable::iterator cstrIter =
IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);
if (cstrIter == IOobjectConstructorTablePtr_->end())
else
{
FatalErrorInFunction
<< "Unknown dynamicFvMesh type "
<< dynamicFvMeshTypeName << nl << nl
<< "Valid dynamicFvMesh types are :" << endl
<< IOobjectConstructorTablePtr_->sortedToc()
<< exit(FatalError);
return autoPtr<dynamicFvMesh>(new staticFvMesh(io));
}
return autoPtr<dynamicFvMesh>(cstrIter()(io));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -201,6 +201,31 @@ ddtCorr
}
template<class Type>
tmp<GeometricField<typename flux<Type>::type, fvsPatchField, surfaceMesh>>
ddtCorr
(
const GeometricField<Type, fvPatchField, volMesh>& U,
const GeometricField
<
typename flux<Type>::type,
fvsPatchField,
surfaceMesh
>& phi,
const GeometricField<Type, fvsPatchField, surfaceMesh>& Uf
)
{
if (U.mesh().changing())
{
return ddtCorr(U, Uf);
}
else
{
return ddtCorr(U, phi);
}
}
template<class Type>
tmp<GeometricField<typename flux<Type>::type, fvsPatchField, surfaceMesh>>
ddtCorr

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -154,6 +154,28 @@ namespace fvc
>& phi
);
template<class Type>
tmp
<
GeometricField
<
typename Foam::flux<Type>::type,
fvsPatchField,
surfaceMesh
>
>
ddtCorr
(
const GeometricField<Type, fvPatchField, volMesh>& U,
const GeometricField
<
typename Foam::flux<Type>::type,
fvsPatchField,
surfaceMesh
>& phi,
const GeometricField<Type, fvsPatchField, surfaceMesh>& Uf
);
template<class Type>
tmp
<

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -219,4 +219,22 @@ Foam::tmp<Foam::surfaceScalarField> Foam::fvc::absolute
}
void Foam::fvc::correctUf
(
surfaceVectorField& Uf,
const volVectorField& U,
const surfaceScalarField& phi
)
{
const fvMesh& mesh = U.mesh();
if (phi.mesh().changing())
{
Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(phi/mesh.magSf() - (n & Uf));
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -147,6 +147,13 @@ namespace fvc
const volScalarField& rho,
const volVectorField& U
);
void correctUf
(
surfaceVectorField& Uf,
const volVectorField& U,
const surfaceScalarField& phi
);
}