Skip to content

Commit d65162c

Browse files
Chris PsenicaChris Psenica
Chris Psenica
authored and
Chris Psenica
committed
Reduced the number of instances of checking if the new user inputs are valid. Now it is just one if statement instead of 3.
1 parent 3f6adab commit d65162c

File tree

3 files changed

+23
-68
lines changed

3 files changed

+23
-68
lines changed

src/adjoint/DAFunction/DAFunctionWallHeatFlux.C

+7-24
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ DAFunctionWallHeatFlux::DAFunctionWallHeatFlux(
4242

4343
// check and assign values for scheme and formulation
4444
formMode_ = functionDict_.lookupOrDefault<word>("formulation", "default");
45+
if (formMode_ != "daCustom" && formMode_ != "default")
46+
{
47+
FatalErrorIn(" ") << "formulation: "
48+
<< formMode_ << " not supported!"
49+
<< " Options are: default and daCustom."
50+
<< abort(FatalError);
51+
}
4552
calcMode_ = functionDict_.lookupOrDefault<bool>("byUnitArea", true);
4653

4754
if (mesh_.thisDb().foundObject<DATurbulenceModel>("DATurbulenceModel"))
@@ -165,14 +172,6 @@ scalar DAFunctionWallHeatFlux::calcFunction()
165172
wallHeatFluxBf[patchI][faceI] = Cp_ * alphaEffBf[patchI][faceI] * dTdz;
166173
}
167174
}
168-
// error message incase of invalid entry
169-
else
170-
{
171-
FatalErrorIn(" ") << "formulation: "
172-
<< formMode_ << " not supported!"
173-
<< " Options are: default and daCustom."
174-
<< abort(FatalError);
175-
}
176175
}
177176
}
178177
}
@@ -210,14 +209,6 @@ scalar DAFunctionWallHeatFlux::calcFunction()
210209
wallHeatFluxBf[patchI][faceI] = alphaEffBf[patchI][faceI] * dHedz;
211210
}
212211
}
213-
// error message incase of invalid entry
214-
else
215-
{
216-
FatalErrorIn(" ") << "formulation: "
217-
<< formMode_ << " not supported!"
218-
<< " Options are: default and daCustom."
219-
<< abort(FatalError);
220-
}
221212
}
222213
}
223214
}
@@ -255,14 +246,6 @@ scalar DAFunctionWallHeatFlux::calcFunction()
255246
wallHeatFluxBf[patchI][faceI] = k_ * dTdz;
256247
}
257248
}
258-
// error message incase of invalid entry
259-
else
260-
{
261-
FatalErrorIn(" ") << "formulation: "
262-
<< formMode_ << " not supported!"
263-
<< " Options are: default and daCustom."
264-
<< abort(FatalError);
265-
}
266249
}
267250
}
268251
}

src/adjoint/DAInput/DAInputThermalCoupling.C

+8-22
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ DAInputThermalCoupling::DAInputThermalCoupling(
3939
// check discipline
4040
discipline_ = daOption_.getAllOptions().getWord("discipline");
4141

42-
// check formulation mode
42+
// check coupling mode and validate
4343
couplingMode_ = daOption_.getAllOptions().subDict("inputInfo").subDict(inputName_).lookupOrDefault<word>("thermalCouplingMode", "default");
44+
if (couplingMode_ != "daCustom" && couplingMode_ != "default")
45+
{
46+
FatalErrorIn(" ") << "thermalCouplingMode: "
47+
<< couplingMode_ << " not supported!"
48+
<< " Options are: default and daCustom."
49+
<< abort(FatalError);
50+
}
4451

4552
size_ = 0;
4653
forAll(patches_, idxI)
@@ -134,13 +141,6 @@ Description:
134141
scalar d = mag(c1 - c2);
135142
deltaCoeffs = 1 / d;
136143
}
137-
else
138-
{
139-
FatalErrorIn(" ") << "thermalCouplingMode "
140-
<< couplingMode_ << " not supported!"
141-
<< " Options are: default and daCustom."
142-
<< abort(FatalError);
143-
}
144144
scalar alphaEffBf = alphaEff.boundaryField()[patchI][faceI];
145145
scalar myKDeltaCoeffs = Cp * alphaEffBf * deltaCoeffs;
146146
// NOTE: we continue to use the counterI from the first loop
@@ -211,13 +211,6 @@ Description:
211211
scalar d = mag(c1 - c2);
212212
deltaCoeffs = 1 / d;
213213
}
214-
else
215-
{
216-
FatalErrorIn(" ") << "thermalCouplingMode "
217-
<< couplingMode_ << " not supported!"
218-
<< " Options are: default and daCustom."
219-
<< abort(FatalError);
220-
}
221214
scalar alphaEffBf = alphaEff.boundaryField()[patchI][faceI];
222215
scalar myKDeltaCoeffs = tmpVal * alphaEffBf * deltaCoeffs;
223216
// NOTE: we continue to use the counterI from the first loop
@@ -262,13 +255,6 @@ Description:
262255
scalar d = mag(c1 - c2);
263256
deltaCoeffs = 1 / d;
264257
}
265-
else
266-
{
267-
FatalErrorIn(" ") << "thermalCouplingMode "
268-
<< couplingMode_ << " not supported!"
269-
<< " Options are: default and daCustom."
270-
<< abort(FatalError);
271-
}
272258
mixedFvPatchField<scalar>& mixedPatch = refCast<mixedFvPatchField<scalar>>(T.boundaryFieldRef()[patchI]);
273259
scalar myKDeltaCoeffs = k * deltaCoeffs;
274260
// NOTE: we continue to use the counterI from the first loop

src/adjoint/DAOutput/DAOutputThermalCoupling.C

+8-22
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ DAOutputThermalCoupling::DAOutputThermalCoupling(
4242
// check discipline
4343
discipline_ = daOption_.getAllOptions().getWord("discipline");
4444

45-
// check formulation mode
45+
// check coupling mode and validate
4646
couplingMode_ = daOption_.getAllOptions().subDict("outputInfo").subDict(outputName_).lookupOrDefault<word>("thermalCouplingMode", "default");
47+
if (couplingMode_ != "daCustom" && couplingMode_ != "default")
48+
{
49+
FatalErrorIn(" ") << "thermalCouplingMode: "
50+
<< couplingMode_ << " not supported!"
51+
<< " Options are: default and daCustom."
52+
<< abort(FatalError);
53+
}
4754

4855
size_ = 0;
4956
forAll(patches_, idxI)
@@ -129,13 +136,6 @@ void DAOutputThermalCoupling::run(scalarList& output)
129136
scalar d = mag(c1 - c2);
130137
deltaCoeffs = 1 / d;
131138
}
132-
else
133-
{
134-
FatalErrorIn(" ") << "thermalCouplingMode: "
135-
<< couplingMode_ << " not supported!"
136-
<< " Options are: default and daCustom."
137-
<< abort(FatalError);
138-
}
139139
scalar alphaEffBf = alphaEff.boundaryField()[patchI][faceI];
140140
// NOTE: we continue to use the counterI from the first loop
141141
output[counterI] = Cp * alphaEffBf * deltaCoeffs;
@@ -201,13 +201,6 @@ void DAOutputThermalCoupling::run(scalarList& output)
201201
scalar d = mag(c1 - c2);
202202
deltaCoeffs = 1 / d;
203203
}
204-
else
205-
{
206-
FatalErrorIn(" ") << "thermalCouplingMode: "
207-
<< couplingMode_ << " not supported!"
208-
<< " Options are: default and daCustom."
209-
<< abort(FatalError);
210-
}
211204
scalar alphaEffBf = alphaEff.boundaryField()[patchI][faceI];
212205
// NOTE: we continue to use the counterI from the first loop
213206
output[counterI] = tmpVal * alphaEffBf * deltaCoeffs;
@@ -249,13 +242,6 @@ void DAOutputThermalCoupling::run(scalarList& output)
249242
scalar d = mag(c1 - c2);
250243
deltaCoeffs = 1 / d;
251244
}
252-
else
253-
{
254-
FatalErrorIn(" ") << "thermalCouplingMode: "
255-
<< couplingMode_ << " not supported!"
256-
<< " Options are: default and daCustom."
257-
<< abort(FatalError);
258-
}
259245
// NOTE: we continue to use the counterI from the first loop
260246
output[counterI] = k * deltaCoeffs;
261247
counterI++;

0 commit comments

Comments
 (0)