ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / explicitSetValue / explicitSetValue.C
blob2a14b793a8de3db75521adcff5d0a1ec05704b6b
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
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 "explicitSetValue.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(explicitSetValue, 0);
37     addToRunTimeSelectionTable
38     (
39         basicSource,
40         explicitSetValue,
41         dictionary
42     );
46 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
48 void Foam::explicitSetValue::setFieldData(const dictionary& dict)
50     scalarFields_.clear();
51     vectorFields_.clear();
53     wordList fieldTypes(dict.toc().size());
54     wordList fieldNames(dict.toc().size());
56     forAll(dict.toc(), i)
57     {
58         const word& fieldName = dict.toc()[i];
59         IOobject io
60         (
61             fieldName,
62             this->mesh().time().timeName(),
63             this->mesh(),
64             IOobject::NO_READ,
65             IOobject::NO_WRITE,
66             false
67         );
68         if (io.headerOk())
69         {
70             fieldTypes[i] = io.headerClassName();
71             fieldNames[i] = dict.toc()[i];
72         }
73         else
74         {
75             FatalErrorIn
76             (
77                 "explicitSetValue::setFieldData"
78             )   << "header not OK " << io.name()
79                 << exit(FatalError);
80         }
81     }
83     addField(scalarFields_, fieldTypes, fieldNames, dict);
84     addField(vectorFields_, fieldTypes, fieldNames, dict);
88 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
90 Foam::explicitSetValue::explicitSetValue
92     const word& name,
93     const word& modelType,
94     const dictionary& dict,
95     const fvMesh& mesh
98     basicSource(name, modelType, dict, mesh),
99     dict_(dict.subDict(modelType + "Coeffs"))
101     setFieldData(dict_.subDict("fieldData"));
105 void Foam::explicitSetValue::setValue(fvMatrix<scalar>& Eqn)
107     setFieldValue(Eqn, scalarFields_[Eqn.psi().name()]);
111 void Foam::explicitSetValue::setValue(fvMatrix<vector>& Eqn)
113     setFieldValue(Eqn, vectorFields_[Eqn.psi().name()]);
117 // ************************************************************************* //