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 "fourthGrad.H"
00027 #include <finiteVolume/leastSquaresGrad.H>
00028 #include <finiteVolume/gaussGrad.H>
00029 #include <finiteVolume/fvMesh.H>
00030 #include <finiteVolume/volMesh.H>
00031 #include <finiteVolume/surfaceMesh.H>
00032 #include <OpenFOAM/GeometricField.H>
00033 #include <finiteVolume/zeroGradientFvPatchField.H>
00034
00035
00036
00037 namespace Foam
00038 {
00039
00040
00041
00042 namespace fv
00043 {
00044
00045
00046
00047 template<class Type>
00048 tmp
00049 <
00050 GeometricField
00051 <
00052 typename outerProduct<vector, Type>::type, fvPatchField, volMesh
00053 >
00054 >
00055 fourthGrad<Type>::grad
00056 (
00057 const GeometricField<Type, fvPatchField, volMesh>& vsf
00058 ) const
00059 {
00060
00061
00062
00063
00064
00065 typedef typename outerProduct<vector, Type>::type GradType;
00066
00067 const fvMesh& mesh = vsf.mesh();
00068
00069
00070
00071 tmp<GeometricField<GradType, fvPatchField, volMesh> > tsecondfGrad
00072 = leastSquaresGrad<Type>(mesh).grad(vsf);
00073 const GeometricField<GradType, fvPatchField, volMesh>& secondfGrad =
00074 tsecondfGrad();
00075
00076 tmp<GeometricField<GradType, fvPatchField, volMesh> > tfGrad
00077 (
00078 new GeometricField<GradType, fvPatchField, volMesh>
00079 (
00080 IOobject
00081 (
00082 "grad("+vsf.name()+')',
00083 vsf.instance(),
00084 mesh,
00085 IOobject::NO_READ,
00086 IOobject::NO_WRITE
00087 ),
00088 secondfGrad
00089 )
00090 );
00091 GeometricField<GradType, fvPatchField, volMesh>& fGrad = tfGrad();
00092
00093 const vectorField& C = mesh.C();
00094
00095 const surfaceScalarField& lambda = mesh.weights();
00096
00097
00098 const leastSquaresVectors& lsv = leastSquaresVectors::New(mesh);
00099 const surfaceVectorField& ownLs = lsv.pVectors();
00100 const surfaceVectorField& neiLs = lsv.nVectors();
00101
00102
00103 const unallocLabelList& own = mesh.owner();
00104 const unallocLabelList& nei = mesh.neighbour();
00105
00106
00107
00108
00109 forAll(own, facei)
00110 {
00111 Type dDotGradDelta = 0.5*
00112 (
00113 (C[nei[facei]] - C[own[facei]])
00114 & (secondfGrad[nei[facei]] - secondfGrad[own[facei]])
00115 );
00116
00117 fGrad[own[facei]] -= lambda[facei]*ownLs[facei]*dDotGradDelta;
00118 fGrad[nei[facei]] -= (1.0 - lambda[facei])*neiLs[facei]*dDotGradDelta;
00119 }
00120
00121
00122 forAll(vsf.boundaryField(), patchi)
00123 {
00124 if (secondfGrad.boundaryField()[patchi].coupled())
00125 {
00126 const fvsPatchVectorField& patchOwnLs =
00127 ownLs.boundaryField()[patchi];
00128
00129 const scalarField& lambdap = lambda.boundaryField()[patchi];
00130
00131
00132 vectorField pd =
00133 mesh.Sf().boundaryField()[patchi]
00134 /(
00135 mesh.magSf().boundaryField()[patchi]
00136 *mesh.deltaCoeffs().boundaryField()[patchi]
00137 );
00138
00139 if (!mesh.orthogonal())
00140 {
00141 pd -= mesh.correctionVectors().boundaryField()[patchi]
00142 /mesh.deltaCoeffs().boundaryField()[patchi];
00143 }
00144
00145 const unallocLabelList& faceCells =
00146 fGrad.boundaryField()[patchi].patch().faceCells();
00147
00148 Field<GradType> neighbourSecondfGrad =
00149 secondfGrad.boundaryField()[patchi].patchNeighbourField();
00150
00151 forAll(faceCells, patchFaceI)
00152 {
00153 fGrad[faceCells[patchFaceI]] -=
00154 0.5*lambdap[patchFaceI]*patchOwnLs[patchFaceI]
00155 *(
00156 pd[patchFaceI]
00157 & (
00158 neighbourSecondfGrad[patchFaceI]
00159 - secondfGrad[faceCells[patchFaceI]]
00160 )
00161 );
00162 }
00163 }
00164 }
00165
00166 fGrad.correctBoundaryConditions();
00167 gaussGrad<Type>::correctBoundaryConditions(vsf, fGrad);
00168
00169 return tfGrad;
00170 }
00171
00172
00173
00174
00175 }
00176
00177
00178
00179 }
00180
00181