24 const word functionName)
44 axis_ = {axisRead[0], axisRead[1], axisRead[2]};
50 scalarList centerRead;
52 center_ = {centerRead[0], centerRead[1], centerRead[2]};
68 reduce(foundCellI, sumOp<label>());
71 FatalErrorIn(
" ") <<
"There should be only one cell found globally while "
72 << foundCellI <<
" was returned."
73 <<
" Please adjust center such that it is located completely"
74 <<
" within a cell in the mesh domain. The center should not "
75 <<
" be outside of the mesh domain or on a mesh face "
78 vector snappedCenter = vector::zero;
80 Info <<
"snap to center " << snappedCenter << endl;
83 if (
mode_ ==
"maxRadius")
89 scalar maxR = -100000;
90 label maxRPatchI = -999, maxRFaceI = -999;
98 vector faceC =
mesh_.Cf().boundaryField()[patchI][faceI] -
center_;
100 tensor faceCTensor(tensor::zero);
101 faceCTensor.xx() = faceC.x();
102 faceCTensor.yy() = faceC.y();
103 faceCTensor.zz() = faceC.z();
105 vector faceCAxial = faceCTensor &
axis_;
106 vector faceCRadial = faceC - faceCAxial;
108 scalar radius = mag(faceCRadial);
118 scalar maxRGlobal = maxR;
119 reduce(maxRGlobal, maxOp<scalar>());
121 if (fabs(maxRGlobal - maxR) < 1e-8)
130 label snappedCenterCellI,
133 scalar centerX = 0.0;
134 scalar centerY = 0.0;
135 scalar centerZ = 0.0;
137 if (snappedCenterCellI >= 0)
139 centerX =
mesh_.C()[snappedCenterCellI][0];
140 centerY =
mesh_.C()[snappedCenterCellI][1];
141 centerZ =
mesh_.C()[snappedCenterCellI][2];
143 reduce(centerX, sumOp<scalar>());
144 reduce(centerY, sumOp<scalar>());
145 reduce(centerZ, sumOp<scalar>());
161 scalar functionValue = 0.0;
163 if (
mode_ ==
"maxRadiusKS")
166 scalar objValTmp = 0.0;
181 vector faceC =
mesh_.Cf().boundaryField()[patchI][faceI] - center;
183 tensor faceCTensor(tensor::zero);
184 faceCTensor.xx() = faceC.x();
185 faceCTensor.yy() = faceC.y();
186 faceCTensor.zz() = faceC.z();
188 vector faceCAxial = faceCTensor &
axis_;
189 vector faceCRadial = faceC - faceCAxial;
191 scalar radius = mag(faceCRadial);
193 objValTmp += exp(
coeffKS_ * radius);
195 if (objValTmp > 1e200)
197 FatalErrorIn(
" ") <<
"KS function summation term too large! "
198 <<
"Reduce coeffKS! " << abort(FatalError);
203 reduce(objValTmp, sumOp<scalar>());
205 functionValue = log(objValTmp) /
coeffKS_;
207 else if (
mode_ ==
"maxInverseRadiusKS")
212 scalar objValTmp = 0.0;
227 vector faceC =
mesh_.Cf().boundaryField()[patchI][faceI] - center;
229 tensor faceCTensor(tensor::zero);
230 faceCTensor.xx() = faceC.x();
231 faceCTensor.yy() = faceC.y();
232 faceCTensor.zz() = faceC.z();
234 vector faceCAxial = faceCTensor &
axis_;
235 vector faceCRadial = faceC - faceCAxial;
237 scalar radius = mag(faceCRadial);
238 scalar iRadius = 1.0 / (radius + 1e-12);
240 objValTmp += exp(
coeffKS_ * iRadius);
242 if (objValTmp > 1e200)
244 FatalErrorIn(
" ") <<
"KS function summation term too large! "
245 <<
"Reduce coeffKS! " << abort(FatalError);
250 reduce(objValTmp, sumOp<scalar>());
252 functionValue = log(objValTmp) /
coeffKS_;
254 else if (
mode_ ==
"maxRadius")
269 tensor faceCTensor(tensor::zero);
270 faceCTensor.xx() = faceC.x();
271 faceCTensor.yy() = faceC.y();
272 faceCTensor.zz() = faceC.z();
274 vector faceCAxial = faceCTensor &
axis_;
275 vector faceCRadial = faceC - faceCAxial;
277 radius = mag(faceCRadial);
280 reduce(radius, sumOp<scalar>());
282 functionValue = radius;
286 FatalErrorIn(
"DAFunctionLocation") <<
"mode: " <<
mode_ <<
" not supported!"
287 <<
"Options are: maxRadius"
288 << abort(FatalError);
294 return functionValue;