extendedCellToCellStencil: Template the type of the weights in weighted sum

This commit is contained in:
Henry
2013-02-19 18:02:52 +00:00
parent 3e3d2dee50
commit 41d7a061da
3 changed files with 45 additions and 28 deletions

View File

@ -68,24 +68,23 @@ public:
// Member Functions
// //- Use map to get the data into stencil order
// template<class T>
// static void collectData
// (
// const mapDistribute& map,
// const labelListList& stencil,
// const GeometricField<T, fvsPatchField, surfaceMesh>& fld,
// List<List<T> >& stencilFld
// );
//
//- Sum surface field contributions to create cell values
template<class Type>
static tmp<GeometricField<Type, fvPatchField, volMesh> > weightedSum
template<class Type, class WeightType>
static
tmp
<
GeometricField
<
typename outerProduct<WeightType, Type>::type,
fvPatchField,
volMesh
>
> weightedSum
(
const mapDistribute& map,
const labelListList& stencil,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const List<List<scalar> >& stencilWeights
const List<List<WeightType> >& stencilWeights
);
};

View File

@ -27,25 +27,36 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::extendedCellToCellStencil::weightedSum
template<class Type, class WeightType>
Foam::tmp
<
Foam::GeometricField
<
typename Foam::outerProduct<WeightType, Type>::type,
Foam::fvPatchField,
Foam::volMesh
>
> Foam::extendedCellToCellStencil::weightedSum
(
const mapDistribute& map,
const labelListList& stencil,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const List<List<scalar> >& stencilWeights
const List<List<WeightType> >& stencilWeights
)
{
typedef typename outerProduct<WeightType, Type>::type WeightedType;
typedef GeometricField<WeightedType, fvPatchField, volMesh>
WeightedFieldType;
const fvMesh& mesh = fld.mesh();
// Collect internal and boundary values
List<List<Type> > stencilFld;
collectData(map, stencil, fld, stencilFld);
tmp<GeometricField<Type, fvPatchField, volMesh> > tsfCorr
tmp<WeightedFieldType> twf
(
new GeometricField<Type, fvPatchField, volMesh>
new WeightedFieldType
(
IOobject
(
@ -62,23 +73,23 @@ Foam::extendedCellToCellStencil::weightedSum
)
)
);
GeometricField<Type, fvPatchField, volMesh>& sf = tsfCorr();
WeightedFieldType& wf = twf();
// cells
forAll(sf, cellI)
forAll(wf, cellI)
{
const List<Type>& stField = stencilFld[cellI];
const List<scalar>& stWeight = stencilWeights[cellI];
const List<WeightType>& stWeight = stencilWeights[cellI];
forAll(stField, i)
{
sf[cellI] += stField[i]*stWeight[i];
wf[cellI] += stWeight[i]*stField[i];
}
}
// Boundaries values?
return tsfCorr;
return twf;
}

View File

@ -116,11 +116,19 @@ public:
}
//- Sum vol field contributions to create cell values
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > weightedSum
template<class Type, class WeightType>
tmp
<
GeometricField
<
typename outerProduct<WeightType, Type>::type,
fvPatchField,
volMesh
>
> weightedSum
(
const GeometricField<Type, fvPatchField, volMesh>& fld,
const List<List<scalar> >& stencilWeights
const List<List<WeightType> >& stencilWeights
) const
{
return weightedSum
@ -131,7 +139,6 @@ public:
stencilWeights
);
}
};