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 "fvcSurfaceIntegrate.H"
00028 #include "fvMesh.H"
00029 #include "zeroGradientFvPatchFields.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 namespace fvc
00039 {
00040
00041
00042
00043 template<class Type>
00044 void surfaceIntegrate
00045 (
00046 Field<Type>& ivf,
00047 const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00048 )
00049 {
00050 const fvMesh& mesh = ssf.mesh();
00051
00052 const unallocLabelList& owner = mesh.owner();
00053 const unallocLabelList& neighbour = mesh.neighbour();
00054
00055 const Field<Type>& issf = ssf;
00056
00057 forAll(owner, facei)
00058 {
00059 ivf[owner[facei]] += issf[facei];
00060 ivf[neighbour[facei]] -= issf[facei];
00061 }
00062
00063 forAll(mesh.boundary(), patchi)
00064 {
00065 const unallocLabelList& pFaceCells =
00066 mesh.boundary()[patchi].faceCells();
00067
00068 const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
00069
00070 forAll(mesh.boundary()[patchi], facei)
00071 {
00072 ivf[pFaceCells[facei]] += pssf[facei];
00073 }
00074 }
00075
00076 ivf /= mesh.V();
00077 }
00078
00079
00080 template<class Type>
00081 tmp<GeometricField<Type, fvPatchField, volMesh> >
00082 surfaceIntegrate
00083 (
00084 const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00085 )
00086 {
00087 const fvMesh& mesh = ssf.mesh();
00088
00089 tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00090 (
00091 new GeometricField<Type, fvPatchField, volMesh>
00092 (
00093 IOobject
00094 (
00095 "surfaceIntegrate("+ssf.name()+')',
00096 ssf.instance(),
00097 mesh,
00098 IOobject::NO_READ,
00099 IOobject::NO_WRITE
00100 ),
00101 mesh,
00102 dimensioned<Type>
00103 (
00104 "0",
00105 ssf.dimensions()/dimVol,
00106 pTraits<Type>::zero
00107 ),
00108 zeroGradientFvPatchField<Type>::typeName
00109 )
00110 );
00111 GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
00112
00113 surfaceIntegrate(vf.internalField(), ssf);
00114 vf.correctBoundaryConditions();
00115
00116 return tvf;
00117 }
00118
00119
00120 template<class Type>
00121 tmp<GeometricField<Type, fvPatchField, volMesh> >
00122 surfaceIntegrate
00123 (
00124 const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
00125 )
00126 {
00127 tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00128 (
00129 fvc::surfaceIntegrate(tssf())
00130 );
00131 tssf.clear();
00132 return tvf;
00133 }
00134
00135
00136 template<class Type>
00137 tmp<GeometricField<Type, fvPatchField, volMesh> >
00138 surfaceSum
00139 (
00140 const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
00141 )
00142 {
00143 const fvMesh& mesh = ssf.mesh();
00144
00145 tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
00146 (
00147 new GeometricField<Type, fvPatchField, volMesh>
00148 (
00149 IOobject
00150 (
00151 "surfaceSum("+ssf.name()+')',
00152 ssf.instance(),
00153 mesh,
00154 IOobject::NO_READ,
00155 IOobject::NO_WRITE
00156 ),
00157 mesh,
00158 dimensioned<Type>("0", ssf.dimensions(), pTraits<Type>::zero),
00159 zeroGradientFvPatchField<Type>::typeName
00160 )
00161 );
00162 GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
00163
00164 const unallocLabelList& owner = mesh.owner();
00165 const unallocLabelList& neighbour = mesh.neighbour();
00166
00167 forAll(owner, facei)
00168 {
00169 vf[owner[facei]] += ssf[facei];
00170 vf[neighbour[facei]] += ssf[facei];
00171 }
00172
00173 forAll(mesh.boundary(), patchi)
00174 {
00175 const unallocLabelList& pFaceCells =
00176 mesh.boundary()[patchi].faceCells();
00177
00178 const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
00179
00180 forAll(mesh.boundary()[patchi], facei)
00181 {
00182 vf[pFaceCells[facei]] += pssf[facei];
00183 }
00184 }
00185
00186 vf.correctBoundaryConditions();
00187
00188 return tvf;
00189 }
00190
00191
00192 template<class Type>
00193 tmp<GeometricField<Type, fvPatchField, volMesh> > surfaceSum
00194 (
00195 const tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >& tssf
00196 )
00197 {
00198 tmp<GeometricField<Type, fvPatchField, volMesh> > tvf = surfaceSum(tssf());
00199 tssf.clear();
00200 return tvf;
00201 }
00202
00203
00204
00205
00206 }
00207
00208
00209
00210 }
00211
00212