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 #include "extendedCellToFaceStencil.H"
00027
00028
00029
00030 template<class Type>
00031 void Foam::extendedCellToFaceStencil::collectData
00032 (
00033 const mapDistribute& map,
00034 const labelListList& stencil,
00035 const GeometricField<Type, fvPatchField, volMesh>& fld,
00036 List<List<Type> >& stencilFld
00037 )
00038 {
00039
00040 List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
00041
00042
00043 forAll(fld, cellI)
00044 {
00045 compactFld[cellI] = fld[cellI];
00046 }
00047
00048 label nCompact = fld.size();
00049 forAll(fld.boundaryField(), patchI)
00050 {
00051 const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
00052
00053 forAll(pfld, i)
00054 {
00055 compactFld[nCompact++] = pfld[i];
00056 }
00057 }
00058
00059
00060 map.distribute(compactFld);
00061
00062
00063 stencilFld.setSize(stencil.size());
00064
00065 forAll(stencil, faceI)
00066 {
00067 const labelList& compactCells = stencil[faceI];
00068
00069 stencilFld[faceI].setSize(compactCells.size());
00070
00071 forAll(compactCells, i)
00072 {
00073 stencilFld[faceI][i] = compactFld[compactCells[i]];
00074 }
00075 }
00076 }
00077
00078
00079 template<class Type>
00080 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00081 Foam::extendedCellToFaceStencil::weightedSum
00082 (
00083 const mapDistribute& map,
00084 const labelListList& stencil,
00085 const GeometricField<Type, fvPatchField, volMesh>& fld,
00086 const List<List<scalar> >& stencilWeights
00087 )
00088 {
00089 const fvMesh& mesh = fld.mesh();
00090
00091
00092 List<List<Type> > stencilFld;
00093 collectData(map, stencil, fld, stencilFld);
00094
00095 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
00096 (
00097 new GeometricField<Type, fvsPatchField, surfaceMesh>
00098 (
00099 IOobject
00100 (
00101 fld.name(),
00102 mesh.time().timeName(),
00103 mesh,
00104 IOobject::NO_READ,
00105 IOobject::NO_WRITE,
00106 false
00107 ),
00108 mesh,
00109 dimensioned<Type>
00110 (
00111 fld.name(),
00112 fld.dimensions(),
00113 pTraits<Type>::zero
00114 )
00115 )
00116 );
00117 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
00118
00119
00120 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
00121 {
00122 const List<Type>& stField = stencilFld[faceI];
00123 const List<scalar>& stWeight = stencilWeights[faceI];
00124
00125 forAll(stField, i)
00126 {
00127 sf[faceI] += stField[i]*stWeight[i];
00128 }
00129 }
00130
00131
00132
00133 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
00134 GeometricBoundaryField& bSfCorr = sf.boundaryField();
00135
00136 forAll(bSfCorr, patchi)
00137 {
00138 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
00139
00140 if (pSfCorr.coupled())
00141 {
00142 label faceI = pSfCorr.patch().patch().start();
00143
00144 forAll(pSfCorr, i)
00145 {
00146 const List<Type>& stField = stencilFld[faceI];
00147 const List<scalar>& stWeight = stencilWeights[faceI];
00148
00149 forAll(stField, j)
00150 {
00151 pSfCorr[i] += stField[j]*stWeight[j];
00152 }
00153
00154 faceI++;
00155 }
00156 }
00157 }
00158
00159 return tsfCorr;
00160 }
00161
00162
00163