1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "inversePointDistanceDiffusivity.H"
27 #include "addToRunTimeSelectionTable.H"
29 #include "pointEdgePoint.H"
30 #include "PointEdgeWave.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
38 addToRunTimeSelectionTable
41 inversePointDistanceDiffusivity,
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 Foam::inversePointDistanceDiffusivity::inversePointDistanceDiffusivity
51 const fvMotionSolver& mSolver,
55 uniformDiffusivity(mSolver, mdData),
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 Foam::inversePointDistanceDiffusivity::~inversePointDistanceDiffusivity()
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 void Foam::inversePointDistanceDiffusivity::correct()
72 const polyMesh& mesh = mSolver().mesh();
73 const polyBoundaryMesh& bdry = mesh.boundaryMesh();
75 labelHashSet patchSet(bdry.size());
77 label nPatchEdges = 0;
79 forAll (patchNames_, i)
81 label pID = bdry.findPatchID(patchNames_[i]);
86 nPatchEdges += bdry[pID].nEdges();
90 // Distance to wall on points and edges.
91 List<pointEdgePoint> pointWallDist(mesh.nPoints());
92 List<pointEdgePoint> edgeWallDist(mesh.nEdges());
96 List<pointEdgePoint> seedInfo(nPatchEdges);
97 labelList seedPoints(nPatchEdges);
101 forAllConstIter(labelHashSet, patchSet, iter)
103 const polyPatch& patch = bdry[iter.key()];
105 const labelList& meshPoints = patch.meshPoints();
107 forAll(meshPoints, i)
109 label pointI = meshPoints[i];
111 if (!pointWallDist[pointI].valid())
114 seedInfo[nPatchEdges] = pointEdgePoint
116 mesh.points()[pointI],
119 seedPoints[nPatchEdges] = pointI;
120 pointWallDist[pointI] = seedInfo[nPatchEdges];
126 seedInfo.setSize(nPatchEdges);
127 seedPoints.setSize(nPatchEdges);
130 PointEdgeWave<pointEdgePoint> waveInfo
138 mesh.globalData().nTotalPoints() // max iterations
143 for (label faceI=0; faceI<mesh.nInternalFaces(); faceI++)
145 const face& f = mesh.faces()[faceI];
151 dist += sqrt(pointWallDist[f[fp]].distSqr());
155 faceDiffusivity_[faceI] = 1.0/dist;
158 forAll(faceDiffusivity_.boundaryField(), patchI)
160 fvsPatchScalarField& bfld = faceDiffusivity_.boundaryField()[patchI];
162 if (patchSet.found(patchI))
164 const unallocLabelList& faceCells = bfld.patch().faceCells();
168 const cell& ownFaces = mesh.cells()[faceCells[i]];
170 labelHashSet cPoints(4*ownFaces.size());
174 forAll(ownFaces, ownFaceI)
176 const face& f = mesh.faces()[ownFaces[ownFaceI]];
180 if (cPoints.insert(f[fp]))
182 dist += sqrt(pointWallDist[f[fp]].distSqr());
186 dist /= cPoints.size();
193 label start = bfld.patch().patch().start();
197 const face& f = mesh.faces()[start+i];
203 dist += sqrt(pointWallDist[f[fp]].distSqr());
214 // ************************************************************************* //