47 void Foam::meshReader::addPolyBoundaryFace
50 const label cellFaceId,
51 const label nCreatedFaces
56 <<
" add bnd for cell " <<
cellId 57 <<
" face " << cellFaceId
69 <<
"Problem with face: " << thisFace <<
endl 70 <<
"Probably multiple definitions " 71 <<
"of a single boundary face." <<
endl 74 else if (cellPolys_[
cellId][cellFaceId] >= 0)
77 <<
"Problem with face: " << thisFace <<
endl 78 <<
"Probably trying to define a boundary face " 79 <<
"on a previously matched internal face." <<
endl 86 cellPolys_[
cellId][cellFaceId] = nCreatedFaces;
90 void Foam::meshReader::addPolyBoundaryFace
92 const cellFaceIdentifier& identifier,
93 const label nCreatedFaces
107 void Foam::meshReader::createPolyBoundary()
109 label nBoundaryFaces = 0;
110 label nMissingFaces = 0;
111 label nInterfaces = 0;
118 cell& curCell = cellPolys_[celli];
129 forAll(boundaryIds_, patchi)
131 nBoundaryFaces += boundaryIds_[patchi].size();
135 <<
"There are " << nMissingFaces
136 <<
" faces to be patched and " << nBoundaryFaces
137 <<
" specified - collect missed boundaries to final patch" <<
endl;
139 patchStarts_.setSize(boundaryIds_.size());
140 patchSizes_.setSize(boundaryIds_.size());
142 label nCreatedFaces = nInternalFaces_;
143 label baffleOffset = cFaces.size();
144 interfaces_.setSize(baffleIds_.size());
147 forAll(boundaryIds_, patchi)
149 const List<cellFaceIdentifier>& idList = boundaryIds_[patchi];
151 patchStarts_[patchi] = nCreatedFaces;
154 if (patchPhysicalTypes_[patchi] ==
"baffle")
158 for (label side = 0; side < 2; ++side)
160 label position = nInterfaces;
164 label baffleI = idList[bndI].cellId() - baffleOffset;
169 && baffleI < baffleFaces_.size()
170 && baffleIds_[baffleI].size()
175 baffleIds_[baffleI][side],
182 baffleIds_[baffleI].clear();
185 interfaces_[position][side] = nCreatedFaces;
197 else if (patchPhysicalTypes_[patchi] ==
"monitoring")
205 label
cellId = idList[bndI].cellId();
206 label
faceId = idList[bndI].faceId();
209 if (
cellId < baffleOffset)
214 monitoring[monitorI++] = faceNr;
219 monitoringSets_.insert(patchNames_[patchi], monitoring);
226 if (idList[bndI].
cellId() < baffleOffset)
240 patchSizes_[patchi] = nCreatedFaces - patchStarts_[patchi];
244 Info<<
"Missing faces added to patch after face " 245 << nCreatedFaces <<
":" <<
endl;
249 for (label side = 0; side < 2; ++side)
251 label position = nInterfaces;
253 forAll(baffleIds_, baffleI)
255 if (baffleIds_[baffleI].size())
260 baffleIds_[baffleI][side],
264 interfaces_[position][side] = nCreatedFaces;
269 baffleIds_[baffleI].clear();
279 nInterfaces += (nMissingFaces - (nMissingFaces % 2)) / 2;
284 const labelList& curFaces = cellPolys_[celli];
286 forAll(curFaces, cellFacei)
288 if (curFaces[cellFacei] < 0)
291 if (nMissingFaces < 4)
293 const face& thisFace = cFaces[celli][cellFacei];
295 Info<<
" cell " << celli <<
" face " << cellFacei
296 <<
" (original cell " << origCellId_[celli] <<
")" 297 <<
" face: " << thisFace
300 else if (nMissingFaces == 5)
305 addPolyBoundaryFace(celli, cellFacei, nCreatedFaces);
312 Info<<
"Added " << nMissingFaces <<
" unmatched faces" <<
endl;
315 if (nMissingFaces > 0)
317 patchSizes_.last() = nMissingFaces;
322 meshFaces_.setSize(nCreatedFaces);
330 const labelList& curFaces = cellPolys_[celli];
334 markupFaces[curFaces[facei]]++;
338 for (label i = nInternalFaces_; i < markupFaces.size(); i++)
343 label nProblemFaces = 0;
345 forAll(markupFaces, facei)
347 if (markupFaces[facei] != 2)
349 const face& problemFace = meshFaces_[facei];
352 <<
"Problem with face " << facei <<
": addressed " 353 << markupFaces[facei] <<
" times (should be 2!). Face: " 354 << problemFace <<
endl;
360 if (nProblemFaces > 0)
362 Info<<
"Number of incorrectly matched faces: " 363 << nProblemFaces <<
endl;
367 if (nInterfaces < interfaces_.size())
369 interfaces_.setSize(nInterfaces);
372 Info<<
"Number of boundary faces: " << nBoundaryFaces <<
nl 373 <<
"Total number of faces: " << nCreatedFaces <<
nl 374 <<
"Number of interfaces: " << nInterfaces <<
endl;
381 Foam::meshReader::polyBoundaryPatches(
const polyMesh&
mesh)
383 label nUsed = 0, nEmpty = 0;
384 label
nPatches = patchStarts_.size();
388 forAll(patchSizes_, patchi)
390 if (patchSizes_[patchi] > 0)
392 oldToNew[patchi] = nUsed++;
397 oldToNew[patchi] =
nPatches - nEmpty;
405 Info<<
"Removing " << nEmpty <<
" empty patches" <<
endl;
422 PtrList<dictionary>
patchDicts(patchNames_.size());
446 if (!patchDict.found(
"type"))
448 patchDict.add(
"type", patchTypes_[patchi],
false);
455 patchi < patchPhysicalTypes_.size()
456 && patchPhysicalTypes_[patchi].size()
457 && patchPhysicalTypes_[patchi] != patchTypes_[patchi]
458 && !patchDict.found(
"physicalType")
461 patchDict.add(
"physicalType", patchPhysicalTypes_[patchi],
false);
465 patchDict.add(
"nFaces", patchSizes_[patchi],
true);
466 patchDict.add(
"startFace", patchStarts_[patchi],
true);
470 forAll(patchStarts_, patchi)
List< faceList > faceListList
List of faceList.
constexpr char nl
The newline '\n' character (0x0a)
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
labelList origCellId_
Lookup original Cell number for a given cell.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
faceList meshFaces_
Global face list for polyMesh.
const fileName & instance() const noexcept
Read access to instance path component.
void preservePatchTypes(const objectRegistry &obr, const word &meshInstance, const fileName &meshDir, const wordList &patchNames, PtrList< dictionary > &patchDicts, const word &defaultFacesName, word &defaultFacesType)
Preserve patch types.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
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.
PtrList< dictionary > patchDicts
List< label > labelList
A List of labels.
label nInternalFaces_
Number of internal faces for polyMesh.
faceListList cellFaces_
List of faces for every cell.
#define InfoInFunction
Report an information message using Foam::Info.
static constexpr const zero Zero
Global zero (0)