ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / actuationDiskSource / actuationDiskSource.C
blob32a025d993bd4010f8c5a3e4aee8656ce9d04b80
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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
25 \*----------------------------------------------------------------------------*/
27 #include "actuationDiskSource.H"
28 #include "fvMesh.H"
29 #include "fvMatrices.H"
30 #include "geometricOneField.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
37     defineTypeNameAndDebug(actuationDiskSource, 0);
38     addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
42 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
44 void Foam::actuationDiskSource::checkData() const
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     }
67 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
69 Foam::actuationDiskSource::actuationDiskSource
71     const word& name,
72     const word& modelType,
73     const dictionary& dict,
74     const fvMesh& mesh
77     basicSource(name, modelType, dict, mesh),
78     dict_(dict.subDict(modelType + "Coeffs")),
79     diskDir_(dict_.lookup("diskDir")),
80     Cp_(readScalar(dict_.lookup("Cp"))),
81     Ct_(readScalar(dict_.lookup("Ct"))),
82     diskArea_(readScalar(dict_.lookup("diskArea")))
84     Info<< "    - creating actuation disk zone: "
85         << this->name() << endl;
87     checkData();
91 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
93 void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
95     bool compressible = false;
96     if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
97     {
98         compressible = true;
99     }
101     const scalarField& cellsV = this->mesh().V();
102     vectorField& Usource = UEqn.source();
103     const vectorField& U = UEqn.psi();
105     if (V() > VSMALL)
106     {
107         if (compressible)
108         {
109             addActuationDiskAxialInertialResistance
110             (
111                 Usource,
112                 cells_,
113                 cellsV,
114                 this->mesh().lookupObject<volScalarField>("rho"),
115                 U
116             );
117         }
118         else
119         {
120             addActuationDiskAxialInertialResistance
121             (
122                 Usource,
123                 cells_,
124                 cellsV,
125                 geometricOneField(),
126                 U
127             );
128         }
129     }
133 void Foam::actuationDiskSource::writeData(Ostream& os) const
135     os  << indent << token::BEGIN_BLOCK << incrIndent << nl;
136     os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
138     if (dict_.found("note"))
139     {
140         os.writeKeyword("note") << string(dict_.lookup("note"))
141             << token::END_STATEMENT << nl;
142     }
144     os << indent << "actuationDisk";
146     dict_.write(os);
148     os << decrIndent << indent << token::END_BLOCK << endl;
152 bool Foam::actuationDiskSource::read(const dictionary& dict)
154     if (basicSource::read(dict))
155     {
156         const dictionary& sourceDict = dict.subDict(name());
157         const dictionary& subDictCoeffs =
158             sourceDict.subDict(typeName + "Coeffs");
159         subDictCoeffs.readIfPresent("diskDir", diskDir_);
160         subDictCoeffs.readIfPresent("Cp", Cp_);
161         subDictCoeffs.readIfPresent("Ct", Ct_);
162         subDictCoeffs.readIfPresent("diskArea", diskArea_);
164         checkData();
166         return true;
167     }
168     else
169     {
170         return false;
171     }
175 // ************************************************************************* //