45 const vector repatchMesh::splitNormal_(3, 2, 1);
48 const scalar repatchMesh::distanceTol_ = 1e-2;
63 label edgeI = pEdges[pEdgeI];
65 if (edgeToFeature_[edgeI] != -1)
85 label nbrEdgeI = pEdges[pEdgeI];
87 if (nbrEdgeI != edgeI)
89 label featI = edgeToFeature_[nbrEdgeI];
108 const label startEdgeI,
114 label edgeI = startEdgeI;
118 label vertI = e.start();
120 while (!isFeaturePoint[vertI])
124 edgeI = nextFeatureEdge(edgeI, vertI);
126 if ((edgeI == -1) || (edgeI == startEdgeI))
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;
171 vertI = e.otherVertex(vertI);
175 edgeI = nextFeatureEdge(edgeI, vertI);
177 if ((edgeI == -1) || (edgeI == initEdgeI))
182 while (!isFeaturePoint[vertI]);
186 featLabels.setSize(featLabelI);
207 label facei = changedFaces[i];
213 label edgeI = fEdges[fEdgeI];
215 if (!regionEdge[edgeI] && (edgeRegion[edgeI] == -1))
217 edgeRegion[edgeI] = region;
219 changedEdges[changedI++] = edgeI;
224 changedEdges.setSize(changedI);
243 label edgeI = changedEdges[i];
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())
384 meshFace_[bFacei] = pp.
start() + patchFacei;
386 bFaces[bFacei] = pp[patchFacei];
395 Pout<<
"read : patches now:" <<
endl;
401 Pout<<
" name : " << bp.
name() << endl
402 <<
" size : " << bp.
size() << endl
403 <<
" start : " << bp.
start() << endl
421 meshPtr_ =
new rMesh(globalPatch.localFaces(), globalPatch.localPoints());
426 const rMesh& msh = *meshPtr_;
428 Pout<<
"** Start of Faces **" <<
endl;
432 const face&
f = msh[facei];
438 ctr += msh.
points()[f[fp]];
448 Pout<<
"** End of Faces **" <<
endl;
450 Pout<<
"** Start of Points **" <<
endl;
455 <<
" coord:" << msh.
points()[pointi]
459 Pout<<
"** End of Points **" <<
endl;
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());
543 patches_.setSize(regionToBoundaryPatch.
size());
566 const labelList& indices = regions.indices();
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;
632 edgeToFeature_.
setSize(meshPtr_->nEdges());
669 rightFaces.
append(bFacei);
682 Pout<<
"getNearest :" 683 <<
" rightBin:" << rightFaces.
size()
684 <<
" leftBin:" << leftFaces.
size()
705 scalar tol = 1e-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;
918 if (minCos >= 0.9999)
923 edgeToFeature_[edgeI] = featureI;
924 featureToEdge_[featureI++] = edgeI;
933 if (eFaces.
size() == 2)
935 label face0I = eFaces[0];
937 label face1I = eFaces[1];
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);
984 forAll(featureToEdge_, fEdgeI)
986 label edgeI = featureToEdge_[fEdgeI];
994 featToMeshPoint[e.
start()] = featPtI;
1003 label end = featToMeshPoint[e.
end()];
1007 featToMeshPoint[e.
end()] = featPtI;
1017 featureEdges_[fEdgeI] =
edge(start, end);
1021 featurePoints_.
setSize(featPtI);
1033 forAll(featureToEdge_, featI)
1035 label edgeI = featureToEdge_[featI];
1039 if (nFeatureEdges(e.
start()) != 2)
1041 isFeaturePoint[e.
start()] =
true;
1044 if (nFeatureEdges(e.
end()) != 2)
1046 isFeaturePoint[e.
end()] =
true;
1063 label startFeatI = -1;
1065 forAll(featVisited, featI)
1067 if (!featVisited[featI])
1075 if (startFeatI == -1)
1086 featureToEdge_[startFeatI],
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;
1168 Pout<<
" name : " << bp.
name() << endl
1169 <<
" size : " << bp.
size() << endl
1170 <<
" start : " << bp.
start() << 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;
1223 Pout<<
" name : " << bp.
name() << endl
1224 <<
" size : " << bp.
size() << endl
1225 <<
" start : " << bp.
start() << endl
1235 const word& patchName,
1236 const word& patchType
1244 <<
"Can't find patch named " << patchName
1271 newPatches.set(
patchi, bpPtr);
1280 patches_ = newPatches;
1287 const label seedFacei,
1293 forAll(protectedEdges, i)
1295 protectedEdge[protectedEdges[i]] =
true;
1303 markZone(protectedEdge, seedFacei, 0, currentZone);
1308 forAll(currentZone, facei)
1310 if (currentZone[facei] == 0)
1312 visited[facei] =
true;
1316 visited[facei] =
false;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
dimensionedScalar sign(const dimensionedScalar &ds)
const rMesh & mesh() const
Access the boundary mesh.
void deletePatch(const word &patchName)
Delete from patch list.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
A class for handling file names.
bool set(const label) const
Is element set.
const word & name() const
Return name.
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const labelListList & faceEdges() const
void setFeatureEdges(const scalar minCos)
Set featureEdges, edgeToFeature, featureSegments according.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
A list that is sorted upon construction or when explicitly requested with the sort() method...
const labelListList & pointEdges() const
Cell-face mesh analysis engine.
void read(const polyMesh &)
Read from repatchMesh of polyMesh.
void changePatchType(const word &patchName, const word &type)
Change patch.
void size(const label)
Override size to be inconsistent with allocated storage.
const word & geometricType() const
Return the type of the patch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const pointField & points() const =0
Return mesh points.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Vector< scalar > vector
A scalar version of the templated Vector.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
label size() const
Return number of elements in table.
scalar avgDim() const
Average length/height/width dimension.
virtual const pointField & points() const
Return raw points.
List< bool > boolList
Bool container classes.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
A list of faces which address into the list of points.
const Point & hitPoint() const
Return hit point.
label region() const
Return region label.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling words, derived from string.
void readTriSurface(const fileName &)
Read from triSurface.
Encapsulation of data needed to search on PrimitivePatches.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool hit() const
Is there a hit.
const Field< PointType > & points() const
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< label > labelList
A List of labels.
Triangle with additional region number.
const Field< PointType > & faceNormals() const
Return face normals for patch.
errorManip< error > abort(error &err)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
label findPatchID(const word &patchName) const
Get index of patch by name.
label nEdges() const
Return number of edges in patch.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
repatchMesh()
Construct null.
void markFaces(const labelList &protectedEdges, const label facei, boolList &visited) const
const word & physicalType() const
Return the optional physical type of the patch.
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
label whichPatch(const label facei) const
Get index of patch face is in.
PrimitivePatch< faceList, const pointField > rMesh
Type of the mesh.
label size() const
Return the number of elements in the UPtrList.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
~repatchMesh()
Destructor.
void setSize(const label)
Reset size of List.
const point & max() const
Maximum describing the bounding box.
const geometricSurfacePatchList & patches() const
Non-pointer based hierarchical recursive searching.
void addPatch(const word &patchName)
Add to back of patch list.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
label end() const
Return end vertex label.
prefixOSstream Pout(cout, "Pout")
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const vectorField & faceAreas() const
A List with indirect addressing.
label index() const
Return the index of this patch in the boundaryMesh.
virtual const faceList & faces() const =0
Return faces.
label start() const
Return start label of this patch in the polyMesh face list.
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index...
Standard boundBox + extra functionality for use in octree.
labelList getNearest(const primitiveMesh &pMesh, const vector &searchSpan) const
Get rMesh index of nearest face for every boundary face in.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
const point & min() const
Minimum describing the bounding box.
A patch is a list of labels that address the faces in the global face list.
Triangulated surface description with patch information.
label index() const
Return index.
const labelListList & edgeFaces() const
label start() const
Return start vertex label.
Like polyPatch but without reference to mesh. patchIdentifier::index is not used. Used in repatchMesh...