156 void createBoundaryEdgeTrees
168 treeBoundaryEdges[surfI] =
189 treeBoundaryEdges[surfI]
201 class findNearestOpSubset
216 shapeMask_(shapeMask)
224 scalar& nearestDistSqr,
231 for (
const label index : indices)
235 if (shapeMask_.
found(edgeIndex))
247 if (distSqr < nearestDistSqr)
249 nearestDistSqr = distSqr;
251 nearestPoint = nearHit.
point();
261 int main(
int argc,
char *argv[])
265 "Hook surfaces to other surfaces by moving and retriangulating their" 266 " boundary edges to match other surface boundary edges" 282 const scalar dist(
args.
get<scalar>(1));
283 const scalar matchTolerance(
max(1
e-6*dist, SMALL));
286 Info<<
"Hooking distance = " << dist <<
endl;
307 const wordList& regions = surfs[surfI].regions();
308 forAll(regions, surfRegionI)
328 refCast<const triSurfaceMesh>(surfs[surfI]);
337 "hookedSurface_" + surfs.names()[surfI],
352 Info<<
nl <<
"Iteration = " << nIters++ <<
endl;
355 createBoundaryEdgeTrees(newSurfaces, bEdgeTrees, treeBoundaryEdges);
357 forAll(newSurfaces, surfI)
359 const triSurface& newSurf = newSurfaces[surfI];
363 visitedFace[surfI] =
bitSet(newSurf.
size(),
false);
366 forAll(newSurfaces, surfI)
375 forAll(bPointsTobEdges, bPointi)
382 const labelList& pEdges = pointEdges[pointi];
394 bEdgeTree.findNearest
413 currentHit.
point().distSqr(samplePt)
414 < nearestHit.
point().distSqr(samplePt)
419 nearestHit = currentHit;
420 bPointsHitTree[bPointi] = treeI;
424 if (nearestHit.
hit())
435 scalar distSqr = nearestHit.
point().distSqr(samplePt);
444 forAll(bPointsTobEdges, bPointi)
450 const label hitSurfI = bPointsHitTree[bPointi];
451 const triSurface& hitSurf = newSurfaces[hitSurfI];
454 treeBoundaryEdges[hitSurfI][eHit.
index()];
461 if (eFaces.
size() != 1)
464 <<
"Edge is attached to " << eFaces.
size()
465 <<
" faces." <<
endl;
470 const label facei = eFaces[0];
472 if (visitedFace[hitSurfI][facei])
501 if (hitSurfI == surfI)
507 newPoints[hitSurfI].append(newPoints[surfI][pointi]);
508 newPointi = newPoints[hitSurfI].size() - 1;
521 visitedFace[hitSurfI].set(facei);
523 forAll(newFacesFromSplit, newFacei)
525 const labelledTri& fN = newFacesFromSplit[newFacei];
529 newFaces[hitSurfI][facei] = fN;
533 newFaces[hitSurfI].
append(fN);
540 Info<<
" Number of edges split = " << nChanged <<
endl;
542 forAll(newSurfaces, surfI)
551 "hookedSurface_" + surfs.names()[surfI],
566 }
while (nChanged > 0 && nIters <=
maxIters);
570 forAll(newSurfaces, surfI)
574 Info<<
"Writing hooked surface " << newSurf.searchableSurface::name()
577 newSurf.searchableSurface::write();
const labelListList & pointEdges() const
Return point-edge addressing.
void setMiss() noexcept
Set the hit status off.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
Ostream & indent(Ostream &os)
Indent stream.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
const Type & shapes() const noexcept
Reference to shape.
const word & name() const noexcept
Return the object name.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
const word dictName("faMeshDefinition")
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
Holds data for octree to work on an edges subset.
label nInternalEdges() const
Number of internal edges.
static void noParallel()
Remove the parallel options.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
label objectIndex(const label index) const
Map from shape index to original (non-subset) edge label.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
IOoject and searching on triSurface.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return point, no checks.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
A class for handling words, derived from Foam::string.
label size() const noexcept
The number of entries in the list.
Tree tree(triangles.begin(), triangles.end())
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
A triFace with additional (region) index.
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
void append(const T &val)
Copy append an element to the end of this list.
label nBoundaryEdges() const
Number of boundary edges == (nEdges() - nInternalEdges())
label index() const noexcept
Return the hit index.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const word & constant() const noexcept
Return constant name.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
bool hit() const noexcept
Is there a hit?
T get(const label index) const
Get a value from the argument at index.
Non-pointer based hierarchical recursive searching.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
scalar distance() const noexcept
Return distance to hit.
const polyBoundaryMesh & patches
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
const point_type & point() const noexcept
Return the point, no checks.
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static constexpr int maxIters
const linePointRef line(const label index) const
Geometric line for edge at specified shape index. Frequently used.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Defines the attributes of an object for which implicit objectRegistry management is supported...
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.