extendedCellToFaceStencilTemplates.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 "extendedCellToFaceStencil.H"
00028
00029
00030
00031 template<class Type>
00032 void Foam::extendedCellToFaceStencil::collectData
00033 (
00034 const mapDistribute& map,
00035 const labelListList& stencil,
00036 const GeometricField<Type, fvPatchField, volMesh>& 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 fvPatchField<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::fvsPatchField, Foam::surfaceMesh> >
00082 Foam::extendedCellToFaceStencil::weightedSum
00083 (
00084 const mapDistribute& map,
00085 const labelListList& stencil,
00086 const GeometricField<Type, fvPatchField, volMesh>& 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, fvsPatchField, surfaceMesh> > tsfCorr
00097 (
00098 new GeometricField<Type, fvsPatchField, surfaceMesh>
00099 (
00100 IOobject
00101 (
00102 fld.name(),
00103 mesh.time().timeName(),
00104 mesh,
00105 IOobject::NO_READ,
00106 IOobject::NO_WRITE,
00107 false
00108 ),
00109 mesh,
00110 dimensioned<Type>
00111 (
00112 fld.name(),
00113 fld.dimensions(),
00114 pTraits<Type>::zero
00115 )
00116 )
00117 );
00118 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
00119
00120
00121 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
00122 {
00123 const List<Type>& stField = stencilFld[faceI];
00124 const List<scalar>& stWeight = stencilWeights[faceI];
00125
00126 forAll(stField, i)
00127 {
00128 sf[faceI] += stField[i]*stWeight[i];
00129 }
00130 }
00131
00132
00133
00134 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
00135 GeometricBoundaryField& bSfCorr = sf.boundaryField();
00136
00137 forAll(bSfCorr, patchi)
00138 {
00139 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
00140
00141 if (pSfCorr.coupled())
00142 {
00143 label faceI = pSfCorr.patch().patch().start();
00144
00145 forAll(pSfCorr, i)
00146 {
00147 const List<Type>& stField = stencilFld[faceI];
00148 const List<scalar>& stWeight = stencilWeights[faceI];
00149
00150 forAll(stField, j)
00151 {
00152 pSfCorr[i] += stField[j]*stWeight[j];
00153 }
00154
00155 faceI++;
00156 }
00157 }
00158 }
00159
00160 return tsfCorr;
00161 }
00162
00163
00164
Copyright © 2000-2009 OpenCFD Ltd