48 Foam::label Foam::mergePolyMesh::patchIndex(
const polyPatch&
p)
52 const word& pType =
p.type();
53 const word& pName =
p.name();
55 bool nameFound =
false;
57 forAll(patchNames_, patchi)
59 if (patchNames_[patchi] == pName)
61 if (patchDicts_[patchi].get<word>(
"type") == pType)
78 ISpanStream is(
os.view());
87 const word&
caseName =
p.boundaryMesh().mesh().time().caseName();
91 Info<<
"label patchIndex(const polyPatch& p) : " 92 <<
"Patch " <<
p.index() <<
" named " 94 <<
" already exists, but patch types " 95 <<
" do not match.\nCreating a composite name as " 100 patchNames_.
append(pName);
103 return patchNames_.
size() - 1;
107 Foam::label Foam::mergePolyMesh::zoneIndex
109 DynamicList<word>&
names,
115 if (
names[zonei] == curName)
128 void Foam::mergePolyMesh::sortProcessorPatches()
130 Info<<
"Reordering processor patches last" <<
endl;
139 const polyBoundaryMesh& oldPatches = boundaryMesh();
143 labelList oldToSorted(oldPatches.size());
147 forAll(oldPatches, patchi)
149 const polyPatch&
pp = oldPatches[patchi];
151 if (!isA<processorPolyPatch>(
pp))
170 forAll(oldPatches, patchi)
172 const polyPatch&
pp = oldPatches[patchi];
174 if (isA<processorPolyPatch>(
pp))
195 addPatches(newPatches);
199 DynamicList<label>&
patchID =
const_cast<DynamicList<label>&
> 217 Foam::mergePolyMesh::mergePolyMesh(
const IOobject&
io)
221 patchNames_(2*boundaryMesh().size()),
222 patchDicts_(2*boundaryMesh().size()),
228 wordList curPatchNames = boundaryMesh().names();
231 forAll(boundaryMesh(), patchi)
234 boundaryMesh()[patchi].write(
os);
235 ISpanStream is(
os.view());
237 patchNames_.push_back(boundaryMesh()[patchi].
name());
244 wordList curPointZoneNames = pointZones().names();
245 if (curPointZoneNames.size())
247 pointZoneNames_.setCapacity(2*curPointZoneNames.size());
248 pointZoneNames_.
append(curPointZoneNames);
252 wordList curFaceZoneNames = faceZones().names();
253 if (curFaceZoneNames.size())
255 faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
256 faceZoneNames_.
append(curFaceZoneNames);
260 wordList curCellZoneNames = cellZones().names();
261 if (curCellZoneNames.size())
263 cellZoneNames_.setCapacity(2*curCellZoneNames.size());
264 cellZoneNames_.
append(curCellZoneNames);
287 pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].
name());
293 zoneID = pz.whichZone(pointi);
298 zoneID = pointZoneIndices[zoneID];
301 renumberPoints[pointi] =
324 cellZoneIndices[zoneI] = zoneIndex(cellZoneNames_, cz[zoneI].
name());
330 zoneID = cz.whichZone(celli);
335 zoneID = cellZoneIndices[zoneID];
338 renumberCells[celli] =
353 const polyBoundaryMesh& bm = m.boundaryMesh();
358 forAll(patchIndices, patchi)
360 patchIndices[patchi] = patchIndex(bm[patchi]);
365 meshMod_.setNumPatches(patchNames_.size());
374 faceZoneIndices[zoneI] = zoneIndex(faceZoneNames_, fz[zoneI].
name());
381 const labelList& nei = m.faceNeighbour();
383 label newOwn, newNei, newPatch, newZone;
388 const face& curFace =
f[facei];
390 face newFace(curFace.size());
394 newFace[pointi] = renumberPoints[curFace[pointi]];
400 if (
min(newFace) < 0)
403 <<
"Error in point mapping for face " << facei
404 <<
". Old face: " << curFace <<
" New face: " << newFace
409 if (facei < m.nInternalFaces() || facei >= m.nFaces())
415 newPatch = patchIndices[bm.whichPatch(facei)];
419 if (newOwn > -1) newOwn = renumberCells[newOwn];
428 newNei = renumberCells[newNei];
432 newZone = fz.whichZone(facei);
437 newZoneFlip = fz[newZone].flipMap()[fz[newZone].whichFace(facei)];
440 newZone = faceZoneIndices[newZone];
443 renumberFaces[facei] =
466 Info<<
"patch names: " << patchNames_ <<
nl 467 <<
"patch dicts: " << patchDicts_ <<
nl 468 <<
"point zone names: " << pointZoneNames_ <<
nl 469 <<
"face zone names: " << faceZoneNames_ <<
nl 470 <<
"cell zone names: " << cellZoneNames_ <<
endl;
473 if (patchNames_.size() != boundaryMesh().size())
475 Info<<
"Copying old patches" <<
endl;
479 const polyBoundaryMesh& oldPatches = boundaryMesh();
484 for (patchi = 0; patchi < oldPatches.size(); patchi++)
489 oldPatches[patchi].clone(oldPatches)
493 Info<<
"Adding new patches. " <<
endl;
495 label endOfLastPatch =
498 : oldPatches[patchi - 1].start() + oldPatches[patchi - 1].size();
500 for (; patchi < patchNames_.size(); patchi++)
504 dict.set(
"nFaces", 0);
505 dict.set(
"startFace", endOfLastPatch);
523 addPatches(newPatches);
527 if (pointZoneNames_.size() > pointZones().size())
529 Info<<
"Adding new pointZones." <<
endl;
531 label zonei = pointZones().size();
533 const label nZones = pointZoneNames_.size();
535 pointZones().setSize(nZones);
537 for (; zonei < nZones; ++zonei)
542 new pointZone(pointZoneNames_[zonei], zonei, pointZones())
546 if (cellZoneNames_.size() > cellZones().size())
548 Info<<
"Adding new cellZones." <<
endl;
550 label zonei = cellZones().size();
552 const label nZones = cellZoneNames_.size();
554 cellZones().setSize(cellZoneNames_.size());
556 for (; zonei < nZones; ++zonei)
561 new cellZone(cellZoneNames_[zonei], zonei, cellZones())
565 if (faceZoneNames_.size() > faceZones().size())
567 Info<<
"Adding new faceZones." <<
endl;
569 label zonei = faceZones().size();
571 const label nZones = faceZoneNames_.size();
573 faceZones().setSize(nZones);
575 for (; zonei < nZones; ++zonei)
580 new faceZone(faceZoneNames_[zonei], zonei, faceZones())
587 sortProcessorPatches();
590 meshMod_.changeMesh(*
this,
false);
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
List< cell > cellList
List of cell.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
constexpr char nl
The newline '\n' character (0x0a)
const word & name() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
void addMesh(const polyMesh &m)
Add a mesh.
#define forAll(list, i)
Loop across all elements in list.
const fileName & caseName() const noexcept
Return the Time::caseName()
List< face > faceList
List of faces.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
void append(const T &val)
Copy append an element to the end of this list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
void merge()
Merge meshes.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
T & last()
Access last element of the list, position [size()-1].
List< word > wordList
List of word.
const dimensionedScalar c
Speed of light in a vacuum.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())