75 scalar minDistSqr = great;
78 scalar almostMinDistSqr = great;
79 label almostMinI = -1;
83 label pointi = meshPoints[i];
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
108 <<
" next nearest point : " << almostMinI
109 <<
" distance " <<
Foam::sqrt(almostMinDistSqr)
112 if (almostMinDistSqr < 4*minDistSqr)
114 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
130 const point& nearPoint
142 scalar almostMinDist = great;
143 label almostMinI = -1;
147 const edge&
e = edges[edgeI];
149 pointHit pHit(
e.line(localPoints).nearestDist(nearPoint));
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 "
192 <<
" next nearest edge : " << almostMinI
193 <<
" distance " << almostMinDist <<
" endpoints "
199 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
215 const point& nearPoint
224 scalar almostMinDist = great;
225 label almostMinI = -1;
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
262 <<
" next nearest face : " << almostMinI
263 <<
" distance " << almostMinDist
264 <<
" to face centre " << mesh.
faceCentres()[almostMinI] <<
nl
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[])
337 const word oldInstance = mesh.pointsInstance();
354 || edgesToSplit.size()
355 || facesToTriangulate.size()
364 bool cellsToSplit = cellsToPyramidise.size();
370 <<
" Boundary cutting module:" <<
nl
371 <<
" points to move :" << pointsToMove.size() <<
nl
372 <<
" edges to split :" << edgesToSplit.size() <<
nl
373 <<
" faces to triangulate:" << facesToTriangulate.size() <<
nl
374 <<
" Cell splitting module:" <<
nl
375 <<
" cells to split :" << cellsToPyramidise.size() <<
nl
376 <<
" Edge collapsing module:" <<
nl
377 <<
" edges to collapse :" << edgesToCollapse.size() <<
nl
384 || (cutBoundary && cellsToSplit)
389 <<
"Used more than one mesh modifying module "
390 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl
409 bool validInputs =
true;
412 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
418 label pointi = findPoint(allBoundary, pts.
first());
420 if (pointi == -1 || !pointToPos.insert(pointi, pts.
second()))
422 Info<<
"Could not insert mesh point " << pointi
423 <<
" for input point " << pts.
first() <<
nl
424 <<
"Perhaps the point is already marked for moving?" <<
endl;
430 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
444 Info<<
"Could not insert mesh edge " << edgeI
445 <<
" for input point " << pts.
first() <<
nl
446 <<
"Perhaps the edge is already marked for cutting?" <<
endl;
453 Info<<
nl <<
"Looking up faces to triangulate ..." <<
nl <<
endl;
454 Map<point> faceToDecompose(facesToTriangulate.size());
455 forAll(facesToTriangulate, i)
459 label facei = findFace(mesh, allBoundary, pts.
first());
461 if (facei == -1 || !faceToDecompose.insert(facei, pts.
second()))
463 Info<<
"Could not insert mesh face " << facei
464 <<
" for input point " << pts.
first() <<
nl
465 <<
"Perhaps the face is already marked for splitting?" <<
endl;
473 Info<<
nl <<
"Looking up cells to convert to pyramids around"
474 <<
" cell centre ..." <<
nl <<
endl;
475 Map<point> cellToPyrCentre(cellsToPyramidise.size());
476 forAll(cellsToPyramidise, i)
482 if (celli == -1 || !cellToPyrCentre.insert(celli, pts.
second()))
484 Info<<
"Could not insert mesh cell " << celli
485 <<
" for input point " << pts.
first() <<
nl
486 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
493 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
495 forAll(edgesToCollapse, i)
501 if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.
second()))
503 Info<<
"Could not insert mesh edge " << edgeI
504 <<
" for input point " << pts.
first() <<
nl
505 <<
"Perhaps the edge is already marked for collapsing?" <<
endl;
515 Info<<
nl <<
"There was a problem in one of the inputs in the"
516 <<
" dictionary. Not modifying mesh." <<
endl;
518 else if (cellToPyrCentre.size())
520 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
529 cutter.setRefinement(cellToPyrCentre, meshMod);
534 if (map().hasMotionPoints())
536 mesh.setPoints(map().preMotionPoints());
539 cutter.topoChange(map());
547 mesh.setInstance(oldInstance);
551 Info<<
"Writing modified mesh to time " << runTime.name() <<
endl;
554 else if (edgeToPos.size())
556 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
572 label edgeI = iter.key();
573 const edge&
e = edges[edgeI];
576 collapsePointToLocation.set(
e[1],
points[
e[0]]);
578 newPoints[
e[0]] = iter();
582 mesh.setPoints(newPoints);
588 cutter.consistentCollapse
592 collapsePointToLocation,
601 cutter.setRefinement(allPointInfo, meshMod);
606 if (map().hasMotionPoints())
608 mesh.setPoints(map().preMotionPoints());
621 mesh.setInstance(oldInstance);
625 Info<<
"Writing modified mesh to time " << runTime.name() <<
endl;
630 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
651 if (map().hasMotionPoints())
653 mesh.setPoints(map().preMotionPoints());
656 cutter.topoChange(map());
664 mesh.setInstance(oldInstance);
668 Info<<
"Writing modified mesh to time " << runTime.name() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A HashTable to objects of type <T> with a label key.
An ordered pair of two objects of type <T> with first() and second() elements.
const Type & second() const
Return second.
const Type & first() const
Return first.
A list of faces which address into the list of points.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const Field< PointType > & points() const
Return reference to global points.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A List obtained as a section of another List.
bool optionFound(const word &opt) const
Return true if the named option is found.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Does modifications to boundary faces.
Does pyramidal decomposition of selected cells. So all faces will become base of pyramid with as top ...
const fileName & name() const
Return the dictionary name.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Calculates points shared by more than two processor patches or cyclic patches.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
virtual const faceList & faces() const =0
Return faces.
const vectorField & cellCentres() const
label findCell(const point &location) const
Find cell enclosing this location (-1 if not in mesh)
const labelListList & cellPoints() const
label nInternalFaces() const
virtual const pointField & points() const =0
Return mesh points.
A class for handling words, derived from string.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
scalar minDist(const List< pointIndexHit > &hitList)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::argList args(argc, argv)