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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::randomise
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
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 
47 Usage
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  magPerturbation | The magnitude of the perturbation | scalar | yes | -
73  field | Name of the operand field | word | yes | -
74  \endtable
75 
76  The inherited entries are elaborated in:
77  - \link functionObject.H \endlink
78  - \link fieldExpression.H \endlink
79 
80  Minimal example by using the \c postProcess utility:
81  \verbatim
82  postProcess -func "randomise(<field>)"
83  \endverbatim
84 
85 See also
86  - Foam::functionObject
87  - Foam::functionObjects::fieldExpression
88  - Foam::functionObjects::fvMeshFunctionObject
89  - ExtendedCodeGuide::functionObjects::field::randomise
90 
91 SourceFiles
92  randomise.C
93  randomiseTemplates.C
94 
95 \*---------------------------------------------------------------------------*/
96 
97 #ifndef functionObjects_randomise_H
98 #define functionObjects_randomise_H
99 
100 #include "fieldExpression.H"
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 namespace Foam
105 {
106 namespace functionObjects
107 {
108 
109 /*---------------------------------------------------------------------------*\
110  Class randomise Declaration
111 \*---------------------------------------------------------------------------*/
112 
113 class randomise
114 :
115  public fieldExpression
116 {
117  // Private Data
118 
119  //- The magnitude of the perturbation
120  scalar magPerturbation_;
121 
122 
123  // Private Member Functions
124 
125  //- Calculate the randomised field and register the result
126  template<class Type>
127  bool calcRandomised();
128 
129  //- Calculate the randomised field and return true if successful
130  virtual bool calc();
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("randomise");
137 
138 
139  // Constructors
140 
141  //- Construct from Time and dictionary
142  randomise
143  (
144  const word& name,
145  const Time& runTime,
146  const dictionary& dict
147  );
148 
149  //- No copy construct
150  randomise(const randomise&) = delete;
151 
152  //- No copy assignment
153  void operator=(const randomise&) = delete;
154 
155 
156  //- Destructor
157  virtual ~randomise() = default;
158 
159 
160  // Member Functions
161 
162  //- Read the randomise data
163  virtual bool read(const dictionary&);
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace functionObjects
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #ifdef NoRepository
175  #include "randomiseTemplates.C"
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::randomise::~randomise
virtual ~randomise()=default
Destructor.
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::randomise::operator=
void operator=(const randomise &)=delete
No copy assignment.
Foam::functionObjects::randomise::randomise
randomise(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: randomise.C:63
Foam::functionObjects::randomise::read
virtual bool read(const dictionary &)
Read the randomise data.
Definition: randomise.C:77
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
randomiseTemplates.C
Foam::functionObjects::randomise::TypeName
TypeName("randomise")
Runtime type information.
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:103
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
fieldExpression.H
Foam::functionObjects::randomise
Adds a random component to an input field, with a specified perturbation magnitude.
Definition: randomise.H:158