resErrorDiv.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 "resErrorDiv.H"
00028 #include "fvc.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 namespace resError
00038 {
00039
00040 template<class Type>
00041 tmp<errorEstimate<Type> >
00042 div
00043 (
00044 const surfaceScalarField& flux,
00045 const GeometricField<Type, fvPatchField, volMesh>& vf
00046 )
00047 {
00048 const fvMesh& mesh = vf.mesh();
00049
00050 const scalarField& vols = mesh.V();
00051 const surfaceVectorField& faceCentres = mesh.Cf();
00052 const volVectorField& cellCentres = mesh.C();
00053 const fvPatchList& patches = mesh.boundary();
00054 const unallocLabelList& owner = mesh.owner();
00055 const unallocLabelList& neighbour = mesh.neighbour();
00056
00057 Field<Type> res(vols.size(), pTraits<Type>::zero);
00058 scalarField aNorm(vols.size(), 0.0);
00059
00060
00061 const surfaceScalarField signF = pos(flux);
00062
00063
00064 GeometricField
00065 <
00066 typename outerProduct<vector, Type>::type, fvPatchField, volMesh
00067 > gradVf = fvc::grad(vf);
00068
00069
00070 forAll (owner, faceI)
00071 {
00072
00073 const vector& curFaceCentre = faceCentres[faceI];
00074
00075
00076 vector ownD = curFaceCentre - cellCentres[owner[faceI]];
00077
00078
00079 res[owner[faceI]] -=
00080 (
00081 vf[owner[faceI]]
00082 + (ownD & gradVf[owner[faceI]])
00083 )*flux[faceI];
00084
00085 aNorm[owner[faceI]] += signF[faceI]*flux[faceI];
00086
00087
00088 vector neiD = curFaceCentre - cellCentres[neighbour[faceI]];
00089
00090
00091 res[neighbour[faceI]] +=
00092 (
00093 vf[neighbour[faceI]]
00094 + (neiD & gradVf[neighbour[faceI]])
00095 )*flux[faceI];
00096
00097 aNorm[neighbour[faceI]] -= (1.0 - signF[faceI])*flux[faceI];
00098 }
00099
00100 forAll (patches, patchI)
00101 {
00102 const vectorField& patchFaceCentres =
00103 faceCentres.boundaryField()[patchI];
00104
00105 const scalarField& patchFlux = flux.boundaryField()[patchI];
00106 const scalarField& patchSignFlux = signF.boundaryField()[patchI];
00107
00108 const labelList& fCells = patches[patchI].faceCells();
00109
00110 forAll (fCells, faceI)
00111 {
00112 vector d =
00113 patchFaceCentres[faceI] - cellCentres[fCells[faceI]];
00114
00115
00116 res[fCells[faceI]] -=
00117 (
00118 vf[fCells[faceI]]
00119 + (d & gradVf[fCells[faceI]])
00120 )*patchFlux[faceI];
00121
00122 aNorm[fCells[faceI]] += patchSignFlux[faceI]*patchFlux[faceI];
00123 }
00124 }
00125
00126 res /= vols;
00127 aNorm /= vols;
00128
00129 return tmp<errorEstimate<Type> >
00130 (
00131 new errorEstimate<Type>
00132 (
00133 vf,
00134 flux.dimensions()*vf.dimensions(),
00135 res,
00136 aNorm
00137 )
00138 );
00139 }
00140
00141
00142 template<class Type>
00143 tmp<errorEstimate<Type> >
00144 div
00145 (
00146 const tmp<surfaceScalarField>& tflux,
00147 const GeometricField<Type, fvPatchField, volMesh>& vf
00148 )
00149 {
00150 tmp<errorEstimate<Type> > Div(resError::div(tflux(), vf));
00151 tflux.clear();
00152 return Div;
00153 }
00154
00155
00156
00157
00158 }
00159
00160
00161
00162 }
00163
00164
00165
00166
00167
00168
Copyright © 2000-2009 OpenCFD Ltd