45 const vector repatchMesh::splitNormal_(3, 2, 1);
48 const scalar repatchMesh::distanceTol_ = 1
e-2;
63 label edgeI = pEdges[pEdgeI];
65 if (edgeToFeature_[edgeI] != -1)
81 const labelList& pEdges = mesh().pointEdges()[vertI];
85 label nbrEdgeI = pEdges[pEdgeI];
87 if (nbrEdgeI != edgeI)
89 label featI = edgeToFeature_[nbrEdgeI];
108 const label startEdgeI,
114 label edgeI = startEdgeI;
116 const edge&
e = mesh().edges()[edgeI];
120 while (!isFeaturePoint[vertI])
124 edgeI = nextFeatureEdge(edgeI, vertI);
126 if ((edgeI == -1) || (edgeI == startEdgeI))
133 const edge&
e = mesh().edges()[edgeI];
135 vertI =
e.otherVertex(vertI);
147 labelList featLabels(featureEdges_.size());
149 label featLabelI = 0;
151 label initEdgeI = edgeI;
156 label featI = edgeToFeature_[edgeI];
163 featLabels[featLabelI++] = featI;
165 featVisited[featI] =
true;
169 const edge&
e = mesh().edges()[edgeI];
171 vertI =
e.otherVertex(vertI);
175 edgeI = nextFeatureEdge(edgeI, vertI);
177 if ((edgeI == -1) || (edgeI == initEdgeI))
182 while (!isFeaturePoint[vertI]);
186 featLabels.setSize(featLabelI);
202 labelList changedEdges(mesh().nEdges(), -1);
207 label facei = changedFaces[i];
209 const labelList& fEdges = mesh().faceEdges()[facei];
213 label edgeI = fEdges[fEdgeI];
215 if (!regionEdge[edgeI] && (edgeRegion[edgeI] == -1))
217 edgeRegion[edgeI] = region;
219 changedEdges[changedI++] = edgeI;
224 changedEdges.setSize(changedI);
238 labelList changedFaces(mesh().size(), -1);
243 label edgeI = changedEdges[i];
245 const labelList& eFaces = mesh().edgeFaces()[edgeI];
249 label facei = eFaces[eFacei];
251 if (faceRegion[facei] == -1)
253 faceRegion[facei] = region;
255 changedFaces[changedI++] = facei;
260 changedFaces.setSize(changedI);
267 void Foam::repatchMesh::markZone
275 faceZone[facei] = currentZone;
287 changedEdges = faceToEdge
297 Pout<<
"From changedFaces:" << changedFaces.size()
298 <<
" to changedEdges:" << changedEdges.size()
302 if (changedEdges.empty())
307 changedFaces = edgeToFace(currentZone, changedEdges, faceZone);
311 Pout<<
"From changedEdges:" << changedEdges.size()
312 <<
" to changedFaces:" << changedFaces.size()
316 if (changedFaces.empty())
359 meshFace_.setSize(nBFaces);
384 meshFace_[bFacei] = pp.
start() + patchFacei;
386 bFaces[bFacei] = pp[patchFacei];
395 Pout<<
"read : patches now:" <<
endl;
426 const rMesh& msh = *meshPtr_;
428 Pout<<
"** Start of Faces **" <<
endl;
432 const face&
f = msh[facei];
448 Pout<<
"** End of Faces **" <<
endl;
450 Pout<<
"** Start of Points **" <<
endl;
455 <<
" coord:" << msh.
points()[pointi]
459 Pout<<
"** End of Points **" <<
endl;
463 featurePoints_.setSize(0);
464 featureEdges_.setSize(0);
466 featureToEdge_.setSize(0);
467 edgeToFeature_.setSize(meshPtr_->nEdges());
470 featureSegments_.setSize(0);
488 regions[triI] = surf[triI].region();
495 label oldRegion = -1111;
496 label boundPatch = 0;
500 if (regions[i] != oldRegion)
502 regionToBoundaryPatch.
insert(regions[i], boundPatch);
504 oldRegion = regions[i];
513 if (surfPatches.
size() == regionToBoundaryPatch.
size())
518 patches_.setSize(surfPatches.
size());
570 meshFace_.setSize(surf.
size());
575 label surfRegion = regions[0];
576 label foamRegion = regionToBoundaryPatch[surfRegion];
578 Pout<<
"Surface region " << surfRegion <<
" becomes boundary patch "
579 << foamRegion <<
" with name " << patches_[foamRegion].
name() <<
endl;
583 label startFacei = 0;
587 label triI = indices[indexI];
591 if (tri.
region() != surfRegion)
596 bp.
size() = bFacei - startFacei;
597 bp.
start() = startFacei;
599 surfRegion = tri.
region();
600 foamRegion = regionToBoundaryPatch[surfRegion];
602 Pout<<
"Surface region " << surfRegion <<
" becomes boundary patch "
603 << foamRegion <<
" with name " << patches_[foamRegion].
name()
609 meshFace_[bFacei] = triI;
611 bFaces[bFacei++] =
face(tri);
617 bp.
size() = bFacei - startFacei;
618 bp.
start() = startFacei;
628 featurePoints_.setSize(0);
629 featureEdges_.setSize(0);
631 featureToEdge_.setSize(0);
632 edgeToFeature_.setSize(meshPtr_->nEdges());
635 featureSegments_.setSize(0);
665 scalar
sign = mesh().faceNormals()[bFacei] & splitNormal_;
669 rightFaces.
append(bFacei);
682 Pout<<
"getNearest :"
683 <<
" rightBin:" << rightFaces.
size()
684 <<
" leftBin:" << leftFaces.
size()
705 scalar tol = 1
e-6 * overallBb.
avgDim();
717 const scalar planarTol =
758 Pout<<
"getNearest : built trees" <<
endl;
773 const scalar searchDimSqr =
magSqr(searchSpan);
775 forAll(nearestBFacei, patchFacei)
781 if (debug && (patchFacei % 1000) == 0)
783 Pout<<
"getNearest : patchFace:" << patchFacei
784 <<
" meshFacei:" << meshFacei <<
" ctr:" << ctr <<
endl;
790 scalar area =
mag(
n);
793 scalar typDim = -great;
802 pointIndexHit rightInfo = rightTree.findNearest(ctr, searchDimSqr);
806 pointIndexHit leftInfo = leftTree.findNearest(ctr, searchDimSqr);
813 label rightFacei = rightFaces[rightInfo.
index()];
814 label leftFacei = leftFaces[leftInfo.
index()];
819 scalar rightSign =
n & ns[rightFacei];
820 scalar leftSign =
n & ns[leftFacei];
824 (rightSign > 0 && leftSign > 0)
825 || (rightSign < 0 && leftSign < 0)
829 if (rightDist < leftDist)
831 nearestBFacei[patchFacei] = rightFacei;
835 nearestBFacei[patchFacei] = leftFacei;
847 typDim *= distanceTol_;
849 if (rightDist < typDim && leftDist < typDim)
854 nearestBFacei[patchFacei] = rightFacei;
858 nearestBFacei[patchFacei] = leftFacei;
864 if (rightDist < leftDist)
866 nearestBFacei[patchFacei] = rightFacei;
870 nearestBFacei[patchFacei] = leftFacei;
879 label rightFacei = rightFaces[rightInfo.
index()];
880 nearestBFacei[patchFacei] = rightFacei;
891 nearestBFacei[patchFacei] = leftFaces[leftInfo.
index()];
896 nearestBFacei[patchFacei] = -1;
901 return nearestBFacei;
907 edgeToFeature_.setSize(mesh().nEdges());
914 featureToEdge_.setSize(mesh().nEdges());
918 if (minCos >= 0.9999)
921 forAll(mesh().edges(), edgeI)
923 edgeToFeature_[edgeI] = featureI;
924 featureToEdge_[featureI++] = edgeI;
929 forAll(mesh().edges(), edgeI)
931 const labelList& eFaces = mesh().edgeFaces()[edgeI];
933 if (eFaces.
size() == 2)
935 label face0I = eFaces[0];
937 label face1I = eFaces[1];
948 const vector& n0 = mesh().faceNormals()[face0I];
950 const vector& n1 = mesh().faceNormals()[face1I];
952 float cosAng = n0 & n1;
956 edgeToFeature_[edgeI] = featureI;
957 featureToEdge_[featureI++] = edgeI;
964 edgeToFeature_[edgeI] = featureI;
965 featureToEdge_[featureI++] = edgeI;
971 featureToEdge_.setSize(featureI);
977 featureEdges_.setSize(featureI);
978 featurePoints_.setSize(mesh().
nPoints());
984 forAll(featureToEdge_, fEdgeI)
986 label edgeI = featureToEdge_[fEdgeI];
988 const edge&
e = mesh().edges()[edgeI];
990 label start = featToMeshPoint[
e.start()];
994 featToMeshPoint[
e.start()] = featPtI;
996 featurePoints_[featPtI] = mesh().points()[
e.start()];
1003 label end = featToMeshPoint[
e.end()];
1007 featToMeshPoint[
e.end()] = featPtI;
1009 featurePoints_[featPtI] = mesh().points()[
e.end()];
1017 featureEdges_[fEdgeI] =
edge(start, end);
1021 featurePoints_.setSize(featPtI);
1033 forAll(featureToEdge_, featI)
1035 label edgeI = featureToEdge_[featI];
1037 const edge&
e = mesh().edges()[edgeI];
1039 if (nFeatureEdges(
e.start()) != 2)
1041 isFeaturePoint[
e.start()] =
true;
1044 if (nFeatureEdges(
e.end()) != 2)
1046 isFeaturePoint[
e.end()] =
true;
1059 boolList featVisited(featureToEdge_.size(),
false);
1063 label startFeatI = -1;
1065 forAll(featVisited, featI)
1067 if (!featVisited[featI])
1075 if (startFeatI == -1)
1086 featureToEdge_[startFeatI],
1097 featureSegments_.setSize(segments.
size());
1099 forAll(featureSegments_, segmentI)
1101 featureSegments_[segmentI] = segments[segmentI];
1119 <<
"Cannot find face " << facei <<
" in list of repatchPatches "
1143 patches_.setSize(patches_.size() + 1);
1158 patches_.set(
patchi, bpPtr);
1162 Pout<<
"addPatch : patches now:" <<
endl;
1182 if (delPatchi == -1)
1185 <<
"Can't find patch named " << patchName
1189 if (patches_[delPatchi].size())
1192 <<
"Trying to delete non-empty patch " << patchName
1193 <<
endl <<
"Current size:" << patches_[delPatchi].size()
1213 patches_ = newPatches;
1217 Pout<<
"deletePatch : patches now:" <<
endl;
1235 const word& patchName,
1236 const word& patchType
1244 <<
"Can't find patch named " << patchName
1280 patches_ = newPatches;
1287 const label seedFacei,
1291 boolList protectedEdge(mesh().nEdges(),
false);
1293 forAll(protectedEdges, i)
1295 protectedEdge[protectedEdges[i]] =
true;
1300 labelList currentZone(mesh().size(), -1);
1303 markZone(protectedEdge, seedFacei, 0, currentZone);
1306 visited.
setSize(mesh().size());
1308 forAll(currentZone, facei)
1310 if (currentZone[facei] == 0)
1312 visited[facei] =
true;
1316 visited[facei] =
false;
#define forAll(list, i)
Loop across all elements in list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
virtual const fileName & name() const
Return the name of the stream.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Point & hitPoint() const
Return hit point.
label index() const
Return index.
bool hit() const
Is there a hit.
A list of faces which address into the list of points.
const labelListList & pointEdges() const
Return point-edge addressing.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void sort()
(stable) sort the list (if changed after construction time)
A List with indirect addressing.
label size() const
Return the number of elements in the UList.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
label size() const
Return the number of elements in the UPtrList.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
scalar avgDim() const
Average length/height/width dimension.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index.
const word & geometricType() const
Return the type of the patch.
const word & name() const
Return name.
Non-pointer based hierarchical recursive searching.
Triangle with additional region number.
label region() const
Return region label.
label index() const
Return the index of this patch in the boundaryMesh.
const word & physicalType() const
Return the optional physical type of the patch.
const word & name() const
Return name.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
Cell-face mesh analysis engine.
const vectorField & faceCentres() const
virtual const faceList & faces() const =0
Return faces.
label nInternalFaces() const
virtual const pointField & points() const =0
Return mesh points.
const vectorField & faceAreas() const
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
void addPatch(const word &patchName)
Add to back of patch list.
void setFeatureEdges(const scalar minCos)
Set featureEdges, edgeToFeature, featureSegments according.
~repatchMesh()
Destructor.
void readTriSurface(const fileName &)
Read from triSurface.
void deletePatch(const word &patchName)
Delete from patch list.
label findIndex(const word &patchName) const
Get index of patch by name.
const rMesh & mesh() const
Access the boundary mesh.
labelList getNearest(const primitiveMesh &pMesh, const vector &searchSpan) const
Get rMesh index of nearest face for every boundary face in.
repatchMesh()
Construct null.
void markFaces(const labelList &protectedEdges, const label facei, boolList &visited) const
void read(const polyMesh &)
Read from repatchMesh of polyMesh.
void changePatchType(const word &patchName, const word &type)
Change patch.
label whichPatch(const label facei) const
Get index of patch face is in.
Like polyPatch but without reference to mesh. patchIdentifier::index is not used. Used in repatchMesh...
Standard boundBox + extra functionality for use in octree.
Encapsulation of data needed to search on PrimitivePatches.
Triangulated surface description with patch information.
const geometricSurfacePatchList & patches() const
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
List< bool > boolList
Bool container classes.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< scalar > magSqr(const dimensioned< Type > &)