74 scalar minDistSqr = GREAT;
77 scalar almostMinDistSqr = GREAT;
78 label almostMinI = -1;
82 label pointi = meshPoints[i];
84 scalar distSqr =
magSqr(nearPoint - points[pointi]);
86 if (distSqr < minDistSqr)
88 almostMinDistSqr = minDistSqr;
94 else if (distSqr < almostMinDistSqr)
96 almostMinDistSqr = distSqr;
103 Info<<
"Found to point " << nearPoint <<
nl 104 <<
" nearest point : " << minI
106 <<
" at " << points[minI] <<
nl 107 <<
" next nearest point : " << almostMinI
108 <<
" distance " <<
Foam::sqrt(almostMinDistSqr)
109 <<
" at " << points[almostMinI] <<
endl;
111 if (almostMinDistSqr < 4*minDistSqr)
113 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
129 const point& nearPoint
138 scalar minDist = GREAT;
141 scalar almostMinDist = GREAT;
142 label almostMinI = -1;
146 const edge& e = edges[edgeI];
152 if (pHit.distance() < minDist)
154 almostMinDist = minDist;
165 else if (pHit.distance() < almostMinDist)
167 almostMinDist = pHit.distance();
180 Info<<
"Did not find edge close to point " << nearPoint <<
endl;
187 Info<<
"Found to point " << nearPoint <<
nl 188 <<
" nearest edge : " << minI
189 <<
" distance " << minDist <<
" endpoints " 190 << mesh.
edges()[minI].line(points) <<
nl 191 <<
" next nearest edge : " << almostMinI
192 <<
" distance " << almostMinDist <<
" endpoints " 193 << mesh.
edges()[almostMinI].line(points) <<
nl 196 if (almostMinDist < 2*minDist)
198 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
214 const point& nearPoint
220 scalar minDist = GREAT;
223 scalar almostMinDist = GREAT;
224 label almostMinI = -1;
228 pointHit pHit(pp[patchFacei].nearestPoint(nearPoint, points));
232 if (pHit.distance() < minDist)
234 almostMinDist = minDist;
237 minDist = pHit.distance();
240 else if (pHit.distance() < almostMinDist)
242 almostMinDist = pHit.distance();
250 Info<<
"Did not find face close to point " << nearPoint <<
endl;
257 Info<<
"Found to point " << nearPoint <<
nl 258 <<
" nearest face : " << minI
259 <<
" distance " << minDist
261 <<
" next nearest face : " << almostMinI
262 <<
" distance " << almostMinDist
263 <<
" to face centre " << mesh.
faceCentres()[almostMinI] <<
nl 266 if (almostMinDist < 2*minDist)
268 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
291 scalar minDistSqr = GREAT;
295 label pointi = cPoints[i];
297 scalar distSqr =
magSqr(nearPoint - mesh.
points()[pointi]);
299 if (distSqr < minDistSqr)
301 minDistSqr = distSqr;
307 Info<<
"Found to point " << nearPoint <<
nl 308 <<
" nearest cell : " << celli
311 <<
" nearest mesh point : " << minI
313 <<
" to " << mesh.
points()[minI] <<
nl 316 if (minDistSqr < 4*distToCcSqr)
318 Info<<
"Mesh point too close to nearest cell centre. Aborting" 331 int main(
int argc,
char *argv[])
337 runTime.functionObjects().off();
339 const word oldInstance = mesh.pointsInstance();
343 Info<<
"Reading modifyMeshDict\n" <<
endl;
368 || edgesToSplit.size()
369 || facesToTriangulate.size()
374 bool collapseEdge = edgesToCollapse.
size();
378 bool cellsToSplit = cellsToPyramidise.
size();
384 <<
" Boundary cutting module:" <<
nl 385 <<
" points to move :" << pointsToMove.size() <<
nl 386 <<
" edges to split :" << edgesToSplit.size() <<
nl 387 <<
" faces to triangulate:" << facesToTriangulate.size() <<
nl 388 <<
" Cell splitting module:" <<
nl 389 <<
" cells to split :" << cellsToPyramidise.size() <<
nl 390 <<
" Edge collapsing module:" <<
nl 391 <<
" edges to collapse :" << edgesToCollapse.size() <<
nl 397 (cutBoundary && collapseEdge)
398 || (cutBoundary && cellsToSplit)
399 || (collapseEdge && cellsToSplit)
403 <<
"Used more than one mesh modifying module " 404 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl 423 bool validInputs =
true;
426 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
432 label pointi = findPoint(allBoundary, pts.
first());
434 if (pointi == -1 || !pointToPos.insert(pointi, pts.
second()))
436 Info<<
"Could not insert mesh point " << pointi
437 <<
" for input point " << pts.
first() <<
nl 438 <<
"Perhaps the point is already marked for moving?" <<
endl;
444 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
458 Info<<
"Could not insert mesh edge " << edgeI
459 <<
" for input point " << pts.
first() <<
nl 460 <<
"Perhaps the edge is already marked for cutting?" <<
endl;
467 Info<<
nl <<
"Looking up faces to triangulate ..." <<
nl <<
endl;
468 Map<point> faceToDecompose(facesToTriangulate.size());
469 forAll(facesToTriangulate, i)
473 label facei = findFace(mesh, allBoundary, pts.
first());
475 if (facei == -1 || !faceToDecompose.insert(facei, pts.
second()))
477 Info<<
"Could not insert mesh face " << facei
478 <<
" for input point " << pts.
first() <<
nl 479 <<
"Perhaps the face is already marked for splitting?" <<
endl;
487 Info<<
nl <<
"Looking up cells to convert to pyramids around" 488 <<
" cell centre ..." <<
nl <<
endl;
489 Map<point> cellToPyrCentre(cellsToPyramidise.size());
490 forAll(cellsToPyramidise, i)
496 if (celli == -1 || !cellToPyrCentre.insert(celli, pts.
second()))
498 Info<<
"Could not insert mesh cell " << celli
499 <<
" for input point " << pts.
first() <<
nl 500 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
507 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
509 forAll(edgesToCollapse, i)
515 if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.
second()))
517 Info<<
"Could not insert mesh edge " << edgeI
518 <<
" for input point " << pts.
first() <<
nl 519 <<
"Perhaps the edge is already marked for collaping?" <<
endl;
529 Info<<
nl <<
"There was a problem in one of the inputs in the" 530 <<
" dictionary. Not modifying mesh." <<
endl;
532 else if (cellToPyrCentre.size())
534 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
543 cutter.setRefinement(cellToPyrCentre, meshMod);
548 if (morphMap().hasMotionPoints())
550 mesh.
movePoints(morphMap().preMotionPoints());
553 cutter.updateMesh(morphMap());
561 mesh.setInstance(oldInstance);
565 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
568 else if (edgeToPos.size())
570 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
586 label edgeI = iter.key();
587 const edge& e = edges[edgeI];
589 collapseEdge[edgeI] =
true;
590 collapsePointToLocation.set(e[1], points[e[0]]);
592 newPoints[e[0]] = iter();
602 cutter.consistentCollapse
606 collapsePointToLocation,
615 cutter.setRefinement(allPointInfo, meshMod);
620 if (morphMap().hasMotionPoints())
622 mesh.
movePoints(morphMap().preMotionPoints());
635 mesh.setInstance(oldInstance);
639 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
644 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
665 if (morphMap().hasMotionPoints())
667 mesh.
movePoints(morphMap().preMotionPoints());
670 cutter.updateMesh(morphMap());
678 mesh.setInstance(oldInstance);
682 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
linePointRef line(const pointField &) const
Return edge line.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelListList & cellPoints() const
const Type & second() const
Return second.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
const Field< PointType > & points() const
Return reference to global points.
virtual const pointField & points() const =0
Return mesh points.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
const Type & first() const
Return first.
const fileName & name() const
Return the dictionary name.
const vectorField & faceCentres() const
Does pyramidal decomposition of selected cells. So all faces will become base of pyramid with as top ...
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
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.
scalar distance() const
Return distance to hit.
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
An ordered pair of two objects of type <T> with first() and second() elements.
bool optionFound(const word &opt) const
Return true if the named option is found.
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 edgeList & edges() const
Return list of edges, address into LOCAL point list.
const vectorField & cellCentres() const
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
label findCell(const point &location) const
Find cell enclosing this location (-1 if not in mesh)
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.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
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)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
label nInternalFaces() const
Does modifications to boundary faces.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A HashTable to objects of type <T> with a label key.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.