initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / fvMotionSolver / fvMotionSolvers / velocity / componentLaplacian / velocityComponentLaplacianFvMotionSolver.C
blob0c0f12a84468268b9723b85007987a2a50f596fa
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 "velocityComponentLaplacianFvMotionSolver.H"
28 #include "motionDiffusivity.H"
29 #include "fvmLaplacian.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "volPointInterpolation.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
37     defineTypeNameAndDebug(velocityComponentLaplacianFvMotionSolver, 0);
39     addToRunTimeSelectionTable
40     (
41         fvMotionSolver,
42         velocityComponentLaplacianFvMotionSolver,
43         dictionary
44     );
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 Foam::velocityComponentLaplacianFvMotionSolver::
51 velocityComponentLaplacianFvMotionSolver
53     const polyMesh& mesh,
54     Istream& msData
57     fvMotionSolver(mesh),
58     cmptName_(msData),
59     cmpt_(0),
60     pointMotionU_
61     (
62         IOobject
63         (
64             "pointMotionU" + cmptName_,
65             fvMesh_.time().timeName(),
66             fvMesh_,
67             IOobject::MUST_READ,
68             IOobject::AUTO_WRITE
69         ),
70         pointMesh::New(fvMesh_)
71     ),
72     cellMotionU_
73     (
74         IOobject
75         (
76             "cellMotionU" + cmptName_,
77             mesh.time().timeName(),
78             mesh,
79             IOobject::READ_IF_PRESENT,
80             IOobject::AUTO_WRITE
81         ),
82         fvMesh_,
83         dimensionedScalar
84         (
85             "cellMotionU",
86             pointMotionU_.dimensions(),
87             0
88         ),
89         cellMotionBoundaryTypes<scalar>(pointMotionU_.boundaryField())
90     ),
91     diffusivityPtr_
92     (
93         motionDiffusivity::New(*this, lookup("diffusivity"))
94     )
96     if (cmptName_ == "x")
97     {
98         cmpt_ = vector::X;
99     }
100     else if (cmptName_ == "y")
101     {
102         cmpt_ = vector::Y;
103     }
104     else if (cmptName_ == "z")
105     {
106         cmpt_ = vector::Z;
107     }
108     else
109     {
110         FatalErrorIn
111         (
112             "velocityComponentLaplacianFvMotionSolver::"
113             "velocityComponentLaplacianFvMotionSolver"
114             "(const polyMesh& mesh, Istream& msData)"
115         )   << "Given component name " << cmptName_ << " should be x, y or z"
116             << exit(FatalError);
117     }
121 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
123 Foam::velocityComponentLaplacianFvMotionSolver::
124 ~velocityComponentLaplacianFvMotionSolver()
128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
130 Foam::tmp<Foam::pointField>
131 Foam::velocityComponentLaplacianFvMotionSolver::curPoints() const
133     volPointInterpolation::New(fvMesh_).interpolate
134     (
135         cellMotionU_,
136         pointMotionU_
137     );
139     tmp<pointField> tcurPoints(new pointField(fvMesh_.points()));
141     tcurPoints().replace
142     (
143         cmpt_,
144         tcurPoints().component(cmpt_)
145       + fvMesh_.time().deltaT().value()*pointMotionU_.internalField()
146     );
148     twoDCorrectPoints(tcurPoints());
150     return tcurPoints;
154 void Foam::velocityComponentLaplacianFvMotionSolver::solve()
156     // The points have moved so before interpolation update
157     // the fvMotionSolver accordingly
158     movePoints(fvMesh_.points());
160     diffusivityPtr_->correct();
161     pointMotionU_.boundaryField().updateCoeffs();
163     Foam::solve
164     (
165         fvm::laplacian
166         (
167             diffusivityPtr_->operator()(),
168             cellMotionU_,
169             "laplacian(diffusivity,cellMotionU)"
170         )
171     );
175 void Foam::velocityComponentLaplacianFvMotionSolver::updateMesh
177     const mapPolyMesh& mpm
180     fvMotionSolver::updateMesh(mpm);
182     // Update diffusivity. Note two stage to make sure old one is de-registered
183     // before creating/registering new one.
184     diffusivityPtr_.reset(NULL);
185     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
189 // ************************************************************************* //