75 scalar minDistSqr = great;
78 scalar almostMinDistSqr = great;
79 label almostMinI = -1;
83 label pointi = meshPoints[i];
85 scalar distSqr =
magSqr(nearPoint - points[pointi]);
87 if (distSqr < minDistSqr)
89 almostMinDistSqr = minDistSqr;
95 else if (distSqr < almostMinDistSqr)
97 almostMinDistSqr = distSqr;
104 Info<<
"Found to point " << nearPoint <<
nl 105 <<
" nearest point : " << minI
107 <<
" at " << points[minI] <<
nl 108 <<
" next nearest point : " << almostMinI
109 <<
" distance " <<
Foam::sqrt(almostMinDistSqr)
110 <<
" at " << points[almostMinI] <<
endl;
112 if (almostMinDistSqr < 4*minDistSqr)
114 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
130 const point& nearPoint
139 scalar minDist = great;
142 scalar almostMinDist = great;
143 label almostMinI = -1;
147 const edge& e = edges[edgeI];
158 minDist = pHit.distance();
166 else if (pHit.distance() < almostMinDist)
168 almostMinDist = pHit.distance();
181 Info<<
"Did not find edge close to point " << nearPoint <<
endl;
188 Info<<
"Found to point " << nearPoint <<
nl 189 <<
" nearest edge : " << minI
190 <<
" distance " << minDist <<
" endpoints " 191 << mesh.
edges()[minI].line(points) <<
nl 192 <<
" next nearest edge : " << almostMinI
193 <<
" distance " << almostMinDist <<
" endpoints " 194 << mesh.
edges()[almostMinI].line(points) <<
nl 197 if (almostMinDist < 2*minDist)
199 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
215 const point& nearPoint
221 scalar minDist = great;
224 scalar almostMinDist = great;
225 label almostMinI = -1;
229 pointHit pHit(pp[patchFacei].nearestPoint(nearPoint, points));
238 minDist = pHit.distance();
241 else if (pHit.distance() < almostMinDist)
243 almostMinDist = pHit.distance();
251 Info<<
"Did not find face close to point " << nearPoint <<
endl;
258 Info<<
"Found to point " << nearPoint <<
nl 259 <<
" nearest face : " << minI
260 <<
" distance " << minDist
262 <<
" next nearest face : " << almostMinI
263 <<
" distance " << almostMinDist
264 <<
" to face centre " << mesh.
faceCentres()[almostMinI] <<
nl 267 if (almostMinDist < 2*minDist)
269 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
292 scalar minDistSqr = great;
296 label pointi = cPoints[i];
298 scalar distSqr =
magSqr(nearPoint - mesh.
points()[pointi]);
300 if (distSqr < minDistSqr)
302 minDistSqr = distSqr;
308 Info<<
"Found to point " << nearPoint <<
nl 309 <<
" nearest cell : " << celli
312 <<
" nearest mesh point : " << minI
314 <<
" to " << mesh.
points()[minI] <<
nl 317 if (minDistSqr < 4*distToCcSqr)
319 Info<<
"Mesh point too close to nearest cell centre. Aborting" 330 int main(
int argc,
char *argv[])
336 runTime.functionObjects().off();
338 const word oldInstance = mesh.pointsInstance();
355 || edgesToSplit.size()
356 || facesToTriangulate.size()
361 bool collapseEdge = edgesToCollapse.
size();
365 bool cellsToSplit = cellsToPyramidise.
size();
371 <<
" Boundary cutting module:" <<
nl 372 <<
" points to move :" << pointsToMove.size() <<
nl 373 <<
" edges to split :" << edgesToSplit.size() <<
nl 374 <<
" faces to triangulate:" << facesToTriangulate.size() <<
nl 375 <<
" Cell splitting module:" <<
nl 376 <<
" cells to split :" << cellsToPyramidise.size() <<
nl 377 <<
" Edge collapsing module:" <<
nl 378 <<
" edges to collapse :" << edgesToCollapse.size() <<
nl 384 (cutBoundary && collapseEdge)
385 || (cutBoundary && cellsToSplit)
386 || (collapseEdge && cellsToSplit)
390 <<
"Used more than one mesh modifying module " 391 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl 410 bool validInputs =
true;
413 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
419 label pointi = findPoint(allBoundary, pts.
first());
421 if (pointi == -1 || !pointToPos.insert(pointi, pts.
second()))
423 Info<<
"Could not insert mesh point " << pointi
424 <<
" for input point " << pts.
first() <<
nl 425 <<
"Perhaps the point is already marked for moving?" <<
endl;
431 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
445 Info<<
"Could not insert mesh edge " << edgeI
446 <<
" for input point " << pts.
first() <<
nl 447 <<
"Perhaps the edge is already marked for cutting?" <<
endl;
454 Info<<
nl <<
"Looking up faces to triangulate ..." <<
nl <<
endl;
455 Map<point> faceToDecompose(facesToTriangulate.size());
456 forAll(facesToTriangulate, i)
460 label facei = findFace(mesh, allBoundary, pts.
first());
462 if (facei == -1 || !faceToDecompose.insert(facei, pts.
second()))
464 Info<<
"Could not insert mesh face " << facei
465 <<
" for input point " << pts.
first() <<
nl 466 <<
"Perhaps the face is already marked for splitting?" <<
endl;
474 Info<<
nl <<
"Looking up cells to convert to pyramids around" 475 <<
" cell centre ..." <<
nl <<
endl;
476 Map<point> cellToPyrCentre(cellsToPyramidise.size());
477 forAll(cellsToPyramidise, i)
483 if (celli == -1 || !cellToPyrCentre.insert(celli, pts.
second()))
485 Info<<
"Could not insert mesh cell " << celli
486 <<
" for input point " << pts.
first() <<
nl 487 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
494 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
496 forAll(edgesToCollapse, i)
502 if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.
second()))
504 Info<<
"Could not insert mesh edge " << edgeI
505 <<
" for input point " << pts.
first() <<
nl 506 <<
"Perhaps the edge is already marked for collapsing?" <<
endl;
516 Info<<
nl <<
"There was a problem in one of the inputs in the" 517 <<
" dictionary. Not modifying mesh." <<
endl;
519 else if (cellToPyrCentre.size())
521 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
530 cutter.setRefinement(cellToPyrCentre, meshMod);
535 if (map().hasMotionPoints())
537 mesh.setPoints(map().preMotionPoints());
540 cutter.topoChange(map());
548 mesh.setInstance(oldInstance);
552 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
555 else if (edgeToPos.size())
557 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
573 label edgeI = iter.key();
574 const edge& e = edges[edgeI];
576 collapseEdge[edgeI] =
true;
577 collapsePointToLocation.set(e[1], points[e[0]]);
579 newPoints[e[0]] = iter();
583 mesh.setPoints(newPoints);
589 cutter.consistentCollapse
593 collapsePointToLocation,
602 cutter.setRefinement(allPointInfo, meshMod);
607 if (map().hasMotionPoints())
609 mesh.setPoints(map().preMotionPoints());
622 mesh.setInstance(oldInstance);
626 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
631 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
652 if (map().hasMotionPoints())
654 mesh.setPoints(map().preMotionPoints());
657 cutter.topoChange(map());
665 mesh.setInstance(oldInstance);
669 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
label findCell(const point &location) const
Find cell enclosing this location (-1 if not in mesh)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
label nInternalFaces() const
Cell-face mesh analysis engine.
void size(const label)
Override size to be inconsistent with allocated storage.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
virtual const pointField & points() const =0
Return mesh points.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
scalar minDist(const List< pointIndexHit > &hitList)
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Does pyramidal decomposition of selected cells. So all faces will become base of pyramid with as top ...
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
A List obtained as a section of another List.
linePointRef line(const pointField &) const
Return edge line.
An ordered pair of two objects of type <T> with first() and second() elements.
const fileName & name() const
Return the dictionary name.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling words, derived from string.
const Field< PointType > & points() const
Return reference to global points.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const vectorField & cellCentres() const
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Type & second() const
Return second.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
Calculates points shared by more than two processor patches or cyclic patches.
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual const faceList & faces() const =0
Return faces.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Foam::argList args(argc, argv)
const Type & first() const
Return first.
Does modifications to boundary faces.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
const labelListList & cellPoints() const
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
A HashTable to objects of type <T> with a label key.