FreeFOAM The Cross-Platform CFD Toolkit
actuationDiskSource.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) 2010-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 the
13  Free Software Foundation; either version 3 of the License, or (at your
14  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, write to the Free Software Foundation,
23  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 \*----------------------------------------------------------------------------*/
26 
27 #include "actuationDiskSource.H"
28 #include <finiteVolume/fvMesh.H>
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(actuationDiskSource, 0);
38  addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
39 }
40 
41 
42 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 void Foam::actuationDiskSource::checkData()
45 {
46  if (magSqr(diskArea_) <= VSMALL)
47  {
48  FatalErrorIn("Foam::actuationDiskSource::checkData()")
49  << "diskArea is approximately zero"
50  << exit(FatalIOError);
51  }
52  if (Cp_ <= VSMALL || Ct_ <= VSMALL)
53  {
54  FatalErrorIn("Foam::actuationDiskSource::checkData()")
55  << "Cp and Ct must be greater than zero"
56  << exit(FatalIOError);
57  }
58  if (mag(diskDir_) < VSMALL)
59  {
60  FatalErrorIn("Foam::actuationDiskSource::checkData()")
61  << "disk direction vector is approximately zero"
62  << exit(FatalIOError);
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
69 Foam::actuationDiskSource::actuationDiskSource
70 (
71  const word& name,
72  const dictionary& dict,
73  const fvMesh& mesh
74 )
75 :
76  basicSource(name, dict, mesh),
77  cellZoneID_(mesh.cellZones().findZoneID(this->cellSetName())),
78  dict_(dict.subDict(typeName + "Coeffs")),
79  diskDir_(dict_.lookup("diskDir")),
80  Cp_(readScalar(dict_.lookup("Cp"))),
81  Ct_(readScalar(dict_.lookup("Ct"))),
82  diskArea_(readScalar(dict_.lookup("diskArea")))
83 {
84  Info<< " - creating actuation disk zone: "
85  << this->name() << endl;
86 
87  bool foundZone = (cellZoneID_ != -1);
88 
89  reduce(foundZone, orOp<bool>());
90 
91  if (!foundZone && Pstream::master())
92  {
94  (
95  "Foam::actuationDiskSource::actuationDiskSource"
96  "(const word&, const dictionary&, const fvMesh&)"
97  ) << "cannot find porous cellZone " << this->name()
98  << exit(FatalError);
99  }
100 
101  checkData();
102 }
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  if (cellZoneID_ == -1)
110  {
111  return;
112  }
113 
114  bool compressible = false;
115  if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
116  {
117  compressible = true;
118  }
119 
120  const labelList& cells = mesh_.cellZones()[cellZoneID_];
121  const scalarField& V = this->mesh().V();
122  vectorField& Usource = UEqn.source();
123  const vectorField& U = UEqn.psi();
124 
125  if (compressible)
126  {
127  addActuationDiskAxialInertialResistance
128  (
129  Usource,
130  cells,
131  V,
132  this->mesh().lookupObject<volScalarField>("rho"),
133  U
134  );
135  }
136  else
137  {
138  addActuationDiskAxialInertialResistance
139  (
140  Usource,
141  cells,
142  V,
144  U
145  );
146  }
147 }
148 
149 
151 {
152 
153  os << indent << token::BEGIN_BLOCK << incrIndent << nl;
154  os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
155 
156  if (dict_.found("note"))
157  {
158  os.writeKeyword("note") << string(dict_.lookup("note"))
159  << token::END_STATEMENT << nl;
160  }
161 
162  os << indent << "actuationDisk";
163 
164  dict_.write(os);
165 
166  os << decrIndent << indent << token::END_BLOCK << endl;
167 }
168 
169 
171 {
172  if (basicSource::read(dict))
173  {
174  const dictionary& sourceDict = dict.subDict(name());
175  const dictionary& subDictCoeffs =
176  sourceDict.subDict(typeName + "Coeffs");
177  subDictCoeffs.readIfPresent("diskDir", diskDir_);
178  subDictCoeffs.readIfPresent("Cp", Cp_);
179  subDictCoeffs.readIfPresent("Ct", Ct_);
180  subDictCoeffs.readIfPresent("diskArea", diskArea_);
181 
182  checkData();
183 
184  return true;
185  }
186  else
187  {
188  return false;
189  }
190 }
191 
192 
193 // ************************************************************************* //