83 scalar minDistSqr = GREAT;
86 scalar almostMinDistSqr = GREAT;
87 label almostMinI = -1;
89 for (
const label pointi : meshPoints)
91 scalar distSqr = nearPoint.distSqr(
points[pointi]);
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)
300 scalar distSqr = nearPoint.distSqr(
mesh.
points()[pointi]);
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;
375 || edgesToSplit.
size()
376 || facesToTriangulate.
size()
377 || facesToSplit.
size()
386 bool cellsToSplit = cellsToPyramidise.
size();
392 <<
" Boundary cutting module:" <<
nl 393 <<
" points to move :" << pointsToMove.
size() <<
nl 394 <<
" edges to split :" << edgesToSplit.
size() <<
nl 395 <<
" faces to split :" << facesToSplit.
size() <<
nl 396 <<
" faces to triangulate:" << facesToTriangulate.
size() <<
nl 397 <<
" Cell splitting module:" <<
nl 398 <<
" cells to split :" << cellsToPyramidise.
size() <<
nl 399 <<
" Edge collapsing module:" <<
nl 400 <<
" edges to collapse :" << edgesToCollapse.
size() <<
nl 407 || (cutBoundary && cellsToSplit)
412 <<
"Used more than one mesh modifying module " 413 <<
"(boundary cutting, cell splitting, edge collapsing)" <<
nl 432 bool validInputs =
true;
435 Info<<
nl <<
"Looking up points to move ..." <<
nl <<
endl;
439 const label pointi = findPoint(allBoundary,
pts.
first());
441 if (pointi == -1 || !pointToPos.insert(pointi,
pts.second()))
443 Info<<
"Could not insert mesh point " << pointi
445 <<
"Perhaps the point is already marked for moving?" <<
endl;
451 Info<<
nl <<
"Looking up edges to split ..." <<
nl <<
endl;
463 Info<<
"Could not insert mesh edge " << edgeI
465 <<
"Perhaps the edge is already marked for cutting?" <<
endl;
472 Info<<
nl <<
"Looking up faces to triangulate ..." <<
nl <<
endl;
478 if (facei == -1 || !faceToDecompose.insert(facei,
pts.second()))
480 Info<<
"Could not insert mesh face " << facei
482 <<
"Perhaps the face is already marked for splitting?" <<
endl;
489 Info<<
nl <<
"Looking up faces to split ..." <<
nl <<
endl;
496 Info<<
"Could not insert mesh face " << facei
498 <<
"Perhaps the face is already marked for splitting?" <<
endl;
512 const label p1 = findPoint(
pp,
pts.second());
525 Info<<
"Could not insert mesh face " << facei
526 <<
" for input coordinates " <<
pts 527 <<
" with vertices " <<
p0 <<
" and " << p1 <<
nl 528 <<
"Perhaps the face is already marked for splitting?" 536 Info<<
nl <<
"Looking up cells to convert to pyramids around" 537 <<
" cell centre ..." <<
nl <<
endl;
543 if (celli == -1 || !cellToPyrCentre.insert(celli,
pts.second()))
545 Info<<
"Could not insert mesh cell " << celli
547 <<
"Perhaps the cell is already marked for splitting?" <<
endl;
554 Info<<
nl <<
"Looking up edges to collapse ..." <<
nl <<
endl;
560 if (edgeI == -1 || !edgeToPos.insert(edgeI,
pts.second()))
562 Info<<
"Could not insert mesh edge " << edgeI
564 <<
"Perhaps the edge is already marked for collaping?" <<
endl;
574 Info<<
nl <<
"There was a problem in one of the inputs in the" 575 <<
" dictionary. Not modifying mesh." <<
endl;
577 else if (cellToPyrCentre.size())
579 Info<<
nl <<
"All input cells located. Modifying mesh." <<
endl;
588 cutter.setRefinement(cellToPyrCentre, meshMod);
593 if (morphMap().hasMotionPoints())
598 cutter.updateMesh(morphMap());
615 else if (edgeToPos.size())
617 Info<<
nl <<
"All input edges located. Modifying mesh." <<
endl;
633 label edgeI = iter.key();
634 const edge&
e = edges[edgeI];
637 collapsePointToLocation.set(
e[1],
points[
e[0]]);
639 newPoints[
e[0]] = iter.val();
649 cutter.consistentCollapse
653 collapsePointToLocation,
662 cutter.setRefinement(allPointInfo, meshMod);
667 if (morphMap().hasMotionPoints())
693 Info<<
nl <<
"All input points located. Modifying mesh." <<
endl;
714 if (morphMap().hasMotionPoints())
719 cutter.updateMesh(morphMap());
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Cell-face mesh analysis engine.
constexpr char nl
The newline '\n' character (0x0a)
const word dictName("faMeshDefinition")
T & first()
Access first element of the list, position [0].
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
const fileName & name() const noexcept
The dictionary name.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
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...
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
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.
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
const dimensionedScalar e
Elementary charge.
const fileName & pointsInstance() const
Return the current instance directory for points.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A class for handling words, derived from Foam::string.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalFaces() const noexcept
Number of internal faces.
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
const Field< point_type > & points() const noexcept
Return reference to global points.
virtual const faceList & faces() const
Return raw faces.
const vectorField & cellCentres() const
label nEdges() const
Number of mesh edges.
label find(const T &val) const
Find index of the first occurrence of the value.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
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.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Direct mesh changes based on v1.3 polyTopoChange syntax.
scalar distance() const noexcept
Return distance to hit.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
Foam::argList args(argc, argv)
Does modifications to boundary faces.
const volScalarField & p0
bool found(const word &optName) const
Return true if the named option is found.
const labelListList & cellPoints() const
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.
static constexpr const zero Zero
Global zero (0)