FreeFOAM The Cross-Platform CFD Toolkit
displacementSBRStressFvMotionSolver.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
30 #include <finiteVolume/fvcDiv.H>
31 #include <finiteVolume/fvcGrad.H>
34 #include <OpenFOAM/mapPolyMesh.H>
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(displacementSBRStressFvMotionSolver, 0);
42 
44  (
45  fvMotionSolver,
46  displacementSBRStressFvMotionSolver,
47  dictionary
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
55 (
56  const polyMesh& mesh,
57  Istream& is
58 )
59 :
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_,
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  )
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
110 {
112  (
113  cellDisplacement_,
114  pointDisplacement_
115  );
116 
117  tmp<pointField> tcurPoints
118  (
119  points0() + pointDisplacement_.internalField()
120  );
121 
122  twoDCorrectPoints(tcurPoints());
123 
124  return tcurPoints;
125 }
126 
127 
129 {
130  // The points have moved so before interpolation update
131  // the fvMotionSolver accordingly
132  movePoints(fvMesh_.points());
133 
134  diffusivityPtr_->correct();
135  pointDisplacement_.boundaryField().updateCoeffs();
136 
137  surfaceScalarField Df = diffusivityPtr_->operator()();
138 
139  volTensorField gradCd = fvc::grad(cellDisplacement_);
140 
142  (
144  (
145  2*Df,
146  cellDisplacement_,
147  "laplacian(diffusivity,cellDisplacement)"
148  )
149 
150  + fvc::div
151  (
152  Df
153  *(
154  (
155  cellDisplacement_.mesh().Sf()
156  & fvc::interpolate(gradCd.T() - gradCd)
157  )
158 
159  // Solid-body rotation "lambda" term
160  - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
161  )
162  )
163 
164  /*
165  - fvc::laplacian
166  (
167  2*Df,
168  cellDisplacement_,
169  "laplacian(diffusivity,cellDisplacement)"
170  )
171 
172  + fvc::div
173  (
174  Df
175  *(
176  (
177  cellDisplacement_.mesh().Sf()
178  & fvc::interpolate(gradCd + gradCd.T())
179  )
180 
181  // Solid-body rotation "lambda" term
182  - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
183  )
184  )
185  */
186  );
187 }
188 
189 
191 (
192  const mapPolyMesh& mpm
193 )
194 {
196 
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"));
201 }
202 
203 
204 // ************************ vim: set sw=4 sts=4 et: ************************ //