exprDriverFields.C
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) 2019-2021 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
26\*---------------------------------------------------------------------------*/
27
28#include "exprDriver.H"
29#include "FieldOps.H"
30#include "Random.H"
31#include "TimeState.H"
32
33// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34
36(
38 label seed,
39 const bool gaussian
40) const
41{
42 if (seed <= 0)
43 {
44 if (timeStatePtr_)
45 {
46 seed = (timeStatePtr_->timeIndex() - seed);
47 }
48 else
49 {
50 seed = -seed;
51 }
52 }
53
54 if (gaussian)
55 {
58 }
59 else
60 {
63 }
64}
65
66
68(
69 const scalarField& vals,
70 const pointField& locs
71)
72{
73 return FieldOps::findMinData(vals, locs).second();
74}
75
76
78(
79 const scalarField& vals,
80 const pointField& locs
81)
82{
83 return FieldOps::findMaxData(vals, locs).second();
84}
85
86
87// ************************************************************************* //
A generator class returning a gaussian distributed random number.
Definition: Random.H:290
label timeIndex() const noexcept
Return current time index.
Definition: TimeStateI.H:37
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.
const TimeState * timeStatePtr_
Reference to the time-state.
Definition: exprDriver.H:214
rDeltaTY field()
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
Definition: FieldOps.C:36
Tuple2< T1, T2 > findMaxData(const Field< T1 > &vals, const Field< T2 > &data)
Locate the max value in a field and return it and associated data.
Tuple2< T1, T2 > findMinData(const Field< T1 > &vals, const Field< T2 > &data)
Locate the min value in a field and return it and associated data.