Go to the documentation of this file.
83 scalar minDistSqr = GREAT;
86 scalar almostMinDistSqr = GREAT;
87 label almostMinI = -1;
89 for (
const label pointi : meshPoints)
93 if (distSqr < minDistSqr)
95 almostMinDistSqr = minDistSqr;
101 else if (distSqr < almostMinDistSqr)
103 almostMinDistSqr = distSqr;
110 Info<<
"Found to point " << nearPoint <<
nl
111 <<
" nearest point : " << minI
114 <<
" next nearest point : " << almostMinI
115 <<
" distance " <<
Foam::sqrt(almostMinDistSqr)
118 if (almostMinDistSqr < 4*minDistSqr)
120 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
136 const point& nearPoint
145 scalar minDist = GREAT;
148 scalar almostMinDist = GREAT;
149 label almostMinI = -1;
151 for (
const edge&
e : edges)
153 pointHit pHit(
e.line(localPoints).nearestDist(nearPoint));
157 if (pHit.distance() < minDist)
159 almostMinDist = minDist;
170 else if (pHit.distance() < almostMinDist)
172 almostMinDist = pHit.distance();
185 Info<<
"Did not find edge close to point " << nearPoint <<
endl;
192 Info<<
"Found to point " << nearPoint <<
nl
193 <<
" nearest edge : " << minI
194 <<
" distance " << minDist <<
" endpoints "
196 <<
" next nearest edge : " << almostMinI
197 <<
" distance " << almostMinDist <<
" endpoints "
201 if (almostMinDist < 2*minDist)
203 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
219 const point& nearPoint
225 scalar minDist = GREAT;
228 scalar almostMinDist = GREAT;
229 label almostMinI = -1;
237 if (pHit.distance() < minDist)
239 almostMinDist = minDist;
242 minDist = pHit.distance();
245 else if (pHit.distance() < almostMinDist)
247 almostMinDist = pHit.distance();
255 Info<<
"Did not find face close to point " << nearPoint <<
endl;
262 Info<<
"Found to point " << nearPoint <<
nl
263 <<
" nearest face : " << minI
264 <<
" distance " << minDist
266 <<
" next nearest face : " << almostMinI
267 <<
" distance " << almostMinDist
271 if (almostMinDist < 2*minDist)
273 Info<<
"Next nearest too close to nearest. Aborting" <<
endl;
296 scalar minDistSqr = GREAT;
298 for (
const label pointi : cPoints)
302 if (distSqr < minDistSqr)
304 minDistSqr = distSqr;
310 Info<<
"Found to point " << nearPoint <<
nl
311 <<
" nearest cell : " << celli
314 <<
" nearest mesh point : " << minI
319 if (minDistSqr < 4*distToCcSqr)
321 Info<<
"Mesh point too close to nearest cell centre. Aborting"
334 int main(
int argc,
char *argv[])
338 "Manipulate mesh elements.\n"
339 "For example, moving points, splitting/collapsing edges etc."
352 const bool overwrite =
args.
found(
"overwrite");
354 Info<<
"Reading modifyMeshDict\n" <<
endl;
372 || edgesToSplit.size()
373 || facesToTriangulate.size()
382 bool cellsToSplit = cellsToPyramidise.size();
388 <<
" Boundary cutting module:" <<
nl
389 <<
" points to move :" << pointsToMove.size() <<
nl
390 <<
" edges to split :" << edgesToSplit.size() <<
nl
391 <<
" faces to triangulate:" << facesToTriangulate.size() <<
nl
392 <<
" Cell splitting module:" <<
nl
393 <<
" cells to split :" << cellsToPyramidise.size() <<
nl
394 <<
" Edge collapsing module:" <<
nl
395 <<
" edges to collapse :" << edgesToCollapse.size() <<
nl
402 || (cutBoundary && cellsToSplit)
407 <<
"Used more than one mesh modifying module "
408 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl
427 bool validInputs =
true;
430 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
434 const label pointi = findPoint(allBoundary, pts.first());
436 if (pointi == -1 || !pointToPos.insert(pointi, pts.second()))
438 Info<<
"Could not insert mesh point " << pointi
439 <<
" for input point " << pts.first() <<
nl
440 <<
"Perhaps the point is already marked for moving?" <<
endl;
446 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
455 || !edgeToCuts.insert(edgeI,
List<point>(1, pts.second()))
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());
471 label facei = findFace(
mesh, allBoundary, pts.first());
473 if (facei == -1 || !faceToDecompose.insert(facei, pts.second()))
475 Info<<
"Could not insert mesh face " << facei
476 <<
" for input point " << pts.first() <<
nl
477 <<
"Perhaps the face is already marked for splitting?" <<
endl;
485 Info<<
nl <<
"Looking up cells to convert to pyramids around"
486 <<
" cell centre ..." <<
nl <<
endl;
487 Map<point> cellToPyrCentre(cellsToPyramidise.size());
490 label celli = findCell(
mesh, pts.first());
492 if (celli == -1 || !cellToPyrCentre.insert(celli, pts.second()))
494 Info<<
"Could not insert mesh cell " << celli
495 <<
" for input point " << pts.first() <<
nl
496 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
503 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
509 if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.second()))
511 Info<<
"Could not insert mesh edge " << edgeI
512 <<
" for input point " << pts.first() <<
nl
513 <<
"Perhaps the edge is already marked for collaping?" <<
endl;
523 Info<<
nl <<
"There was a problem in one of the inputs in the"
524 <<
" dictionary. Not modifying mesh." <<
endl;
526 else if (cellToPyrCentre.size())
528 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
537 cutter.setRefinement(cellToPyrCentre, meshMod);
542 if (morphMap().hasMotionPoints())
547 cutter.updateMesh(morphMap());
564 else if (edgeToPos.size())
566 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
582 label edgeI = iter.key();
583 const edge&
e = edges[edgeI];
586 collapsePointToLocation.set(
e[1],
points[
e[0]]);
588 newPoints[
e[0]] = iter.val();
598 cutter.consistentCollapse
602 collapsePointToLocation,
611 cutter.setRefinement(allPointInfo, meshMod);
616 if (morphMap().hasMotionPoints())
642 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
663 if (morphMap().hasMotionPoints())
668 cutter.updateMesh(morphMap());
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
Calculates points shared by more than two processor patches or cyclic patches.
A class for handling words, derived from Foam::string.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Does modifications to boundary faces.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const labelListList & cellPoints() const
static constexpr const zero Zero
Global zero (0)
label nInternalFaces() const
Number of internal faces.
A List obtained as a section of another List.
static word timeName(const scalar t, const int precision=precision_)
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static void addNote(const string ¬e)
Add extra notes for the usage information.
const word dictName("blockMeshDict")
label nEdges() const
Number of mesh edges.
A HashTable to objects of type <T> with a label key.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
const fileName & pointsInstance() const
Return the current instance directory for points.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
const fileName & name() const
The dictionary name.
scalar distance() const
Return distance to hit.
messageStream Info
Information stream (uses stdout - output is on the master only)
Does pyramidal decomposition of selected cells. So all faces will become base of pyramid with as top ...
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label nBoundaryFaces() const
Number of boundary faces (== nFaces - nInternalFaces)
const Field< point_type > & points() const
Return reference to global points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An ordered pair of two objects of type <T> with first() and second() elements.
forAllConstIters(mixture.phases(), phase)
dimensionedScalar sqrt(const dimensionedScalar &ds)
const vectorField & faceCentres() const
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
const dimensionedScalar e
Elementary charge.
label nPoints() const
Number of 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.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
bool found(const word &optName) const
Return true if the named option is found.
A list of faces which address into the list of points.
Cell-face mesh analysis engine.