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];
153 if (pHit.distance() < minDist)
155 almostMinDist = minDist;
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));
233 if (pHit.distance() < minDist)
235 almostMinDist = minDist;
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" 332 int main(
int argc,
char *argv[])
338 runTime.functionObjects().off();
340 const word oldInstance = mesh.pointsInstance();
344 Info<<
"Reading modifyMeshDict\n" <<
endl;
369 || edgesToSplit.size()
370 || facesToTriangulate.size()
375 bool collapseEdge = edgesToCollapse.
size();
379 bool cellsToSplit = cellsToPyramidise.
size();
385 <<
" Boundary cutting module:" <<
nl 386 <<
" points to move :" << pointsToMove.size() <<
nl 387 <<
" edges to split :" << edgesToSplit.size() <<
nl 388 <<
" faces to triangulate:" << facesToTriangulate.size() <<
nl 389 <<
" Cell splitting module:" <<
nl 390 <<
" cells to split :" << cellsToPyramidise.size() <<
nl 391 <<
" Edge collapsing module:" <<
nl 392 <<
" edges to collapse :" << edgesToCollapse.size() <<
nl 398 (cutBoundary && collapseEdge)
399 || (cutBoundary && cellsToSplit)
400 || (collapseEdge && cellsToSplit)
404 <<
"Used more than one mesh modifying module " 405 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl 424 bool validInputs =
true;
427 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
433 label pointi = findPoint(allBoundary, pts.
first());
435 if (pointi == -1 || !pointToPos.insert(pointi, pts.
second()))
437 Info<<
"Could not insert mesh point " << pointi
438 <<
" for input point " << pts.
first() <<
nl 439 <<
"Perhaps the point is already marked for moving?" <<
endl;
445 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
459 Info<<
"Could not insert mesh edge " << edgeI
460 <<
" for input point " << pts.
first() <<
nl 461 <<
"Perhaps the edge is already marked for cutting?" <<
endl;
468 Info<<
nl <<
"Looking up faces to triangulate ..." <<
nl <<
endl;
469 Map<point> faceToDecompose(facesToTriangulate.size());
470 forAll(facesToTriangulate, i)
474 label facei = findFace(mesh, allBoundary, pts.
first());
476 if (facei == -1 || !faceToDecompose.insert(facei, pts.
second()))
478 Info<<
"Could not insert mesh face " << facei
479 <<
" for input point " << pts.
first() <<
nl 480 <<
"Perhaps the face is already marked for splitting?" <<
endl;
488 Info<<
nl <<
"Looking up cells to convert to pyramids around" 489 <<
" cell centre ..." <<
nl <<
endl;
490 Map<point> cellToPyrCentre(cellsToPyramidise.size());
491 forAll(cellsToPyramidise, i)
497 if (celli == -1 || !cellToPyrCentre.insert(celli, pts.
second()))
499 Info<<
"Could not insert mesh cell " << celli
500 <<
" for input point " << pts.
first() <<
nl 501 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
508 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
510 forAll(edgesToCollapse, i)
516 if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.
second()))
518 Info<<
"Could not insert mesh edge " << edgeI
519 <<
" for input point " << pts.
first() <<
nl 520 <<
"Perhaps the edge is already marked for collaping?" <<
endl;
530 Info<<
nl <<
"There was a problem in one of the inputs in the" 531 <<
" dictionary. Not modifying mesh." <<
endl;
533 else if (cellToPyrCentre.size())
535 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
544 cutter.setRefinement(cellToPyrCentre, meshMod);
549 if (morphMap().hasMotionPoints())
551 mesh.
movePoints(morphMap().preMotionPoints());
554 cutter.updateMesh(morphMap());
562 mesh.setInstance(oldInstance);
566 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
569 else if (edgeToPos.size())
571 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
587 label edgeI = iter.key();
588 const edge& e = edges[edgeI];
590 collapseEdge[edgeI] =
true;
591 collapsePointToLocation.set(e[1], points[e[0]]);
593 newPoints[e[0]] = iter();
603 cutter.consistentCollapse
607 collapsePointToLocation,
616 cutter.setRefinement(allPointInfo, meshMod);
621 if (morphMap().hasMotionPoints())
623 mesh.
movePoints(morphMap().preMotionPoints());
636 mesh.setInstance(oldInstance);
640 Info<<
"Writing modified mesh to time " << runTime.timeName() <<
endl;
645 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
666 if (morphMap().hasMotionPoints())
668 mesh.
movePoints(morphMap().preMotionPoints());
671 cutter.updateMesh(morphMap());
679 mesh.setInstance(oldInstance);
683 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)
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)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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 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 ...
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.
linePointRef line(const pointField &) const
Return edge line.
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.
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
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Field< PointType > & localPoints() const
Return pointField of points in patch.
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...
scalar distance() const
Return distance to hit.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
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.