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/>.
25 Foam::equationOperation
28 Defines a single operation to be performed in sequence while evaluating an
29 equation read from a dictionary.
38 \*---------------------------------------------------------------------------*/
40 #ifndef equationOperation_H
41 #define equationOperation_H
45 #include "IOstreams.H"
46 #include "dimensionedScalar.H"
47 // #include "Istream.H"
48 // #include "Ostream.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declaration of friend functions and operators
57 class equationOperation;
62 int operator==(const equationOperation&, const equationOperation&);
63 int operator!=(const equationOperation&, const equationOperation&);
65 // Friend IOstream Operators
67 Istream& operator>>(Istream&, equationOperation&);
68 Ostream& operator<<(Ostream&, const equationOperation&);
72 /*---------------------------------------------------------------------------*\
73 Class equationOperation Declaration
74 \*---------------------------------------------------------------------------*/
76 class equationOperation
96 stdiagTensorFieldSource,
98 stsymmTensorFieldSource,
99 stsphericalTensorSource,
100 stsphericalTensorFieldSource
161 // Source to read the data from
162 sourceTypeEnum source_;
164 // Index in the field where the data is located. Note, the
165 // equationOperation lists created by equationReader make this variable a
166 // 1-indexed (i.e. starts from 1, not zero) in order to use its sign to
167 // store the sign of the variable. The sourceTypes are zero-indexed, so
168 // equationReader will constantly be adding / subtracting 1 to get these
172 // Component index - for Types with multiple components
173 label componentIndex_;
175 // Rather than store the keywords that have to be searched in a dictionary,
176 // equationReader keeps its own list of keywords, and the dictLookupIndex
177 // is the index in this list. This is only applicable if the sourceType is
178 // of type sldictSource
179 label dictLookupIndex_;
181 // The operation to be performed (+ - sin exp min, etc...)
182 operationType operation_;
184 // A pointer to the scalarField source data retrieval function
185 mutable const scalarField&
186 (Foam::equationReader::*getSourceScalarFieldFunction_)
188 const equationReader * eqnReader,
189 const label equationIndex,
190 const label equationOperationIndex,
191 const label maxStoreIndex,
192 const label storageOffset
195 // A pointer to the scalarField operation to be performed
196 mutable void (Foam::equationReader::*opScalarFieldFunction_)
198 const equationReader * eqnReader,
201 const label storageOffset,
204 const scalarField& source
207 // A pointer to the scalar source data retrieval function
208 mutable scalar (Foam::equationReader::*getSourceScalarFunction_)
210 const equationReader * eqnReader,
211 const label equationIndex,
212 const label equationOperationIndex,
213 const label maxStoreIndex,
214 const label storageOffset
217 // A pointer to the scalar operation to be performed
218 mutable void (Foam::equationReader::*opScalarFunction_)
220 const equationReader * eqnReader,
223 const label storageOffset,
229 // A pointer to the dimensions source data retrieval function
230 mutable dimensionSet (Foam::equationReader::*getSourceDimsFunction_)
232 const equationReader * eqnReader,
233 const label equationIndex,
234 const label equationOperationIndex,
235 const label maxStoreIndex,
236 const label storageOffset
239 // A pointer to the dimension operation to be performed
240 mutable void (Foam::equationReader::*opDimsFunction_)
242 const equationReader * eqnReader,
245 const label storageOffset,
248 dimensionSet sourceDims
254 // Static data members
256 static const char* const typeName;
264 equationOperation(const equationOperation& eqop);
266 //- Construct from components
269 sourceTypeEnum source,
271 label componentIndex,
272 label dictLookupIndex,
273 operationType operation,
275 (Foam::equationReader::*getSourceScalarFieldFunction_)
277 const equationReader *,
283 void (Foam::equationReader::*opScalarFieldFunction_)
285 const equationReader *,
293 scalar (Foam::equationReader::*getSourceScalarFunction)
295 const equationReader *,
301 void (Foam::equationReader::*opScalarFunction)
303 const equationReader *,
311 dimensionSet (Foam::equationReader::*getSourceDimsFunction)
313 const equationReader *,
319 void (Foam::equationReader::*opDimsFunction)
321 const equationReader *,
333 ~equationOperation();
339 //- Const access to source
340 inline const sourceTypeEnum& sourceType() const;
343 inline sourceTypeEnum& sourceType();
345 //- Const access to source index
346 inline const label& sourceIndex() const;
348 //- Access to source index
349 inline label& sourceIndex();
351 //- Const access to componentIndex
352 inline const label& componentIndex() const;
354 //- Access to componentIndex
355 inline label& componentIndex();
357 //- Const access to dictionary lookup name index
358 inline const label& dictLookupIndex() const;
360 //- Access to dictionary lookup name index
361 inline label& dictLookupIndex();
363 //- Const access to operation
364 inline const operationType& operation() const;
366 //- Access to operation
367 inline operationType& operation();
371 //- Assign the source scalarField function
372 void assignSourceScalarFieldFunction
375 (Foam::equationReader::*getSourceScalarFieldFunction)
377 const equationReader *,
385 //- Assign the operation scalarField function
386 void assignOpScalarFieldFunction
388 void (Foam::equationReader::*opScalarFieldFunction)
390 const equationReader *,
400 //- Assign the source scalar function
401 void assignSourceScalarFunction
403 scalar (Foam::equationReader::*getSourceScalarFunction)
405 const equationReader *,
413 //- Assign the operation scalar function
414 void assignOpScalarFunction
416 void (Foam::equationReader::*opScalarFunction)
418 const equationReader *,
428 //- Assign the source dimensions function
429 void assignSourceDimsFunction
431 dimensionSet (Foam::equationReader::*getSourceDimsFunction)
433 const equationReader *,
441 //- Assign the operation dimensions function
442 void assignOpDimsFunction
444 void (Foam::equationReader::*opDimsFunction)
446 const equationReader *,
456 //- Call the getSourceScalarField function
457 const scalarField& getSourceScalarFieldFunction
459 const equationReader * eqnReader,
460 const label equationIndex,
461 const label equationOperationIndex,
462 const label maxStoreIndex,
463 const label storageOffset
466 //- Call the operation scalarField function
467 void opScalarFieldFunction
469 const equationReader * eqnReader,
472 const label storageOffset,
475 const scalarField& source
478 //- Call the getSourceScalar function
479 scalar getSourceScalarFunction
481 const equationReader * eqnReader,
482 const label equationIndex,
483 const label equationOperationIndex,
484 const label maxStoreIndex,
485 const label storageOffset
488 //- Call the operation scalar function
489 void opScalarFunction
491 const equationReader * eqnReader,
494 const label storageOffset,
500 //- Call the getSourceDims function
501 dimensionSet getSourceDimsFunction
503 const equationReader * eqnReader,
504 const label equationIndex,
505 const label equationOperationIndex,
506 const label maxStoreIndex,
507 const label storageOffset
512 const equationReader * eqnReader,
515 const label storageOffset,
518 dimensionSet sourceDims
523 //- Look up operation number, given a word
524 static operationType findOp(const word& opName);
526 //- Look up operation name
527 static word opName(const operationType& op);
529 //- Look up sourceType name
530 static word sourceName(const sourceTypeEnum& st);
534 void operator=(equationOperation&);
537 // Friend IOstream Operators
539 friend Istream& operator>>(Istream&, equationOperation&);
540 friend Ostream& operator<<(Ostream&, const equationOperation&);
545 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
547 } // End namespace Foam
549 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
551 #include "equationOperationI.H"
553 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
557 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //