extendedFaceToCellStencilTemplates.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "extendedFaceToCellStencil.H"
00028
00029
00030
00031 template<class Type>
00032 void Foam::extendedFaceToCellStencil::collectData
00033 (
00034 const mapDistribute& map,
00035 const labelListList& stencil,
00036 const GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
00037 List<List<Type> >& stencilFld
00038 )
00039 {
00040
00041 List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
00042
00043
00044 forAll(fld, cellI)
00045 {
00046 compactFld[cellI] = fld[cellI];
00047 }
00048
00049 label nCompact = fld.size();
00050 forAll(fld.boundaryField(), patchI)
00051 {
00052 const fvsPatchField<Type>& pfld = fld.boundaryField()[patchI];
00053
00054 forAll(pfld, i)
00055 {
00056 compactFld[nCompact++] = pfld[i];
00057 }
00058 }
00059
00060
00061 map.distribute(compactFld);
00062
00063
00064 stencilFld.setSize(stencil.size());
00065
00066 forAll(stencil, faceI)
00067 {
00068 const labelList& compactCells = stencil[faceI];
00069
00070 stencilFld[faceI].setSize(compactCells.size());
00071
00072 forAll(compactCells, i)
00073 {
00074 stencilFld[faceI][i] = compactFld[compactCells[i]];
00075 }
00076 }
00077 }
00078
00079
00080 template<class Type>
00081 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
00082 Foam::extendedFaceToCellStencil::weightedSum
00083 (
00084 const mapDistribute& map,
00085 const labelListList& stencil,
00086 const GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
00087 const List<List<scalar> >& stencilWeights
00088 )
00089 {
00090 const fvMesh& mesh = fld.mesh();
00091
00092
00093 List<List<Type> > stencilFld;
00094 collectData(map, stencil, fld, stencilFld);
00095
00096 tmp<GeometricField<Type, fvPatchField, volMesh> > tsfCorr
00097 (
00098 new GeometricField<Type, fvPatchField, volMesh>
00099 (
00100 IOobject
00101 (
00102 fld.name(),
00103 mesh.time().timeName(),
00104 mesh
00105 ),
00106 mesh,
00107 dimensioned<Type>
00108 (
00109 fld.name(),
00110 fld.dimensions(),
00111 pTraits<Type>::zero
00112 )
00113 )
00114 );
00115 GeometricField<Type, fvPatchField, volMesh>& sf = tsfCorr();
00116
00117
00118 forAll(sf, cellI)
00119 {
00120 const List<Type>& stField = stencilFld[cellI];
00121 const List<scalar>& stWeight = stencilWeights[cellI];
00122
00123 forAll(stField, i)
00124 {
00125 sf[cellI] += stField[i]*stWeight[i];
00126 }
00127 }
00128
00129
00130
00131 return tsfCorr;
00132 }
00133
00134
00135
Copyright © 2000-2009 OpenCFD Ltd