DAFoam
v4.0.2
Discrete Adjoint with OpenFOAM
dafoam
src
adjoint
DATimeOp
DATimeOpAverage.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
3
DAFoam : Discrete Adjoint with OpenFOAM
4
Version : v4
5
6
\*---------------------------------------------------------------------------*/
7
8
#include "
DATimeOpAverage.H
"
9
10
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11
12
namespace
Foam
13
{
14
15
defineTypeNameAndDebug
(DATimeOpAverage, 0);
16
addToRunTimeSelectionTable
(DATimeOp, DATimeOpAverage, dictionary);
17
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
18
19
DATimeOpAverage::DATimeOpAverage
(
20
const
word timeOpType,
21
const
dictionary options)
22
:
DATimeOp
(timeOpType, options)
23
{
24
}
25
26
scalar
DATimeOpAverage::compute
(
27
const
scalarList& valList,
28
const
label iStart,
29
const
label iEnd)
30
{
31
// return the average value from valList
32
scalar avg = 0.0;
33
// NOTE. We need to use <= here
34
for
(label i = iStart; i <= iEnd; i++)
35
{
36
avg += valList[i];
37
}
38
avg /= (iEnd - iStart + 1);
39
return
avg;
40
}
41
42
scalar
DATimeOpAverage::dFScaling
(
43
const
scalarList& valList,
44
const
label iStart,
45
const
label iEnd,
46
const
label timeIdx)
47
{
48
// return 1/N as the dF scaling
49
50
scalar scaling = 1.0 / (iEnd - iStart + 1);
51
52
return
scaling;
53
}
54
55
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57
}
// End namespace Foam
58
59
// ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(DAFunction, DAFunctionForce, dictionary)
Foam::DATimeOp
Definition:
DATimeOp.H:27
DATimeOpAverage.H
Foam::DATimeOpAverage::dFScaling
virtual scalar dFScaling(const scalarList &valList, const label iStart, const label iEnd, const label timeIdx)
compute the scaling factor for dF/d? calculation.
Definition:
DATimeOpAverage.C:42
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFunction, 0)
Foam
Definition:
checkGeometry.C:32
Foam::DATimeOpAverage::compute
virtual scalar compute(const scalarList &valList, const label iStart, const label iEnd)
compute the timeOp value based on valList
Definition:
DATimeOpAverage.C:26
Foam::DATimeOpAverage::DATimeOpAverage
DATimeOpAverage(const word timeOpType, const dictionary options)
Definition:
DATimeOpAverage.C:19
Generated by
1.8.17