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-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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  const TimeState* ts = this->timeState();
45 
46  if (ts)
47  {
48  seed = (ts->timeIndex() - seed);
49  }
50  else
51  {
52  seed = -seed;
53  }
54  }
55 
56  if (gaussian)
57  {
60  }
61  else
62  {
65  }
66 }
67 
68 
70 (
71  const scalarField& vals,
72  const pointField& locs
73 )
74 {
75  return FieldOps::findMinData(vals, locs).second();
76 }
77 
78 
80 (
81  const scalarField& vals,
82  const pointField& locs
83 )
84 {
85  return FieldOps::findMaxData(vals, locs).second();
86 }
87 
88 
89 // ************************************************************************* //
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
rDeltaTY field()
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:47
A generator class returning a uniformly distributed random number on the given interval.
Definition: Random.H:96
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
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.
const TimeState * timeState() const noexcept
Reference to the current time-state (can be nullptr)
Definition: exprDriver.C:247
label timeIndex() const noexcept
Return the current time index.
Definition: TimeStateI.H:43
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.
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:28
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A generator class returning a gaussian distributed random number.
Definition: Random.H:97
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.