ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / fvMotionSolver / motionDiffusivity / motionDirectional / motionDirectionalDiffusivity.C
blobf98469edd490d101f84a3b393725d6669513c397
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "motionDirectionalDiffusivity.H"
27 #include "surfaceInterpolate.H"
28 #include "zeroGradientFvPatchFields.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(motionDirectionalDiffusivity, 0);
37     addToRunTimeSelectionTable
38     (
39         motionDiffusivity,
40         motionDirectionalDiffusivity,
41         Istream
42     );
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 Foam::motionDirectionalDiffusivity::motionDirectionalDiffusivity
50     const fvMotionSolver& mSolver,
51     Istream& mdData
54     uniformDiffusivity(mSolver, mdData),
55     diffusivityVector_(mdData)
59 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
61 Foam::motionDirectionalDiffusivity::~motionDirectionalDiffusivity()
65 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
67 void Foam::motionDirectionalDiffusivity::correct()
69     const fvMesh& mesh = mSolver().mesh();
71     static bool first = true;
73     if (!first)
74     {
75         const volVectorField& cellMotionU =
76             mesh.lookupObject<volVectorField>("cellMotionU");
78         volVectorField D
79         (
80             IOobject
81             (
82                 "D",
83                 mesh.time().timeName(),
84                 mesh
85             ),
86             diffusivityVector_.y()*vector::one
87           + (diffusivityVector_.x() - diffusivityVector_.y())*cellMotionU
88            /(mag(cellMotionU) + dimensionedScalar("small", dimVelocity, SMALL)),
89             zeroGradientFvPatchVectorField::typeName
90         );
91         D.correctBoundaryConditions();
93         const surfaceVectorField n(mesh.Sf()/mesh.magSf());
94         faceDiffusivity_ == (n & cmptMultiply(fvc::interpolate(D), n));
95     }
96     else
97     {
98         first = false;
99         const_cast<fvMotionSolver&>(mSolver()).solve();
100         correct();
101     }
105 // ************************************************************************* //