1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 A set of data sources for the equationReader templated by Type.
33 equationSourceTemplates.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef equationSource_H
41 #define equationSource_H
47 #include "GeometricFields.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Class equationSource Declaration
57 \*---------------------------------------------------------------------------*/
65 //- Name of templated type
66 word templateTypeName_;
68 //- Individual "Type"s as sources
69 UPtrList<const Type> singles_;
71 //- Names associated with singles_
72 wordList singleNames_;
74 //- Dimensions associated with singles_
75 PtrList<dimensionSet> singleDimensions_;
77 //- Fields of Type - holds the source data for regular
78 // Field<Type>'s, but also can hold source data for GeometricFields
79 // fields_[sourceIndex][geoIndex][cellIndex]
81 // sourceIndex is the source variable index
82 // geoIndex is to accommodate GeometricFields:
83 // 0 = internalField (or standard Field<Type>)
84 // 1+ = boundary patch as a Field<Type>
85 // cellIndex is the index number of the Field<Type>
86 PtrList<UPtrList<const Field<Type> > > fields_;
88 //- Dimensions associated with the fields_
89 PtrList<dimensionSet> fieldDimensions_;
91 //- Names associated with the fields_
96 // Static data members
98 static const char* const typeName;
103 //- Construct from components
104 explicit equationSource
106 const word& templateTypeName
116 //- Individual "Type"s as sources
117 inline const UPtrList<const Type>& singles() const;
119 //- Names associated with singles
120 inline const wordList& singleNames() const;
122 //- Dimensions associated with singles_
123 inline const PtrList<dimensionSet>& singleDimensions() const;
125 //- Fields of Type - holds the source data for regular
126 inline const PtrList<UPtrList<const Field<Type> > >&
129 //- Dimensions associated with the fields_
130 inline const PtrList<dimensionSet>& fieldDimensions() const;
132 //- Names associated with the fields_
133 inline const wordList& fieldNames() const;
137 //- True if lookupName is a valid single source
138 bool foundSingle(const word& lookupName) const;
140 //- True if lookupName is a valid field source
141 bool foundField(const word& lookupName) const;
143 //- Returns single sourceIndex for lookupName - fails if not found
144 label lookupSingle(const word& lookupName) const;
146 //- Returns field sourceIndex for lookupName - fails if not found
147 label lookupField(const word& lookupName) const;
149 //- Returns the number of fields associated with sourceIndex
150 label geoSize(label sourceIndex) const;
152 //- Returns the field size associated with source and geo indices
159 //- Return componentIndex for a given component name
160 // Returns -1 if not found (error handled by calling function)
161 label lookupComponentIndex(const word& componentName) const;
163 //- Returns the number of singles_
164 label nSingles() const;
166 //- Returns the number of fields_
167 label nFields() const;
171 //- Retrieve scalar value from singles
172 const scalar& singleValue
178 //- Retrieve dimensions from singles
179 const dimensionSet& singleDimensions(label sourceIndex) const;
181 //- Retrieve name associated with singles
182 const word& singleName(label sourceIndex) const;
184 //- Retrieve scalar value from field
185 const scalar& fieldValue
188 label componentIndex,
193 //- Retrieve component as entire field
198 label componentIndex,
202 //- Retrieve dimensions from field
203 const dimensionSet& fieldDimensions(label sourceIndex) const;
205 //- Retrieve name associated with field
206 const word& fieldName(label sourceIndex) const;
208 // Adding data sources
210 //- Add single source
213 const Type& singleIn,
215 dimensionSet dimensions = dimless
218 //- Add dimensionedSingle source
221 const dimensioned<Type>& dSingleIn
227 const Field<Type>& fieldIn,
229 dimensionSet dimensions = dimless
232 //- Add dimensioned field source
233 template<class GeoMesh>
236 const DimensionedField<Type, GeoMesh>& dFieldIn
239 //- Add geometric field source
240 template<template<class> class PatchField, class GeoMesh>
243 const GeometricField<Type, PatchField, GeoMesh>& gFieldIn
246 // Removing data sources
248 //- Remove a single source and reorder index
249 void removeSingle(label sourceIndex);
251 //- Remove a field source and reorderd index
252 void removeField(label sourceIndex);
256 //- Output sources to a dictionary
257 dictionary outputDictionary() const;
261 label equationSource<scalar>::lookupComponentIndex
263 const word& componentName
267 const scalar& equationSource<scalar>::singleValue
274 const scalar& equationSource<scalar>::fieldValue
277 label componentIndex,
283 void equationSource<scalar>::fullFieldValue
287 label componentIndex,
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 } // End namespace Foam
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 #include "equationSourceI.H"
300 # include "equationSource.C"
301 //# include "equationScalarSource.C"
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //