24 const word functionName)
37 dictionary resWeightDict = daOption.
getAllOptions().subDict(
"function").subDict(functionName).subDict(
"resWeight");
39 forAll(resWeightDict.toc(), idxI)
41 word resName = resWeightDict.toc()[idxI];
42 scalar weight = resWeightDict.getScalar(resName);
45 Info <<
"residual weights for DAFunctionResidualNorm " <<
resWeight_;
57 scalar functionValue = 0.0;
59 const objectRegistry& db =
mesh_.thisDb();
64 options.set(
"isPC", 0);
70 const word stateName =
stateInfo_[
"volVectorStates"][idxI];
71 const word resName = stateName +
"Res";
72 const volVectorField& stateRes =
mesh_.thisDb().lookupObject<volVectorField>(resName);
77 for (label i = 0; i < 3; i++)
79 functionValue += weight2 * stateRes[cellI][i] * stateRes[cellI][i];
86 const word stateName =
stateInfo_[
"volScalarStates"][idxI];
87 const word resName = stateName +
"Res";
88 const volScalarField& stateRes =
mesh_.thisDb().lookupObject<volScalarField>(resName);
93 functionValue += weight2 * stateRes[cellI] * stateRes[cellI];
99 const word stateName =
stateInfo_[
"modelStates"][idxI];
100 const word resName = stateName +
"Res";
101 const volScalarField& stateRes =
mesh_.thisDb().lookupObject<volScalarField>(resName);
106 functionValue += weight2 * stateRes[cellI] * stateRes[cellI];
112 const word stateName =
stateInfo_[
"surfaceScalarStates"][idxI];
113 const word resName = stateName +
"Res";
114 const surfaceScalarField& stateRes =
mesh_.thisDb().lookupObject<surfaceScalarField>(resName);
119 functionValue += weight2 * stateRes[faceI] * stateRes[faceI];
121 forAll(stateRes.boundaryField(), patchI)
123 forAll(stateRes.boundaryField()[patchI], faceI)
125 scalar bPhiRes = stateRes.boundaryField()[patchI][faceI];
126 functionValue += weight2 * bPhiRes * bPhiRes;
132 reduce(functionValue, sumOp<scalar>());
139 return functionValue;