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 "skewCorrectionVectors.H"
00027 #include <finiteVolume/surfaceFields.H>
00028 #include <finiteVolume/volFields.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034 defineTypeNameAndDebug(skewCorrectionVectors, 0);
00035 }
00036
00037
00038
00039
00040 Foam::skewCorrectionVectors::skewCorrectionVectors(const fvMesh& mesh)
00041 :
00042 MeshObject<fvMesh, skewCorrectionVectors>(mesh),
00043 skew_(true),
00044 skewCorrectionVectors_(NULL)
00045 {}
00046
00047
00048 Foam::skewCorrectionVectors::~skewCorrectionVectors()
00049 {
00050 deleteDemandDrivenData(skewCorrectionVectors_);
00051 }
00052
00053
00054 void Foam::skewCorrectionVectors::makeSkewCorrectionVectors() const
00055 {
00056 if (debug)
00057 {
00058 Info<< "surfaceInterpolation::makeSkewCorrectionVectors() : "
00059 << "Constructing skew correction vectors"
00060 << endl;
00061 }
00062
00063 skewCorrectionVectors_ = new surfaceVectorField
00064 (
00065 IOobject
00066 (
00067 "skewCorrectionVectors",
00068 mesh_.pointsInstance(),
00069 mesh_,
00070 IOobject::NO_READ,
00071 IOobject::NO_WRITE,
00072 false
00073 ),
00074 mesh_,
00075 dimless
00076 );
00077 surfaceVectorField& SkewCorrVecs = *skewCorrectionVectors_;
00078
00079
00080 const volVectorField& C = mesh_.C();
00081 const surfaceVectorField& Cf = mesh_.Cf();
00082 const surfaceVectorField& Sf = mesh_.Sf();
00083
00084 const unallocLabelList& owner = mesh_.owner();
00085
00086
00087 surfaceVectorField d = Sf/(mesh_.magSf()*mesh_.deltaCoeffs());
00088
00089 if (!mesh_.orthogonal())
00090 {
00091 d -= mesh_.correctionVectors()/mesh_.deltaCoeffs();
00092 }
00093
00094 forAll(owner, faceI)
00095 {
00096 vector Cpf = Cf[faceI] - C[owner[faceI]];
00097
00098 SkewCorrVecs[faceI] =
00099 Cpf - ((Sf[faceI] & Cpf)/(Sf[faceI] & d[faceI]))*d[faceI];
00100 }
00101
00102
00103 forAll(SkewCorrVecs.boundaryField(), patchI)
00104 {
00105 fvsPatchVectorField& patchSkewCorrVecs =
00106 SkewCorrVecs.boundaryField()[patchI];
00107
00108 if (!patchSkewCorrVecs.coupled())
00109 {
00110 patchSkewCorrVecs = vector::zero;
00111 }
00112 else
00113 {
00114 const fvPatch& p = patchSkewCorrVecs.patch();
00115 const unallocLabelList& faceCells = p.faceCells();
00116 const vectorField& patchFaceCentres = Cf.boundaryField()[patchI];
00117 const vectorField& patchSf = Sf.boundaryField()[patchI];
00118 const vectorField& patchD = d.boundaryField()[patchI];
00119
00120 forAll(p, patchFaceI)
00121 {
00122 vector Cpf =
00123 patchFaceCentres[patchFaceI] - C[faceCells[patchFaceI]];
00124
00125 patchSkewCorrVecs[patchFaceI] =
00126 Cpf
00127 - (
00128 (patchSf[patchFaceI] & Cpf)/
00129 (patchSf[patchFaceI] & patchD[patchFaceI])
00130 )*patchD[patchFaceI];
00131 }
00132 }
00133 }
00134
00135 scalar skewCoeff = 0.0;
00136
00137 if (Sf.internalField().size())
00138 {
00139 skewCoeff = max(mag(SkewCorrVecs)/mag(d)).value();
00140 }
00141
00142 if (debug)
00143 {
00144 Info<< "surfaceInterpolation::makeSkewCorrectionVectors() : "
00145 << "skew coefficient = " << skewCoeff << endl;
00146 }
00147
00148
00149
00150 if (skewCoeff < 1e-5)
00151 {
00152 skew_ = false;
00153 deleteDemandDrivenData(skewCorrectionVectors_);
00154 }
00155 else
00156 {
00157 skew_ = true;
00158 }
00159
00160 if (debug)
00161 {
00162 Info<< "surfaceInterpolation::makeSkewCorrectionVectors() : "
00163 << "Finished constructing skew correction vectors"
00164 << endl;
00165 }
00166 }
00167
00168
00169 bool Foam::skewCorrectionVectors::skew() const
00170 {
00171 if (skew_ == true && !skewCorrectionVectors_)
00172 {
00173 makeSkewCorrectionVectors();
00174 }
00175
00176 return skew_;
00177 }
00178
00179
00180 const Foam::surfaceVectorField& Foam::skewCorrectionVectors::operator()() const
00181 {
00182 if (!skew())
00183 {
00184 FatalErrorIn("skewCorrectionVectors::operator()()")
00185 << "Cannot return correctionVectors; mesh is not skewed"
00186 << abort(FatalError);
00187 }
00188
00189 return *skewCorrectionVectors_;
00190 }
00191
00192
00193
00194 bool Foam::skewCorrectionVectors::movePoints()
00195 {
00196 skew_ = true;
00197 deleteDemandDrivenData(skewCorrectionVectors_);
00198
00199 return true;
00200 }
00201
00202
00203