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.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_.
boundary().size()),
125 patchDicts_(2*mesh_.
boundary().size()),
131 wordList curPatchNames = mesh_.boundary().names();
135 patchNames_.append(mesh_.boundary()[
patchi].name());
138 mesh_.boundary()[
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());
210 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());
241 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.boundary();
272 const faceZoneList& fz = m.faceZones();
277 faceZoneIndices[zonei] = zoneIndex(faceZoneNames_, fz[zonei].
name());
279 faceZonesAddedFaces_.setSize(faceZoneNames_.
size());
280 faceZonesAddedOrientedFaces_.setSize(faceZoneNames_.
size());
286 const labelList& nei = m.faceNeighbour();
288 label newOwn, newNei, newPatch;
292 const face& curFace =
f[facei];
294 face newFace(curFace.size());
298 newFace[pointi] = renumberPoints[curFace[pointi]];
304 if (
min(newFace) < 0)
307 <<
"Error in point mapping for face " << facei
308 <<
". Old face: " << curFace <<
" New face: " << newFace
313 if (facei < m.nInternalFaces() || facei >= m.nFaces())
319 newPatch = patchIndices[bm.whichPatch(facei)];
323 if (newOwn > -1) newOwn = renumberCells[newOwn];
332 newNei = renumberCells[newNei];
335 renumberFaces[facei] = meshMod_.
addFace
345 const labelList zones(fz.whichZones(facei));
348 const faceZone& fzi = fz[zones[zonei]];
349 const bool flip = fzi.flipMap()[fzi.localIndex(facei)];
353 faceZonesAddedOrientedFaces_[faceZoneIndices[zones[zonei]]]
354 .insert(renumberFaces[facei], flip);
358 faceZonesAddedFaces_[faceZoneIndices[zones[zonei]]]
359 .insert(renumberFaces[facei]);
370 Info<<
"patch names: " << patchNames_ <<
nl
371 <<
"patch dicts: " << patchDicts_ <<
nl
372 <<
"point zone names: " << pointZoneNames_ <<
nl
373 <<
"face zone names: " << faceZoneNames_ <<
nl
374 <<
"cell zone names: " << cellZoneNames_ <<
endl;
378 if (patchNames_.size() != mesh_.boundary().size())
382 Info<<
"Copying old patches" <<
endl;
387 const polyBoundaryMesh& oldPatches = mesh_.boundary();
394 newPatches[
patchi] = oldPatches[
patchi].clone(oldPatches).ptr();
399 Info<<
"Adding new patches. " <<
endl;
402 label endOfLastPatch =
405 : oldPatches[
patchi - 1].start() + oldPatches[
patchi - 1].size();
411 dict.set(
"nFaces", 0);
412 dict.set(
"startFace", endOfLastPatch);
426 mesh_.removeBoundary();
427 mesh_.addPatches(newPatches);
431 if (pointZoneNames_.size() > mesh_.pointZones().size())
435 Info<<
"Adding new pointZones. " <<
endl;
438 label nZones = mesh_.pointZones().size();
440 mesh_.pointZones().setSize(pointZoneNames_.size());
442 for (
label zonei = nZones; zonei < pointZoneNames_.size(); zonei++)
444 mesh_.pointZones().set
449 pointZoneNames_[zonei],
457 if (cellZoneNames_.size() > mesh_.cellZones().size())
461 Info<<
"Adding new cellZones. " <<
endl;
464 label nZones = mesh_.cellZones().size();
466 mesh_.cellZones().setSize(cellZoneNames_.size());
468 for (
label zonei = nZones; zonei < cellZoneNames_.size(); zonei++)
470 mesh_.cellZones().set
475 cellZoneNames_[zonei],
483 if (faceZoneNames_.size() > mesh_.faceZones().size())
487 Info<<
"Adding new faceZones. " <<
endl;
490 label nZones = mesh_.faceZones().size();
492 mesh_.faceZones().setSize(faceZoneNames_.size());
494 for (
label zonei = nZones; zonei < faceZoneNames_.size(); zonei++)
496 mesh_.faceZones().set
501 faceZoneNames_[zonei],
511 autoPtr<polyTopoChangeMap> map(meshMod_.changeMesh(mesh_));
514 mesh_.pointZones().insert(pointZonesAddedPoints_);
517 mesh_.faceZones().insert(faceZonesAddedOrientedFaces_);
520 mesh_.faceZones().insert(faceZonesAddedFaces_);
523 mesh_.cellZones().insert(cellZonesAddedCells_);
525 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.
Motion of the mesh specified as a list of pointMeshMovers.
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.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
faceListList boundary(nPatches)