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 patchDicts_.append(dictionary(IStringStream(
os.str())()));
85 const word&
caseName =
p.boundaryMesh().mesh().time().caseName();
89 Info<<
"label patchIndex(const polyPatch& p) : " 90 <<
"Patch " <<
p.index() <<
" named " 92 <<
" already exists, but patch types " 93 <<
" do not match.\nCreating a composite name as " 101 return patchNames_.
size() - 1;
105 Foam::label Foam::mergePolyMesh::zoneIndex
107 DynamicList<word>&
names,
113 if (
names[zonei] == curName)
126 void Foam::mergePolyMesh::sortProcessorPatches()
128 Info<<
"Reordering processor patches last" <<
endl;
137 const polyBoundaryMesh& oldPatches = boundaryMesh();
141 labelList oldToSorted(oldPatches.size());
145 forAll(oldPatches, patchi)
147 const polyPatch& pp = oldPatches[patchi];
149 if (!isA<processorPolyPatch>(pp))
168 forAll(oldPatches, patchi)
170 const polyPatch& pp = oldPatches[patchi];
172 if (isA<processorPolyPatch>(pp))
193 addPatches(newPatches);
197 DynamicList<label>&
patchID =
const_cast<DynamicList<label>&
> 215 Foam::mergePolyMesh::mergePolyMesh(
const IOobject&
io)
219 patchNames_(2*boundaryMesh().size()),
220 patchDicts_(2*boundaryMesh().size()),
226 wordList curPatchNames = boundaryMesh().names();
228 forAll(boundaryMesh(), patchi)
230 patchNames_.append(boundaryMesh()[patchi].
name());
233 boundaryMesh()[patchi].write(
os);
234 patchDicts_.append(dictionary(IStringStream(
os.str())()));
240 wordList curPointZoneNames = pointZones().names();
241 if (curPointZoneNames.size())
243 pointZoneNames_.setCapacity(2*curPointZoneNames.size());
244 pointZoneNames_.
append(curPointZoneNames);
248 wordList curFaceZoneNames = faceZones().names();
249 if (curFaceZoneNames.size())
251 faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
252 faceZoneNames_.
append(curFaceZoneNames);
256 wordList curCellZoneNames = cellZones().names();
257 if (curCellZoneNames.size())
259 cellZoneNames_.setCapacity(2*curCellZoneNames.size());
260 cellZoneNames_.
append(curCellZoneNames);
283 pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].
name());
289 zoneID = pz.whichZone(pointi);
294 zoneID = pointZoneIndices[zoneID];
297 renumberPoints[pointi] =
320 cellZoneIndices[zoneI] = zoneIndex(cellZoneNames_, cz[zoneI].
name());
326 zoneID = cz.whichZone(celli);
331 zoneID = cellZoneIndices[zoneID];
334 renumberCells[celli] =
349 const polyBoundaryMesh& bm = m.boundaryMesh();
354 forAll(patchIndices, patchi)
356 patchIndices[patchi] = patchIndex(bm[patchi]);
361 meshMod_.setNumPatches(patchNames_.size());
370 faceZoneIndices[zoneI] = zoneIndex(faceZoneNames_, fz[zoneI].
name());
377 const labelList& nei = m.faceNeighbour();
379 label newOwn, newNei, newPatch, newZone;
384 const face& curFace =
f[facei];
386 face newFace(curFace.size());
390 newFace[pointi] = renumberPoints[curFace[pointi]];
396 if (
min(newFace) < 0)
399 <<
"Error in point mapping for face " << facei
400 <<
". Old face: " << curFace <<
" New face: " << newFace
405 if (facei < m.nInternalFaces() || facei >= m.nFaces())
411 newPatch = patchIndices[bm.whichPatch(facei)];
415 if (newOwn > -1) newOwn = renumberCells[newOwn];
424 newNei = renumberCells[newNei];
428 newZone = fz.whichZone(facei);
433 newZoneFlip = fz[newZone].flipMap()[fz[newZone].whichFace(facei)];
436 newZone = faceZoneIndices[newZone];
439 renumberFaces[facei] =
462 Info<<
"patch names: " << patchNames_ <<
nl 463 <<
"patch dicts: " << patchDicts_ <<
nl 464 <<
"point zone names: " << pointZoneNames_ <<
nl 465 <<
"face zone names: " << faceZoneNames_ <<
nl 466 <<
"cell zone names: " << cellZoneNames_ <<
endl;
469 if (patchNames_.size() != boundaryMesh().size())
471 Info<<
"Copying old patches" <<
endl;
475 const polyBoundaryMesh& oldPatches = boundaryMesh();
480 for (patchi = 0; patchi < oldPatches.size(); patchi++)
485 oldPatches[patchi].clone(oldPatches)
489 Info<<
"Adding new patches. " <<
endl;
491 label endOfLastPatch =
494 : oldPatches[patchi - 1].start() + oldPatches[patchi - 1].size();
496 for (; patchi < patchNames_.size(); patchi++)
499 dictionary
dict(patchDicts_[patchi]);
500 dict.set(
"nFaces", 0);
501 dict.set(
"startFace", endOfLastPatch);
519 addPatches(newPatches);
523 if (pointZoneNames_.size() > pointZones().size())
525 Info<<
"Adding new pointZones." <<
endl;
527 label zonei = pointZones().size();
529 const label nZones = pointZoneNames_.size();
531 pointZones().setSize(nZones);
533 for (; zonei < nZones; ++zonei)
538 new pointZone(pointZoneNames_[zonei], zonei, pointZones())
542 if (cellZoneNames_.size() > cellZones().size())
544 Info<<
"Adding new cellZones." <<
endl;
546 label zonei = cellZones().size();
548 const label nZones = cellZoneNames_.size();
550 cellZones().setSize(cellZoneNames_.size());
552 for (; zonei < nZones; ++zonei)
557 new cellZone(cellZoneNames_[zonei], zonei, cellZones())
561 if (faceZoneNames_.size() > faceZones().size())
563 Info<<
"Adding new faceZones." <<
endl;
565 label zonei = faceZones().size();
567 const label nZones = faceZoneNames_.size();
569 faceZones().setSize(nZones);
571 for (; zonei < nZones; ++zonei)
576 new faceZone(faceZoneNames_[zonei], zonei, faceZones())
583 sortProcessorPatches();
586 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.
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)
List< face > faceList
A List of faces.
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.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
vectorField pointField
pointField is a vectorField.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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
A List of words.
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.
const fileName & caseName() const
Return the Time::caseName()
List< cell > cellList
A List of cells.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.