Skip to content

Commit 4ff31f5

Browse files
committed
Renamed RefStd to RefVar.
1 parent 3a99d4c commit 4ff31f5

21 files changed

+52
-51
lines changed

src/adjoint/DAObjFunc/DAObjFunc.C

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ DAObjFunc::DAObjFunc(
5656
objFuncCellValues_[idxI] = 0.0;
5757
}
5858

59-
calcRefStd_ = objFuncDict_.lookupOrDefault<label>("calcRefStd", 0);
60-
if (calcRefStd_)
59+
calcRefVar_ = objFuncDict_.lookupOrDefault<label>("calcRefVar", 0);
60+
if (calcRefVar_)
6161
{
6262
objFuncDict_.readEntry<scalarList>("ref", ref_);
6363
}
@@ -318,24 +318,24 @@ scalar DAObjFunc::getObjFuncValue()
318318
return objFuncValue_;
319319
}
320320

321-
void DAObjFunc::calcRefStd(scalar& objFuncValue)
321+
void DAObjFunc::calcRefVar(scalar& objFuncValue)
322322
{
323323
/*
324324
Description:
325325
Call the variable difference with respect to a given reference and take a square of it.
326-
This can be used in FIML. This function is for calcRefStd == 1
326+
This can be used in FIML. This function is for calcRefVar == 1
327327
*/
328328

329-
if (calcRefStd_)
329+
if (calcRefVar_)
330330
{
331331
if (ref_.size() == 1)
332332
{
333-
objFuncValue = sqrt((objFuncValue - ref_[0]) * (objFuncValue - ref_[0]));
333+
objFuncValue = (objFuncValue - ref_[0]) * (objFuncValue - ref_[0]);
334334
}
335335
else
336336
{
337337
label idxI = mesh_.time().timeIndex() - 1;
338-
objFuncValue = sqrt((objFuncValue - ref_[idxI]) * (objFuncValue - ref_[idxI]));
338+
objFuncValue = (objFuncValue - ref_[idxI]) * (objFuncValue - ref_[idxI]);
339339
}
340340
}
341341
}

src/adjoint/DAObjFunc/DAObjFunc.H

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ protected:
9292
/// the connectivity information for the objective function
9393
List<List<word>> objFuncConInfo_;
9494

95-
/// whether to calculate sqrt((obj-ref)^2)
96-
label calcRefStd_;
95+
/// whether to calculate (obj-ref)^2
96+
label calcRefVar_;
9797

98-
/// if calcRefStd_ is True, set the reference value list
98+
/// if calcRefVar_ is True, set the reference value list
9999
scalarList ref_;
100100

101101
public:
@@ -243,8 +243,8 @@ public:
243243
/// whether to compute reference coefficients for special objFunc treatment such as totalPressureRatio
244244
label calcRefCoeffs = 1;
245245

246-
/// calculate the varDiff
247-
void calcRefStd(scalar& objFuncValue);
246+
/// calculate (var-ref)^2
247+
void calcRefVar(scalar& objFuncValue);
248248
};
249249

250250
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAObjFunc/DAObjFuncCenterOfPressure.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void DAObjFuncCenterOfPressure::calcObjFunc(
129129
objFuncValue = scale_ * (weightedPressure / totalPressure + (center_ & axis_));
130130

131131
// check if we need to calculate refDiff.
132-
this->calcRefStd(objFuncValue);
132+
this->calcRefVar(objFuncValue);
133133

134134
return;
135135
}

src/adjoint/DAObjFunc/DAObjFuncForce.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void DAObjFuncForce::calcObjFunc(
192192
reduce(objFuncValue, sumOp<scalar>());
193193

194194
// check if we need to calculate refDiff.
195-
this->calcRefStd(objFuncValue);
195+
this->calcRefVar(objFuncValue);
196196

197197
return;
198198
}

src/adjoint/DAObjFunc/DAObjFuncLocation.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void DAObjFuncLocation::calcObjFunc(
220220
}
221221

222222
// check if we need to calculate refDiff.
223-
this->calcRefStd(objFuncValue);
223+
this->calcRefVar(objFuncValue);
224224

225225
return;
226226
}

src/adjoint/DAObjFunc/DAObjFuncMass.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void DAObjFuncMass::calcObjFunc(
9797
reduce(objFuncValue, sumOp<scalar>());
9898

9999
// check if we need to calculate refDiff.
100-
this->calcRefStd(objFuncValue);
100+
this->calcRefVar(objFuncValue);
101101

102102
return;
103103
}

src/adjoint/DAObjFunc/DAObjFuncMassFlowRate.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void DAObjFuncMassFlowRate::calcObjFunc(
120120
reduce(objFuncValue, sumOp<scalar>());
121121

122122
// check if we need to calculate refDiff.
123-
this->calcRefStd(objFuncValue);
123+
this->calcRefVar(objFuncValue);
124124

125125
return;
126126
}

src/adjoint/DAObjFunc/DAObjFuncMeshQualityKS.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void DAObjFuncMeshQualityKS::calcObjFunc(
220220
objFuncValue = log(objFuncValue) / coeffKS_;
221221

222222
// check if we need to calculate refDiff.
223-
this->calcRefStd(objFuncValue);
223+
this->calcRefVar(objFuncValue);
224224

225225
return;
226226
}

src/adjoint/DAObjFunc/DAObjFuncMoment.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void DAObjFuncMoment::calcObjFunc(
166166
reduce(objFuncValue, sumOp<scalar>());
167167

168168
// check if we need to calculate refDiff.
169-
this->calcRefStd(objFuncValue);
169+
this->calcRefVar(objFuncValue);
170170

171171
return;
172172
}

src/adjoint/DAObjFunc/DAObjFuncPatchMean.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void DAObjFuncPatchMean::calcObjFunc(
133133
reduce(objFuncValue, sumOp<scalar>());
134134

135135
// check if we need to calculate refDiff.
136-
this->calcRefStd(objFuncValue);
136+
this->calcRefVar(objFuncValue);
137137

138138
return;
139139
}

src/adjoint/DAObjFunc/DAObjFuncPower.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void DAObjFuncPower::calcObjFunc(
169169
reduce(objFuncValue, sumOp<scalar>());
170170

171171
// check if we need to calculate refDiff.
172-
this->calcRefStd(objFuncValue);
172+
this->calcRefVar(objFuncValue);
173173

174174
return;
175175
}

src/adjoint/DAObjFunc/DAObjFuncTotalPressure.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void DAObjFuncTotalPressure::calcObjFunc(
133133
reduce(objFuncValue, sumOp<scalar>());
134134

135135
// check if we need to calculate refDiff.
136-
this->calcRefStd(objFuncValue);
136+
this->calcRefVar(objFuncValue);
137137

138138
return;
139139
}

src/adjoint/DAObjFunc/DAObjFuncTotalPressureRatio.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void DAObjFuncTotalPressureRatio::calcObjFunc(
218218
}
219219

220220
// check if we need to calculate refDiff.
221-
this->calcRefStd(objFuncValue);
221+
this->calcRefVar(objFuncValue);
222222

223223
return;
224224
}

src/adjoint/DAObjFunc/DAObjFuncTotalTemperatureRatio.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void DAObjFuncTotalTemperatureRatio::calcObjFunc(
208208
}
209209

210210
// check if we need to calculate refDiff.
211-
this->calcRefStd(objFuncValue);
211+
this->calcRefVar(objFuncValue);
212212

213213
return;
214214
}

src/adjoint/DAObjFunc/DAObjFuncVariableVolSum.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void DAObjFuncVariableVolSum::calcObjFunc(
168168
objFuncValue /= totalVol;
169169

170170
// check if we need to calculate refDiff.
171-
this->calcRefStd(objFuncValue);
171+
this->calcRefVar(objFuncValue);
172172

173173
return;
174174
}

src/adjoint/DAObjFunc/DAObjFuncVonMisesStressKS.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void DAObjFuncVonMisesStressKS::calcObjFunc(
122122
objFuncValue = log(objValTmp) / coeffKS_;
123123

124124
// check if we need to calculate refDiff.
125-
this->calcRefStd(objFuncValue);
125+
this->calcRefVar(objFuncValue);
126126

127127
return;
128128
}

src/adjoint/DAObjFunc/DAObjFuncWallHeatFlux.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void DAObjFuncWallHeatFlux::calcObjFunc(
247247
reduce(objFuncValue, sumOp<scalar>());
248248

249249
// check if we need to calculate refDiff.
250-
this->calcRefStd(objFuncValue);
250+
this->calcRefVar(objFuncValue);
251251

252252
return;
253253
}

tests/refs/DAFoam_Test_DAPimpleFoamRef.txt

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Dictionary Key: CD
22
@value 7.747035248407224 1e-08 1e-10
33
Dictionary Key: CMZVAR
4-
@value 2.365561943460486 1e-08 1e-10
4+
@value 41.05825112111668 1e-08 1e-10
55
Dictionary Key: fail
66
@value 0 1e-08 1e-10
77
Dictionary Key: CD
@@ -29,26 +29,27 @@ Dictionary Key: uin
2929
@value 0.1887121251618032 0.0001 1e-06
3030
Dictionary Key: CMZVAR
3131
Dictionary Key: actuator
32-
@value -0.001597469280766449 0.0001 1e-06
33-
@value -0.01707170912348184 0.0001 1e-06
34-
@value 3.148224254461253e-07 0.0001 1e-06
32+
@value 0.0129164206206973 0.0001 1e-06
33+
@value -0.06721779867591618 0.0001 1e-06
34+
@value 1.01218774787428e-06 0.0001 1e-06
3535
@value 0 0.0001 1e-06
36-
@value -0.007276463264693517 0.0001 1e-06
37-
@value -2.577659403962896e-06 0.0001 1e-06
38-
@value 0.009587229516594336 0.0001 1e-06
39-
@value 0.008658035611138083 0.0001 1e-06
40-
@value -6.122600337971326e-06 0.0001 1e-06
41-
@value 5.423032937126702e-07 0.0001 1e-06
42-
@value 0.001393758772332803 0.0001 1e-06
43-
@value -0.0004203826176466521 0.0001 1e-06
36+
@value -0.03989829709014971 0.0001 1e-06
37+
@value -1.174777939902339e-05 0.0001 1e-06
38+
@value -0.01318488544862298 0.0001 1e-06
39+
@value 0.02098447283371081 0.0001 1e-06
40+
@value 7.847578532670927e-05 0.0001 1e-06
41+
@value 1.135345283703712e-06 0.0001 1e-06
42+
@value -0.00490063870041851 0.0001 1e-06
43+
@value -0.007270668470157968 0.0001 1e-06
4444
@value 0 0.0001 1e-06
4545
Dictionary Key: alpha
46-
@value 0.01140386202332798 0.0001 1e-06
46+
@value 0.1694703610086252 0.0001 1e-06
4747
Dictionary Key: parameter
48-
@value 0.009648381370298942 0.0001 1e-06
48+
@value 0.01322002733662093 0.0001 1e-06
4949
Dictionary Key: twist
50-
@value 0.1082950879976247 0.0001 1e-06
50+
@value 2.800461713324844 0.0001 1e-06
5151
Dictionary Key: uin
52-
@value 0.04179259679528147 0.0001 1e-06
52+
@value 0.5352121060453168 0.0001 1e-06
53+
5354
Dictionary Key: fail
5455
@value 0 0.0001 1e-06

tests/refs/DAFoam_Test_DASimpleFoamADRef.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Dictionary Key: CD
33
Dictionary Key: CL
44
@value 0.4874216250833033 1e-08 1e-10
55
Dictionary Key: CMZDIFF
6-
@value 0.1076180636003673 1e-08 1e-10
6+
@value 0.0115816476130927 1e-08 1e-10
77
Dictionary Key: COP
88
@value 0.2298218575123644 1e-08 1e-10
99
Dictionary Key: R1
@@ -34,13 +34,13 @@ Dictionary Key: twist
3434
@value 0.09008667655578639 1e-05 1e-07
3535
Dictionary Key: CMZDIFF
3636
Dictionary Key: alpha
37-
@value 0.002364897292529736 1e-05 1e-07
37+
@value 0.0005090113344677443 1e-05 1e-07
3838
Dictionary Key: shapey
39-
@value -0.005352177769828416 1e-05 1e-07
40-
@value -0.1823542243438478 1e-05 1e-07
41-
@value -0.5260050985687549 1e-05 1e-07
39+
@value -0.001151982015258751 1e-05 1e-07
40+
@value -0.03924921702616808 1e-05 1e-07
41+
@value -0.1132153003029267 1e-05 1e-07
4242
Dictionary Key: twist
43-
@value 0.002276428167860035 1e-05 1e-07
43+
@value 0.0004899695826971005 1e-05 1e-07
4444
Dictionary Key: COP
4545
Dictionary Key: alpha
4646
@value -0.002070288134429892 1e-05 1e-07

tests/runTests_DAPimpleFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"center": [0.25, 0.0, 0.05],
105105
"scale": 1.0,
106106
"addToAdjoint": True,
107-
"calcRefStd": True,
107+
"calcRefVar": True,
108108
"ref": [0.1, 0.05, 0.04, 0.02, 0.02, 0.01, 0.0, -0.01, -0.01, -0.02]
109109
}
110110
}

tests/runTests_DASimpleFoamAD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"center": [0.25, 0.0, 0.05],
131131
"scale": 1.0 / (0.5 * U0 * U0 * A0 * 1.0),
132132
"addToAdjoint": True,
133-
"calcRefStd": True,
133+
"calcRefVar": True,
134134
"ref": [0.1]
135135
}
136136
},

0 commit comments

Comments
 (0)