1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "inversePointDistanceDiffusivity.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "pointEdgePoint.H"
31 #include "PointEdgeWave.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
39 addToRunTimeSelectionTable
42 inversePointDistanceDiffusivity,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::inversePointDistanceDiffusivity::inversePointDistanceDiffusivity
52 const fvMotionSolver& mSolver,
56 uniformDiffusivity(mSolver, mdData),
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 Foam::inversePointDistanceDiffusivity::~inversePointDistanceDiffusivity()
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 void Foam::inversePointDistanceDiffusivity::correct()
73 const polyMesh& mesh = mSolver().mesh();
74 const polyBoundaryMesh& bdry = mesh.boundaryMesh();
76 labelHashSet patchSet(bdry.size());
78 label nPatchEdges = 0;
80 forAll (patchNames_, i)
82 label pID = bdry.findPatchID(patchNames_[i]);
87 nPatchEdges += bdry[pID].nEdges();
91 // Distance to wall on points and edges.
92 List<pointEdgePoint> pointWallDist(mesh.nPoints());
93 List<pointEdgePoint> edgeWallDist(mesh.nEdges());
97 List<pointEdgePoint> seedInfo(nPatchEdges);
98 labelList seedPoints(nPatchEdges);
102 forAllConstIter(labelHashSet, patchSet, iter)
104 const polyPatch& patch = bdry[iter.key()];
106 const labelList& meshPoints = patch.meshPoints();
108 forAll(meshPoints, i)
110 label pointI = meshPoints[i];
112 if (!pointWallDist[pointI].valid())
115 seedInfo[nPatchEdges] = pointEdgePoint
117 mesh.points()[pointI],
120 seedPoints[nPatchEdges] = pointI;
121 pointWallDist[pointI] = seedInfo[nPatchEdges];
127 seedInfo.setSize(nPatchEdges);
128 seedPoints.setSize(nPatchEdges);
131 PointEdgeWave<pointEdgePoint> waveInfo
139 mesh.globalData().nTotalPoints() // max iterations
144 for (label faceI=0; faceI<mesh.nInternalFaces(); faceI++)
146 const face& f = mesh.faces()[faceI];
152 dist += sqrt(pointWallDist[f[fp]].distSqr());
156 faceDiffusivity_[faceI] = 1.0/dist;
159 forAll(faceDiffusivity_.boundaryField(), patchI)
161 fvsPatchScalarField& bfld = faceDiffusivity_.boundaryField()[patchI];
163 if (patchSet.found(patchI))
165 const unallocLabelList& faceCells = bfld.patch().faceCells();
169 const cell& ownFaces = mesh.cells()[faceCells[i]];
171 labelHashSet cPoints(4*ownFaces.size());
175 forAll(ownFaces, ownFaceI)
177 const face& f = mesh.faces()[ownFaces[ownFaceI]];
181 if (cPoints.insert(f[fp]))
183 dist += sqrt(pointWallDist[f[fp]].distSqr());
187 dist /= cPoints.size();
194 label start = bfld.patch().patch().start();
198 const face& f = mesh.faces()[start+i];
204 dist += sqrt(pointWallDist[f[fp]].distSqr());
215 // ************************************************************************* //