OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

velocityComponentLaplacianFvMotionSolver.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "velocityComponentLaplacianFvMotionSolver.H"
00028 #include "motionDiffusivity.H"
00029 #include "fvmLaplacian.H"
00030 #include "addToRunTimeSelectionTable.H"
00031 #include "volPointInterpolation.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037     defineTypeNameAndDebug(velocityComponentLaplacianFvMotionSolver, 0);
00038 
00039     addToRunTimeSelectionTable
00040     (
00041         fvMotionSolver,
00042         velocityComponentLaplacianFvMotionSolver,
00043         dictionary
00044     );
00045 }
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 Foam::velocityComponentLaplacianFvMotionSolver::
00051 velocityComponentLaplacianFvMotionSolver
00052 (
00053     const polyMesh& mesh,
00054     Istream& msData
00055 )
00056 :
00057     fvMotionSolver(mesh),
00058     cmptName_(msData),
00059     cmpt_(0),
00060     pointMotionU_
00061     (
00062         IOobject
00063         (
00064             "pointMotionU" + cmptName_,
00065             fvMesh_.time().timeName(),
00066             fvMesh_,
00067             IOobject::MUST_READ,
00068             IOobject::AUTO_WRITE
00069         ),
00070         pointMesh::New(fvMesh_)
00071     ),
00072     cellMotionU_
00073     (
00074         IOobject
00075         (
00076             "cellMotionU" + cmptName_,
00077             mesh.time().timeName(),
00078             mesh,
00079             IOobject::READ_IF_PRESENT,
00080             IOobject::AUTO_WRITE
00081         ),
00082         fvMesh_,
00083         dimensionedScalar
00084         (
00085             "cellMotionU",
00086             pointMotionU_.dimensions(),
00087             0
00088         ),
00089         cellMotionBoundaryTypes<scalar>(pointMotionU_.boundaryField())
00090     ),
00091     diffusivityPtr_
00092     (
00093         motionDiffusivity::New(*this, lookup("diffusivity"))
00094     )
00095 {
00096     if (cmptName_ == "x")
00097     {
00098         cmpt_ = vector::X;
00099     }
00100     else if (cmptName_ == "y")
00101     {
00102         cmpt_ = vector::Y;
00103     }
00104     else if (cmptName_ == "z")
00105     {
00106         cmpt_ = vector::Z;
00107     }
00108     else
00109     {
00110         FatalErrorIn
00111         (
00112             "velocityComponentLaplacianFvMotionSolver::"
00113             "velocityComponentLaplacianFvMotionSolver"
00114             "(const polyMesh& mesh, Istream& msData)"
00115         )   << "Given component name " << cmptName_ << " should be x, y or z"
00116             << exit(FatalError);
00117     }
00118 }
00119 
00120 
00121 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00122 
00123 Foam::velocityComponentLaplacianFvMotionSolver::
00124 ~velocityComponentLaplacianFvMotionSolver()
00125 {}
00126 
00127 
00128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00129 
00130 Foam::tmp<Foam::pointField>
00131 Foam::velocityComponentLaplacianFvMotionSolver::curPoints() const
00132 {
00133     volPointInterpolation::New(fvMesh_).interpolate
00134     (
00135         cellMotionU_,
00136         pointMotionU_
00137     );
00138 
00139     tmp<pointField> tcurPoints(new pointField(fvMesh_.points()));
00140 
00141     tcurPoints().replace
00142     (
00143         cmpt_,
00144         tcurPoints().component(cmpt_)
00145       + fvMesh_.time().deltaT().value()*pointMotionU_.internalField()
00146     );
00147 
00148     twoDCorrectPoints(tcurPoints());
00149 
00150     return tcurPoints;
00151 }
00152 
00153 
00154 void Foam::velocityComponentLaplacianFvMotionSolver::solve()
00155 {
00156     // The points have moved so before interpolation update
00157     // the fvMotionSolver accordingly
00158     movePoints(fvMesh_.points());
00159 
00160     diffusivityPtr_->correct();
00161     pointMotionU_.boundaryField().updateCoeffs();
00162 
00163     Foam::solve
00164     (
00165         fvm::laplacian
00166         (
00167             diffusivityPtr_->operator()(),
00168             cellMotionU_,
00169             "laplacian(diffusivity,cellMotionU)"
00170         )
00171     );
00172 }
00173 
00174 
00175 void Foam::velocityComponentLaplacianFvMotionSolver::updateMesh
00176 (
00177     const mapPolyMesh& mpm
00178 )
00179 {
00180     fvMotionSolver::updateMesh(mpm);
00181 
00182     // Update diffusivity. Note two stage to make sure old one is de-registered
00183     // before creating/registering new one.
00184     diffusivityPtr_.reset(NULL);
00185     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
00186 }
00187 
00188 
00189 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd