-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaneuveringOutput.C
74 lines (46 loc) · 1.95 KB
/
maneuveringOutput.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "maneuveringOutput.H"
// * * * * * * * * * * * * Base maneuveringOutput * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
maneuveringOutput::maneuveringOutput(const fvMesh &mesh, const dictionary &dict, const uniformDimensionedVectorField& velocityAndyaw)
:
mesh_(mesh),
sensor_(maneuveringInput::create(dict, velocityAndyaw)),
controlMethod_(controlMethod::create(dict)),
timeIndex_(mesh.time().timeIndex())
{}
// * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * *//
scalar maneuveringOutput::output()
{
// Get time data
const scalar deltaT = mesh_.time().deltaTValue();
const scalar t = mesh_.time().timeOutputValue();
if(t < controlMethod_->cStartTime() || t > controlMethod_->cEndTime())
{
return controlMethod_->outputSignal();
}
// Update the old-time quantities
if (timeIndex_ != mesh_.time().timeIndex())
{
timeIndex_ = mesh_.time().timeIndex();
}
sensor_->update();
// Get the target patch average field value
const scalar InputValue = sensor_->input();
const scalar outputSignal = controlMethod_->calculate(InputValue, deltaT);
//Info << "maneuveringOutput: targetValue = " << targetValue_->value(t) << endl;
Info << "maneuveringOutput: currentValue = " << InputValue << endl;
//Info << "maneuveringOutput: error = " << targetValue_->value(t) - sensorValue << endl;
Info << "maneuveringOutput: outputSignal = " << outputSignal << endl;
return outputSignal;
}
void maneuveringOutput::write(Ostream& os, const word dictName) const
{
os.beginBlock(dictName);
//targetValue_->writeData(os);
// os.writeEntry("field", sensor_->fieldName());
controlMethod_->write(os);
//os.beginBlock("sensor");
//sensor_->write(os);
//os.endBlock();
os.endBlock();
}