1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
29 #include "fvMatrices.H"
30 #include "geometricOneField.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(actuationDiskSource, 0);
38 addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
42 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 void Foam::actuationDiskSource::checkData() const
46 if (magSqr(diskArea_) <= VSMALL)
48 FatalErrorIn("Foam::actuationDiskSource::checkData()")
49 << "diskArea is approximately zero"
50 << exit(FatalIOError);
52 if (Cp_ <= VSMALL || Ct_ <= VSMALL)
54 FatalErrorIn("Foam::actuationDiskSource::checkData()")
55 << "Cp and Ct must be greater than zero"
56 << exit(FatalIOError);
58 if (mag(diskDir_) < VSMALL)
60 FatalErrorIn("Foam::actuationDiskSource::checkData()")
61 << "disk direction vector is approximately zero"
62 << exit(FatalIOError);
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 Foam::actuationDiskSource::actuationDiskSource
72 const dictionary& dict,
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;
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))
100 const scalarField& V = this->mesh().V();
101 vectorField& Usource = UEqn.source();
102 const vectorField& U = UEqn.psi();
106 addActuationDiskAxialInertialResistance
111 this->mesh().lookupObject<volScalarField>("rho"),
117 addActuationDiskAxialInertialResistance
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"))
136 os.writeKeyword("note") << string(dict_.lookup("note"))
137 << token::END_STATEMENT << nl;
140 os << indent << "actuationDisk";
144 os << decrIndent << indent << token::END_BLOCK << endl;
148 bool Foam::actuationDiskSource::read(const dictionary& dict)
150 if (basicSource::read(dict))
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_);
171 // ************************************************************************* //