FreeFOAM The Cross-Platform CFD Toolkit
velocityComponentLaplacianFvMotionSolver.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 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(velocityComponentLaplacianFvMotionSolver, 0);
37 
39  (
40  fvMotionSolver,
41  velocityComponentLaplacianFvMotionSolver,
42  dictionary
43  );
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 Foam::velocityComponentLaplacianFvMotionSolver::
50 velocityComponentLaplacianFvMotionSolver
51 (
52  const polyMesh& mesh,
53  Istream& msData
54 )
55 :
56  fvMotionSolver(mesh),
57  cmptName_(msData),
58  cmpt_(0),
59  pointMotionU_
60  (
61  IOobject
62  (
63  "pointMotionU" + cmptName_,
64  fvMesh_.time().timeName(),
65  fvMesh_,
66  IOobject::MUST_READ,
67  IOobject::AUTO_WRITE
68  ),
69  pointMesh::New(fvMesh_)
70  ),
71  cellMotionU_
72  (
73  IOobject
74  (
75  "cellMotionU" + cmptName_,
76  mesh.time().timeName(),
77  mesh,
78  IOobject::READ_IF_PRESENT,
79  IOobject::AUTO_WRITE
80  ),
81  fvMesh_,
83  (
84  "cellMotionU",
85  pointMotionU_.dimensions(),
86  0
87  ),
88  cellMotionBoundaryTypes<scalar>(pointMotionU_.boundaryField())
89  ),
90  diffusivityPtr_
91  (
92  motionDiffusivity::New(*this, lookup("diffusivity"))
93  )
94 {
95  if (cmptName_ == "x")
96  {
97  cmpt_ = vector::X;
98  }
99  else if (cmptName_ == "y")
100  {
101  cmpt_ = vector::Y;
102  }
103  else if (cmptName_ == "z")
104  {
105  cmpt_ = vector::Z;
106  }
107  else
108  {
110  (
111  "velocityComponentLaplacianFvMotionSolver::"
112  "velocityComponentLaplacianFvMotionSolver"
113  "(const polyMesh& mesh, Istream& msData)"
114  ) << "Given component name " << cmptName_ << " should be x, y or z"
115  << exit(FatalError);
116  }
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
121 
124 {}
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
131 {
133  (
134  cellMotionU_,
135  pointMotionU_
136  );
137 
138  tmp<pointField> tcurPoints(new pointField(fvMesh_.points()));
139 
140  tcurPoints().replace
141  (
142  cmpt_,
143  tcurPoints().component(cmpt_)
144  + fvMesh_.time().deltaT().value()*pointMotionU_.internalField()
145  );
146 
147  twoDCorrectPoints(tcurPoints());
148 
149  return tcurPoints;
150 }
151 
152 
154 {
155  // The points have moved so before interpolation update
156  // the fvMotionSolver accordingly
157  movePoints(fvMesh_.points());
158 
159  diffusivityPtr_->correct();
160  pointMotionU_.boundaryField().updateCoeffs();
161 
163  (
165  (
166  diffusivityPtr_->operator()(),
167  cellMotionU_,
168  "laplacian(diffusivity,cellMotionU)"
169  )
170  );
171 }
172 
173 
175 (
176  const mapPolyMesh& mpm
177 )
178 {
180 
181  // Update diffusivity. Note two stage to make sure old one is de-registered
182  // before creating/registering new one.
183  diffusivityPtr_.reset(NULL);
184  diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
185 }
186 
187 
188 // ************************ vim: set sw=4 sts=4 et: ************************ //