Loading...
Searching...
No Matches
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, with a specified perturbation
35 magnitude.
36
37 Operands:
38 \table
39 Operand | Type | Location
40 input | vol<Type>Field | <time>/inputField
41 output file | - | -
42 output field | vol<Type>Field | <time>/outputField
43 \endtable
44
45 where \c Type can be one of:
46 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
47
48Usage
49 Minimal example by using \c system/controlDict.functions:
50 \verbatim
51 randomiseFO
52 {
53 // Mandatory entries
54 type randomise;
55 libs (fieldFunctionObjects);
56 magPerturbation <scalar>;
57 field <word>;
58
59 // Inherited entries
60 ...
61 }
62 \endverbatim
63
64 where the entries mean:
65 \table
66 Property | Description | Type | Reqd | Deflt
67 type | Type name: randomise | word | yes | -
68 libs | Library name: fieldFunctionObjects | word | yes | -
69 magPerturbation | The magnitude of the perturbation | scalar | yes | -
70 field | Name of the operand field | word | yes | -
71 \endtable
72
73 The inherited entries are elaborated in:
74 - \link fieldExpression.H \endlink
75
76SourceFiles
77 randomise.C
78
79\*---------------------------------------------------------------------------*/
80
81#ifndef Foam_functionObjects_randomise_H
82#define Foam_functionObjects_randomise_H
83
84#include "fieldExpression.H"
85#include "volRegion.H"
86
87// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88
89namespace Foam
90{
91namespace functionObjects
92{
93
94/*---------------------------------------------------------------------------*\
95 Class randomise Declaration
96\*---------------------------------------------------------------------------*/
97
98class randomise
99:
100 public fieldExpression,
101 public volRegion
102{
103 // Private Data
104
105 //- The magnitude of the perturbation
106 scalar magPerturbation_;
107
108
109 // Private Member Functions
110
111 //- Calculate randomised field and register result
112 // Defined as file-local template implementation
113 template<class Type>
114 bool calcTemplate();
115
116
117protected:
118
119 // Protected Member Functions
120
121 //- Calculate the randomised field and return true if successful
122 virtual bool calc();
123
124 //- No copy construct
125 randomise(const randomise&) = delete;
126
127 //- No copy assignment
128 void operator=(const randomise&) = delete;
129
130
131public:
132
133
134 //- Runtime type information
135 TypeName("randomise");
136
137
138 // Constructors
140 //- Construct from name, Time and dictionary
142 (
143 const word& name,
144 const Time& runTime,
145 const dictionary& dict
146 );
147
148
149 //- Destructor
150 virtual ~randomise() = default;
151
152
153 // Member Functions
154
155 //- Read the function-object dictionary
156 virtual bool read(const dictionary& dict);
157};
158
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162} // End namespace functionObjects
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#endif
168
169// ************************************************************************* //
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. blendingFactor etc....
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
Adds a random component to an input field, with a specified perturbation magnitude.
Definition randomise.H:143
TypeName("randomise")
Runtime type information.
virtual bool calc()
Calculate the randomised field and return true if successful.
Definition randomise.C:93
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition randomise.C:128
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:112
volRegion(const fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
Definition volRegion.C:143
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