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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "actuationDiskSource.H"
29 #include "fvMesh.H"
30 #include "fvMatrix.H"
31 #include "geometricOneField.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace fv
39 {
40  defineTypeNameAndDebug(actuationDiskSource, 0);
42  (
43  option,
44  actuationDiskSource,
45  dictionary
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 void Foam::fv::actuationDiskSource::checkData() const
54 {
55  if (magSqr(diskArea_) <= VSMALL)
56  {
58  << "diskArea is approximately zero"
59  << exit(FatalIOError);
60  }
61  if (Cp_ <= VSMALL || Ct_ <= VSMALL)
62  {
64  << "Cp and Ct must be greater than zero"
65  << exit(FatalIOError);
66  }
67  if (mag(diskDir_) < VSMALL)
68  {
70  << "disk direction vector is approximately zero"
71  << exit(FatalIOError);
72  }
73  if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
74  {
76  << "upstream location " << upstreamPoint_ << " not found in mesh"
77  << exit(FatalIOError);
78  }
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 
84 Foam::fv::actuationDiskSource::actuationDiskSource
85 (
86  const word& name,
87  const word& modelType,
88  const dictionary& dict,
89  const fvMesh& mesh
90 )
91 :
92  cellSetOption(name, modelType, dict, mesh),
93  diskDir_(coeffs_.get<vector>("diskDir")),
94  Cp_(coeffs_.get<scalar>("Cp")),
95  Ct_(coeffs_.get<scalar>("Ct")),
96  diskArea_(coeffs_.get<scalar>("diskArea")),
97  upstreamPoint_(coeffs_.get<point>("upstreamPoint")),
98  upstreamCellId_(-1)
99 {
100  coeffs_.readEntry("fields", fieldNames_);
101  applied_.setSize(fieldNames_.size(), false);
102 
103  Info<< " - creating actuation disk zone: "
104  << this->name() << endl;
105 
106  upstreamCellId_ = mesh.findCell(upstreamPoint_);
107 
108  checkData();
109 }
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
115 (
116  fvMatrix<vector>& eqn,
117  const label fieldi
118 )
119 {
120  const scalarField& cellsV = mesh_.V();
121  vectorField& Usource = eqn.source();
122  const vectorField& U = eqn.psi();
123 
124  if (V() > VSMALL)
125  {
126  addActuationDiskAxialInertialResistance
127  (
128  Usource,
129  cells_,
130  cellsV,
132  U
133  );
134  }
135 }
136 
137 
139 (
140  const volScalarField& rho,
141  fvMatrix<vector>& eqn,
142  const label fieldi
143 )
144 {
145  const scalarField& cellsV = mesh_.V();
146  vectorField& Usource = eqn.source();
147  const vectorField& U = eqn.psi();
148 
149  if (V() > VSMALL)
150  {
151  addActuationDiskAxialInertialResistance
152  (
153  Usource,
154  cells_,
155  cellsV,
156  rho,
157  U
158  );
159  }
160 }
161 
162 
164 {
166  {
167  coeffs_.readIfPresent("diskDir", diskDir_);
168  coeffs_.readIfPresent("Cp", Cp_);
169  coeffs_.readIfPresent("Ct", Ct_);
170  coeffs_.readIfPresent("diskArea", diskArea_);
171 
172  checkData();
173 
174  return true;
175  }
176 
177  return false;
178 }
179 
180 
181 // ************************************************************************* //
Foam::fv::actuationDiskSource::diskDir_
vector diskDir_
Disk area normal.
Definition: actuationDiskSource.H:111
Foam::fv::actuationDiskSource::Ct_
scalar Ct_
Thrust coefficient.
Definition: actuationDiskSource.H:117
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:54
Foam::FatalIOError
IOerror FatalIOError
fvMatrix.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::fv::actuationDiskSource::diskArea_
scalar diskArea_
Disk area.
Definition: actuationDiskSource.H:120
rho
rho
Definition: readInitialConditions.H:96
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:285
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
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:62
Foam::Field< scalar >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOption.C:255
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::checkData
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
U
U
Definition: pEqn.H:72
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
geometricOneField.H
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fvMatrix::source
Field< Type > & source()
Definition: fvMatrix.H:295
Foam::fv::actuationDiskSource::upstreamPoint_
point upstreamPoint_
Upstream point sample.
Definition: actuationDiskSource.H:123
Foam::fv::actuationDiskSource::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: actuationDiskSource.C:163
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::fv::actuationDiskSource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Source term to momentum equation.
Definition: actuationDiskSource.C:115
Foam::fv::actuationDiskSource::Cp_
scalar Cp_
Power coefficient.
Definition: actuationDiskSource.H:114
Foam::fv::actuationDiskSource::upstreamCellId_
label upstreamCellId_
Upstream cell ID.
Definition: actuationDiskSource.H:126
Foam::GeometricField< scalar, fvPatchField, volMesh >
actuationDiskSource.H