Go to the documentation of this file.
56 const fileName& fName,
65 file <<
"# vtk DataFile Version 3.0\n";
66 file <<
"vtk output\n";
68 file <<
"DATASET UNSTRUCTURED_GRID\n";
72 if( boxTypes[leafI] & bType )
76 file <<
"POINTS " << 8*nBoxes <<
" float\n";
79 if( boxTypes[leafI] & bType )
81 FixedList<point, 8> vertices;
82 octree.returnLeaf(leafI).vertices(octree.rootBox(), vertices);
86 const point&
p = vertices[vI];
88 file <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z() <<
nl;
94 file <<
"\nCELLS " << nBoxes
95 <<
" " << 9 * nBoxes <<
nl;
100 if( boxTypes[leafI] & bType )
102 const label start = 8 * nBoxes;
103 file << 8 <<
" " << start <<
" " << start+1
104 <<
" " << start+3 <<
" " << start+2
105 <<
" " << start+4 <<
" " << start+5
106 <<
" " << start+7 <<
" " << start+6 <<
nl;
115 file <<
"CELL_TYPES " << nBoxes <<
nl;
116 for(
label i=0;i<nBoxes;++i)
133 # pragma omp parallel for schedule(guided, 100)
135 for(
label cubeI=0;cubeI<nLeaves;++cubeI)
176 # pragma omp parallel
180 const label nThreads = omp_get_num_threads();
181 const label threadI = omp_get_thread_num();
183 const label nThreads = 1;
184 const label threadI = 0;
190 numLocalNodes.
setSize(nThreads);
197 label& nLocalNodes = numLocalNodes[threadI];
201 # pragma omp for schedule(static, 100)
214 label minLeaf(leafI);
217 if( pLeaves[plI] > -1 )
219 for(
label i=plI+1;i<8;++i)
220 if( pLeaves[plI] == pLeaves[i] )
222 validLeaf[plI] =
false;
223 validLeaf[i] =
false;
228 validLeaf[plI] =
false;
233 minLeaf =
Foam::min(minLeaf, pLeaves[plI]);
237 validLeaf[plI] =
false;
241 if( (minLeaf == leafI) && validLeaf[7-nI] )
261 for(
label i=0;i<threadI;++i)
262 startNode += numLocalNodes[i];
266 # pragma omp for schedule(static, 100)
279 label minLeaf(leafI);
282 if( pLeaves[plI] > -1 )
284 for(
label i=plI+1;i<8;++i)
285 if( pLeaves[plI] == pLeaves[i] )
287 validLeaf[plI] =
false;
288 validLeaf[i] =
false;
293 validLeaf[plI] =
false;
298 minLeaf =
Foam::min(minLeaf, pLeaves[plI]);
302 validLeaf[plI] =
false;
306 if( (minLeaf == leafI) && validLeaf[7-nI] )
313 nodeLabels(pLeaves[plI], (7-plI)) = startNode;
324 # pragma omp critical
336 badLeaves[leafI] |= 1;
337 writeOctreeToVTK(
"badLeaves.vtk",
octree_, badLeaves, 1);
342 Info <<
"Checking for existence of negative node labels" <<
endl;
353 label minLeaf(leafI);
356 if( pLeaves[plI] > -1 )
358 for(
label i=plI+1;i<8;++i)
359 if( pLeaves[plI] == pLeaves[i] )
361 validLeaf[plI] =
false;
362 validLeaf[i] =
false;
367 validLeaf[plI] =
false;
372 minLeaf =
Foam::min(minLeaf, pLeaves[plI]);
376 validLeaf[plI] =
false;
380 Info <<
"Min leaf " << minLeaf <<
endl;
381 Info <<
"Valid leaf " << validLeaf <<
endl;
382 Info <<
"pLeaves " << pLeaves <<
endl;
383 Info <<
"Node position " << nI <<
endl;
385 Info <<
"1.Leaf " << leafI <<
" node labels "
390 Info <<
"Leaf at position " << i <<
" has node labels "
411 # pragma omp parallel for schedule(dynamic, 100)
419 if( storedNode[nodeI] )
422 storedNode[nodeI] =
true;
429 if( pLeaves[plI] < 0 )
447 # pragma omp parallel for schedule(dynamic, 40)
463 const bool nonManifoldMesh
468 if( nonManifoldMesh )
471 # pragma omp parallel for schedule(dynamic, 40)
514 patchesToRemove.
transfer(patchesToRemoveCopy);
525 forAll(matchedPatches, ptchI)
526 activePatch[matchedPatches[ptchI]] =
true;
530 if( activePatch[ts[triI].region()] )
531 removeFacets[triI] =
true;
545 removeFacets[facets[i]] =
true;
555 forAll(containedTriangles, i)
557 if( removeFacets[containedTriangles[i]] )
584 patchesToKeep.
transfer(patchesToKeepCopy);
595 forAll(matchedPatches, ptchI)
596 activePatch[matchedPatches[ptchI]] =
true;
600 if( activePatch[ts[triI].region()] )
601 keepFacets[triI] =
true;
616 keepFacets[facets[i]] =
true;
626 forAll(containedTriangles, i)
628 if( keepFacets[containedTriangles[i]] )
639 # pragma omp parallel for if( boxType.size() > 1000 ) \
640 private(neighs) schedule(dynamic, 20)
646 for(
label i=0;i<6;++i)
653 const label neiLabel = neighs[neiI];
674 std::map<label, labelLongList> exchangeData;
687 const label leafI = iter();
719 # pragma omp parallel for schedule(static, 1)
766 # pragma omp parallel
780 const label nThreads = omp_get_num_threads();
781 const label threadI = omp_get_thread_num();
782 const label nChunks = 4 * omp_get_num_threads();
785 const label nThreads(1);
786 const label threadI(0);
787 const label nChunks(1);
805 label chunkI=threadI;
810 const label start = chunkSize * chunkI;
813 const label nBefore = helperFaces.
size();
815 for(
label leafI=start;leafI<end;++leafI)
822 for(
label i=0;i<12;++i)
825 for(
label fI=0;fI<6;++fI)
835 if( neighbours.
size() != 1 )
838 const label nei = neighbours[0];
846 for(
label pI=0;pI<4;++pI)
855 if( edgeCentreLabel[feI] != -1 )
856 f.append(edgeCentreLabel[feI]);
863 helperOwner.
append(leafI);
864 helperNeighbour.
append(-1);
872 helperOwner.
append(leafI);
873 helperNeighbour.
append(nei);
882 for(
label j=
f.size()-1;j>i;--j)
892 helperNeighbour.
append(leafI);
899 helperOwner.
append(leafI);
900 helperNeighbour.
append(nei);
906 for(
label fI=0;fI<6;++fI)
916 if( neighbours.
size() != 1 )
918 const label nei = neighbours[0];
927 const label* fNodes =
930 for(
label i=0;i<4;++i)
937 helperNeighbour.
append(leafI);
944 chunkSizes[chunkI] = helperFaces.
size() - nBefore;
949 # pragma omp critical
951 nFaces += helperFaces.
size();
972 label chunkI=threadI;
977 label start(0), localStart(0);
978 for(
label i=0;i<chunkI;++i)
979 start += chunkSizes[i];
980 for(
label i=threadI;i<chunkI;i+=nThreads)
981 localStart += chunkSizes[i];
983 for(
label faceI=0;faceI<chunkSizes[chunkI];++faceI)
986 helperOwner[localStart];
988 helperNeighbour[localStart];
989 rowSizes[start++] = helperFaces.
sizeOfRow(localStart++);
1002 # pragma omp barrier
1008 label chunkI=threadI;
1013 label start(0), localStart(0);
1015 for(
label i=0;i<chunkI;++i)
1016 start += chunkSizes[i];
1017 for(
label i=threadI;i<chunkI;i+=nThreads)
1018 localStart += chunkSizes[i];
1020 for(
label faceI=0;faceI<chunkSizes[chunkI];++faceI)
1024 helperFaces(localStart, i);
1041 sum[(*octreeFacesOwnersPtr_)[faceI]] +=
n;
1042 const label nei = (*octreeFacesNeighboursPtr_)[faceI];
1058 Info <<
"Leaf " << lfI <<
" is not closed " <<
sum[lfI] <<
endl;
1075 if( neighbour[fI] < 0 )
1077 ++nlf[neighbour[fI]];
1086 leafFaces(owner[fI], nlf[owner[fI]]++) = fI;
1087 if( neighbour[fI] < 0 )
1089 leafFaces(neighbour[fI], nlf[neighbour[fI]]++) = fI;
1114 if( owner[faceI] < 0 )
1116 if( neighbour[faceI] < 0 )
1119 ++nNei[owner[faceI]];
1120 ++nNei[neighbour[faceI]];
1130 if( owner[faceI] < 0 )
1132 if( neighbour[faceI] < 0 )
1135 leafLeaves(owner[faceI], nNei[owner[faceI]]++) = neighbour[faceI];
1136 leafLeaves(neighbour[faceI], nNei[neighbour[faceI]]++) = owner[faceI];
1165 for(
label eI=0;eI<nEdges;++eI)
1170 faces(faceI, (eI+1)%nEdges)
1226 const label own = owner[fI];
1227 const label nei = neighbour[fI];
void calculateNodeFaces() const
calculate node-faces addressing
vectorField pointField
pointField is a vectorField.
VRWGraph * leafEdgesPtr_
leaf-edges addressing
face reverseFace() const
Return face with reverse direction.
VRWGraph * nodeEdgesPtr_
node-edges addressing
void append(const T &e)
Append an element at the end of the list.
const List< direction > & nodeType() const
return type of node (INNERNODE,or OUTERNODE)
VRWGraph * faceEdgesPtr_
face-edges addressing
#define forAll(list, i)
Loop across all elements in list.
VRWGraph * leafLeavesPtr_
leaf-leaves addressing
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
bool useDATABoxes_
use DATA boxes
labelLongList * octreeFacesNeighboursPtr_
friend Ostream & operator(Ostream &, const LongList< T, Offset > &)
Template functions to aid in the implementation of demand driven data.
void setRow(const label rowI, const FixedList< T, width > &l)
Set row with the list.
const VRWGraph & nodeLabels() const
return nodeLabels
void containedTriangles(const label, DynList< label > &) const
static bool & parRun()
Is this a parallel run?
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void createOctreeFaces() const
calculate faces
void findUsedBoxes() const
assemble boxTypePtr_ list
pointField * octreePointsPtr_
coordinates of octree nodes
VRWGraph * edgeFacesPtr_
edge-faces addressing
const labelList & neiProcs() const
neighbour processors of the current one
static const label faceEdges_[6][4]
face-edges addressing for the octree cube
Ostream & endl(Ostream &os)
Add newline and flush stream.
direction cubeType() const
return type
label size() const
Size of the active part of the list.
void createNodeLabels() const
calculate nodeLabelsPtr_
dimensioned< scalar > mag(const dimensioned< Type > &)
A HashTable with keys but without contents.
void appendIfNotIn(const label rowI, const label)
Append an element to the given row if it does not exist there.
const Map< label > & globalToLocalLeafAddressing() const
return global leaf label to local label addressing
labelLongList * octreeFacesOwnersPtr_
const labelLongList & octreeFaceOwner() const
return owners of octree faces
bool isDict(const word &) const
Check if entry is a sub-dictionary.
List< direction > * nodeTypePtr_
identify created nodes as OUTERNODE or INNERNODE
void findLeavesForCubeVertex(const label, const direction, FixedList< label, 8 > &) const
find neighbouring leaves of a vertex
void findNeighboursInDirection(const meshOctreeCubeCoordinates &, const label dir, DynList< label > &neighbourLeaves) const
find neighbours over a leaf cube face in the given direction
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void setSize(const label)
Reset size of List.
label numberOfLeaves() const
return leaves of the octree
const dictionary & meshDict_
reference to the dictionary
void calculateEdgeLeaves() const
calculate edge-leaves addressing
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Pre-declare SubField and related Field type.
const VRWGraph & leafAtProcs() const
return processors which contain each octree leaf
bool hasContainedEdges(const label) const
const geometricSurfacePatchList & patches() const
access to patches
label size() const
Returns the number of rows.
List< direction > * boxTypePtr_
identify which boxes should be used as mesh cells
void setSize(const label)
Reset the number of rows.
#define forAllRow(graph, rowI, index)
labelList findPatches(const word &patchName) const
return a list of patch indices corresponding to the given
void setSizeAndColumnWidth(const label newNumRows, const label rcWidth)
wordList patchNames(nPatches)
FRWGraph< label, 8 > * nodeLeavesPtr_
node leaves
void createOctreePoints() const
calculate octreePointsPtr_
label sizeOfRow(const label rowI) const
Returns the number of elements in the given row.
void calculateLeafEdges() const
calculate leaf-edges
A list of keyword definitions, which are a keyword followed by any number of values (e....
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
const VRWGraph & nodeFaces() const
return node-faces addressing
void createOctreeEdges() const
calculate edges
const VRWGraph & edgeLeaves() const
return edge-leaves addressing
const VRWGraph & leafFaces() const
return octree box-faces addressing
void createNodeLeaves() const
calculate nodeLeavesPtr_
const double e
Elementary charge.
static const label faceNodes_[6][4]
cube nodes making each face
void calculateLeafLeaves() const
calculate leaf-leaves addressing
const VRWGraph & faceEdges() const
return face-edges addressing
void reverseAddressing(const GraphType &origGraph)
const labelLongList & octreeFaceNeighbour() const
return neighbours of octree faces
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
LongList< edge > * octreeEdgesPtr_
edges of the octree
void setSize(const label)
Reset size of List.
VRWGraph * octreeFacesPtr_
faces of the octree
const List< direction > & boxType() const
return which octree boxes are used for mesh creation
label nNodes_
number of created octree nodes
const VRWGraph & leafLeaves() const
return leaf-leaves addressing
const boundBox & rootBox() const
return rootBox
void calculateNodeType() const
calculate nodeTypePtr_
direction level() const
return level
label size() const
return the number of triangles
void appendList(const ListType &l)
Append a list as a row at the end of the graph.
VRWGraph * edgeLeavesPtr_
edges-leaves addressing
void calculateEdgeFaces() const
calculate edge-faces
void setSize(const label)
Reset size of List.
VRWGraph * nodeFacesPtr_
node-faces addressing
A 1D vector of objects of type <T> with a fixed size <Size>.
void exchangeMap(const std::map< label, ListType > &m, LongList< T > &data, const Pstream::commsTypes commsType)
const labelLongList & globalLeafLabel() const
return global labels of octree leaves
bool insert(const Key &key)
Insert a new entry.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const LongList< edge > & octreeEdges() const
return octree edges, created for MESHCELL boxes
void append(const label rowI, const label)
Append an element to the given row.
Octree for mesh generation.
short procNo() const
return processor number
A bounding box defined in terms of the points at its extremities.
bool hasContainedTriangles(const label) const
VRWGraph * nodeLabelsPtr_
node labels
const pointField & octreePoints() const
return coordinates of octree vertices
const VRWGraph & nodeEdges() const
return node-edges addressing
const FRWGraph< label, 8 > & nodeLeaves() const
return nodeLeaves
A face is a list of labels corresponding to mesh vertices.
label facetSubsetIndex(const word &) const
void facetsInSubset(const label, ListType &) const
void size(const label)
Override size to be inconsistent with allocated storage.
const VRWGraph & octreeFaces() const
return octree faces, created for MESHCELL boxes
label numberOfNodes() const
return number of octree nodes
label findEdgeCentre(const label leafI, const direction eI) const
find edge centre if it exists
vector point
Point is a vector.
const triSurf & surface() const
return a reference to the surface
const meshOctree & octree_
reference to the octree
const VRWGraph & leafEdges() const
return leaf-edges addressing
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
void calculateLeafFaces() const
calculate leaf-faces addressing
void vertices(const boundBox &, FixedList< point, 8 > &) const
calculate vertices
LongList< label > labelLongList
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void setRowSize(const label rowI, const label newSize)
Reset the size of the given row.
const meshOctreeCubeBasic & returnLeaf(const label) const
void clear()
Clear the list, i.e. set next free to zero.
const VRWGraph & edgeFaces() const
return edge-faces addressing
void setSizeAndRowSize(const ListType &)
set the size and row sizes
VRWGraph * leafFacesPtr_
octree box-faces addressing