BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / fvMotionSolver / fvMotionSolvers / displacement / SBRStress / displacementSBRStressFvMotionSolver.C
blobeac555d2243b834297c4c7a956aecbd6ab274e43
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "displacementSBRStressFvMotionSolver.H"
27 #include "motionDiffusivity.H"
28 #include "fvmLaplacian.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "fvcDiv.H"
31 #include "fvcGrad.H"
32 #include "surfaceInterpolate.H"
33 #include "fvcLaplacian.H"
34 #include "mapPolyMesh.H"
35 #include "volPointInterpolation.H"
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 namespace Foam
41     defineTypeNameAndDebug(displacementSBRStressFvMotionSolver, 0);
43     addToRunTimeSelectionTable
44     (
45         fvMotionSolver,
46         displacementSBRStressFvMotionSolver,
47         dictionary
48     );
52 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
54 Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
56     const polyMesh& mesh,
57     Istream& is
60     displacementFvMotionSolver(mesh, is),
61     pointDisplacement_
62     (
63         IOobject
64         (
65             "pointDisplacement",
66             fvMesh_.time().timeName(),
67             fvMesh_,
68             IOobject::MUST_READ,
69             IOobject::AUTO_WRITE
70         ),
71         pointMesh::New(fvMesh_)
72     ),
73     cellDisplacement_
74     (
75         IOobject
76         (
77             "cellDisplacement",
78             mesh.time().timeName(),
79             mesh,
80             IOobject::READ_IF_PRESENT,
81             IOobject::AUTO_WRITE
82         ),
83         fvMesh_,
84         dimensionedVector
85         (
86             "cellDisplacement",
87             pointDisplacement_.dimensions(),
88             vector::zero
89         ),
90         cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
91     ),
92     diffusivityPtr_
93     (
94         motionDiffusivity::New(*this, lookup("diffusivity"))
95     )
99 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
101 Foam::displacementSBRStressFvMotionSolver::
102 ~displacementSBRStressFvMotionSolver()
106 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
108 Foam::tmp<Foam::pointField>
109 Foam::displacementSBRStressFvMotionSolver::curPoints() const
111     volPointInterpolation::New(fvMesh_).interpolate
112     (
113         cellDisplacement_,
114         pointDisplacement_
115     );
117     tmp<pointField> tcurPoints
118     (
119         points0() + pointDisplacement_.internalField()
120     );
122     twoDCorrectPoints(tcurPoints());
124     return tcurPoints;
128 void Foam::displacementSBRStressFvMotionSolver::solve()
130     // The points have moved so before interpolation update
131     // the fvMotionSolver accordingly
132     movePoints(fvMesh_.points());
134     diffusivityPtr_->correct();
135     pointDisplacement_.boundaryField().updateCoeffs();
137     surfaceScalarField Df(diffusivityPtr_->operator()());
139     volTensorField gradCd(fvc::grad(cellDisplacement_));
141     Foam::solve
142     (
143         fvm::laplacian
144         (
145             2*Df,
146             cellDisplacement_,
147             "laplacian(diffusivity,cellDisplacement)"
148         )
150       + fvc::div
151         (
152             Df
153            *(
154                (
155                    cellDisplacement_.mesh().Sf()
156                  & fvc::interpolate(gradCd.T() - gradCd)
157                )
159                // Solid-body rotation "lambda" term
160              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
161             )
162         )
164         /*
165       - fvc::laplacian
166         (
167             2*Df,
168             cellDisplacement_,
169             "laplacian(diffusivity,cellDisplacement)"
170         )
172       + fvc::div
173         (
174             Df
175            *(
176                (
177                    cellDisplacement_.mesh().Sf()
178                  & fvc::interpolate(gradCd + gradCd.T())
179                )
181                // Solid-body rotation "lambda" term
182              - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
183            )
184         )
185         */
186     );
190 void Foam::displacementSBRStressFvMotionSolver::updateMesh
192     const mapPolyMesh& mpm
195     displacementFvMotionSolver::updateMesh(mpm);
197     // Update diffusivity. Note two stage to make sure old one is de-registered
198     // before creating/registering new one.
199     diffusivityPtr_.reset(NULL);
200     diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
204 // ************************************************************************* //