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