Michalak-Gooch gradient limiter

This commit is contained in:
Hrvoje Jasak 2016-03-17 11:51:12 +00:00
parent 867584532b
commit 90ad79799e
3 changed files with 373 additions and 0 deletions

View file

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::michalakGoochGrad
Description
Michalak-Gooch gradient limiter applied to a runTime selected
base gradient scheme.
SourceFiles
michalakGoochGrad.C
\*---------------------------------------------------------------------------*/
#ifndef michalakGoochGrad_H
#define michalakGoochGrad_H
#include "gradScheme.H"
#include "LimitedGrad.H"
#include "MichalakGoochLimiter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fv
{
/*---------------------------------------------------------------------------*\
Class michalakGoochGrad Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class michalakGoochGrad
:
public fv::gradScheme<Type>,
public LimitedGrad<Type, MichalakGoochLimiter>
{
// Private Member Functions
//- Disallow default bitwise copy construct
michalakGoochGrad(const michalakGoochGrad&);
//- Disallow default bitwise assignment
void operator=(const michalakGoochGrad&);
public:
//- RunTime type information
TypeName("michalakGooch");
// Constructors
//- Construct from mesh and schemeData
michalakGoochGrad(const fvMesh& mesh, Istream& schemeData)
:
gradScheme<Type>(mesh),
LimitedGrad<Type, MichalakGoochLimiter>(mesh, schemeData)
{}
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
virtual tmp
<
GeometricField
<typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
> calcGrad
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const word& name
) const
{
return LimitedGrad<Type, MichalakGoochLimiter>::gradientField
(
vf,
name
);
}
//- Return the BlockLduSystem corresponding to the implicit cell
// limited grad discretization. For block coupled systems.
virtual tmp
<
BlockLduSystem<vector, typename outerProduct<vector, Type>::type>
> fvmGrad
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
return LimitedGrad<Type, MichalakGoochLimiter>::gradientMatrix
(
vf
);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "michalakGoochGrad.H"
#include "fvMesh.H"
#include "volMesh.H"
#include "surfaceMesh.H"
#include "volFields.H"
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fv
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFvGradScheme(michalakGoochGrad)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp
<
BlockLduSystem<vector, outerProduct<vector, vector>::type>
>
michalakGoochGrad<vector>::fvmGrad
(
const volVectorField& vf
) const
{
FatalErrorIn
(
"tmp<BlockLduSystem> michalakGoochGrad<vector>::fvmGrad\n"
"(\n"
" GeometricField<vector, fvPatchField, volMesh>&"
")\n"
) << "Implicit gradient operators with cell limiters defined only for "
<< "scalar."
<< abort(FatalError);
typedef outerProduct<vector, vector>::type GradType;
tmp<BlockLduSystem<vector, GradType> > tbs
(
new BlockLduSystem<vector, GradType>(vf.mesh())
);
return tbs;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
MichalakGoochLimiter
Description
Michalak-Gooch limiter, AIAA-2009-954
Author
Hrvoje Jasak
\*---------------------------------------------------------------------------*/
#ifndef MichalakGoochLimiter_H
#define MichalakGoochLimiter_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MichalakGoochLimiter Declaration
\*---------------------------------------------------------------------------*/
class MichalakGoochLimiter
{
// Private data
//- Coefficient
const scalar k_;
public:
// Constructors
//- Construct null
MichalakGoochLimiter()
:
k_(1.5)
{}
// Destructor - default
// Member functions
//- Set scalar limiter value
inline void limiter
(
scalar& lim,
const scalar& cellVolume,
const scalar& deltaOneMax,
const scalar& deltaOneMin,
const scalar& extrapolate
)
{
// If there is no span or extrapolation, do not limit. Note that
// deltaOneMax and deltaOneMin are bound by zero and min is
// negative
if
(
deltaOneMax - deltaOneMin < SMALL
|| mag(extrapolate) < SMALL
)
{
return;
}
scalar y;
if (extrapolate > 0)
{
y = deltaOneMax/extrapolate;
}
else
{
y = deltaOneMin/extrapolate;
}
if (y < k_)
{
const scalar C2 = (3 - 2*k_)/sqr(k_);
const scalar C3 = -1/(3*sqr(k_)) - 2/(3*k_)*C2;
lim = min(lim, y + C2*sqr(y) + C3*pow3(y));
}
}
//- Set Type limiter
template<class Type>
inline void limiter
(
Type& lim,
const scalar& cellVolume,
const Type& deltaOneMax,
const Type& deltaOneMin,
const Type& extrapolate
)
{
for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++)
{
limiter
(
lim.component(cmpt),
cellVolume,
deltaOneMax.component(cmpt),
deltaOneMin.component(cmpt),
extrapolate.component(cmpt)
);
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif
// ************************************************************************* //