40 Foam::label Foam::mergePolyMesh::patchIndex(
const polyPatch&
p)
44 const word& pType =
p.type();
45 const word& pName =
p.name();
47 bool nameFound =
false;
51 if (patchNames_[
patchi] == pName)
53 if (word(patchDicts_[
patchi][
"type"]) == pType)
70 patchDicts_.append(dictionary(IStringStream(os.str())()));
77 const word& caseName =
p.boundaryMesh().mesh().time().caseName();
79 patchNames_.
append(pName +
"_" + caseName);
81 Info<<
"label patchIndex(const polyPatch& p) : "
82 <<
"Patch " <<
p.index() <<
" named "
83 << pName <<
" in mesh " << caseName
84 <<
" already exists, but patch types "
85 <<
" do not match.\nCreating a composite name as "
93 return patchNames_.
size() - 1;
99 DynamicList<word>& names,
105 if (names[zonei] == curName)
112 names.append(curName);
114 return names.size() - 1;
124 patchNames_(2*mesh_.boundaryMesh().size()),
125 patchDicts_(2*mesh_.boundaryMesh().size()),
131 wordList curPatchNames = mesh_.boundaryMesh().names();
135 patchNames_.append(mesh_.boundaryMesh()[
patchi].name());
138 mesh_.boundaryMesh()[
patchi].write(os);
139 patchDicts_.append(dictionary(IStringStream(os.str())()));
145 wordList curPointZoneNames = mesh_.pointZones().toc();
146 if (curPointZoneNames.size())
148 pointZoneNames_.setCapacity(2*curPointZoneNames.size());
151 forAll(curPointZoneNames, zonei)
153 pointZoneNames_.append(curPointZoneNames[zonei]);
156 pointZonesAddedPoints_.setSize(pointZoneNames_.size());
159 wordList curFaceZoneNames = mesh_.faceZones().toc();
161 if (curFaceZoneNames.size())
163 faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
166 forAll(curFaceZoneNames, zonei)
168 faceZoneNames_.append(curFaceZoneNames[zonei]);
171 faceZonesAddedOrientedFaces_.setSize(faceZoneNames_.size());
173 faceZonesAddedFaces_.setSize(faceZoneNames_.size());
176 wordList curCellZoneNames = mesh_.cellZones().toc();
178 if (curCellZoneNames.size())
180 cellZoneNames_.setCapacity(2*curCellZoneNames.size());
183 forAll(curCellZoneNames, zonei)
185 cellZoneNames_.append(curCellZoneNames[zonei]);
188 cellZonesAddedCells_.setSize(cellZoneNames_.size());
203 const pointZoneList& pz = m.pointZones();
208 pointZoneIndices[zonei] = zoneIndex(pointZoneNames_, pz[zonei].
name());
209 pointZonesAddedPoints_.setSize(pointZoneNames_.
size());
214 renumberPoints[pointi] = meshMod_.
addPoint
221 const labelList zones(pz.whichZones(pointi));
224 pointZonesAddedPoints_[pointZoneIndices[zones[zonei]]]
225 .insert(renumberPoints[pointi]);
234 const cellZoneList& cz = m.cellZones();
239 cellZoneIndices[zonei] = zoneIndex(cellZoneNames_, cz[zonei].
name());
240 cellZonesAddedCells_.setSize(cellZoneNames_.
size());
245 renumberCells[celli] = meshMod_.
addCell(-1);
247 const labelList zones(cz.whichZones(celli));
250 cellZonesAddedCells_[cellZoneIndices[zones[zonei]]]
251 .insert(renumberCells[celli]);
256 const polyBoundaryMesh& bm = m.boundaryMesh();
272 const faceZoneList& fz = m.faceZones();
277 faceZoneIndices[zonei] = zoneIndex(faceZoneNames_, fz[zonei].
name());
284 const labelList& nei = m.faceNeighbour();
286 label newOwn, newNei, newPatch;
290 const face& curFace =
f[facei];
292 face newFace(curFace.size());
296 newFace[pointi] = renumberPoints[curFace[pointi]];
302 if (
min(newFace) < 0)
305 <<
"Error in point mapping for face " << facei
306 <<
". Old face: " << curFace <<
" New face: " << newFace
311 if (facei < m.nInternalFaces() || facei >= m.nFaces())
317 newPatch = patchIndices[bm.whichPatch(facei)];
321 if (newOwn > -1) newOwn = renumberCells[newOwn];
330 newNei = renumberCells[newNei];
333 renumberFaces[facei] = meshMod_.
addFace
343 const labelList zones(fz.whichZones(facei));
346 const faceZone& fzi = fz[zones[zonei]];
347 const bool flip = fzi.flipMap()[fzi.localIndex(facei)];
351 faceZonesAddedOrientedFaces_[faceZoneIndices[zones[zonei]]]
352 .insert(renumberFaces[facei], flip);
356 faceZonesAddedFaces_[faceZoneIndices[zones[zonei]]]
357 .insert(renumberFaces[facei]);
368 Info<<
"patch names: " << patchNames_ <<
nl
369 <<
"patch dicts: " << patchDicts_ <<
nl
370 <<
"point zone names: " << pointZoneNames_ <<
nl
371 <<
"face zone names: " << faceZoneNames_ <<
nl
372 <<
"cell zone names: " << cellZoneNames_ <<
endl;
376 if (patchNames_.size() != mesh_.boundaryMesh().size())
380 Info<<
"Copying old patches" <<
endl;
383 List<polyPatch*> newPatches(patchNames_.size());
385 const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();
392 newPatches[
patchi] = oldPatches[
patchi].clone(oldPatches).ptr();
397 Info<<
"Adding new patches. " <<
endl;
400 label endOfLastPatch =
403 : oldPatches[
patchi - 1].start() + oldPatches[
patchi - 1].size();
409 dict.set(
"nFaces", 0);
410 dict.set(
"startFace", endOfLastPatch);
424 mesh_.removeBoundary();
425 mesh_.addPatches(newPatches);
429 if (pointZoneNames_.size() > mesh_.pointZones().size())
433 Info<<
"Adding new pointZones. " <<
endl;
436 label nZones = mesh_.pointZones().size();
438 mesh_.pointZones().setSize(pointZoneNames_.size());
440 for (
label zonei = nZones; zonei < pointZoneNames_.size(); zonei++)
442 mesh_.pointZones().set
447 pointZoneNames_[zonei],
455 if (cellZoneNames_.size() > mesh_.cellZones().size())
459 Info<<
"Adding new cellZones. " <<
endl;
462 label nZones = mesh_.cellZones().size();
464 mesh_.cellZones().setSize(cellZoneNames_.size());
466 for (
label zonei = nZones; zonei < cellZoneNames_.size(); zonei++)
468 mesh_.cellZones().set
473 cellZoneNames_[zonei],
481 if (faceZoneNames_.size() > mesh_.faceZones().size())
485 Info<<
"Adding new faceZones. " <<
endl;
488 label nZones = mesh_.faceZones().size();
490 mesh_.faceZones().setSize(faceZoneNames_.size());
492 for (
label zonei = nZones; zonei < faceZoneNames_.size(); zonei++)
494 mesh_.faceZones().set
499 faceZoneNames_[zonei],
509 autoPtr<polyTopoChangeMap> map(meshMod_.changeMesh(mesh_));
512 mesh_.pointZones().insert(pointZonesAddedPoints_);
515 mesh_.faceZones().insert(faceZonesAddedOrientedFaces_);
518 mesh_.faceZones().insert(faceZonesAddedFaces_);
521 mesh_.cellZones().insert(cellZonesAddedCells_);
523 mesh_.topoChange(map);
#define forAll(list, i)
Loop across all elements in list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
T & last()
Return the last element of the list.
void addMesh(const polyMesh &m)
Add a mesh.
mergePolyMesh(polyMesh &mesh)
Construct from polyMesh.
void merge()
Merge meshes.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
void setNumPatches(const label nPatches)
Explicitly set the number of patches if construct-without-mesh.
label addCell(const label masterCellID)
Add cell and return new cell index.
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
label addFace(const face &f, const label own, const label nei, const label masterFaceID, const bool flipFaceFlux, const label patchID)
Add face to cells and return new face index.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
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< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.