randomise.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::randomise
26 
27 Description
28  Adds a random component to a field, with a specified perturbation magnitude.
29 
30  The operation can be applied to any volume field.
31 
32 See also
33  Foam::functionObjects::fvMeshFunctionObject
34 
35 SourceFiles
36  randomise.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_randomise_H
41 #define functionObjects_randomise_H
42 
43 #include "fieldExpression.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace functionObjects
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class randomise Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class randomise
57 :
58  public fieldExpression
59 {
60  // Private member data
61 
62  //- The magnitude of the perturbation
63  scalar magPerturbation_;
64 
65 
66  // Private Member Functions
67 
68  //- Add random component to the field and register the result
69  template<class Type>
70  bool calcRandomised();
71 
72  //- Calculate the randomised field and return true if successful
73  virtual bool calc();
74 
75 
76 public:
77 
78  //- Runtime type information
79  TypeName("randomise");
80 
81 
82  // Constructors
83 
84  //- Construct from Time and dictionary
85  randomise
86  (
87  const word& name,
88  const Time& runTime,
89  const dictionary& dict
90  );
91 
92 
93  //- Destructor
94  virtual ~randomise();
95 
96 
97  // Member Functions
98 
99  //- Read the randomise data
100  virtual bool read(const dictionary&);
101 };
102 
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace functionObjects
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #ifdef NoRepository
112  #include "randomiseTemplates.C"
113 #endif
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 #endif
118 
119 // ************************************************************************* //
dictionary dict
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
TypeName("randomise")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the randomise data.
Definition: randomise.C:83
randomise(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: randomise.C:63
virtual ~randomise()
Destructor.
Definition: randomise.C:77
Adds a random component to a field, with a specified perturbation magnitude.
Definition: randomise.H:55
Namespace for OpenFOAM.