66 bool Foam::localPointRegion::isDuplicate
82 if (f0[fp0] != f1[fp1])
89 fp1 = f1.fcIndex(fp1);
93 fp1 = f1.rcIndex(fp1);
101 void Foam::localPointRegion::countPointRegions
103 const polyMesh& mesh,
105 const Map<label>& candidateFace,
111 labelList minPointRegion(mesh.nPoints(), -1);
113 meshPointMap_.resize(candidateFace.size()/100);
115 DynamicList<labelList> pointRegions(meshPointMap_.size());
118 meshFaceMap_.resize(meshPointMap_.size());
122 label facei = iter.key();
124 if (!mesh.isInternalFace(facei))
126 const face&
f = mesh.faces()[facei];
128 if (minRegion[facei].empty())
131 <<
"Face from candidateFace without minRegion set." <<
endl
132 <<
"Face:" << facei <<
" fc:" << mesh.faceCentres()[facei]
143 if (candidatePoint[pointi])
145 label region = minRegion[facei][fp];
147 if (minPointRegion[pointi] == -1)
149 minPointRegion[pointi] = region;
151 else if (minPointRegion[pointi] != region)
155 if (iter != meshPointMap_.end())
157 labelList& regions = pointRegions[iter()];
160 label sz = regions.size();
161 regions.setSize(sz+1);
162 regions[sz] = region;
167 label localPointi = meshPointMap_.size();
168 meshPointMap_.insert(pointi, localPointi);
170 regions[0] = minPointRegion[pointi];
172 pointRegions.append(regions);
175 label meshFaceMapI = meshFaceMap_.size();
176 meshFaceMap_.insert(facei, meshFaceMapI);
182 minPointRegion.clear();
188 label facei = iter.key();
190 if (mesh.isInternalFace(facei))
192 const face&
f = mesh.faces()[facei];
198 if (candidatePoint[
f[fp]] && meshPointMap_.found(
f[fp]))
200 label meshFaceMapI = meshFaceMap_.size();
201 meshFaceMap_.insert(facei, meshFaceMapI);
209 pointRegions.shrink();
210 pointRegions_.setSize(pointRegions.size());
213 pointRegions_[i].transfer(pointRegions[i]);
217 faceRegions_.setSize(meshFaceMap_.size());
220 faceRegions_[iter()].labelList::transfer(minRegion[iter.key()]);
242 void Foam::localPointRegion::calcPointRegions
244 const polyMesh& mesh,
248 label nBnd = mesh.nFaces()-mesh.nInternalFaces();
249 const labelList& faceOwner = mesh.faceOwner();
250 const labelList& faceNeighbour = mesh.faceNeighbour();
265 Map<label> candidateFace(2*nBnd);
266 label candidateFacei = 0;
268 Map<label> candidateCell(nBnd);
269 label candidateCelli = 0;
271 forAll(mesh.faces(), facei)
273 const face&
f = mesh.faces()[facei];
277 if (candidatePoint[
f[fp]])
280 if (candidateFace.insert(facei, candidateFacei))
286 if (candidateCell.insert(faceOwner[facei], candidateCelli))
291 if (mesh.isInternalFace(facei))
293 label nei = faceNeighbour[facei];
294 if (candidateCell.insert(nei, candidateCelli))
308 globalIndex globalCells(mesh.nCells());
318 label facei = iter.key();
319 const face&
f = mesh.faces()[facei];
321 if (mesh.isInternalFace(facei))
323 label globOwn = globalCells.toGlobal(faceOwner[facei]);
324 label globNei = globalCells.toGlobal(faceNeighbour[facei]);
325 minRegion[facei].setSize(
f.
size(),
min(globOwn, globNei));
329 label globOwn = globalCells.toGlobal(faceOwner[facei]);
330 minRegion[facei].setSize(
f.
size(), globOwn);
343 Map<label> minPointValue(100);
347 minPointValue.clear();
349 label celli = iter.key();
350 const cell& cFaces = mesh.cells()[celli];
355 label facei = cFaces[cFacei];
357 if (minRegion[facei].size())
359 const face&
f = mesh.faces()[facei];
366 if (iter == minPointValue.end())
368 minPointValue.insert(pointi, minRegion[facei][fp]);
372 label currentMin = iter();
373 iter() =
min(currentMin, minRegion[facei][fp]);
382 label facei = cFaces[cFacei];
384 if (minRegion[facei].size())
386 const face&
f = mesh.faces()[facei];
390 label minVal = minPointValue[
f[fp]];
392 if (minVal != minRegion[facei][fp])
394 minRegion[facei][fp] = minVal;
416 mesh.nFaces()-mesh.nInternalFaces(),
417 mesh.nInternalFaces()
430 countPointRegions(mesh, candidatePoint, candidateFace, minRegion);
472 calcPointRegions(mesh, candidatePoint);
490 forAll(candidatePoints, i)
492 candidatePoint[candidatePoints[i]] =
true;
495 calcPointRegions(mesh, candidatePoint);
531 if (otherFacei > bFacei)
535 if (isDuplicate(
f, otherF,
true))
539 <<
" has local points:" <<
f
540 <<
" which are in same order as face:"
542 <<
" with local points:" << otherF
545 else if (isDuplicate(
f, otherF,
false))
552 duplicateFace[bFacei] != -1
553 || duplicateFace[otherFacei] != -1
557 <<
"One of two duplicate faces already marked"
558 <<
" as duplicate." <<
nl
559 <<
"This means that three or more faces share"
560 <<
" the same points and this is illegal." <<
nl
561 <<
"Face:" << meshFace0
562 <<
" with local points:" <<
f
563 <<
" which are in same order as face:"
565 <<
" with local points:" << otherF
569 duplicateFace[bFacei] = otherFacei;
570 duplicateFace[otherFacei] = bFacei;
576 return duplicateFace;
595 const labelList duplicateFace(findDuplicateFaces(mesh, testFaces));
602 label otherFacei = duplicateFace[i];
604 if (otherFacei != -1 && i < otherFacei)
606 label meshFace0 = testFaces[i];
608 label meshFace1 = testFaces[otherFacei];
614 (patch0 != -1 && isA<processorPolyPatch>(
patches[patch0]))
615 || (patch1 != -1 && isA<processorPolyPatch>(
patches[patch1]))
619 <<
"One of two duplicate faces is on"
620 <<
" processorPolyPatch."
621 <<
"This is not allowed." <<
nl
622 <<
"Face:" << meshFace0
623 <<
" is on patch:" <<
patches[patch0].name()
625 <<
"Face:" << meshFace1
626 <<
" is on patch:" <<
patches[patch1].name()
648 newMap.
insert(newFacei, iter());
651 meshFaceMap_.transfer(newMap);
666 meshPointMap_.transfer(newMap);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
friend class iterator
Declare friendship with the iterator.
A List with indirect addressing.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & pointFaces() const
Return point-face addressing.
label size() const
Return the number of elements in the list.
A face is a list of labels corresponding to mesh vertices.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
localPointRegion(const polyMesh &mesh)
Construct from mesh. Assumes all non-coupled boundary points.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
void operator()(face &x, const face &y) const
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
const labelList & reverseFaceMap() const
Reverse face map.
Cell-face mesh analysis engine.
virtual const faceList & faces() const =0
Return faces.
label nInternalFaces() const
virtual const pointField & points() const =0
Return mesh points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
Pair< label > labelPair
Label pair.
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.
errorManip< error > abort(error &err)
List< bool > boolList
Bool container classes.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< small) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &mergedCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]