44 void Foam::meshReader::addPolyBoundaryFace
47 const label cellFaceId,
48 const label nCreatedFaces
53 <<
" add bnd for cell " <<
cellId
54 <<
" face " << cellFaceId
63 if (cellPolys_[
cellId][cellFaceId] > nInternalFaces_)
66 <<
"Problem with face: " << thisFace <<
endl
67 <<
"Probably multiple definitions "
68 <<
"of a single boundary face." <<
endl
71 else if (cellPolys_[
cellId][cellFaceId] >= 0)
74 <<
"Problem with face: " << thisFace <<
endl
75 <<
"Probably trying to define a boundary face "
76 <<
"on a previously matched internal face." <<
endl
78 << meshFaces_[cellPolys_[
cellId][cellFaceId]]
82 meshFaces_[nCreatedFaces] = thisFace;
83 cellPolys_[
cellId][cellFaceId] = nCreatedFaces;
87 void Foam::meshReader::addPolyBoundaryFace
89 const cellFaceIdentifier& identifier,
90 const label nCreatedFaces
93 addPolyBoundaryFace(identifier.cell, identifier.face, nCreatedFaces);
99 void Foam::meshReader::createPolyBoundary()
101 label nBoundaryFaces = 0;
102 label nMissingFaces = 0;
103 label nInterfaces = 0;
110 cell& curCell = cellPolys_[celli];
123 nBoundaryFaces += boundaryIds_[
patchi].size();
127 <<
"There are " << nMissingFaces
128 <<
" faces to be patched and " << nBoundaryFaces
129 <<
" specified - collect missed boundaries to final patch" <<
endl;
131 patchStarts_.setSize(boundaryIds_.size());
132 patchSizes_.setSize(boundaryIds_.size());
134 label nCreatedFaces = nInternalFaces_;
135 label baffleOffset = cFaces.size();
136 interfaces_.setSize(baffleIds_.size());
141 const List<cellFaceIdentifier>& idList = boundaryIds_[
patchi];
143 patchStarts_[
patchi] = nCreatedFaces;
146 if (patchPhysicalTypes_[
patchi] ==
"baffle")
150 for (
label side = 0; side < 2; ++side)
152 label position = nInterfaces;
156 label baffleI = idList[bndI].cell - baffleOffset;
161 && baffleI < baffleFaces_.size()
162 && baffleIds_[baffleI].size()
167 baffleIds_[baffleI][side],
174 baffleIds_[baffleI].clear();
177 interfaces_[position][side] = nCreatedFaces;
189 else if (patchPhysicalTypes_[
patchi] ==
"monitoring")
192 List<label> monitoring(idList.size());
201 if (
cellId < baffleOffset)
206 monitoring[monitorI++] = faceNr;
211 monitoringSets_.insert(patchNames_[
patchi], monitoring);
218 if (idList[bndI].cell < baffleOffset)
232 patchSizes_[
patchi] = nCreatedFaces - patchStarts_[
patchi];
236 Info<<
"Missing faces added to patch after face "
237 << nCreatedFaces <<
":" <<
endl;
241 for (
label side = 0; side < 2; ++side)
243 label position = nInterfaces;
245 forAll(baffleIds_, baffleI)
247 if (baffleIds_[baffleI].size())
252 baffleIds_[baffleI][side],
256 interfaces_[position][side] = nCreatedFaces;
261 baffleIds_[baffleI].clear();
271 nInterfaces += (nMissingFaces - (nMissingFaces % 2)) / 2;
276 const labelList& curFaces = cellPolys_[celli];
278 forAll(curFaces, cellFacei)
280 if (curFaces[cellFacei] < 0)
283 if (nMissingFaces < 4)
285 const face& thisFace = cFaces[celli][cellFacei];
287 Info<<
" cell " << celli <<
" face " << cellFacei
288 <<
" (original cell " << origCellId_[celli] <<
")"
289 <<
" face: " << thisFace
292 else if (nMissingFaces == 5)
297 addPolyBoundaryFace(celli, cellFacei, nCreatedFaces);
304 Info<<
"Added " << nMissingFaces <<
" unmatched faces" <<
endl;
307 if (nMissingFaces > 0)
309 patchSizes_.last() = nMissingFaces;
314 meshFaces_.setSize(nCreatedFaces);
318 labelList markupFaces(meshFaces_.size(), 0);
322 const labelList& curFaces = cellPolys_[celli];
326 markupFaces[curFaces[facei]]++;
330 for (
label i = nInternalFaces_; i < markupFaces.size(); i++)
335 label nProblemFaces = 0;
337 forAll(markupFaces, facei)
339 if (markupFaces[facei] != 2)
341 const face& problemFace = meshFaces_[facei];
344 <<
"Problem with face " << facei <<
": addressed "
345 << markupFaces[facei] <<
" times (should be 2!). Face: "
346 << problemFace <<
endl;
352 if (nProblemFaces > 0)
354 Info<<
"Number of incorrectly matched faces: "
355 << nProblemFaces <<
endl;
359 if (nInterfaces < interfaces_.size())
361 interfaces_.setSize(nInterfaces);
364 Info<<
"Number of boundary faces: " << nBoundaryFaces <<
nl
365 <<
"Total number of faces: " << nCreatedFaces <<
nl
366 <<
"Number of interfaces: " << nInterfaces <<
endl;
373 Foam::meshReader::polyBoundaryPatches(
const polyMesh& mesh)
375 label nUsed = 0, nEmpty = 0;
382 if (patchSizes_[
patchi] > 0)
384 oldToNew[
patchi] = nUsed++;
397 Info<<
"Removing " << nEmpty <<
" empty patches" <<
endl;
414 PtrList<dictionary>
patchDicts(patchNames_.size());
438 patchDict.add(
"type", patchTypes_[
patchi],
false);
439 if (patchPhysicalTypes_.size() && patchPhysicalTypes_[
patchi].size())
441 patchDict.add(
"startFace", patchPhysicalTypes_[
patchi],
false);
445 patchDict.add(
"nFaces", patchSizes_[
patchi],
true);
446 patchDict.add(
"startFace", patchStarts_[
patchi],
true);
#define forAll(list, i)
Loop across all elements in list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
labelList origCellId_
Lookup original Cell number for a given cell.
faceListList cellFaces_
List of faces for every cell.
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.
#define InfoInFunction
Report an information message using Foam::Info.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< faceList > faceListList
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.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
PtrList< dictionary > patchDicts