initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / fvMotionSolver / fvMotionSolvers / displacement / SBRStress / displacementSBRStressFvMotionSolver.C
blob8c536691819eebc97682f036ab9cdfc842d25508
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 "displacementSBRStressFvMotionSolver.H"
28 #include "motionDiffusivity.H"
29 #include "fvmLaplacian.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "fvcDiv.H"
32 #include "fvcGrad.H"
33 #include "surfaceInterpolate.H"
34 #include "fvcLaplacian.H"
35 #include "mapPolyMesh.H"
36 #include "volPointInterpolation.H"
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 namespace Foam
42     defineTypeNameAndDebug(displacementSBRStressFvMotionSolver, 0);
44     addToRunTimeSelectionTable
45     (
46         fvMotionSolver,
47         displacementSBRStressFvMotionSolver,
48         dictionary
49     );
53 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
55 Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
57     const polyMesh& mesh,
58     Istream& is
61     displacementFvMotionSolver(mesh, is),
62     pointDisplacement_
63     (
64         IOobject
65         (
66             "pointDisplacement",
67             fvMesh_.time().timeName(),
68             fvMesh_,
69             IOobject::MUST_READ,
70             IOobject::AUTO_WRITE
71         ),
72         pointMesh::New(fvMesh_)
73     ),
74     cellDisplacement_
75     (
76         IOobject
77         (
78             "cellDisplacement",
79             mesh.time().timeName(),
80             mesh,
81             IOobject::READ_IF_PRESENT,
82             IOobject::AUTO_WRITE
83         ),
84         fvMesh_,
85         dimensionedVector
86         (
87             "cellDisplacement",
88             pointDisplacement_.dimensions(),
89             vector::zero
90         ),
91         cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
92     ),
93     diffusivityPtr_
94     (
95         motionDiffusivity::New(*this, lookup("diffusivity"))
96     )
100 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
102 Foam::displacementSBRStressFvMotionSolver::
103 ~displacementSBRStressFvMotionSolver()
107 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
109 Foam::tmp<Foam::pointField>
110 Foam::displacementSBRStressFvMotionSolver::curPoints() const
112     volPointInterpolation::New(fvMesh_).interpolate
113     (
114         cellDisplacement_,
115         pointDisplacement_
116     );
118     tmp<pointField> tcurPoints
119     (
120         points0() + pointDisplacement_.internalField()
121     );
123     twoDCorrectPoints(tcurPoints());
125     return tcurPoints;
129 void Foam::displacementSBRStressFvMotionSolver::solve()
131     // The points have moved so before interpolation update
132     // the fvMotionSolver accordingly
133     movePoints(fvMesh_.points());
135     diffusivityPtr_->correct();
136     pointDisplacement_.boundaryField().updateCoeffs();
138     surfaceScalarField Df = diffusivityPtr_->operator()();
140     volTensorField gradCd = fvc::grad(cellDisplacement_);
142     Foam::solve
143     (
144         fvm::laplacian
145         (
146             2*Df,
147             cellDisplacement_,
148             "laplacian(diffusivity,cellDisplacement)"
149         )
151       + fvc::div
152         (
153             Df
154            *(
155                (
156                    cellDisplacement_.mesh().Sf()
157                  & fvc::interpolate(gradCd.T() - gradCd)
158                )
160                // Solid-body rotation "lambda" term
161              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
162             )
163         )
165         /*
166       - fvc::laplacian
167         (
168             2*Df,
169             cellDisplacement_,
170             "laplacian(diffusivity,cellDisplacement)"
171         )
173       + fvc::div
174         (
175             Df
176            *(
177                (
178                    cellDisplacement_.mesh().Sf()
179                  & fvc::interpolate(gradCd + gradCd.T())
180                )
182                // Solid-body rotation "lambda" term
183              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
184            )
185         )
186         */
187     );
191 void Foam::displacementSBRStressFvMotionSolver::updateMesh
193     const mapPolyMesh& mpm
196     displacementFvMotionSolver::updateMesh(mpm);
198     // Update diffusivity. Note two stage to make sure old one is de-registered
199     // before creating/registering new one.
200     diffusivityPtr_.reset(NULL);
201     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
205 // ************************************************************************* //