Skip to content

Commit fed0263

Browse files
authored
Renamed RefDifference to RefVar (#612)
* Added sqrt for calcRefDiff. * Renamed RefDiff to RefStd * Updated tests for the refStd. * Renamed RefStd to RefVar.
1 parent 7570ed7 commit fed0263

19 files changed

+41
-42
lines changed

src/adjoint/DAObjFunc/DAObjFunc.C

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

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

321-
void DAObjFunc::calcRefDiffSquare(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 calcRefDiffSquare_ == 1
326+
This can be used in FIML. This function is for calcRefVar == 1
327327
*/
328328

329-
if (calcRefDiffSquare_)
329+
if (calcRefVar_)
330330
{
331331
if (ref_.size() == 1)
332332
{
@@ -338,7 +338,6 @@ void DAObjFunc::calcRefDiffSquare(scalar& objFuncValue)
338338
objFuncValue = (objFuncValue - ref_[idxI]) * (objFuncValue - ref_[idxI]);
339339
}
340340
}
341-
342341
}
343342

344343
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAObjFunc/DAObjFunc.H

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ protected:
9393
List<List<word>> objFuncConInfo_;
9494

9595
/// whether to calculate (obj-ref)^2
96-
label calcRefDiffSquare_;
96+
label calcRefVar_;
9797

98-
/// if calcRefDiffSquare_ 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 varDiffSquare
247-
void calcRefDiffSquare(scalar& objFuncValue);
246+
/// calculate (var-ref)^2
247+
void calcRefVar(scalar& objFuncValue);
248248
};
249249

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

src/adjoint/DAObjFunc/DAObjFuncCenterOfPressure.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ void DAObjFuncCenterOfPressure::calcObjFunc(
128128

129129
objFuncValue = scale_ * (weightedPressure / totalPressure + (center_ & axis_));
130130

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

134134
return;
135135
}

src/adjoint/DAObjFunc/DAObjFuncForce.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ void DAObjFuncForce::calcObjFunc(
191191
// need to reduce the sum of force across all processors
192192
reduce(objFuncValue, sumOp<scalar>());
193193

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

197197
return;
198198
}

src/adjoint/DAObjFunc/DAObjFuncLocation.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ void DAObjFuncLocation::calcObjFunc(
219219
<< abort(FatalError);
220220
}
221221

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

225225
return;
226226
}

src/adjoint/DAObjFunc/DAObjFuncMass.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ void DAObjFuncMass::calcObjFunc(
9696
// need to reduce the sum of force across all processors
9797
reduce(objFuncValue, sumOp<scalar>());
9898

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

102102
return;
103103
}

src/adjoint/DAObjFunc/DAObjFuncMassFlowRate.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ void DAObjFuncMassFlowRate::calcObjFunc(
119119
// need to reduce the sum of force across all processors
120120
reduce(objFuncValue, sumOp<scalar>());
121121

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

125125
return;
126126
}

src/adjoint/DAObjFunc/DAObjFuncMeshQualityKS.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ void DAObjFuncMeshQualityKS::calcObjFunc(
219219

220220
objFuncValue = log(objFuncValue) / coeffKS_;
221221

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

225225
return;
226226
}

src/adjoint/DAObjFunc/DAObjFuncMoment.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ void DAObjFuncMoment::calcObjFunc(
165165
// need to reduce the sum of force across all processors
166166
reduce(objFuncValue, sumOp<scalar>());
167167

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

171171
return;
172172
}

src/adjoint/DAObjFunc/DAObjFuncPatchMean.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ void DAObjFuncPatchMean::calcObjFunc(
132132
// need to reduce the sum of force across all processors
133133
reduce(objFuncValue, sumOp<scalar>());
134134

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

138138
return;
139139
}

src/adjoint/DAObjFunc/DAObjFuncPower.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ void DAObjFuncPower::calcObjFunc(
168168
// need to reduce the sum of force across all processors
169169
reduce(objFuncValue, sumOp<scalar>());
170170

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

174174
return;
175175
}

src/adjoint/DAObjFunc/DAObjFuncTotalPressure.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ void DAObjFuncTotalPressure::calcObjFunc(
132132
// need to reduce the sum of force across all processors
133133
reduce(objFuncValue, sumOp<scalar>());
134134

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

138138
return;
139139
}

src/adjoint/DAObjFunc/DAObjFuncTotalPressureRatio.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ void DAObjFuncTotalPressureRatio::calcObjFunc(
217217
}
218218
}
219219

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

223223
return;
224224
}

src/adjoint/DAObjFunc/DAObjFuncTotalTemperatureRatio.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ void DAObjFuncTotalTemperatureRatio::calcObjFunc(
207207
}
208208
}
209209

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

213213
return;
214214
}

src/adjoint/DAObjFunc/DAObjFuncVariableVolSum.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ void DAObjFuncVariableVolSum::calcObjFunc(
167167

168168
objFuncValue /= totalVol;
169169

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

173173
return;
174174
}

src/adjoint/DAObjFunc/DAObjFuncVonMisesStressKS.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ void DAObjFuncVonMisesStressKS::calcObjFunc(
121121

122122
objFuncValue = log(objValTmp) / coeffKS_;
123123

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

127127
return;
128128
}

src/adjoint/DAObjFunc/DAObjFuncWallHeatFlux.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ void DAObjFuncWallHeatFlux::calcObjFunc(
246246
// need to reduce the sum of force across all processors
247247
reduce(objFuncValue, sumOp<scalar>());
248248

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

252252
return;
253253
}

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-
"calcRefDiffSquare": 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-
"calcRefDiffSquare": True,
133+
"calcRefVar": True,
134134
"ref": [0.1]
135135
}
136136
},

0 commit comments

Comments
 (0)