69 label fp0 =
f.find(
e[0]);
70 label fp1 =
f.fcIndex(fp0);
71 label fp2 =
f.fcIndex(fp1);
156void createBoundaryEdgeTrees
168 treeBoundaryEdges[surfI] =
197 treeBoundaryEdges[surfI]
209class findNearestOpSubset
224 shapeMask_(shapeMask)
232 scalar& nearestDistSqr,
239 for (
const label index : indices)
241 const label edgeIndex = shape.
edgeLabels()[index];
243 if (shapeMask_.
found(edgeIndex))
257 if (distSqr < nearestDistSqr)
259 nearestDistSqr = distSqr;
271int main(
int argc,
char *argv[])
275 "Hook surfaces to other surfaces by moving and retriangulating their"
276 " boundary edges to match other surface boundary edges"
278 argList::noParallel();
279 argList::addArgument(
"hookTolerance",
"The point merge tolerance");
280 argList::addOption(
"dict",
"file",
"Alternative surfaceHookUpDict");
292 const scalar dist(
args.
get<scalar>(1));
293 const scalar matchTolerance(
max(1
e-6*dist, SMALL));
294 const label maxIters = 100;
296 Info<<
"Hooking distance = " << dist <<
endl;
317 const wordList& regions = surfs[surfI].regions();
318 forAll(regions, surfRegionI)
338 refCast<const triSurfaceMesh>(surfs[surfI]);
347 "hookedSurface_" + surfs.names()[surfI],
362 Info<<
nl <<
"Iteration = " << nIters++ <<
endl;
365 createBoundaryEdgeTrees(newSurfaces, bEdgeTrees, treeBoundaryEdges);
367 forAll(newSurfaces, surfI)
369 const triSurface& newSurf = newSurfaces[surfI];
373 visitedFace[surfI] =
bitSet(newSurf.
size(),
false);
376 forAll(newSurfaces, surfI)
385 forAll(bPointsTobEdges, bPointi)
392 const labelList& pEdges = pointEdges[pointi];
404 bEdgeTree.findNearest
429 nearestHit = currentHit;
430 bPointsHitTree[bPointi] = treeI;
436 if (nearestHit.
hit())
454 forAll(bPointsTobEdges, bPointi)
460 const label hitSurfI = bPointsHitTree[bPointi];
461 const triSurface& hitSurf = newSurfaces[hitSurfI];
464 treeBoundaryEdges[hitSurfI][eHit.
index()];
471 if (eFaces.
size() != 1)
474 <<
"Edge is attached to " << eFaces.
size()
475 <<
" faces." <<
endl;
480 const label facei = eFaces[0];
482 if (visitedFace[hitSurfI][facei])
511 if (hitSurfI == surfI)
517 newPoints[hitSurfI].append(newPoints[surfI][pointi]);
518 newPointi = newPoints[hitSurfI].size() - 1;
531 visitedFace[hitSurfI].set(facei);
533 forAll(newFacesFromSplit, newFacei)
535 const labelledTri& fN = newFacesFromSplit[newFacei];
539 newFaces[hitSurfI][facei] = fN;
543 newFaces[hitSurfI].
append(fN);
550 Info<<
" Number of edges split = " << nChanged <<
endl;
552 forAll(newSurfaces, surfI)
561 "hookedSurface_" + surfs.names()[surfI],
576 }
while (nChanged > 0 && nIters <= maxIters);
580 forAll(newSurfaces, surfI)
584 Info<<
"Writing hooked surface " << newSurf.searchableSurface::name()
587 newSurf.searchableSurface::write();
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Minimal example by using system/controlDict.functions:
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
const point_type & rawPoint() const noexcept
The point, no checks.
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const point_type & rawPoint() const noexcept
The point, no checks. Same as point()
label index() const noexcept
Return the hit index.
void setMiss() noexcept
Set the hit status off.
bool hit() const noexcept
Is there a hit?
const point_type & hitPoint() const
Return hit point. Fatal if not hit.
label nEdges() const
Number of edges in patch.
const labelListList & pointEdges() const
Return point-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalEdges() const
Number of internal edges.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool found(const T &val, label pos=0) const
True if the value if found in the list.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
T get(const label index) const
Get a value from the argument at index.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Non-pointer based hierarchical recursive searching.
const Type & shapes() const
Reference to shape.
A triFace with additional (region) index.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Standard boundBox with extra functionality for use in octree.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
Holds data for octree to work on an edges subset.
const edgeList & edges() const
const labelList & edgeLabels() const
const pointField & points() const
IOoject and searching on triSurface.
Triangulated surface description with patch information.
A class for handling words, derived from Foam::string.
const polyBoundaryMesh & patches
const word dictName("faMeshDefinition")
#define WarningInFunction
Report a warning using Foam::Warning.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.