DAFoam
v3.0.6
Discrete Adjoint with OpenFOAM
dafoam
src
adjoint
DAOption
DAOption.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
3
DAFoam : Discrete Adjoint with OpenFOAM
4
Version : v3
5
6
\*---------------------------------------------------------------------------*/
7
8
#include "
DAOption.H
"
9
10
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11
12
namespace
Foam
13
{
14
15
// Constructors
16
DAOption::DAOption(
17
const
fvMesh&
mesh
,
18
PyObject* pyOptions)
19
: regIOobject(
20
IOobject(
21
"DAOption"
,
// always use DAOption for the db name
22
mesh
.time().timeName(),
23
mesh
,
// register to mesh
24
IOobject::NO_READ,
25
IOobject::NO_WRITE,
26
true
// always register object
27
)),
28
mesh_(
mesh
)
29
{
30
/*
31
Description:
32
Construct from fvMesh and a dict object from Python
33
Input:
34
mesh: Foam::fvMesh object
35
pyOptions: dictionary from Python, which contains all
36
options for DAFoam
37
*/
38
39
// now we need to convert the pyOptions<PyObject*> to allOptions_<dictionary> in OpenFOAM
40
DAUtility::pyDict2OFDict
(pyOptions, allOptions_);
41
42
//Info << "All DAFoam Options:";
43
//Info << this->getAllOptions() << endl;
44
}
45
46
DAOption::~DAOption
()
47
{
48
}
49
50
void
DAOption::updateDAOption
(PyObject* pyOptions)
51
{
52
/*
53
Description:
54
Update the allOptions_ dict in DAOption based on the pyOptions from pyDAFoam
55
Input:
56
pyOptions: A Python dictionary from pyDAFoam
57
Output:
58
allOptions_: the OpenFOAM dictionary used in DAOption
59
*/
60
61
// assign allOptions_ based on pyOptions
62
DAUtility::pyDict2OFDict
(pyOptions, allOptions_);
63
}
64
65
// this is a virtual function for regIOobject
66
bool
DAOption::writeData
(Ostream& os)
const
67
{
68
allOptions_.write(os);
69
return
true
;
70
}
71
72
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73
74
}
// End namespace Foam
75
76
// ************************************************************************* //
DAOption.H
Foam::DAOption::~DAOption
virtual ~DAOption()
Destructor.
Definition:
DAOption.C:46
Foam::DAOption::updateDAOption
void updateDAOption(PyObject *pyOptions)
update the allOptions_ dict in DAOption based on the pyOptions from pyDAFoam
Definition:
DAOption.C:50
mesh
fvMesh & mesh
Definition:
createRefsHeatTransfer.H:4
Foam::DAUtility::pyDict2OFDict
static void pyDict2OFDict(PyObject *pyDict, dictionary &ofDict)
convert a python dictionary object to OpenFoam dictionary
Definition:
DAUtility.C:24
Foam
Definition:
multiFreqScalarFvPatchField.C:144
Foam::DAOption::writeData
bool writeData(Ostream &os) const
this is a virtual function for regIOobject
Definition:
DAOption.C:66
Generated by
1.8.17