43 const scalar twoDPointCorrector::edgeOrthogonalityTol = 1.0 - 1
e-4;
47 void twoDPointCorrector::calcAddressing()
const
50 planeNormalPtr_ =
new vector(0, 0, 0);
51 vector& pn = *planeNormalPtr_;
66 if (isA<wedgePolyPatch>(patches[patchI]))
70 pn = refCast<const wedgePolyPatch>(patches[patchI]).centreNormal();
74 Pout <<
"Found normal from wedge patch " << patchI;
86 if (isA<emptyPolyPatch>(patches[patchI]) && patches[patchI].size())
88 pn = patches[patchI].faceAreas()[0];
92 Pout <<
"Found normal from empty patch " << patchI;
101 if (
mag(pn) < VSMALL)
105 "twoDPointCorrector::twoDPointCorrector(const polyMesh& mesh, "
107 ) <<
"Cannot determine normal vector from patches."
117 Pout <<
" twoDPointCorrector normal: " << pn <<
endl;
122 labelList& neIndices = *normalEdgeIndicesPtr_;
128 label nNormalEdges = 0;
133 meshEdges[edgeI].vec(meshPoints)/
134 (meshEdges[edgeI].mag(meshPoints) + VSMALL);
136 if (
mag(edgeVector & pn) > edgeOrthogonalityTol)
139 neIndices[nNormalEdges++] = edgeI;
143 neIndices.setSize(nNormalEdges);
150 if (meshPoints.size() % 2 != 0)
154 "twoDPointCorrector::twoDPointCorrector("
155 "const polyMesh& mesh, const vector& n)"
156 ) <<
"the number of vertices in the geometry "
157 <<
"is odd - this should not be the case for a 2-D case. "
158 <<
"Please check the geometry."
162 if (2*nNormalEdges != meshPoints.size())
166 "twoDPointCorrector::twoDPointCorrector("
167 "const polyMesh& mesh, const vector& n)"
168 ) <<
"The number of points in the mesh is "
169 <<
"not equal to twice the number of edges normal to the plane "
170 <<
"- this may be OK only for wedge geometries.\n"
171 <<
" Please check the geometry or adjust "
172 <<
"the orthogonality tolerance.\n" <<
endl
173 <<
"Number of normal edges: " << nNormalEdges
174 <<
" number of points: " << meshPoints.size()
181 void twoDPointCorrector::clearAddressing()
const
193 required_(mesh_.nGeometricD() == 2),
194 planeNormalPtr_(NULL),
195 normalEdgeIndicesPtr_(NULL)
214 if (
mag(pn.
x()) >= edgeOrthogonalityTol)
218 else if (
mag(pn.
y()) >= edgeOrthogonalityTol)
222 else if (
mag(pn.
z()) >= edgeOrthogonalityTol)
228 FatalErrorIn(
"direction twoDPointCorrector::normalDir() const")
229 <<
"Plane normal not aligned with the coordinate system" <<
nl
241 if (!planeNormalPtr_)
246 return *planeNormalPtr_;
253 if (!normalEdgeIndicesPtr_)
258 return *normalEdgeIndicesPtr_;
264 if (!required_)
return;
279 point& pStart = p[meshEdges[neIndices[edgeI]].start()];
281 point& pEnd = p[meshEdges[neIndices[edgeI]].
end()];
284 const point A = 0.5*(pStart + pEnd);
287 pStart = A + pn*(pn & (pStart -
A));
288 pEnd = A + pn*(pn & (pEnd -
A));