@@ -25,6 +25,7 @@ DAFvSourceActuatorLine::DAFvSourceActuatorLine(
25
25
: DAFvSource (modelType , mesh , daOption , daModel , daIndex )
26
26
{
27
27
printIntervalUnsteady_ = daOption .getOption < label > ("printIntervalUnsteady" );
28
+ this -> initFvSourcePars ();
28
29
}
29
30
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30
31
@@ -50,6 +51,10 @@ void DAFvSourceActuatorLine::calcFvSource(volVectorField& fvSource)
50
51
51
52
dictionary fvSourceSubDict = daOption_ .getAllOptions ().subDict ("fvSource" );
52
53
54
+ DAGlobalVar & globalVar =
55
+ const_cast < DAGlobalVar & > (mesh_ .thisDb ().lookupObject < DAGlobalVar > ("DAGlobalVar" ));
56
+ HashTable < List < scalar >>& actuatorLinePars = globalVar .actuatorLinePars ;
57
+
53
58
// loop over all the cell indices for all actuator lines
54
59
forAll (fvSourceSubDict .toc (), idxI )
55
60
{
@@ -58,21 +63,22 @@ void DAFvSourceActuatorLine::calcFvSource(volVectorField& fvSource)
58
63
59
64
// sub dictionary with all parameters for this disk
60
65
dictionary lineSubDict = fvSourceSubDict .subDict (lineName );
61
-
62
- // now read in all parameters for this actuator line
63
66
// center of the actuator line
64
- scalarList center1 ;
65
- lineSubDict .readEntry < scalarList > ("center" , center1 );
66
- vector center = {center1 [0 ], center1 [1 ], center1 [2 ]};
67
+ vector center = {
68
+ actuatorLinePars [lineName ][0 ],
69
+ actuatorLinePars [lineName ][1 ],
70
+ actuatorLinePars [lineName ][2 ]};
67
71
// thrust direction
68
- scalarList direction1 ;
69
- lineSubDict .readEntry < scalarList > ("direction" , direction1 );
70
- vector direction = {direction1 [0 ], direction1 [1 ], direction1 [2 ]};
72
+ vector direction = {
73
+ actuatorLinePars [lineName ][3 ],
74
+ actuatorLinePars [lineName ][4 ],
75
+ actuatorLinePars [lineName ][5 ]};
71
76
direction = direction / mag (direction );
72
77
// initial vector for the actuator line
73
- scalarList initial1 ;
74
- lineSubDict .readEntry < scalarList > ("initial" , initial1 );
75
- vector initial = {initial1 [0 ], initial1 [1 ], initial1 [2 ]};
78
+ vector initial = {
79
+ actuatorLinePars [lineName ][6 ],
80
+ actuatorLinePars [lineName ][7 ],
81
+ actuatorLinePars [lineName ][8 ]};
76
82
initial = initial / mag (initial );
77
83
if (fabs (direction & initial ) > 1.0e-10 )
78
84
{
@@ -81,22 +87,22 @@ void DAFvSourceActuatorLine::calcFvSource(volVectorField& fvSource)
81
87
// rotation direction, can be either right or left
82
88
word rotDir = lineSubDict .getWord ("rotDir" );
83
89
// inner and outer radius of the lines
84
- scalar innerRadius = lineSubDict . get < scalar > ( "innerRadius" ) ;
85
- scalar outerRadius = lineSubDict . get < scalar > ( "outerRadius" ) ;
90
+ scalar innerRadius = actuatorLinePars [ lineName ][ 9 ] ;
91
+ scalar outerRadius = actuatorLinePars [ lineName ][ 10 ] ;
86
92
// rotation speed in rpm
87
- scalar rpm = lineSubDict . get < scalar > ( "rpm" ) ;
93
+ scalar rpm = actuatorLinePars [ lineName ][ 15 ] ;
88
94
scalar radPerS = rpm / 60.0 * 2.0 * pi ;
89
95
// smooth factor which should be of grid size
90
- scalar eps = lineSubDict . get < scalar > ( "eps" ) ;
96
+ scalar eps = actuatorLinePars [ lineName ][ 17 ] ;
91
97
// scaling factor to ensure a desired integrated thrust
92
- scalar scale = lineSubDict . get < scalar > ( "scale" ) ;
98
+ scalar scale = actuatorLinePars [ lineName ][ 11 ] ;
93
99
// phase (rad) of the rotation positive value means rotates ahead of time for phase rad
94
- scalar phase = lineSubDict . get < scalar > ( "phase" ) ;
100
+ scalar phase = actuatorLinePars [ lineName ][ 16 ] ;
95
101
// number of blades for this line model
96
102
label nBlades = lineSubDict .get < label > ("nBlades" );
97
- scalar POD = lineSubDict . getScalar ( "POD" ) ;
98
- scalar expM = lineSubDict . getScalar ( "expM" ) ;
99
- scalar expN = lineSubDict . getScalar ( "expN" ) ;
103
+ scalar POD = actuatorLinePars [ lineName ][ 12 ] ;
104
+ scalar expM = actuatorLinePars [ lineName ][ 13 ] ;
105
+ scalar expN = actuatorLinePars [ lineName ][ 14 ] ;
100
106
// Now we need to compute normalized eps in the radial direction, i.e. epsRStar this is because
101
107
// we need to smooth the radial distribution of the thrust, here the radial location is
102
108
// normalized as rStar = (r - rInner) / (rOuter - rInner), so to make epsRStar consistent with this
@@ -157,24 +163,20 @@ void DAFvSourceActuatorLine::calcFvSource(volVectorField& fvSource)
157
163
for (label bb = 0 ; bb < nBlades ; bb ++ )
158
164
{
159
165
scalar thetaBlade = bb * 2.0 * pi / nBlades + radPerS * t + phase ;
160
- if (daOption_ .getOption < word > ("runStatus" ) == "solvePrimal" )
166
+ #ifdef CODI_NO_AD
167
+ if (cellI == 0 )
161
168
{
162
- if (cellI == 0 )
169
+ if (mesh_ .time ().timeIndex () % printIntervalUnsteady_ == 0
170
+ || mesh_ .time ().timeIndex () == 1 )
163
171
{
164
- if (mesh_ .time ().timeIndex () % printIntervalUnsteady_ == 0
165
- || mesh_ .time ().timeIndex () == 1 )
166
- {
167
- scalar twoPi = 2.0 * pi ;
168
- Info << "blade " << bb << " theta: "
169
- #if defined(CODI_ADF ) || defined(CODI_ADR )
170
- << fmod (thetaBlade .getValue (), twoPi .getValue ()) * 180.0 / pi .getValue ()
171
- #else
172
- << fmod (thetaBlade , twoPi ) * 180.0 / pi
173
- #endif
174
- << " deg" << endl ;
175
- }
172
+ scalar twoPi = 2.0 * pi ;
173
+ Info << "blade " << bb << " theta: "
174
+ //<< fmod(thetaBlade.getValue(), twoPi.getValue()) * 180.0 / pi.getValue()
175
+ << fmod (thetaBlade , twoPi ) * 180.0 / pi
176
+ << " deg" << endl ;
176
177
}
177
178
}
179
+ #endif
178
180
// compute the rotated vector of initial by thetaBlade degree
179
181
// We use a simplified version of Rodrigues rotation formulation
180
182
vector rotatedVec = vector ::zero ;
@@ -236,20 +238,79 @@ void DAFvSourceActuatorLine::calcFvSource(volVectorField& fvSource)
236
238
reduce (thrustTotal , sumOp < scalar > ( ));
237
239
reduce (torqueTotal , sumOp < scalar > ( ));
238
240
239
- if (daOption_ .getOption < word > ("runStatus" ) == "solvePrimal" )
241
+ #ifdef CODI_NO_AD
242
+ if (mesh_ .time ().timeIndex () % printIntervalUnsteady_ == 0 || mesh_ .time ().timeIndex () == 1 )
240
243
{
241
- if (mesh_ .time ().timeIndex () % printIntervalUnsteady_ == 0 || mesh_ .time ().timeIndex () == 1 )
242
- {
243
- Info << "Actuator line source: " << lineName << endl ;
244
- Info << "Total thrust source: " << thrustTotal << endl ;
245
- Info << "Total torque source: " << torqueTotal << endl ;
246
- }
244
+ Info << "Actuator line source: " << lineName << endl ;
245
+ Info << "Total thrust source: " << thrustTotal << endl ;
246
+ Info << "Total torque source: " << torqueTotal << endl ;
247
247
}
248
+ #endif
248
249
}
249
250
250
251
fvSource .correctBoundaryConditions ();
251
252
}
252
253
254
+ void DAFvSourceActuatorLine ::initFvSourcePars ()
255
+ {
256
+ /*
257
+ Description:
258
+ Initialize the values for all types of fvSource in DAGlobalVar, including
259
+ actuatorDiskPars, heatSourcePars, etc
260
+ */
261
+
262
+ // now we need to initialize actuatorDiskPars
263
+ dictionary fvSourceSubDict = daOption_ .getAllOptions ().subDict ("fvSource" );
264
+
265
+ forAll (fvSourceSubDict .toc (), idxI )
266
+ {
267
+ word diskName = fvSourceSubDict .toc ()[idxI ];
268
+ // sub dictionary with all parameters for this disk
269
+ dictionary lineSubDict = fvSourceSubDict .subDict (diskName );
270
+ word type = lineSubDict .getWord ("type" );
271
+
272
+ if (type == "actuatorLine" )
273
+ {
274
+
275
+ // now read in all parameters for this actuator disk
276
+ scalarList centerList ;
277
+ lineSubDict .readEntry < scalarList > ("center" , centerList );
278
+
279
+ scalarList dirList ;
280
+ lineSubDict .readEntry < scalarList > ("direction" , dirList );
281
+
282
+ scalarList initList ;
283
+ lineSubDict .readEntry < scalarList > ("initial" , initList );
284
+
285
+ // we have 18 design variables for each line
286
+ scalarList dvList (18 );
287
+ dvList [0 ] = centerList [0 ];
288
+ dvList [1 ] = centerList [1 ];
289
+ dvList [2 ] = centerList [2 ];
290
+ dvList [3 ] = dirList [0 ];
291
+ dvList [4 ] = dirList [1 ];
292
+ dvList [5 ] = dirList [2 ];
293
+ dvList [6 ] = initList [0 ];
294
+ dvList [7 ] = initList [1 ];
295
+ dvList [8 ] = initList [2 ];
296
+ dvList [9 ] = lineSubDict .getScalar ("innerRadius" );
297
+ dvList [10 ] = lineSubDict .getScalar ("outerRadius" );
298
+ dvList [11 ] = lineSubDict .getScalar ("scale" );
299
+ dvList [12 ] = lineSubDict .getScalar ("POD" );
300
+ dvList [13 ] = lineSubDict .getScalar ("expM" );
301
+ dvList [14 ] = lineSubDict .getScalar ("expN" );
302
+ dvList [15 ] = lineSubDict .getScalar ("rpm" );
303
+ dvList [16 ] = lineSubDict .getScalar ("phase" );
304
+ dvList [17 ] = lineSubDict .getScalar ("eps" );
305
+
306
+ // set actuatorDiskPars
307
+ DAGlobalVar & globalVar =
308
+ const_cast < DAGlobalVar & > (mesh_ .thisDb ().lookupObject < DAGlobalVar > ("DAGlobalVar" ));
309
+ globalVar .actuatorLinePars .set (diskName , dvList );
310
+ }
311
+ }
312
+ }
313
+
253
314
} // End namespace Foam
254
315
255
316
// ************************************************************************* //
0 commit comments