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

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