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) 2011-2015 OpenFOAM Foundation
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 "actuationDiskSource.H"
27 #include "fvMesh.H"
28 #include "fvMatrix.H"
29 #include "geometricOneField.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(actuationDiskSource, 0);
40  (
41  option,
42  actuationDiskSource,
43  dictionary
44  );
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
52 {
53  if (magSqr(diskArea_) <= VSMALL)
54  {
56  << "diskArea is approximately zero"
57  << exit(FatalIOError);
58  }
59  if (Cp_ <= VSMALL || Ct_ <= VSMALL)
60  {
62  << "Cp and Ct must be greater than zero"
63  << exit(FatalIOError);
64  }
65  if (mag(diskDir_) < VSMALL)
66  {
68  << "disk direction vector is approximately zero"
69  << exit(FatalIOError);
70  }
72  {
74  << "upstream location " << upstreamPoint_ << " not found in mesh"
75  << exit(FatalIOError);
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
83 (
84  const word& name,
85  const word& modelType,
86  const dictionary& dict,
87  const fvMesh& mesh
88 )
89 :
90  cellSetOption(name, modelType, dict, mesh),
91  diskDir_(coeffs_.lookup("diskDir")),
92  Cp_(readScalar(coeffs_.lookup("Cp"))),
93  Ct_(readScalar(coeffs_.lookup("Ct"))),
94  diskArea_(readScalar(coeffs_.lookup("diskArea"))),
95  upstreamPoint_(coeffs_.lookup("upstreamPoint")),
96  upstreamCellId_(-1)
97 {
98  coeffs_.lookup("fieldNames") >> fieldNames_;
99  applied_.setSize(fieldNames_.size(), false);
100 
101  Info<< " - creating actuation disk zone: "
102  << this->name() << endl;
103 
104  upstreamCellId_ = mesh.findCell(upstreamPoint_);
105 
106  checkData();
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
113 (
114  fvMatrix<vector>& eqn,
115  const label fieldI
116 )
117 {
118  const scalarField& cellsV = mesh_.V();
119  vectorField& Usource = eqn.source();
120  const vectorField& U = eqn.psi();
121 
122  if (V() > VSMALL)
123  {
124  addActuationDiskAxialInertialResistance
125  (
126  Usource,
127  cells_,
128  cellsV,
130  U
131  );
132  }
133 }
134 
135 
137 (
138  const volScalarField& rho,
139  fvMatrix<vector>& eqn,
140  const label fieldI
141 )
142 {
143  const scalarField& cellsV = mesh_.V();
144  vectorField& Usource = eqn.source();
145  const vectorField& U = eqn.psi();
146 
147  if (V() > VSMALL)
148  {
149  addActuationDiskAxialInertialResistance
150  (
151  Usource,
152  cells_,
153  cellsV,
154  rho,
155  U
156  );
157  }
158 }
159 
160 
162 {
164  {
165  coeffs_.readIfPresent("diskDir", diskDir_);
166  coeffs_.readIfPresent("Cp", Cp_);
167  coeffs_.readIfPresent("Ct", Ct_);
168  coeffs_.readIfPresent("diskArea", diskArea_);
169 
170  checkData();
171 
172  return true;
173  }
174  else
175  {
176  return false;
177  }
178 }
179 
180 
181 // ************************************************************************* //
Foam::fv::actuationDiskSource::diskDir_
vector diskDir_
Disk area normal.
Definition: actuationDiskSource.H:110
Foam::maxOp
Definition: ops.H:172
Foam::fv::actuationDiskSource::Ct_
scalar Ct_
Thrust coefficient.
Definition: actuationDiskSource.H:116
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.
Definition: cellSetOption.H:71
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:52
Foam::FatalIOError
IOerror FatalIOError
fvMatrix.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::fv::actuationDiskSource::diskArea_
scalar diskArea_
Disk area.
Definition: actuationDiskSource.H:119
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:281
U
U
Definition: pEqn.H:46
Foam::fv::actuationDiskSource::actuationDiskSource
actuationDiskSource(const actuationDiskSource &)
Disallow default bitwise copy construct.
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOptionIO.C:30
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
rho
rho
Definition: pEqn.H:3
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
geometricOneField.H
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::fvMatrix::source
Field< Type > & source()
Definition: fvMatrix.H:291
Foam::fv::actuationDiskSource::upstreamPoint_
point upstreamPoint_
Upstream point sample.
Definition: actuationDiskSource.H:122
Foam::fv::actuationDiskSource::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: actuationDiskSource.C:161
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::actuationDiskSource::checkData
void checkData() const
Check data.
Definition: actuationDiskSource.C:51
Foam::fv::actuationDiskSource::Cp_
scalar Cp_
Power coefficient.
Definition: actuationDiskSource.H:113
Foam::fv::actuationDiskSource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldI)
Source term to momentum equation.
Definition: actuationDiskSource.C:113
Foam::fv::actuationDiskSource::upstreamCellId_
label upstreamCellId_
Upstream cell ID.
Definition: actuationDiskSource.H:125
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
actuationDiskSource.H