randomise.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) 2016 OpenFOAM Foundation
9 Copyright (C) 2020-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::functionObjects::randomise
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Adds a random component to an input field,
35 with a specified perturbation magnitude.
36
37 Operands:
38 \table
39 Operand | Type | Location
40 input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
41 output file | - | -
42 output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
43 \endtable
44
45 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
46
47Usage
48 Minimal example by using \c system/controlDict.functions:
49 \verbatim
50 randomise1
51 {
52 // Mandatory entries (unmodifiable)
53 type randomise;
54 libs (fieldFunctionObjects);
55
56 // Mandatory entries (runtime modifiable)
57 magPerturbation 0.1;
58
59 // Mandatory (inherited) entries (runtime modifiable)
60 field <field>;
61
62 // Optional (inherited) entries
63 ...
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Req'd | Dflt
70 type | Type name: randomise | word | yes | -
71 libs | Library name: fieldFunctionObjects | word | yes | -
72 regionType | Selection type: all/cellSet/cellZone | word | no | all
73 magPerturbation | The magnitude of the perturbation | scalar | yes | -
74 field | Name of the operand field | word | yes | -
75 name | Name of cellSet/cellZone if required | word | conditional | -
76 \endtable
77
78 The inherited entries are elaborated in:
79 - \link functionObject.H \endlink
80 - \link fieldExpression.H \endlink
81
82 Minimal example by using the \c postProcess utility:
83 \verbatim
84 postProcess -func "randomise(<field>)"
85 \endverbatim
86
87See also
88 - Foam::functionObject
89 - Foam::functionObjects::fieldExpression
90 - Foam::functionObjects::fvMeshFunctionObject
91 - ExtendedCodeGuide::functionObjects::field::randomise
92
93SourceFiles
94 randomise.C
95
96\*---------------------------------------------------------------------------*/
97
98#ifndef functionObjects_randomise_H
99#define functionObjects_randomise_H
100
101#include "fieldExpression.H"
102#include "volRegion.H"
103
104// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105
106namespace Foam
107{
108namespace functionObjects
109{
110
111/*---------------------------------------------------------------------------*\
112 Class randomise Declaration
113\*---------------------------------------------------------------------------*/
114
115class randomise
116:
117 public fieldExpression,
118 public volRegion
119{
120 // Private Data
121
122 //- The magnitude of the perturbation
123 scalar magPerturbation_;
124
125
126 // Private Member Functions
127
128 //- Calculate randomised field and register result
129 // Defined as file-local template implementation
130 template<class Type>
131 bool calcTemplate();
132
133
134protected:
135
136 // Protected Member Functions
137
138 //- Calculate the randomised field and return true if successful
139 virtual bool calc();
140
141 //- No copy construct
142 randomise(const randomise&) = delete;
143
144 //- No copy assignment
145 void operator=(const randomise&) = delete;
146
147
148public:
149
150
151 //- Runtime type information
152 TypeName("randomise");
153
154
155 // Constructors
156
157 //- Construct from Time and dictionary
159 (
160 const word& name,
161 const Time& runTime,
162 const dictionary& dict
163 );
164
165
166 //- Destructor
167 virtual ~randomise() = default;
168
169
170 // Member Functions
171
172 //- Read the randomise data
173 virtual bool read(const dictionary& dict);
174};
175
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179} // End namespace functionObjects
180} // End namespace Foam
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184#endif
185
186// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Adds a random component to an input field, with a specified perturbation magnitude.
Definition: randomise.H:176
TypeName("randomise")
Runtime type information.
virtual bool calc()
Calculate the randomised field and return true if successful.
Definition: randomise.C:100
virtual bool read(const dictionary &dict)
Read the randomise data.
Definition: randomise.C:135
virtual ~randomise()=default
Destructor.
void operator=(const randomise &)=delete
No copy assignment.
randomise(const randomise &)=delete
No copy construct.
Volume (cell) region selection class.
Definition: volRegion.H:116
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73