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.
This commit is contained in:
parent
2fd4b6bce4
commit
450779d29a
2 changed files with 53 additions and 57 deletions
|
|
@ -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(bSfCorr, patchi)
|
||||
{
|
||||
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
|
||||
|
||||
if (pSfCorr.coupled())
|
||||
forAll(faceFlux, facei)
|
||||
{
|
||||
const labelUList& pOwner =
|
||||
mesh.boundary()[patchi].faceCells();
|
||||
const label celli =
|
||||
(faceFlux[facei] > 0) ? owner[facei] : neighbour[facei];
|
||||
|
||||
const vectorField& pCf = Cf.boundaryField()[patchi];
|
||||
setComponent(sfCorr[facei], cmpt) =
|
||||
(Cf[facei] - C[celli]) & gradVf[celli];
|
||||
}
|
||||
|
||||
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
|
||||
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
|
||||
Boundary& bSfCorr = sfCorr.boundaryFieldRef();
|
||||
|
||||
const Field<typename outerProduct<vector, Type>::type> pGradVfNei
|
||||
(
|
||||
gradVf.boundaryField()[patchi].patchNeighbourField()
|
||||
);
|
||||
forAll(bSfCorr, patchi)
|
||||
{
|
||||
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
|
||||
|
||||
// Build the d-vectors
|
||||
vectorField pd(Cf.boundaryField()[patchi].patch().delta());
|
||||
|
||||
forAll(pOwner, facei)
|
||||
if (pSfCorr.coupled())
|
||||
{
|
||||
label own = pOwner[facei];
|
||||
const labelUList& pOwner =
|
||||
mesh.boundary()[patchi].faceCells();
|
||||
|
||||
if (pFaceFlux[facei] > 0)
|
||||
const vectorField& pCf = Cf.boundaryField()[patchi];
|
||||
|
||||
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
|
||||
|
||||
const vectorField pGradVfNei
|
||||
(
|
||||
gradVf.boundaryField()[patchi].patchNeighbourField()
|
||||
);
|
||||
|
||||
// Build the d-vectors
|
||||
const vectorField pd
|
||||
(
|
||||
Cf.boundaryField()[patchi].patch().delta()
|
||||
);
|
||||
|
||||
forAll(pOwner, facei)
|
||||
{
|
||||
pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue