1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "inverseFaceDistanceDiffusivity.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "wallPoint.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(inverseFaceDistanceDiffusivity, 0);
39 addToRunTimeSelectionTable
42 inverseFaceDistanceDiffusivity,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::inverseFaceDistanceDiffusivity::inverseFaceDistanceDiffusivity
52 const fvMotionSolver& mSolver,
56 uniformDiffusivity(mSolver, mdData),
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 Foam::inverseFaceDistanceDiffusivity::~inverseFaceDistanceDiffusivity()
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 void Foam::inverseFaceDistanceDiffusivity::correct()
73 const polyMesh& mesh = mSolver().mesh();
74 const polyBoundaryMesh& bdry = mesh.boundaryMesh();
76 labelHashSet patchSet(bdry.size());
78 label nPatchFaces = 0;
80 forAll (patchNames_, i)
82 label pID = bdry.findPatchID(patchNames_[i]);
87 nPatchFaces += bdry[pID].size();
91 List<wallPoint> faceDist(nPatchFaces);
92 labelList changedFaces(nPatchFaces);
96 forAllConstIter(labelHashSet, patchSet, iter)
98 const polyPatch& patch = bdry[iter.key()];
100 const vectorField::subField fc = patch.faceCentres();
102 forAll(fc, patchFaceI)
104 changedFaces[nPatchFaces] = patch.start() + patchFaceI;
106 faceDist[nPatchFaces] = wallPoint(fc[patchFaceI], 0);
111 faceDist.setSize(nPatchFaces);
112 changedFaces.setSize(nPatchFaces);
114 MeshWave<wallPoint> waveInfo
119 mesh.globalData().nTotalCells() // max iterations
122 const List<wallPoint>& faceInfo = waveInfo.allFaceInfo();
123 const List<wallPoint>& cellInfo = waveInfo.allCellInfo();
125 for (label faceI=0; faceI<mesh.nInternalFaces(); faceI++)
127 scalar dist = faceInfo[faceI].distSqr();
129 faceDiffusivity_[faceI] = 1.0/sqrt(dist);
132 forAll(faceDiffusivity_.boundaryField(), patchI)
134 fvsPatchScalarField& bfld = faceDiffusivity_.boundaryField()[patchI];
136 const unallocLabelList& faceCells = bfld.patch().faceCells();
138 if (patchSet.found(patchI))
142 scalar dist = cellInfo[faceCells[i]].distSqr();
143 bfld[i] = 1.0/sqrt(dist);
148 label start = bfld.patch().patch().start();
152 scalar dist = faceInfo[start+i].distSqr();
153 bfld[i] = 1.0/sqrt(dist);
160 // ************************************************************************* //