47 DynamicList<word>& allPatchNames,
48 DynamicList<word>& allPatchTypes
53 const word& pType = p.type();
54 const word& pName = p.name();
61 allPatchNames.append(pName);
62 allPatchTypes.append(pType);
64 return allPatchNames.size() - 1;
66 else if (allPatchTypes[patchi] == pType)
77 const word& caseName = p.boundaryMesh().mesh().time().caseName();
79 allPatchNames.append(pName +
"_" + caseName);
80 allPatchTypes.append(pType);
82 Pout<<
"label patchIndex(const polyPatch& p) : " 83 <<
"Patch " << p.index() <<
" named " 84 << pName <<
" in mesh " << caseName
85 <<
" already exists, but patch types" 86 <<
" do not match.\nCreating a composite name as " 87 << allPatchNames.last() <<
endl;
89 return allPatchNames.size() - 1;
98 DynamicList<word>& names
110 names.append(curName);
112 return names.size() - 1;
117 void Foam::polyMeshAdder::mergePatchNames
119 const polyBoundaryMesh& patches0,
120 const polyBoundaryMesh& patches1,
122 DynamicList<word>& allPatchNames,
123 DynamicList<word>& allPatchTypes,
130 allPatchNames.append(patches0.names());
131 allPatchTypes.append(patches0.types());
141 from1ToAllPatches.setSize(patches1.size());
145 from1ToAllPatches[
patchi] = patchIndex
152 allPatchTypes.shrink();
153 allPatchNames.shrink();
156 fromAllTo1Patches.setSize(allPatchNames.size());
157 fromAllTo1Patches = -1;
159 forAll(from1ToAllPatches, i)
161 fromAllTo1Patches[from1ToAllPatches[i]] = i;
168 const polyBoundaryMesh& patches
182 const polyBoundaryMesh& patches
196 const polyMesh& mesh0,
197 const polyMesh& mesh1,
198 const polyBoundaryMesh& allBoundaryMesh,
199 const label nAllPatches,
202 const label nInternalFaces,
209 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
210 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
214 DynamicList<polyPatch*> allPatches(nAllPatches);
218 from0ToAllPatches.setSize(patches0.size());
219 from0ToAllPatches = -1;
221 label startFacei = nInternalFaces;
229 label filteredPatchi;
231 if (nFaces[patchi] == 0 && isA<processorPolyPatch>(patches0[patchi]))
239 filteredPatchi = allPatches.size();
243 patches0[patchi].
clone 251 startFacei += nFaces[
patchi];
255 from0ToAllPatches[
patchi] = filteredPatchi;
258 if (fromAllTo1Patches[patchi] != -1)
260 from1ToAllPatches[fromAllTo1Patches[
patchi]] = filteredPatchi;
265 forAll(from1ToAllPatches, patchi)
269 if (allPatchi >= patches0.size())
273 label filteredPatchi;
277 nFaces[allPatchi] == 0
278 && isA<processorPolyPatch>(patches1[patchi])
287 filteredPatchi = allPatches.size();
291 patches1[patchi].
clone 299 startFacei += nFaces[allPatchi];
302 from1ToAllPatches[
patchi] = filteredPatchi;
308 return move(allPatches);
315 const label nInternalFaces,
323 for (
label facei = nInternalFaces; facei < owner.size(); ++facei)
325 oldToNew[facei] = facei;
335 SortableList<label> nbr(cFaces.size());
339 label facei = cFaces[i];
341 label nbrCelli = neighbour[facei];
346 if (nbrCelli == celli)
348 nbrCelli = owner[facei];
351 if (celli < nbrCelli)
375 oldToNew[cFaces[nbr.indices()[i]]] = newFacei++;
384 if (oldToNew[facei] == -1)
387 <<
"Did not determine new position" 388 <<
" for face " << facei
409 void Foam::polyMeshAdder::mergePrimitives
411 const polyMesh& mesh0,
412 const polyMesh& mesh1,
413 const faceCoupleInfo& coupleInfo,
415 const label nAllPatches,
426 label& nInternalFaces,
435 const polyBoundaryMesh& patches0 = mesh0.boundaryMesh();
436 const polyBoundaryMesh& patches1 = mesh1.boundaryMesh();
446 allPoints.setSize(mesh0.nPoints() + mesh1.nPoints());
449 from0ToAllPoints.setSize(mesh0.nPoints());
450 from0ToAllPoints = -1;
451 from1ToAllPoints.setSize(mesh1.nPoints());
452 from1ToAllPoints = -1;
458 coupleInfo.coupleToMasterPoints()
462 coupleInfo.coupleToSlavePoints()
465 forAll(coupleToMasterPoints, couplePointi)
467 const labelList& masterPoints = coupleToMasterPoints[couplePointi];
471 label mesh0Pointi = masterPatch.meshPoints()[masterPoints[j]];
472 from0ToAllPoints[mesh0Pointi] = allPointi;
473 allPoints[allPointi] = mesh0.points()[mesh0Pointi];
476 const labelList& slavePoints = coupleToSlavePoints[couplePointi];
480 label mesh1Pointi = slavePatch.meshPoints()[slavePoints[j]];
481 from1ToAllPoints[mesh1Pointi] = allPointi;
482 allPoints[allPointi] = mesh1.points()[mesh1Pointi];
490 forAll(mesh0.points(), pointi)
492 if (from0ToAllPoints[pointi] == -1)
494 allPoints[allPointi] = mesh0.points()[pointi];
495 from0ToAllPoints[pointi] = allPointi;
501 forAll(mesh1.points(), pointi)
503 if (from1ToAllPoints[pointi] == -1)
505 allPoints[allPointi] = mesh1.points()[pointi];
506 from1ToAllPoints[pointi] = allPointi;
511 allPoints.setSize(allPointi);
518 nFacesPerPatch.setSize(nAllPatches);
522 allFaces.setSize(mesh0.nFaces() + mesh1.nFaces());
523 allOwner.setSize(allFaces.size());
525 allNeighbour.setSize(allFaces.size());
529 from0ToAllFaces.setSize(mesh0.nFaces());
530 from0ToAllFaces = -1;
531 from1ToAllFaces.setSize(mesh1.nFaces());
532 from1ToAllFaces = -1;
535 for (
label facei = 0; facei < mesh0.nInternalFaces(); facei++)
537 allFaces[allFacei] =
renumber(from0ToAllPoints, mesh0.faces()[facei]);
538 allOwner[allFacei] = mesh0.faceOwner()[facei];
539 allNeighbour[allFacei] = mesh0.faceNeighbour()[facei];
540 from0ToAllFaces[facei] = allFacei++;
545 forAll(masterPatch, coupleFacei)
547 const label mesh0Facei = masterPatch.addressing()[coupleFacei];
549 if (from0ToAllFaces[mesh0Facei] == -1)
552 from0ToAllFaces[mesh0Facei] = allFacei;
555 label patch0 = patches0.whichPatch(mesh0Facei);
556 nFacesPerPatch[patch0]--;
559 const label mesh1Facei = slavePatch.addressing()[coupleFacei];
561 if (from1ToAllFaces[mesh1Facei] == -1)
563 from1ToAllFaces[mesh1Facei] = allFacei;
565 label patch1 = patches1.whichPatch(mesh1Facei);
566 nFacesPerPatch[from1ToAllPatches[patch1]]--;
571 allFaces[allFacei] = coupleInfo.coupleFace(coupleFacei);
572 allOwner[allFacei] = mesh0.faceOwner()[mesh0Facei];
573 allNeighbour[allFacei] = mesh1.faceOwner()[mesh1Facei] + mesh0.nCells();
579 for (
label facei = 0; facei < mesh1.nInternalFaces(); facei++)
581 allFaces[allFacei] =
renumber(from1ToAllPoints, mesh1.faces()[facei]);
582 allOwner[allFacei] = mesh1.faceOwner()[facei] + mesh0.nCells();
583 allNeighbour[allFacei] = mesh1.faceNeighbour()[facei] + mesh0.nCells();
584 from1ToAllFaces[facei] = allFacei++;
587 nInternalFaces = allFacei;
590 for (
label allPatchi = 0; allPatchi < nAllPatches; allPatchi++)
592 if (allPatchi < patches0.size())
595 const polyPatch& pp = patches0[allPatchi];
597 nFacesPerPatch[allPatchi] += pp.size();
599 label facei = pp.start();
603 if (from0ToAllFaces[facei] == -1)
611 allOwner[allFacei] = mesh0.faceOwner()[facei];
612 allNeighbour[allFacei] = -1;
614 from0ToAllFaces[facei] = allFacei++;
619 if (fromAllTo1Patches[allPatchi] != -1)
622 const polyPatch& pp = patches1[fromAllTo1Patches[allPatchi]];
624 nFacesPerPatch[allPatchi] += pp.size();
626 label facei = pp.start();
630 if (from1ToAllFaces[facei] == -1)
639 mesh1.faceOwner()[facei]
641 allNeighbour[allFacei] = -1;
643 from1ToAllFaces[facei] = allFacei++;
649 allFaces.setSize(allFacei);
650 allOwner.setSize(allFacei);
651 allNeighbour.setSize(allFacei);
656 from1ToAllCells.setSize(mesh1.nCells());
657 from1ToAllCells = -1;
661 from1ToAllCells[i] = i + mesh0.nCells();
665 nCells = mesh0.nCells() + mesh1.nCells();
667 primitiveMesh::calcCells(allCells, allOwner, allNeighbour, nCells);
689 void Foam::polyMeshAdder::mergePointZones
691 const label nAllPoints,
697 DynamicList<word>& zoneNames,
699 List<DynamicList<label>>& pzPoints
702 zoneNames.setCapacity(pz0.size() + pz1.size());
703 zoneNames.append(pz0.names());
705 from1ToAll.setSize(pz1.size());
709 from1ToAll[zoneI] = zoneIndex(pz1[zoneI].
name(), zoneNames);
725 const pointZone& pz = pz0[zoneI];
729 label point0 = pz[i];
730 label allPointi = from0ToAllPoints[point0];
732 if (pointToZone[allPointi] == -1)
734 pointToZone[allPointi] = zoneI;
736 else if (pointToZone[allPointi] != zoneI)
738 labelList& pZones = addPointToZones[allPointi];
750 const pointZone& pz = pz1[zoneI];
751 const label allZoneI = from1ToAll[zoneI];
755 label point1 = pz[i];
756 label allPointi = from1ToAllPoints[point1];
758 if (pointToZone[allPointi] == -1)
760 pointToZone[allPointi] = allZoneI;
762 else if (pointToZone[allPointi] != allZoneI)
764 labelList& pZones = addPointToZones[allPointi];
777 forAll(pointToZone, allPointi)
779 label zoneI = pointToZone[allPointi];
785 forAll(addPointToZones, allPointi)
787 const labelList& pZones = addPointToZones[allPointi];
795 pzPoints.setSize(zoneNames.size());
798 pzPoints[zoneI].setCapacity(
nPoints[zoneI]);
800 forAll(pointToZone, allPointi)
802 label zoneI = pointToZone[allPointi];
805 pzPoints[zoneI].append(allPointi);
808 forAll(addPointToZones, allPointi)
810 const labelList& pZones = addPointToZones[allPointi];
813 pzPoints[pZones[i]].append(allPointi);
818 pzPoints[i].shrink();
824 void Foam::polyMeshAdder::mergeFaceZones
828 const polyMesh& mesh0,
829 const polyMesh& mesh1,
836 DynamicList<word>& zoneNames,
838 List<DynamicList<label>>& fzFaces,
839 List<DynamicList<bool>>& fzFlips
843 const labelList& owner0 = mesh0.faceOwner();
845 const labelList& owner1 = mesh1.faceOwner();
848 zoneNames.setCapacity(fz0.size() + fz1.size());
849 zoneNames.
append(fz0.names());
851 from1ToAll.setSize(fz1.size());
855 from1ToAll[zoneI] = zoneIndex(fz1[zoneI].
name(), zoneNames);
861 labelList faceToZone(allOwner.size(), -1);
863 boolList faceToFlip(allOwner.size(),
false);
869 const labelList& addressing = fz0[zoneI];
870 const boolList& flipMap = fz0[zoneI].flipMap();
874 label face0 = addressing[i];
875 bool flip0 = flipMap[i];
877 label allFacei = from0ToAllFaces[face0];
881 label allCell0 = owner0[face0];
882 if (allOwner[allFacei] != allCell0)
887 if (faceToZone[allFacei] == -1)
889 faceToZone[allFacei] = zoneI;
890 faceToFlip[allFacei] = flip0;
892 else if (faceToZone[allFacei] != zoneI)
894 labelList& fZones = addFaceToZones[allFacei];
895 boolList& flipZones = addFaceToFlips[allFacei];
900 flipZones.append(flip0);
910 const labelList& addressing = fz1[zoneI];
911 const boolList& flipMap = fz1[zoneI].flipMap();
913 const label allZoneI = from1ToAll[zoneI];
917 label face1 = addressing[i];
918 bool flip1 = flipMap[i];
920 label allFacei = from1ToAllFaces[face1];
924 label allCell1 = from1ToAllCells[owner1[face1]];
925 if (allOwner[allFacei] != allCell1)
930 if (faceToZone[allFacei] == -1)
932 faceToZone[allFacei] = allZoneI;
933 faceToFlip[allFacei] = flip1;
935 else if (faceToZone[allFacei] != allZoneI)
937 labelList& fZones = addFaceToZones[allFacei];
938 boolList& flipZones = addFaceToFlips[allFacei];
943 flipZones.append(flip1);
955 forAll(faceToZone, allFacei)
957 label zoneI = faceToZone[allFacei];
963 forAll(addFaceToZones, allFacei)
965 const labelList& fZones = addFaceToZones[allFacei];
973 fzFaces.setSize(zoneNames.size());
974 fzFlips.setSize(zoneNames.size());
977 fzFaces[zoneI].setCapacity(nFaces[zoneI]);
978 fzFlips[zoneI].setCapacity(nFaces[zoneI]);
980 forAll(faceToZone, allFacei)
982 label zoneI = faceToZone[allFacei];
983 bool flip = faceToFlip[allFacei];
986 fzFaces[zoneI].append(allFacei);
987 fzFlips[zoneI].append(flip);
990 forAll(addFaceToZones, allFacei)
992 const labelList& fZones = addFaceToZones[allFacei];
993 const boolList& flipZones = addFaceToFlips[allFacei];
997 label zoneI = fZones[i];
998 fzFaces[zoneI].append(allFacei);
999 fzFlips[zoneI].append(flipZones[i]);
1005 fzFaces[i].shrink();
1006 fzFlips[i].shrink();
1010 fzFaces[i] = UIndirectList<label>(fzFaces[i], order)();
1011 fzFlips[i] = UIndirectList<bool>(fzFlips[i], order)();
1016 void Foam::polyMeshAdder::mergeCellZones
1018 const label nAllCells,
1024 DynamicList<word>& zoneNames,
1026 List<DynamicList<label>>& czCells
1029 zoneNames.setCapacity(cz0.size() + cz1.size());
1030 zoneNames.append(cz0.names());
1032 from1ToAll.setSize(cz1.size());
1035 from1ToAll[zoneI] = zoneIndex(cz1[zoneI].
name(), zoneNames);
1050 const cellZone& cz = cz0[zoneI];
1053 label cell0 = cz[i];
1055 if (cellToZone[cell0] == -1)
1057 cellToZone[cell0] = zoneI;
1059 else if (cellToZone[cell0] != zoneI)
1061 labelList& cZones = addCellToZones[cell0];
1073 const cellZone& cz = cz1[zoneI];
1074 const label allZoneI = from1ToAll[zoneI];
1077 label cell1 = cz[i];
1078 label allCelli = from1ToAllCells[cell1];
1080 if (cellToZone[allCelli] == -1)
1082 cellToZone[allCelli] = allZoneI;
1084 else if (cellToZone[allCelli] != allZoneI)
1086 labelList& cZones = addCellToZones[allCelli];
1099 forAll(cellToZone, allCelli)
1101 label zoneI = cellToZone[allCelli];
1107 forAll(addCellToZones, allCelli)
1109 const labelList& cZones = addCellToZones[allCelli];
1112 nCells[cZones[i]]++;
1117 czCells.setSize(zoneNames.size());
1120 czCells[zoneI].setCapacity(nCells[zoneI]);
1122 forAll(cellToZone, allCelli)
1124 label zoneI = cellToZone[allCelli];
1127 czCells[zoneI].append(allCelli);
1130 forAll(addCellToZones, allCelli)
1132 const labelList& cZones = addCellToZones[allCelli];
1135 czCells[cZones[i]].append(allCelli);
1140 czCells[i].shrink();
1146 void Foam::polyMeshAdder::mergeZones
1148 const label nAllPoints,
1150 const label nAllCells,
1152 const polyMesh& mesh0,
1153 const polyMesh& mesh1,
1161 DynamicList<word>& pointZoneNames,
1162 List<DynamicList<label>>& pzPoints,
1164 DynamicList<word>& faceZoneNames,
1165 List<DynamicList<label>>& fzFaces,
1166 List<DynamicList<bool>>& fzFlips,
1168 DynamicList<word>& cellZoneNames,
1169 List<DynamicList<label>>& czCells
1217 void Foam::polyMeshAdder::addZones
1219 const DynamicList<word>& pointZoneNames,
1220 const List<DynamicList<label>>& pzPoints,
1222 const DynamicList<word>& faceZoneNames,
1223 const List<DynamicList<label>>& fzFaces,
1224 const List<DynamicList<bool>>& fzFlips,
1226 const DynamicList<word>& cellZoneNames,
1227 const List<DynamicList<label>>& czCells,
1232 List<pointZone*>
pZones(pzPoints.size());
1235 pZones[i] =
new pointZone
1244 List<faceZone*> fZones(fzFaces.size());
1247 fZones[i] =
new faceZone
1257 List<cellZone*> cZones(czCells.size());
1260 cZones[i] =
new cellZone
1303 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1325 label nInternalFaces;
1333 labelList nFaces(allPatchNames.size(), 0);
1348 allPatchNames.size(),
1423 allPatchNames.
size(),
1425 mesh0.nInternalFaces()
1426 + mesh1.nInternalFaces()
1461 getPatchSizes(patches0),
1462 getPatchStarts(patches0)
1513 const bool validBoundary
1524 labelList fromAllTo1Patches(allPatchNames.size(), -1);
1548 label nInternalFaces;
1550 labelList nFaces(allPatchNames.size(), 0);
1565 allPatchNames.size(),
1632 labelList mesh0PatchSizes(getPatchSizes(patches0));
1633 labelList mesh0PatchStarts(getPatchStarts(patches0));
1640 labelList patchSizes(allPatchNames.size());
1641 labelList patchStarts(allPatchNames.size());
1643 label startFacei = nInternalFaces;
1647 label allPatchi = 0;
1649 forAll(from0ToAllPatches, patch0)
1654 if (nFaces[patch0] == 0 && isA<processorPolyPatch>(patches0[patch0]))
1659 from0ToAllPatches[patch0] = -1;
1662 if (fromAllTo1Patches[patch0] != -1)
1664 from1ToAllPatches[fromAllTo1Patches[patch0]] = -1;
1669 patchSizes[allPatchi] = nFaces[patch0];
1670 patchStarts[allPatchi] = startFacei;
1673 from0ToAllPatches[patch0] = allPatchi;
1676 if (fromAllTo1Patches[patch0] != -1)
1678 from1ToAllPatches[fromAllTo1Patches[patch0]] = allPatchi;
1681 startFacei += nFaces[patch0];
1689 const label sz0 = from0ToAllPatches.size();
1692 forAll(from0ToAllPatches, patchi)
1694 if (from0ToAllPatches[patchi] != -1)
1696 newToOld[nNew++] =
patchi;
1700 mesh0.reorderPatches(newToOld,
false);
1704 forAll(from1ToAllPatches, patch1)
1706 label uncompactAllPatchi = from1ToAllPatches[patch1];
1708 if (uncompactAllPatchi >= from0ToAllPatches.size())
1714 nFaces[uncompactAllPatchi] == 0
1715 && isA<processorPolyPatch>(patches1[patch1])
1720 from1ToAllPatches[patch1] = -1;
1724 patchSizes[allPatchi] = nFaces[uncompactAllPatchi];
1725 patchStarts[allPatchi] = startFacei;
1740 from1ToAllPatches[patch1] = allPatchi;
1742 startFacei += nFaces[uncompactAllPatchi];
1748 patchSizes.setSize(allPatchi);
1749 patchStarts.setSize(allPatchi);
1788 mesh0.resetMotion();
1789 mesh0.resetPrimitives
1801 mesh0.pointZones().
clear();
1802 mesh0.faceZones().clear();
1803 mesh0.cellZones().clear();
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
List< labelList > labelListList
A List of labelList.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< List< bool > > boolListList
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const indirectPrimitivePatch & masterPatch() const
Addressing engine for coupled faces on mesh0.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added m...
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
List< bool > boolList
Bool container classes.
void clear()
Delete object (if the pointer is valid) and set pointer to.
vectorField pointField
pointField is a vectorField.
void append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
MeshZones< pointZone, polyMesh > meshPointZones
A MeshZones with the type pointZone.
errorManip< error > abort(error &err)
MeshZones< cellZone, polyMesh > meshCellZones
A MeshZones with the type cellZone.
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
MeshZones< faceZone, polyMesh > meshFaceZones
A MeshZones with the type faceZone.
word name(const complex &)
Return a string representation of a complex.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
prefixOSstream Pout(cout, "Pout")
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Mesh consisting of general polyhedral cells.
void stableSort(UList< T > &)
static autoPtr< polyMesh > add(const IOobject &io, const polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, autoPtr< mapAddedPolyMesh > &mapPtr)
Add two polyMeshes. Returns new polyMesh and map construct.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
List< cell > cellList
list of cells
IOporosityModelList pZones(mesh)