FreeFOAM The Cross-Platform CFD Toolkit
SRFModel.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 
26 #include "SRFModel.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  namespace SRF
34  {
35  defineTypeNameAndDebug(SRFModel, 0);
36  defineRunTimeSelectionTable(SRFModel, dictionary);
37  }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
43 Foam::SRF::SRFModel::SRFModel
44 (
45  const word& type,
46  const volVectorField& Urel
47 )
48 :
50  (
51  IOobject
52  (
53  "SRFProperties",
54  Urel.time().constant(),
55  Urel.db(),
56  IOobject::MUST_READ,
57  IOobject::NO_WRITE
58  )
59  ),
60  Urel_(Urel),
61  mesh_(Urel_.mesh()),
62  axis_(lookup("axis")),
63  SRFModelCoeffs_(subDict(type + "Coeffs")),
64  omega_(dimensionedVector("omega", dimless/dimTime, vector::zero))
65 {
66  // Normalise the axis
67  axis_ /= mag(axis_);
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  if (regIOobject::read())
82  {
83  // Re-read axis
84  SRFModelCoeffs_.lookup("axis") >> axis_;
85  axis_ /= mag(axis_);
86 
87  // Re-read sub-model coeffs
88  SRFModelCoeffs_ = subDict(type() + "Coeffs");
89 
90  return true;
91  }
92  else
93  {
94  return false;
95  }
96 }
97 
98 
100 {
101  return axis_;
102 }
103 
104 
106 {
107  return omega_;
108 }
109 
110 
113 {
115  (
117  (
118  IOobject
119  (
120  "Fcoriolis",
121  mesh_.time().timeName(),
122  mesh_,
125  ),
126  2.0*omega_ ^ Urel_
127  )
128  );
129 }
130 
131 
134 {
136  (
138  (
139  IOobject
140  (
141  "Fcentrifugal",
142  mesh_.time().timeName(),
143  mesh_,
146  ),
147  omega_ ^ (omega_ ^ mesh_.C())
148  )
149  );
150 }
151 
152 
155 {
156  return Fcoriolis() + Fcentrifugal();
157 }
158 
159 
161 (
162  const vectorField& positions
163 ) const
164 {
165  return omega_.value() ^ (positions - axis_*(axis_ & positions));
166 }
167 
168 
170 {
171  return tmp<volVectorField>
172  (
173  new volVectorField
174  (
175  IOobject
176  (
177  "Usrf",
178  mesh_.time().timeName(),
179  mesh_,
182  ),
183  omega_ ^ (mesh_.C() - axis_*(axis_ & mesh_.C()))
184  )
185  );
186 }
187 
188 
190 {
191  const volVectorField Usrf = U();
192 
193  tmp<volVectorField> tUabs
194  (
195  new volVectorField
196  (
197  IOobject
198  (
199  "Uabs",
200  mesh_.time().timeName(),
201  mesh_,
204  false
205  ),
206  Usrf
207  )
208  );
209 
210  // Add SRF contribution to internal field
211  tUabs().internalField() += Urel_.internalField();
212 
213  // Add Urel boundary contributions
214  const volVectorField::GeometricBoundaryField& bvf = Urel_.boundaryField();
215 
216  forAll(bvf, i)
217  {
218  if (isA<SRFVelocityFvPatchVectorField>(bvf[i]))
219  {
220  // Only include relative contributions from
221  // SRFVelocityFvPatchVectorField's
222  const SRFVelocityFvPatchVectorField& UrelPatch =
223  refCast<const SRFVelocityFvPatchVectorField>(bvf[i]);
224  if (UrelPatch.relative())
225  {
226  tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
227  }
228  }
229  else
230  {
231  tUabs().boundaryField()[i] += Urel_.boundaryField()[i];
232  }
233  }
234 
235  return tUabs;
236 }
237 
238 
239 // ************************ vim: set sw=4 sts=4 et: ************************ //