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:
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
<
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user