BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / cfdTools / general / fieldSources / basicSource / explicitSource / explicitSourceTemplates.C
blobdb963363e5d60f6f89f237949fb9ca1545038f65
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::explicitSource::addSource
29     fvMatrix<Type>& Eqn,
30     const Type& sourceData
31 ) const
33     Type data = sourceData;
34     if (volumeMode_ == vmAbsolute)
35     {
36         // Convert to specific quantity
37         data /= V_;
38     }
40     DimensionedField<Type, volMesh> rhs
41     (
42         IOobject
43         (
44             "rhs",
45             Eqn.psi().mesh().time().timeName(),
46             Eqn.psi().mesh(),
47             IOobject::NO_READ,
48             IOobject::NO_WRITE,
49             false
50         ),
51         Eqn.psi().mesh(),
52         dimensioned<Type>
53         (
54             "zero",
55             Eqn.dimensions()/dimVolume,
56             pTraits<Type>::zero
57         )
58     );
59     UIndirectList<Type>(rhs, this->cells()) = data;    
61     Eqn -= rhs;
65 template <class Type>
66 void Foam::explicitSource::addField
68     HashTable<Type>& fields,
69     const wordList& fieldTypes,
70     const wordList& fieldNames,
71     const dictionary& fieldDataDict
74     typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
76     forAll (fieldTypes, fieldI)
77     {
78         word fieldName = fieldNames[fieldI];
79         word fieldType = fieldTypes[fieldI];
81         if
82         (
83             (
84                 fieldType
85              == GeometricField<Type, fvPatchField, volMesh>::typeName
86             ) &&
87             (
88                 this->mesh().foundObject<geometricField>(fieldName)
89             )
90         )
91         {
92             Type fieldValue = fieldDataDict.lookupOrDefault<Type>
93             (
94                 fieldName,
95                 pTraits<Type>::zero
96             );
98             fields.insert(fieldName, fieldValue);
99         }
100     }
104 // ************************************************************************* //