Skip to content
Snippets Groups Projects
Commit 450779d2 authored by Henry Weller's avatar Henry Weller
Browse files

linearUpwind: Evaluate the gradient of each component of the field to provide...

linearUpwind: Evaluate the gradient of each component of the field to provide support all field types

Also reduces peak-storage as it now generates a volVectorField for each component
rather than the gradient of the field type.
parent 2fd4b6bc
Branches
Tags
1 merge request!60Merge foundation
......@@ -65,66 +65,65 @@ Foam::linearUpwind<Type>::correction
const volVectorField& C = mesh.C();
const surfaceVectorField& Cf = mesh.Cf();
tmp
<
GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>
> tgradVf = gradScheme_().grad(vf, gradSchemeName_);
const GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>& gradVf = tgradVf();
forAll(faceFlux, facei)
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
{
label celli = (faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
sfCorr[facei] = (Cf[facei] - C[celli]) & gradVf[celli];
}
tmp<volVectorField> tgradVf =
gradScheme_().grad(vf.component(cmpt), gradSchemeName_);
const volVectorField& gradVf = tgradVf();
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
Boundary& bSfCorr = sfCorr.boundaryFieldRef();
forAll(faceFlux, facei)
{
const label celli =
(faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
forAll(bSfCorr, patchi)
{
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
setComponent(sfCorr[facei], cmpt) =
(Cf[facei] - C[celli]) & gradVf[celli];
}
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
Boundary& bSfCorr = sfCorr.boundaryFieldRef();
if (pSfCorr.coupled())
forAll(bSfCorr, patchi)
{
const labelUList& pOwner =
mesh.boundary()[patchi].faceCells();
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
const vectorField& pCf = Cf.boundaryField()[patchi];
if (pSfCorr.coupled())
{
const labelUList& pOwner =
mesh.boundary()[patchi].faceCells();
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
const vectorField& pCf = Cf.boundaryField()[patchi];
const Field<typename outerProduct<vector, Type>::type> pGradVfNei
(
gradVf.boundaryField()[patchi].patchNeighbourField()
);
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
// Build the d-vectors
vectorField pd(Cf.boundaryField()[patchi].patch().delta());
const vectorField pGradVfNei
(
gradVf.boundaryField()[patchi].patchNeighbourField()
);
forAll(pOwner, facei)
{
label own = pOwner[facei];
// Build the d-vectors
const vectorField pd
(
Cf.boundaryField()[patchi].patch().delta()
);
if (pFaceFlux[facei] > 0)
{
pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
}
else
forAll(pOwner, facei)
{
pSfCorr[facei] =
(pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
label own = pOwner[facei];
if (pFaceFlux[facei] > 0)
{
setComponent(pSfCorr[facei], cmpt) =
(pCf[facei] - C[own])
& gradVf[own];
}
else
{
setComponent(pSfCorr[facei], cmpt) =
(pCf[facei] - pd[facei] - C[own])
& pGradVfNei[facei];
}
}
}
}
......@@ -136,9 +135,7 @@ Foam::linearUpwind<Type>::correction
namespace Foam
{
//makelimitedSurfaceInterpolationScheme(linearUpwind)
makelimitedSurfaceInterpolationTypeScheme(linearUpwind, scalar)
makelimitedSurfaceInterpolationTypeScheme(linearUpwind, vector)
makelimitedSurfaceInterpolationScheme(linearUpwind)
}
// ************************************************************************* //
......@@ -57,7 +57,7 @@ class linearUpwind
// Private Data
word gradSchemeName_;
tmp<fv::gradScheme<Type>> gradScheme_;
tmp<fv::gradScheme<scalar>> gradScheme_;
// Private Member Functions
......@@ -88,7 +88,7 @@ public:
gradSchemeName_("grad"),
gradScheme_
(
new fv::gaussGrad<Type>(mesh)
new fv::gaussGrad<scalar>(mesh)
)
{}
......@@ -105,7 +105,7 @@ public:
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
fv::gradScheme<scalar>::New
(
mesh,
mesh.gradScheme(gradSchemeName_)
......@@ -125,7 +125,7 @@ public:
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
fv::gradScheme<scalar>::New
(
mesh,
mesh.gradScheme(gradSchemeName_)
......@@ -148,7 +148,6 @@ public:
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment