59 "void refineBoundaryLayers::refineFace(const face&,"
60 " const FixedList<label, 2>&, DynList<DynList<label, 4> >&)"
61 ) <<
"Face " <<
f <<
" is not a quad" <<
endl;
67 if( (nLayersInDirection[0] <= 1) && (nLayersInDirection[1] <= 1) )
73 const edge e =
f.faceEdge(eI);
81 const label seI = splitEdgesAtPoint_(
f[eI], peI);
82 const edge& se = splitEdges_[seI];
88 const label s = newVerticesForSplitEdge_.sizeOfRow(seI) - 1;
89 if(
e.start() == se.
start() )
92 newF.
append(newVerticesForSplitEdge_(seI, pI));
96 for(
label pI=
s-1;pI>0;--pI)
97 newF.
append(newVerticesForSplitEdge_(seI, pI));
109 label dir0(-1), dir1(-1);
110 labelPair dir0Edges(-1, -1), dir1Edges(-1, -1);
113 const edge e =
f.faceEdge(eI);
115 label ses(-1), see(-1);
116 bool start(
false), end(
false);
119 const edge& se = splitEdges_[splitEdgesAtPoint_(
e.start(), i)];
121 if( (se.
start() ==
e.start()) && (se.
end() ==
f.prevLabel(eI)) )
123 ses = splitEdgesAtPoint_(
e.start(), i);
131 const edge& se = splitEdges_[splitEdgesAtPoint_(
e.end(), i)];
133 if( (se.
start() ==
e.end()) && (se.
end() ==
f[(eI+2)%4]) )
135 see = splitEdgesAtPoint_(
e.end(), i);
148 else if( dir1 == -1 )
157 "void refineBoundaryLayers::refineFace(const face&,"
158 " const FixedList<label, 2>&, DynList<DynList<label, 4> >&)"
159 ) <<
"More than two split directions for a face"
167 Pout <<
"Splits in direction " << nLayersInDirection <<
endl;
170 Pout <<
"dir0Edges " << dir0Edges <<
endl;
172 Pout <<
"dir1Edges " << dir1Edges <<
endl;
175 if( (dir0 < 0) && (dir1 < 0) )
180 if( splitEdgesAtPoint_.size() >=
f[pI] )
181 Pout <<
"Split edges at point " <<
f[pI]
182 <<
" are " << splitEdgesAtPoint_[
f[pI]] <<
endl;
184 Pout <<
"Splits in direction " << nLayersInDirection <<
endl;
187 Pout <<
"dir0Edges " << dir0Edges <<
endl;
189 Pout <<
"dir1Edges " << dir1Edges <<
endl;
193 "void refineBoundaryLayers::refineFace(const face&,"
194 " const FixedList<label, 2>&, DynList<DynList<label, 4> >&)"
199 if( (dir1 != -1) && (dir0 == -1) )
202 dir0Edges = dir1Edges;
205 else if( (dir0 != -1) && (dir1 != -1) && (dir1 !=
f.fcIndex(dir0)) )
213 dir0Edges = dir1Edges;
218 const label nLayersDir0 = dir0>=0?nLayersInDirection[dir0%2]:1;
219 const label nLayersDir1 = dir1>=0?nLayersInDirection[dir1%2]:1;
223 Pout <<
"dirEdges0 " << dir0Edges <<
endl;
224 Pout <<
"dir1Edges " << dir1Edges <<
endl;
227 Pout <<
"Points on edge " << dir0Edges.first() <<
" with nodes "
228 << splitEdges_[dir0Edges.first()]
229 <<
" are " << newVerticesForSplitEdge_[dir0Edges.first()] <<
endl;
230 Pout <<
"Points on edge " << dir0Edges.second() <<
" with nodes "
231 << splitEdges_[dir0Edges.second()]
232 <<
" are " << newVerticesForSplitEdge_[dir0Edges.second()] <<
endl;
236 Pout <<
"Points on edge " << dir1Edges.
first() <<
" with nodes "
237 << splitEdges_[dir1Edges.
first()]
238 <<
" are " << newVerticesForSplitEdge_[dir1Edges.
first()] <<
endl;
239 Pout <<
"Points on edge " << dir1Edges.
second() <<
" with nodes "
240 << splitEdges_[dir1Edges.
second()]
241 <<
" are " << newVerticesForSplitEdge_[dir1Edges.
second()] <<
endl;
243 Pout <<
"nLayersDir0 " << nLayersDir0 <<
endl;
244 Pout <<
"nLayersDir1 " << nLayersDir1 <<
endl;
249 facePoints.
setSize(nLayersDir0+1);
252 facePoints[i].
setSize(nLayersDir1+1);
257 for(
label i=0;i<nLayersDir0;++i)
259 facePoints[i][0] = newVerticesForSplitEdge_(dir0Edges.second(), i);
260 facePoints[i][nLayersDir1] =
261 newVerticesForSplitEdge_(dir0Edges.first(), i);
263 facePoints[nLayersDir0][0] = splitEdges_[dir0Edges.second()].end();
264 facePoints[nLayersDir0][nLayersDir1] = splitEdges_[dir0Edges.first()].end();
266 for(
label i=1;i<nLayersDir1;++i)
268 facePoints[0][i] = newVerticesForSplitEdge_(dir1Edges.
first(), i);
269 facePoints[nLayersDir0][i] =
270 newVerticesForSplitEdge_(dir1Edges.
second(), i);
276 const point v10 =
points[facePoints[nLayersDir0][0]];
277 const point v01 =
points[facePoints[0][nLayersDir1]];
278 const point v11 =
points[facePoints[nLayersDir0][nLayersDir1]];
282 Pout <<
"Point " << pointI <<
" coordinates " <<
points[pointI] <<
endl;
293 if( facePoints[i][j] < 0 )
296 Pout <<
"Determining u " << facePoints[0][0]
297 <<
" coordinates " <<
points[facePoints[0][0]] <<
endl;
298 Pout <<
"Other point " << facePoints[i][0]
299 <<
" coordinates " <<
points[facePoints[i][0]] <<
endl;
300 Pout <<
"Points at aplit edge "
301 << newVerticesForSplitEdge_[dir0Edges.second()] <<
endl;
307 splitEdges_[dir0Edges.second()].mag(
points)
311 Pout <<
"Determining v " << facePoints[0][0]
312 <<
" coordinates " <<
points[facePoints[0][0]] <<
endl;
313 Pout <<
"Other point " << facePoints[0][j]
314 <<
" coordinates " <<
points[facePoints[0][j]] <<
endl;
315 Pout <<
"Points at aplit edge "
316 << newVerticesForSplitEdge_[dir1Edges.
first()] <<
endl;
326 Pout <<
"Generating point of face " <<
endl;
335 (1.0 - u) * (1.0 - v) * v00 +
336 u * (1.0 - v) * v10 +
342 Pout <<
"Point coordinate " << newP <<
endl;
346 facePoints[i][j] =
points.size();
353 Pout <<
"Face points after creating vertices " << facePoints <<
endl;
357 for(
label j=0;j<nLayersDir1;++j)
359 for(
label i=0;i<nLayersDir0;++i)
366 if( (i == (nLayersDir0 - 1)) && (j == 0) )
369 Pout <<
"1. Adding additional points on edge " <<
endl;
373 const label eLabel = dir0Edges.second();
375 newVerticesForSplitEdge_.sizeOfRow(eLabel) - 1;
377 for(
label index=i+1;index<size;++index)
378 f.
append(newVerticesForSplitEdge_(eLabel, index));
385 (i == (nLayersDir0 - 1)) &&
386 (j == (nLayersDir1 - 1))
390 Pout <<
"2. Adding additional points on edge " <<
endl;
396 newVerticesForSplitEdge_.sizeOfRow(eLabel) - 1;
398 for(
label index=j+1;index<size;++index)
399 f.
append(newVerticesForSplitEdge_(eLabel, index));
402 f.
append(facePoints[i+1][j+1]);
404 if( (i == (nLayersDir0 - 1)) && (j == (nLayersDir1 - 1)) )
407 Pout <<
"3. Adding additional points on edge " <<
endl;
410 const label eLabel = dir0Edges.first();
412 newVerticesForSplitEdge_.sizeOfRow(eLabel) - 2;
413 for(
label index=size;index>i;--index)
414 f.
append(newVerticesForSplitEdge_(eLabel, index));
419 if( (dir1 != -1) && (i == 0) && (j == (nLayersDir1 - 1)) )
422 Pout <<
"4. Adding additional points on edge " <<
endl;
427 newVerticesForSplitEdge_.sizeOfRow(eLabel) - 2;
428 for(
label index=size;index>j;--index)
429 f.
append(newVerticesForSplitEdge_(eLabel, index));
438 Pout <<
"Decomposed faces are " << newFaces <<
endl;
448 const label transpose
452 const face&
f = faces[faceI];
455 Pout <<
"Creating matrix of points on a split face " << faceI <<
endl;
456 Pout <<
"Face comprises of points " <<
f <<
endl;
457 Pout <<
"New faces from face " << facesFromFace_.sizeOfRow(faceI) <<
endl;
460 label procStart = mesh_.faces().size();
463 procStart = procBoundaries[0].patchStart();
466 (faceI < procStart) ||
467 procBoundaries[mesh_.faceIsInProcPatch(faceI)].owner()
475 const label pos =
f.which(newFaces_(facesFromFace_(faceI, 0), 0));
479 const label nfI = facesFromFace_(faceI, i);
481 if( (numSplitsI == 1) && newFaces_.contains(nfI,
f.nextLabel(
pos)) )
488 const label numSplitsJ = (facesFromFace_.sizeOfRow(faceI) / numSplitsI);
492 Pout <<
"Num splits in direction 0 " << numSplitsI <<
endl;
493 Pout <<
"Num splits in direction 1 " << numSplitsJ <<
endl;
496 facePoints.setSize(numSplitsI+1);
498 facePoints[i].setSize(numSplitsJ+1);
503 const label nfI = facesFromFace_(faceI, fI);
505 const label i = fI % numSplitsI;
506 const label j = fI / numSplitsI;
509 Pout <<
"New face " << fI <<
" is " << newFaces_[nfI] <<
endl;
514 if( newFaces_.sizeOfRow(nfI) == 4 )
516 facePoints[i][j] = newFaces_(nfI, 0);
517 facePoints[i+1][j] = newFaces_(nfI, 1);
518 facePoints[i+1][j+1] = newFaces_(nfI, 2);
519 facePoints[i][j+1] = newFaces_(nfI, 3);
526 if(
f.which(newFaces_(nfI, pI)) >= 0 )
528 facePoints[i+1][0] = newFaces_(nfI, pI);
535 if(
f.which(newFaces_(nfI, pI)) >= 0 )
537 facePoints[0][j+1] = newFaces_(nfI, pI);
544 if(
f.which(newFaces_(nfI, pI)) >= 0 )
546 facePoints[i+1][j+1] = newFaces_(nfI, pI);
554 Pout <<
"Generated matrix of points on face " << faceI
555 <<
" is " << facePoints <<
endl;
564 const label pos =
f.which(newFaces_(facesFromFace_(faceI, 0), 0));
568 const label nfI = facesFromFace_(faceI, j);
570 if( (numSplitsJ == 1) && newFaces_.contains(nfI,
f.prevLabel(
pos)) )
577 const label numSplitsI = (facesFromFace_.sizeOfRow(faceI) / numSplitsJ);
580 Pout <<
"2. Face comprises of points " <<
f <<
endl;
581 Pout <<
"2. Num splits in direction 0 " << numSplitsI <<
endl;
582 Pout <<
"2. Num splits in direction 1 " << numSplitsJ <<
endl;
585 facePoints.setSize(numSplitsI+1);
587 facePoints[i].setSize(numSplitsJ+1);
592 const label nfI = facesFromFace_(faceI, fI);
594 const label i = fI / numSplitsJ;
595 const label j = fI % numSplitsJ;
598 Pout <<
"2. New face " << fI <<
" is " << newFaces_[nfI] <<
endl;
603 if( newFaces_.sizeOfRow(nfI) == 4 )
605 facePoints[i][j] = newFaces_(nfI, 0);
606 facePoints[i+1][j] = newFaces_(nfI, 1);
607 facePoints[i+1][j+1] = newFaces_(nfI, 2);
608 facePoints[i][j+1] = newFaces_(nfI, 3);
615 if(
f.which(newFaces_(nfI, pI)) >= 0 )
617 facePoints[0][j+1] = newFaces_(nfI, pI);
624 if(
f.which(newFaces_(nfI, pI)) >= 0 )
626 facePoints[i+1][0] = newFaces_(nfI, pI);
633 if(
f.which(newFaces_(nfI, pI)) >= 0 )
635 facePoints[i+1][j+1] = newFaces_(nfI, pI);
643 Pout <<
"Generated matrix of points on processor face " << faceI
644 <<
" is " << facePoints <<
endl;
651 transposedFacePoints.
setSize(facePoints[0].size());
652 forAll(transposedFacePoints, j)
653 transposedFacePoints[j].
setSize(facePoints.size());
657 transposedFacePoints[j][i] = facePoints[i][j];
659 facePoints = transposedFacePoints;
662 Pout <<
"Transposed face points " << facePoints <<
endl;
671 const label transpose
675 const face&
f = faces[faceI];
678 Pout <<
"Creating matrix of faces on a split face " << faceI <<
endl;
679 Pout <<
"Face comprises of points " <<
f <<
endl;
682 label procStart = mesh_.faces().size();
685 procStart = procBoundaries[0].patchStart();
688 (faceI < procStart) ||
689 procBoundaries[mesh_.faceIsInProcPatch(faceI)].owner()
697 const label pos =
f.which(newFaces_(facesFromFace_(faceI, 0), 0));
701 const label nfI = facesFromFace_(faceI, i);
703 if( (numSplitsI == 1) && newFaces_.contains(nfI,
f.nextLabel(
pos)) )
710 label numSplitsJ = (facesFromFace_.sizeOfRow(faceI) / numSplitsI);
713 Pout <<
"3. Num splits in direction 0 " << numSplitsI <<
endl;
714 Pout <<
"3. Num splits in direction 1 " << numSplitsJ <<
endl;
717 faceFaces.setSize(numSplitsI);
719 faceFaces[i].setSize(numSplitsJ);
724 const label nfI = facesFromFace_(faceI, fI);
726 const label i = fI % numSplitsI;
727 const label j = fI / numSplitsI;
730 Pout <<
"3. New face " << fI <<
" is " << newFaces_[nfI] <<
endl;
735 faceFaces[i][j] = nfI;
739 Pout <<
"3. Generated matrix of points on face " << faceI
740 <<
" is " << faceFaces <<
endl;
749 const label pos =
f.which(newFaces_(facesFromFace_(faceI, 0), 0));
753 const label nfI = facesFromFace_(faceI, j);
755 if( (numSplitsJ == 1) && newFaces_.contains(nfI,
f.prevLabel(
pos)) )
762 const label numSplitsI = (facesFromFace_.sizeOfRow(faceI) / numSplitsJ);
765 Pout <<
"4. Num splits in direction 0 " << numSplitsI <<
endl;
766 Pout <<
"4. Num splits in direction 1 " << numSplitsJ <<
endl;
769 faceFaces.setSize(numSplitsI);
771 faceFaces[i].setSize(numSplitsJ);
776 const label nfI = facesFromFace_(faceI, fI);
778 const label i = fI / numSplitsJ;
779 const label j = fI % numSplitsJ;
782 Pout <<
"4. New face " << fI <<
" is " << newFaces_[nfI] <<
endl;
787 faceFaces[i][j] = nfI;
791 Pout <<
"4. Generated matrix of faces on processor face " << faceI
792 <<
" is " << faceFaces <<
endl;
799 transposedFaceFaces.
setSize(faceFaces[0].size());
800 forAll(transposedFaceFaces, j)
801 transposedFaceFaces[j].
setSize(faceFaces.size());
805 transposedFaceFaces[j][i] = faceFaces[i][j];
807 faceFaces = transposedFaceFaces;
810 Pout <<
"Transposed face faces " << faceFaces <<
endl;
836 for(
label faceI=0;faceI<nInternalFaces;++faceI)
838 const face&
f = faces[faceI];
853 const edge fe =
f.faceEdge(eI);
862 const label beI = bpEdges(bps, bpsI);
864 if( edges[beI] == fe )
872 const label dir = eI % 2;
873 nRefinementInDirection[dir] =
876 nRefinementInDirection[dir],
885 refineFace(
f, nRefinementInDirection, newFacesForFace);
888 forAll(newFacesForFace, fI)
895 Pout <<
"Internal face " << faceI <<
" with points " <<
f
896 <<
" is refined " <<
endl;
898 Pout <<
"New face " << i <<
" is "
910 const face& bf = bFaces[bfI];
911 const label faceI = startingBoundaryFace + bfI;
926 const label beI = bfEdges(bfI, eI);
932 label neiFace = beFaces(beI, 0);
935 neiFace = beFaces(beI, 1);
941 if( neiLayers.
size() == 0 )
946 bool foundSame(
false);
950 if( neiLayers.
contains(currLayers[i]) )
957 if( foundSame || (neiLayers.
size() == 0) )
966 refineFace(bf, nRefinementInDirection, newFacesForFace);
969 forAll(newFacesForFace, fI)
976 Pout <<
"Boundary face " << faceI <<
" with points " << bf
977 <<
" owner cell " <<
mesh_.
owner()[faceI] <<
" is refined " <<
endl;
979 Pout <<
"New face " << i <<
" is "
992 std::map<label, DynList<labelPair, 2> > localSplits;
993 forAll(procBoundaries, patchI)
997 const label start = procBoundaries[patchI].patchStart();
998 const label size = procBoundaries[patchI].patchSize();
1000 for(
label fI=0;fI<size;++fI)
1002 const label faceI = start + fI;
1003 const face&
f = faces[faceI];
1007 const edge fe =
f.faceEdge(eI);
1016 const label beI = bpEdges(bps, bpeI);
1018 if( edges[beI] == fe )
1022 const label nSplits0 =
1026 const label dir = (eI % 2);
1029 Pout <<
"Face " << fI <<
" owner of proc patch "
1030 << procBoundaries[patchI].myProcNo()
1032 << procBoundaries[patchI].neiProcNo()
1033 <<
" bnd face patch "
1034 << facePatches[beFaces(beI, 0)]
1035 <<
" direction " << dir
1036 <<
" nSplits " << nSplits0 <<
endl;
1043 sendData.
append(nSplits0);
1044 localSplits[faceI].append(
labelPair(dir, nSplits0));
1053 procBoundaries[patchI].neiProcNo(),
1057 toOtherProc << sendData;
1061 forAll(procBoundaries, patchI)
1069 procBoundaries[patchI].neiProcNo()
1072 fromOtherProc >> receivedData;
1074 const label start = procBoundaries[patchI].patchStart();
1077 while( counter < receivedData.size() )
1079 const label fI = receivedData[counter++];
1080 const label dir = ((receivedData[counter++] + 1) % 2);
1081 const label nSplits = receivedData[counter++];
1086 if( currentSplits[i].first() == dir )
1087 currentSplits[i].second() =
1088 Foam::max(currentSplits[i].second(), nSplits);
1095 Pout <<
"Starting splitting processor boundaries" <<
endl;
1099 forAll(procBoundaries, patchI)
1101 const label start = procBoundaries[patchI].patchStart();
1102 const label size = procBoundaries[patchI].patchSize();
1104 for(
label fI=0;fI<size;++fI)
1106 const label faceI = start + fI;
1108 std::map<label, DynList<labelPair, 2> >::const_iterator it =
1109 localSplits.find(faceI);
1111 if( it == localSplits.end() )
1120 if( procBoundaries[patchI].owner() )
1126 nLayersInDirection[dirSplits[i].first()] =
1127 dirSplits[i].second();
1130 Pout <<
"Face " << fI <<
" at owner processor "
1131 << procBoundaries[patchI].myProcNo()
1132 <<
" neighbour processor "
1133 << procBoundaries[patchI].neiProcNo()
1134 <<
" face " << faces[faceI] <<
" refinement direction "
1135 << nLayersInDirection <<
endl;
1139 refineFace(faces[faceI], nLayersInDirection, facesFromFace);
1154 nLayersInDirection[(dirSplits[i].first()+1)%2] =
1155 dirSplits[i].second();
1157 const face rFace = faces[faceI].reverseFace();
1160 Pout <<
"Face " << fI <<
" at owner processor "
1161 << procBoundaries[patchI].myProcNo()
1162 <<
" neighbour processor "
1163 << procBoundaries[patchI].neiProcNo()
1164 <<
" face " << rFace <<
" refinement direction "
1165 << nLayersInDirection <<
endl;
1169 refineFace(rFace, nLayersInDirection, facesFromFace);
1189 forAll(procBoundaries, patchI)
1191 const label start = procBoundaries[patchI].patchStart();
1192 const label size = procBoundaries[patchI].patchSize();
1194 for(
label fI=0;fI<size;++fI)
1196 const label faceI = start + fI;
1197 const face&
f = faces[faceI];
1198 Pout <<
"Face " << fI <<
" in patch "
1199 << procBoundaries[patchI].patchName()
1200 <<
" has nodes " <<
f
1201 <<
" local splits " << localSplits[faceI]
1205 Pout <<
" Face points ";
1213 Pout <<
"New face " << ffI <<
" with label " << nfI
1214 <<
" consists of points ";
1249 file <<
"# vtk DataFile Version 3.0\n";
1250 file <<
"vtk output\n";
1252 file <<
"DATASET POLYDATA\n";
1260 file <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z() <<
nl;
1271 file <<
"\nPOLYGONS " << faces.
size()
1272 <<
" " << counter <<
nl;
1284 Info <<
"Finished refining boundary-layer faces " <<
endl;