Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / actuationDiskSource / actuationDiskSource.C
blobd2b6b6ba2ae3cc229a7bff878d91e6629af55117
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
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 dictionary& dict,
73     const fvMesh& mesh
76     basicSource(name, dict, mesh),
77     dict_(dict.subDict(typeName + "Coeffs")),
78     diskDir_(dict_.lookup("diskDir")),
79     Cp_(readScalar(dict_.lookup("Cp"))),
80     Ct_(readScalar(dict_.lookup("Ct"))),
81     diskArea_(readScalar(dict_.lookup("diskArea")))
83     Info<< "    - creating actuation disk zone: "
84         << this->name() << endl;
86     checkData();
90 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
92 void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
94     bool compressible = false;
95     if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
96     {
97         compressible = true;
98     }
100     const scalarField& V = this->mesh().V();
101     vectorField& Usource = UEqn.source();
102     const vectorField& U = UEqn.psi();
104     if (compressible)
105     {
106         addActuationDiskAxialInertialResistance
107         (
108             Usource,
109             cells_,
110             V,
111             this->mesh().lookupObject<volScalarField>("rho"),
112             U
113         );
114     }
115     else
116     {
117         addActuationDiskAxialInertialResistance
118         (
119             Usource,
120             cells_,
121             V,
122             geometricOneField(),
123             U
124         );
125     }
129 void Foam::actuationDiskSource::writeData(Ostream& os) const
131     os  << indent << token::BEGIN_BLOCK << incrIndent << nl;
132     os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
134     if (dict_.found("note"))
135     {
136         os.writeKeyword("note") << string(dict_.lookup("note"))
137             << token::END_STATEMENT << nl;
138     }
140     os << indent << "actuationDisk";
142     dict_.write(os);
144     os << decrIndent << indent << token::END_BLOCK << endl;
148 bool Foam::actuationDiskSource::read(const dictionary& dict)
150     if (basicSource::read(dict))
151     {
152         const dictionary& sourceDict = dict.subDict(name());
153         const dictionary& subDictCoeffs =
154             sourceDict.subDict(typeName + "Coeffs");
155         subDictCoeffs.readIfPresent("diskDir", diskDir_);
156         subDictCoeffs.readIfPresent("Cp", Cp_);
157         subDictCoeffs.readIfPresent("Ct", Ct_);
158         subDictCoeffs.readIfPresent("diskArea", diskArea_);
160         checkData();
162         return true;
163     }
164     else
165     {
166         return false;
167     }
171 // ************************************************************************* //