24 const word functionName)
44 label nInterF =
mesh_.nInternalFaces();
45 label faceCounter = 0;
48 if (
mesh.boundaryMesh()[patchI].type() ==
"processor")
58 faceCounter +=
mesh.boundaryMesh()[patchI].size();
80 scalar functionValue = 0.0;
82 if (
metric_ ==
"faceOrthogonality")
85 const scalarField faceOrthogonality(
86 polyMeshTools::faceOrthogonality(
89 mesh_.cellCentres()));
92 forAll(faceOrthogonality, faceI)
96 functionValue += exp(
coeffKS_ * faceOrthogonality[faceI]);
99 if (functionValue > 1e200)
101 FatalErrorIn(
" ") <<
"KS function summation term too large! "
102 <<
"Reduce coeffKS! " << abort(FatalError);
106 else if (
metric_ ==
"nonOrthoAngle")
108 const scalarField faceOrthogonality(
109 polyMeshTools::faceOrthogonality(
112 mesh_.cellCentres()));
115 scalarField nonOrthoAngle = faceOrthogonality;
116 forAll(faceOrthogonality, faceI)
118 scalar val = faceOrthogonality[faceI];
121 scalar boundV = 1.0 - 1e-6;
131 scalar angleRad = acos(val);
133 scalar pi = constant::mathematical::pi;
134 scalar angleDeg = angleRad * 180.0 / pi;
135 nonOrthoAngle[faceI] = angleDeg;
139 forAll(nonOrthoAngle, faceI)
143 functionValue += exp(
coeffKS_ * nonOrthoAngle[faceI]);
146 if (functionValue > 1e200)
148 FatalErrorIn(
" ") <<
"KS function summation term too large! "
149 <<
"Reduce coeffKS! " << abort(FatalError);
153 else if (
metric_ ==
"faceSkewness")
155 const scalarField faceSkewness(
156 polyMeshTools::faceSkewness(
161 mesh_.cellCentres()));
164 forAll(faceSkewness, faceI)
168 functionValue += exp(
coeffKS_ * faceSkewness[faceI]);
171 if (functionValue > 1e200)
173 FatalErrorIn(
" ") <<
"KS function summation term too large! "
174 <<
"Reduce coeffKS! " << abort(FatalError);
180 FatalErrorIn(
" ") <<
"metric not valid! "
181 <<
"Options: faceOrthogonality, nonOrthoAngle, or faceSkewness "
182 << abort(FatalError);
186 reduce(functionValue, sumOp<scalar>());
188 functionValue = log(functionValue) /
coeffKS_;
193 return functionValue;