Loading...
Searching...
No Matches
multiply.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2020-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::multiply
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Multiplies a given list of (at least two or more) fields and outputs the
34 result into a new field.
35
36 \verbatim
37 fieldResult = field1 * field2 * ... * fieldN
38 \endverbatim
39
40 Operands:
41 \table
42 Operand | Type | Location
43 input field | vol<Type>Field(s) | <time>/inputFields
44 output file | - | -
45 output field | vol<Type>Field | <time>/outputField
46 \endtable
47
48 where \c Type can be one of:
49 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
50
51Usage
52 Minimal example by using \c system/controlDict.functions:
53 \verbatim
54 multiplyFO
55 {
56 // Mandatory entries
57 type multiply;
58 libs (fieldFunctionObjects);
59
60 // Inherited entries
61 fields (<wordList>); // (<field1> <field2> ... <fieldN>);
62 ...
63 }
64 \endverbatim
65
66 where the entries mean:
67 \table
68 Property | Description | Type | Reqd | Deflt
69 type | Type name: multiply | word | yes | -
70 libs | Library name: fieldFunctionObjects | word | yes | -
71 fields | Names of the operand fields | wordList | yes | -
72 \endtable
73
74 The inherited entries are elaborated in:
75 - \link fieldsExpression.H \endlink
76
77SourceFiles
78 multiply.C
79 multiplyTemplates.C
80
81\*---------------------------------------------------------------------------*/
82
83#ifndef Foam_functionObjects_multiply_H
84#define Foam_functionObjects_multiply_H
85
86#include "fieldsExpression.H"
87
88// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89
90namespace Foam
91{
92namespace functionObjects
93{
94
95/*---------------------------------------------------------------------------*\
96 Class multiply Declaration
97\*---------------------------------------------------------------------------*/
98
99class multiply
100:
101 public fieldsExpression
102{
103 //- Helper struct to define valid operations
104 template<class Type1, class Type2>
105 struct is_valid_op
106 {
107 static constexpr bool value =
108 (pTraits<Type1>::rank == 0 || pTraits<Type2>::rank == 0)
109 || (pTraits<Type1>::rank == 1 && pTraits<Type2>::rank == 1);
110 };
111
112
113 // Private Member Functions
114
115 //- Initialise the result field
116 template<class Type>
117 bool initialiseResult(const word& fieldName);
118
119 //- Multiply the result field with the given field
120 template<class Type>
121 bool multiplyResult(const word& fieldName, bool& processed);
122
123 //- Multiply two fields of given types and return true if successful
124 template<class Type1, class Type2>
125 bool multiplyFieldType
126 (
127 GeometricField<Type1, fvPatchField, volMesh>& result,
128 const word& fieldName,
129 bool& processed
130 );
131
132 //- Multiply the list of fields and return true if successful
133 virtual bool calc();
135
136public:
137
138 //- Grant fieldsExpression access to private and protected members
139 friend class fieldsExpression;
140
141
142 //- Runtime type information
143 TypeName("multiply");
144
145
146 // Constructors
147
148 //- Construct from name, Time and dictionary
150 (
151 const word& name,
152 const Time& runTime,
153 const dictionary& dict
154 );
155
156 //- No copy construct
157 multiply(const multiply&) = delete;
158
159 //- No copy assignment
160 void operator=(const multiply&) = delete;
161
162
163 //- Destructor
164 virtual ~multiply() = default;
165};
166
167
168// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169
170} // End namespace functionObjects
171} // End namespace Foam
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175#ifdef NoRepository
176 #include "multiplyTemplates.C"
177#endif
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181#endif
182
183// ************************************************************************* //
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Intermediate class for handling field expression function objects (e.g. add, subtract etc....
virtual bool calc()=0
Calculate expression.
Multiplies a given list of (at least two or more) fields and outputs the result into a new field.
Definition multiply.H:137
void operator=(const multiply &)=delete
No copy assignment.
friend class fieldsExpression
Grant fieldsExpression access to private and protected members.
Definition multiply.H:186
TypeName("multiply")
Runtime type information.
multiply(const multiply &)=delete
No copy construct.
virtual ~multiply()=default
Destructor.
multiply(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition multiply.C:38
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68