Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / explicitSource / explicitSource.C
blob7c798af97e3524dc1a18dca6bea9c693815bd41e
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "explicitSource.H"
27 #include "fvMesh.H"
28 #include "volFields.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "HashSet.H"
32 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
34 namespace Foam
36     defineTypeNameAndDebug(explicitSource, 0);
37     addToRunTimeSelectionTable
38     (
39         basicSource,
40         explicitSource,
41         dictionary
42     );
45     // * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
47     template<> const char* NamedEnum
48     <
49         explicitSource::volumeModeType,
50         2
51         >::names[] =
52     {
53         "absolute",
54         "specific"
55     };
57     const NamedEnum<explicitSource::volumeModeType, 2>
58         explicitSource::volumeModeTypeNames_;
62 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
64 void Foam::explicitSource::setFieldData(const dictionary& dict)
66     scalarFields_.clear();
67     vectorFields_.clear();
69     wordList fieldTypes(dict.toc().size());
70     wordList fieldNames(dict.toc().size());
72     forAll(dict.toc(), i)
73     {
74         const word& fieldName = dict.toc()[i];
75         IOobject io
76         (
77             fieldName,
78             this->mesh().time().timeName(0),
79             this->mesh(),
80             IOobject::NO_READ,
81             IOobject::NO_WRITE,
82             false
83         );
84         if (io.headerOk())
85         {
86             fieldTypes[i] = io.headerClassName();
87             fieldNames[i] = dict.toc()[i];
88         }
89         else
90         {
91             FatalErrorIn
92             (
93                 "explicitSource::setFieldData"
94             )   << "header not OK " << io.name()
95                 << exit(FatalError);
96         }
97     }
99     addField(scalarFields_, fieldTypes, fieldNames, dict);
100     addField(vectorFields_, fieldTypes, fieldNames, dict);
104 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
106 Foam::explicitSource::explicitSource
108     const word& name,
109     const dictionary& dict,
110     const fvMesh& mesh
113     basicSource(name, dict, mesh),
114     dict_(dict.subDict(typeName + "Coeffs")),
115     volumeMode_(volumeModeTypeNames_.read(dict_.lookup("volumeMode")))
117     setFieldData(dict_.subDict("fieldData"));
121 void Foam::explicitSource::addSu(fvMatrix<scalar>& Eqn)
123     addSource(Eqn, scalarFields_[Eqn.psi().name()]);
127 void Foam::explicitSource::addSu(fvMatrix<vector>& Eqn)
129     addSource(Eqn, vectorFields_[Eqn.psi().name()]);
133 // ************************************************************************* //