41 List<DynamicList<label, primitiveMesh::cellsPerPoint_> >
53 label curPoint = labels[j];
54 DynamicList<label, primitiveMesh::cellsPerPoint_>& curPointCells =
58 curPointCells.append(i);
66 pointCellAddr[pointI].transfer(pc[pointI]);
89 const face& curFace = patchFaces[fI];
90 const labelList& facePoints = patchFaces[fI];
94 const labelList& facePointCells = pointCells[facePoints[pointI]];
96 forAll(facePointCells, cellI)
98 faceList cellFaces = cellsFaceShapes[facePointCells[cellI]];
100 forAll(cellFaces, cellFace)
105 FaceCells[fI] = facePointCells[cellI];
120 "polyMesh::facePatchFaceCells(const faceList& patchFaces," 121 "const labelListList& pointCells," 122 "const faceListList& cellsFaceShapes," 123 "const label patchID)" 124 ) <<
"face " << fI <<
" in patch " << patchID
125 <<
" does not have neighbour cell" 126 <<
" face: " << patchFaces[fI]
136 void Foam::polyMesh::setTopology
143 label& defaultPatchStart,
154 cells.
setSize(cellsAsShapes.size());
156 forAll(cellsFaceShapes, cellI)
158 cellsFaceShapes[cellI] = cellsAsShapes[cellI].faces();
160 cells[cellI].setSize(cellsFaceShapes[cellI].
size());
163 static_cast<labelList&
>(cells[cellI]) = -1;
166 maxFaces += cellsFaceShapes[cellI].
size();
176 labelListList PointCells = cellShapePointCells(cellsAsShapes);
188 const faceList& curFaces = cellsFaceShapes[cellI];
194 labelList faceOfNeiCell(curFaces.size(), -1);
196 label nNeighbours = 0;
202 if (cells[cellI][faceI] >= 0)
continue;
206 const face& curFace = curFaces[faceI];
216 PointCells[curPoints[pointI]];
219 forAll(curNeighbours, neiI)
221 label curNei = curNeighbours[neiI];
227 const faceList& searchFaces = cellsFaceShapes[curNei];
229 forAll(searchFaces, neiFaceI)
231 if (searchFaces[neiFaceI] == curFace)
237 neiCells[faceI] = curNei;
238 faceOfNeiCell[faceI] = neiFaceI;
253 for (
label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
257 label minNei = cells.size();
261 if (neiCells[ncI] > -1 && neiCells[ncI] < minNei)
264 minNei = neiCells[ncI];
271 faces_[
nFaces] = curFaces[nextNei];
274 cells[cellI][nextNei] =
nFaces;
275 cells[neiCells[nextNei]][faceOfNeiCell[nextNei]] =
nFaces;
278 neiCells[nextNei] = -1;
287 "polyMesh::setTopology\n" 289 " const cellShapeList& cellsAsShapes,\n" 290 " const faceListList& boundaryFaces,\n" 291 " const wordList& boundaryPatchNames,\n" 292 " labelList& patchSizes,\n" 293 " labelList& patchStarts,\n" 294 " label& defaultPatchStart,\n" 298 ) <<
"Error in internal face insertion" 306 patchSizes.setSize(boundaryFaces.size(), -1);
307 patchStarts.setSize(boundaryFaces.size(), -1);
309 forAll(boundaryFaces, patchI)
311 const faceList& patchFaces = boundaryFaces[patchI];
327 const face& curFace = patchFaces[faceI];
329 const label cellInside = curPatchFaceCells[faceI];
332 const faceList& facesOfCellInside = cellsFaceShapes[cellInside];
336 forAll(facesOfCellInside, cellFaceI)
340 if (cells[cellInside][cellFaceI] >= 0)
344 "polyMesh::setTopology\n" 346 " const cellShapeList& cellsAsShapes,\n" 347 " const faceListList& boundaryFaces,\n" 348 " const wordList& boundaryPatchNames,\n" 349 " labelList& patchSizes,\n" 350 " labelList& patchStarts,\n" 351 " label& defaultPatchStart,\n" 355 ) <<
"Trying to specify a boundary face " << curFace
356 <<
" on the face on cell " << cellInside
357 <<
" which is either an internal face or already " 358 <<
"belongs to some other patch. This is face " 359 << faceI <<
" of patch " 360 << patchI <<
" named " 361 << boundaryPatchNames[patchI] <<
"." 368 faces_[
nFaces] = facesOfCellInside[cellFaceI];
370 cells[cellInside][cellFaceI] =
nFaces;
378 FatalErrorIn(
"polyMesh::polyMesh(... construct from shapes...)")
379 <<
"face " << faceI <<
" of patch " << patchI
380 <<
" does not seem to belong to cell " << cellInside
381 <<
" which, according to the addressing, " 382 <<
"should be next to it." 390 patchSizes[patchI] = nFaces - curPatchStart;
391 patchStarts[patchI] = curPatchStart;
396 defaultPatchStart =
nFaces;
402 forAll(curCellFaces, faceI)
404 if (curCellFaces[faceI] == -1)
406 curCellFaces[faceI] =
nFaces;
407 faces_[
nFaces] = cellsFaceShapes[cellI][faceI];
421 Foam::polyMesh::polyMesh
429 const word& defaultBoundaryPatchName,
430 const word& defaultBoundaryPatchType,
431 const wordList& boundaryPatchPhysicalTypes,
489 clearedPrimitives_(
false),
502 boundaryFaces.
size() + 1
504 bounds_(points_, syncPar),
508 tetBasePtIsPtr_(NULL),
552 globalMeshDataPtr_(NULL),
554 topoChanging_(
false),
560 Info<<
"Constructing polyMesh from cell and boundary shapes." <<
endl;
569 label defaultPatchStart;
586 forAll(boundaryFaces, patchI)
594 boundaryPatchTypes[patchI],
595 boundaryPatchNames[patchI],
605 boundaryPatchPhysicalTypes.
size()
606 && boundaryPatchPhysicalTypes[patchI].
size()
609 boundary_[patchI].physicalType() =
610 boundaryPatchPhysicalTypes[patchI];
614 label nAllPatches = boundaryFaces.
size();
617 label nDefaultFaces = nFaces - defaultPatchStart;
623 if (nDefaultFaces > 0)
625 WarningIn(
"polyMesh::polyMesh(... construct from shapes...)")
626 <<
"Found " << nDefaultFaces
627 <<
" undefined faces in mesh; adding to default patch." <<
endl;
631 label patchI =
findIndex(boundaryPatchNames, defaultBoundaryPatchName);
635 if (patchI != boundaryFaces.
size()-1 || boundary_[patchI].
size())
637 FatalErrorIn(
"polyMesh::polyMesh(... construct from shapes...)")
638 <<
"Default patch " << boundary_[patchI].
name()
639 <<
" already has faces in it or is not" 643 WarningIn(
"polyMesh::polyMesh(... construct from shapes...)")
644 <<
"Reusing existing patch " << patchI
645 <<
" for undefined faces." <<
endl;
652 boundaryPatchTypes[patchI],
653 boundaryPatchNames[patchI],
654 nFaces - defaultPatchStart,
668 defaultBoundaryPatchType,
669 defaultBoundaryPatchName,
670 nFaces - defaultPatchStart,
672 boundary_.
size() - 1,
682 boundary_.
setSize(nAllPatches);
693 boundary_.calcGeometry();
706 Foam::polyMesh::polyMesh
714 const word& defaultBoundaryPatchName,
715 const word& defaultBoundaryPatchType,
773 clearedPrimitives_(
false),
786 boundaryFaces.
size() + 1
788 bounds_(points_, syncPar),
792 tetBasePtIsPtr_(NULL),
836 globalMeshDataPtr_(NULL),
838 topoChanging_(
false),
844 Info<<
"Constructing polyMesh from cell and boundary shapes." <<
endl;
853 label defaultPatchStart;
870 forAll(boundaryDicts, patchI)
874 patchDict.
set(
"nFaces", patchSizes[patchI]);
875 patchDict.
set(
"startFace", patchStarts[patchI]);
883 boundaryPatchNames[patchI],
891 label nAllPatches = boundaryFaces.
size();
893 label nDefaultFaces = nFaces - defaultPatchStart;
899 if (nDefaultFaces > 0)
901 WarningIn(
"polyMesh::polyMesh(... construct from shapes...)")
902 <<
"Found " << nDefaultFaces
903 <<
" undefined faces in mesh; adding to default patch." <<
endl;
907 label patchI =
findIndex(boundaryPatchNames, defaultBoundaryPatchName);
911 if (patchI != boundaryFaces.
size()-1 || boundary_[patchI].
size())
913 FatalErrorIn(
"polyMesh::polyMesh(... construct from shapes...)")
914 <<
"Default patch " << boundary_[patchI].
name()
915 <<
" already has faces in it or is not" 919 WarningIn(
"polyMesh::polyMesh(... construct from shapes...)")
920 <<
"Reusing existing patch " << patchI
921 <<
" for undefined faces." <<
endl;
928 boundary_[patchI].
type(),
929 boundary_[patchI].
name(),
930 nFaces - defaultPatchStart,
944 defaultBoundaryPatchType,
945 defaultBoundaryPatchName,
946 nFaces - defaultPatchStart,
948 boundary_.
size() - 1,
958 boundary_.
setSize(nAllPatches);
969 boundary_.calcGeometry();
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
label size() const
Return the number of elements in the PtrList.
bool set(const label) const
Is element set.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A simple container for copying or transferring objects of type <T>.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & instance() const
void updateMesh()
Correct polyBoundaryMesh after topology update.
const cellList & cells() const
A list of keyword definitions, which are a keyword followed by any number of values (e...
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
List< faceList > faceListList
static bool sameVertices(const face &, const face &)
Return true if the faces have the same vertices.
void setSize(const label)
Reset size of List.
List< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
#define WarningIn(functionName)
Report a warning using Foam::Warning.
virtual const pointField & points() const
Return raw points.
primitiveMesh()
Construct null.
label size() const
Return number of elements in table.
errorManip< error > abort(error &err)
const word & name() const
Return name.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
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 FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
void set(entry *)
Assign a new entry, overwrite any existing entry.
virtual bool checkMesh(const bool report=false) const
Check mesh for correctness. Returns false for no error.
List< word > wordList
A List of words.
Registry of regIOobjects.
List< label > labelList
A List of labels.
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
void removeFiles() const
Remove all files from mesh instance()
const Time & time() const
Return time.
List< labelList > labelListList
A List of labelList.
static label worldComm
Default communicator (all processors)
bool found(const word &) const
Return true if hashedEntry is found in table.