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

displacementLaplacianFvMotionSolver.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 "displacementLaplacianFvMotionSolver.H"
00028 #include "motionDiffusivity.H"
00029 #include "fvmLaplacian.H"
00030 #include "addToRunTimeSelectionTable.H"
00031 #include "OFstream.H"
00032 #include "meshTools.H"
00033 #include "mapPolyMesh.H"
00034 #include "volPointInterpolation.H"
00035 
00036 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00037 
00038 namespace Foam
00039 {
00040     defineTypeNameAndDebug(displacementLaplacianFvMotionSolver, 0);
00041 
00042     addToRunTimeSelectionTable
00043     (
00044         fvMotionSolver,
00045         displacementLaplacianFvMotionSolver,
00046         dictionary
00047     );
00048 }
00049 
00050 
00051 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00052 
00053 Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
00054 (
00055     const polyMesh& mesh,
00056     Istream& is
00057 )
00058 :
00059     displacementFvMotionSolver(mesh, is),
00060     pointDisplacement_
00061     (
00062         IOobject
00063         (
00064             "pointDisplacement",
00065             fvMesh_.time().timeName(),
00066             fvMesh_,
00067             IOobject::MUST_READ,
00068             IOobject::AUTO_WRITE
00069         ),
00070         pointMesh::New(fvMesh_)
00071     ),
00072     cellDisplacement_
00073     (
00074         IOobject
00075         (
00076             "cellDisplacement",
00077             mesh.time().timeName(),
00078             mesh,
00079             IOobject::READ_IF_PRESENT,
00080             IOobject::AUTO_WRITE
00081         ),
00082         fvMesh_,
00083         dimensionedVector
00084         (
00085             "cellDisplacement",
00086             pointDisplacement_.dimensions(),
00087             vector::zero
00088         ),
00089         cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
00090     ),
00091     pointLocation_(NULL),
00092     diffusivityPtr_
00093     (
00094         motionDiffusivity::New(*this, lookup("diffusivity"))
00095     ),
00096     frozenPointsZone_
00097     (
00098         found("frozenPointsZone")
00099       ? fvMesh_.pointZones().findZoneID(lookup("frozenPointsZone"))
00100       : -1
00101     )
00102 {
00103     IOobject io
00104     (
00105         "pointLocation",
00106         fvMesh_.time().timeName(),
00107         fvMesh_,
00108         IOobject::MUST_READ,
00109         IOobject::AUTO_WRITE
00110     );
00111 
00112     if (debug)
00113     {
00114         Info<< "displacementLaplacianFvMotionSolver:" << nl
00115             << "    diffusivity       : " << diffusivityPtr_().type() << nl
00116             << "    frozenPoints zone : " << frozenPointsZone_ << endl;
00117     }
00118 
00119 
00120     if (io.headerOk())
00121     {
00122         pointLocation_.reset
00123         (
00124             new pointVectorField
00125             (
00126                 io,
00127                 pointMesh::New(fvMesh_)
00128             )
00129         );
00130 
00131         if (debug)
00132         {
00133             Info<< "displacementLaplacianFvMotionSolver :"
00134                 << " Read pointVectorField "
00135                 << io.name() << " to be used for boundary conditions on points."
00136                 << nl
00137                 << "Boundary conditions:"
00138                 << pointLocation_().boundaryField().types() << endl;
00139         }
00140     }
00141 }
00142 
00143 
00144 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00145 
00146 Foam::displacementLaplacianFvMotionSolver::
00147 ~displacementLaplacianFvMotionSolver()
00148 {}
00149 
00150 
00151 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00152 
00153 Foam::tmp<Foam::pointField>
00154 Foam::displacementLaplacianFvMotionSolver::curPoints() const
00155 {
00156     volPointInterpolation::New(fvMesh_).interpolate
00157     (
00158         cellDisplacement_,
00159         pointDisplacement_
00160     );
00161 
00162     if (pointLocation_.valid())
00163     {
00164         if (debug)
00165         {
00166             Info<< "displacementLaplacianFvMotionSolver : applying "
00167                 << " boundary conditions on " << pointLocation_().name()
00168                 << " to new point location."
00169                 << endl;
00170         }
00171 
00172         pointLocation_().internalField() =
00173             points0()
00174           + pointDisplacement_.internalField();
00175 
00176         pointLocation_().correctBoundaryConditions();
00177 
00178         // Implement frozen points
00179         if (frozenPointsZone_ != -1)
00180         {
00181             const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
00182 
00183             forAll(pz, i)
00184             {
00185                 pointLocation_()[pz[i]] = points0()[pz[i]];
00186             }
00187         }
00188 
00189         twoDCorrectPoints(pointLocation_().internalField());
00190 
00191         return tmp<pointField>(pointLocation_().internalField());
00192     }
00193     else
00194     {
00195         tmp<pointField> tcurPoints
00196         (
00197             points0() + pointDisplacement_.internalField()
00198         );
00199 
00200         // Implement frozen points
00201         if (frozenPointsZone_ != -1)
00202         {
00203             const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
00204 
00205             forAll(pz, i)
00206             {
00207                 tcurPoints()[pz[i]] = points0()[pz[i]];
00208             }
00209         }
00210 
00211         twoDCorrectPoints(tcurPoints());
00212 
00213         return tcurPoints;
00214     }
00215 }
00216 
00217 
00218 void Foam::displacementLaplacianFvMotionSolver::solve()
00219 {
00220     // The points have moved so before interpolation update
00221     // the fvMotionSolver accordingly
00222     movePoints(fvMesh_.points());
00223 
00224     diffusivityPtr_->correct();
00225     pointDisplacement_.boundaryField().updateCoeffs();
00226 
00227     Foam::solve
00228     (
00229         fvm::laplacian
00230         (
00231             diffusivityPtr_->operator()(),
00232             cellDisplacement_,
00233             "laplacian(diffusivity,cellDisplacement)"
00234         )
00235     );
00236 }
00237 
00238 
00239 void Foam::displacementLaplacianFvMotionSolver::updateMesh
00240 (
00241     const mapPolyMesh& mpm
00242 )
00243 {
00244     displacementFvMotionSolver::updateMesh(mpm);
00245 
00246     // Update diffusivity. Note two stage to make sure old one is de-registered
00247     // before creating/registering new one.
00248     diffusivityPtr_.reset(NULL);
00249     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
00250 }
00251 
00252 
00253 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd