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