ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / explicitSetValue / explicitSetValueTemplates.C
blobf67c3183436edcb72c1c5171f3fe0fb86a93800a
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 template <class Type>
27 void Foam::explicitSetValue::setFieldValue
29     fvMatrix<Type>& Eqn,
30     const Type& value
31 ) const
33     Type data = value;
35     DimensionedField<Type, volMesh> rhs
36     (
37         IOobject
38         (
39             "rhs",
40             Eqn.psi().mesh().time().timeName(),
41             Eqn.psi().mesh(),
42             IOobject::NO_READ,
43             IOobject::NO_WRITE,
44             false
45         ),
46         Eqn.psi().mesh(),
47         dimensioned<Type>
48         (
49             "zero",
50             dimless,
51             pTraits<Type>::zero
52         )
53     );
55     List<Type> values(this->cells().size());
57     forAll (values, i)
58     {
59         values[i] = data;
60     }
62     Eqn.setValues(this->cells(), values);
66 template <class Type>
67 void Foam::explicitSetValue::addField
69     HashTable<Type>& fields,
70     const wordList& fieldTypes,
71     const wordList& fieldNames,
72     const dictionary& fieldDataDict
75     typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
77     forAll (fieldTypes, fieldI)
78     {
79         word fieldName = fieldNames[fieldI];
80         word fieldType = fieldTypes[fieldI];
82         if
83         (
84             (
85                 fieldType
86              == GeometricField<Type, fvPatchField, volMesh>::typeName
87             ) &&
88             (
89                 this->mesh().foundObject<geometricField>(fieldName)
90             )
91         )
92         {
93             Type fieldValue = fieldDataDict.lookupOrDefault<Type>
94             (
95                 fieldName,
96                 pTraits<Type>::zero
97             );
99             fields.insert(fieldName, fieldValue);
100         }
101     }
105 // ************************************************************************* //