initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / fvMotionSolver / motionDiffusivity / inverseDistance / inverseDistanceDiffusivity.C
blob09dfcae98a107d94c6b0848815462422267ec752
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "inverseDistanceDiffusivity.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "patchWave.H"
30 #include "HashSet.H"
31 #include "surfaceInterpolate.H"
32 #include "zeroGradientFvPatchFields.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     defineTypeNameAndDebug(inverseDistanceDiffusivity, 0);
40     addToRunTimeSelectionTable
41     (
42         motionDiffusivity,
43         inverseDistanceDiffusivity,
44         Istream
45     );
49 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
51 Foam::inverseDistanceDiffusivity::inverseDistanceDiffusivity
53     const fvMotionSolver& mSolver,
54     Istream& mdData
57     uniformDiffusivity(mSolver, mdData),
58     patchNames_(mdData)
60     correct();
64 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
66 Foam::inverseDistanceDiffusivity::~inverseDistanceDiffusivity()
70 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
72 Foam::tmp<Foam::scalarField> Foam::inverseDistanceDiffusivity::y() const
74     const polyMesh& mesh = mSolver().mesh();
76     labelHashSet patchSet(mesh.boundaryMesh().patchSet(patchNames_));
78     if (patchSet.size())
79     {
80         return tmp<scalarField>
81         (
82             new scalarField(patchWave(mesh, patchSet, false).distance())
83         );
84     }
85     else
86     {
87         return tmp<scalarField>(new scalarField(mesh.nCells(), 1.0));
88     }
92 void Foam::inverseDistanceDiffusivity::correct()
94     const fvMesh& mesh = mSolver().mesh();
96     volScalarField y_
97     (
98         IOobject
99         (
100             "y",
101             mesh.time().timeName(),
102             mesh
103         ),
104         mesh,
105         dimless,
106         zeroGradientFvPatchScalarField::typeName
107     );
108     y_.internalField() = y();
109     y_.correctBoundaryConditions();
111     faceDiffusivity_ = 1.0/fvc::interpolate(y_);
115 // ************************************************************************* //