inversePointDistanceDiffusivity.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 "inversePointDistanceDiffusivity.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "HashSet.H"
00030 #include "pointEdgePoint.H"
00031 #include "PointEdgeWave.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
00038
00039 addToRunTimeSelectionTable
00040 (
00041 motionDiffusivity,
00042 inversePointDistanceDiffusivity,
00043 Istream
00044 );
00045 }
00046
00047
00048
00049
00050 Foam::inversePointDistanceDiffusivity::inversePointDistanceDiffusivity
00051 (
00052 const fvMotionSolver& mSolver,
00053 Istream& mdData
00054 )
00055 :
00056 uniformDiffusivity(mSolver, mdData),
00057 patchNames_(mdData)
00058 {
00059 correct();
00060 }
00061
00062
00063
00064
00065 Foam::inversePointDistanceDiffusivity::~inversePointDistanceDiffusivity()
00066 {}
00067
00068
00069
00070
00071 void Foam::inversePointDistanceDiffusivity::correct()
00072 {
00073 const polyMesh& mesh = mSolver().mesh();
00074 const polyBoundaryMesh& bdry = mesh.boundaryMesh();
00075
00076 labelHashSet patchSet(bdry.size());
00077
00078 label nPatchEdges = 0;
00079
00080 forAll (patchNames_, i)
00081 {
00082 label pID = bdry.findPatchID(patchNames_[i]);
00083
00084 if (pID > -1)
00085 {
00086 patchSet.insert(pID);
00087 nPatchEdges += bdry[pID].nEdges();
00088 }
00089 }
00090
00091
00092 List<pointEdgePoint> pointWallDist(mesh.nPoints());
00093 List<pointEdgePoint> edgeWallDist(mesh.nEdges());
00094
00095 {
00096
00097 List<pointEdgePoint> seedInfo(nPatchEdges);
00098 labelList seedPoints(nPatchEdges);
00099
00100 nPatchEdges = 0;
00101
00102 forAllConstIter(labelHashSet, patchSet, iter)
00103 {
00104 const polyPatch& patch = bdry[iter.key()];
00105
00106 const labelList& meshPoints = patch.meshPoints();
00107
00108 forAll(meshPoints, i)
00109 {
00110 label pointI = meshPoints[i];
00111
00112 if (!pointWallDist[pointI].valid())
00113 {
00114
00115 seedInfo[nPatchEdges] = pointEdgePoint
00116 (
00117 mesh.points()[pointI],
00118 0.0
00119 );
00120 seedPoints[nPatchEdges] = pointI;
00121 pointWallDist[pointI] = seedInfo[nPatchEdges];
00122
00123 nPatchEdges++;
00124 }
00125 }
00126 }
00127 seedInfo.setSize(nPatchEdges);
00128 seedPoints.setSize(nPatchEdges);
00129
00130
00131 PointEdgeWave<pointEdgePoint> waveInfo
00132 (
00133 mesh,
00134 seedPoints,
00135 seedInfo,
00136
00137 pointWallDist,
00138 edgeWallDist,
00139 mesh.globalData().nTotalPoints()
00140 );
00141 }
00142
00143
00144 for (label faceI=0; faceI<mesh.nInternalFaces(); faceI++)
00145 {
00146 const face& f = mesh.faces()[faceI];
00147
00148 scalar dist = 0;
00149
00150 forAll(f, fp)
00151 {
00152 dist += sqrt(pointWallDist[f[fp]].distSqr());
00153 }
00154 dist /= f.size();
00155
00156 faceDiffusivity_[faceI] = 1.0/dist;
00157 }
00158
00159 forAll(faceDiffusivity_.boundaryField(), patchI)
00160 {
00161 fvsPatchScalarField& bfld = faceDiffusivity_.boundaryField()[patchI];
00162
00163 if (patchSet.found(patchI))
00164 {
00165 const unallocLabelList& faceCells = bfld.patch().faceCells();
00166
00167 forAll(bfld, i)
00168 {
00169 const cell& ownFaces = mesh.cells()[faceCells[i]];
00170
00171 labelHashSet cPoints(4*ownFaces.size());
00172
00173 scalar dist = 0;
00174
00175 forAll(ownFaces, ownFaceI)
00176 {
00177 const face& f = mesh.faces()[ownFaces[ownFaceI]];
00178
00179 forAll(f, fp)
00180 {
00181 if (cPoints.insert(f[fp]))
00182 {
00183 dist += sqrt(pointWallDist[f[fp]].distSqr());
00184 }
00185 }
00186 }
00187 dist /= cPoints.size();
00188
00189 bfld[i] = 1.0/dist;
00190 }
00191 }
00192 else
00193 {
00194 label start = bfld.patch().patch().start();
00195
00196 forAll(bfld, i)
00197 {
00198 const face& f = mesh.faces()[start+i];
00199
00200 scalar dist = 0;
00201
00202 forAll(f, fp)
00203 {
00204 dist += sqrt(pointWallDist[f[fp]].distSqr());
00205 }
00206 dist /= f.size();
00207
00208 bfld[i] = 1.0/dist;
00209 }
00210 }
00211 }
00212 }
00213
00214
00215
Copyright © 2000-2009 OpenCFD Ltd