/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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.
OpenFOAM 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 OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "fvMesh.H"
#include "fvcGrad.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
Foam::GeometricField
<
typename Foam::outerProduct::type,
Foam::fvPatchField,
Foam::volMesh
>&
Foam::calcFvcGrad::gradField(const word& gradName, const dimensionSet& dims)
{
Info<< "gradField" << endl;
typedef typename outerProduct::type gradType;
typedef GeometricField vfGradType;
const fvMesh& mesh = refCast(obr_);
if (!mesh.foundObject(gradName))
{
vfGradType* gradFieldPtr
(
new vfGradType
(
IOobject
(
gradName,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensioned
(
"zero",
dims/dimLength,
pTraits::zero
)
)
);
mesh.objectRegistry::store(gradFieldPtr);
}
const vfGradType& field = mesh.lookupObject(gradName);
return const_cast(field);
}
template
void Foam::calcFvcGrad::calcGrad
(
const word& fieldName,
const word& resultName,
bool& processed
)
{
typedef GeometricField vfType;
typedef GeometricField sfType;
typedef typename outerProduct::type gradType;
typedef GeometricField vfGradType;
const fvMesh& mesh = refCast(obr_);
if (mesh.foundObject(fieldName))
{
const vfType& vf = mesh.lookupObject(fieldName);
vfGradType& field = gradField(resultName, vf.dimensions());
// De-reference the tmp to avoid a clash with the cached grad field
field = fvc::grad(vf)();
processed = true;
}
else if (mesh.foundObject(fieldName))
{
const sfType& sf = mesh.lookupObject(fieldName);
vfGradType& field = gradField(resultName, sf.dimensions());
// De-reference the tmp to avoid a clash with the cached grad field
field = fvc::grad(sf)();
processed = true;
}
}
// ************************************************************************* //