FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

displacementSBRStressFvMotionSolver.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "displacementSBRStressFvMotionSolver.H"
00027 #include <fvMotionSolvers/motionDiffusivity.H>
00028 #include <finiteVolume/fvmLaplacian.H>
00029 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00030 #include <finiteVolume/fvcDiv.H>
00031 #include <finiteVolume/fvcGrad.H>
00032 #include <finiteVolume/surfaceInterpolate.H>
00033 #include <finiteVolume/fvcLaplacian.H>
00034 #include <OpenFOAM/mapPolyMesh.H>
00035 #include <finiteVolume/volPointInterpolation.H>
00036 
00037 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00038 
00039 namespace Foam
00040 {
00041     defineTypeNameAndDebug(displacementSBRStressFvMotionSolver, 0);
00042 
00043     addToRunTimeSelectionTable
00044     (
00045         fvMotionSolver,
00046         displacementSBRStressFvMotionSolver,
00047         dictionary
00048     );
00049 }
00050 
00051 
00052 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00053 
00054 Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
00055 (
00056     const polyMesh& mesh,
00057     Istream& is
00058 )
00059 :
00060     displacementFvMotionSolver(mesh, is),
00061     pointDisplacement_
00062     (
00063         IOobject
00064         (
00065             "pointDisplacement",
00066             fvMesh_.time().timeName(),
00067             fvMesh_,
00068             IOobject::MUST_READ,
00069             IOobject::AUTO_WRITE
00070         ),
00071         pointMesh::New(fvMesh_)
00072     ),
00073     cellDisplacement_
00074     (
00075         IOobject
00076         (
00077             "cellDisplacement",
00078             mesh.time().timeName(),
00079             mesh,
00080             IOobject::READ_IF_PRESENT,
00081             IOobject::AUTO_WRITE
00082         ),
00083         fvMesh_,
00084         dimensionedVector
00085         (
00086             "cellDisplacement",
00087             pointDisplacement_.dimensions(),
00088             vector::zero
00089         ),
00090         cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
00091     ),
00092     diffusivityPtr_
00093     (
00094         motionDiffusivity::New(*this, lookup("diffusivity"))
00095     )
00096 {}
00097 
00098 
00099 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00100 
00101 Foam::displacementSBRStressFvMotionSolver::
00102 ~displacementSBRStressFvMotionSolver()
00103 {}
00104 
00105 
00106 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00107 
00108 Foam::tmp<Foam::pointField>
00109 Foam::displacementSBRStressFvMotionSolver::curPoints() const
00110 {
00111     volPointInterpolation::New(fvMesh_).interpolate
00112     (
00113         cellDisplacement_,
00114         pointDisplacement_
00115     );
00116 
00117     tmp<pointField> tcurPoints
00118     (
00119         points0() + pointDisplacement_.internalField()
00120     );
00121 
00122     twoDCorrectPoints(tcurPoints());
00123 
00124     return tcurPoints;
00125 }
00126 
00127 
00128 void Foam::displacementSBRStressFvMotionSolver::solve()
00129 {
00130     // The points have moved so before interpolation update
00131     // the fvMotionSolver accordingly
00132     movePoints(fvMesh_.points());
00133 
00134     diffusivityPtr_->correct();
00135     pointDisplacement_.boundaryField().updateCoeffs();
00136 
00137     surfaceScalarField Df = diffusivityPtr_->operator()();
00138 
00139     volTensorField gradCd = fvc::grad(cellDisplacement_);
00140 
00141     Foam::solve
00142     (
00143         fvm::laplacian
00144         (
00145             2*Df,
00146             cellDisplacement_,
00147             "laplacian(diffusivity,cellDisplacement)"
00148         )
00149 
00150       + fvc::div
00151         (
00152             Df
00153            *(
00154                (
00155                    cellDisplacement_.mesh().Sf()
00156                  & fvc::interpolate(gradCd.T() - gradCd)
00157                )
00158 
00159                // Solid-body rotation "lambda" term
00160              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
00161             )
00162         )
00163 
00164         /*
00165       - fvc::laplacian
00166         (
00167             2*Df,
00168             cellDisplacement_,
00169             "laplacian(diffusivity,cellDisplacement)"
00170         )
00171 
00172       + fvc::div
00173         (
00174             Df
00175            *(
00176                (
00177                    cellDisplacement_.mesh().Sf()
00178                  & fvc::interpolate(gradCd + gradCd.T())
00179                )
00180 
00181                // Solid-body rotation "lambda" term
00182              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
00183            )
00184         )
00185         */
00186     );
00187 }
00188 
00189 
00190 void Foam::displacementSBRStressFvMotionSolver::updateMesh
00191 (
00192     const mapPolyMesh& mpm
00193 )
00194 {
00195     displacementFvMotionSolver::updateMesh(mpm);
00196 
00197     // Update diffusivity. Note two stage to make sure old one is de-registered
00198     // before creating/registering new one.
00199     diffusivityPtr_.reset(NULL);
00200     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
00201 }
00202 
00203 
00204 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines