Go to the documentation of this file.
63 Info <<
"Refining boundary boxes to the given size" <<
endl;
71 const scalar startIter = omp_get_wtime();
76 bool useNLayers(
false);
80 # pragma omp parallel for schedule(dynamic, 100)
86 Info <<
"Checking leaf " << oc <<
endl;
98 scalar maxThicknessForLevel(0.0);
101 const label triI = containedTriangles(elRowI, tI);
107 const std::pair<direction, scalar>& rp = refRequests[i];
108 if( rp.first <= oc.
level() )
113 if( rp.first < minRequestedLevel )
116 minRequestedLevel = rp.first;
117 maxThicknessForLevel = rp.second;
121 (rp.first == minRequestedLevel) &&
122 (rp.second > maxThicknessForLevel)
125 maxThicknessForLevel = rp.second;
132 refineCubes[leafI] = 1;
134 if( maxThicknessForLevel > VSMALL )
136 rThickness[leafI] = maxThicknessForLevel;
149 if( useNLayers && changed )
164 const scalar refTime = omp_get_wtime();
165 Info <<
"Time for refinement " << (refTime-startIter) <<
endl;
175 const scalar distTime = omp_get_wtime();
176 Info <<
"Time for distributing data to processors "
177 << (distTime-refTime) <<
endl;
183 Info <<
"Time for load distribution "
184 << (omp_get_wtime()-distTime) <<
endl;
191 Info <<
"Finished refining boundary boxes" <<
endl;
203 Info <<
"Refining boxes inside objects" <<
endl;
214 forAll(refObjects, objectI)
216 const entry& objectEntry =
217 dict.lookupEntry(objectNames[objectI],
false,
false);
237 forAll(refObjects, objectI)
244 objectEntries[objectI].keyword(),
245 objectEntries[objectI].
dict()
250 objectEntries.
clear();
272 refObjects[oI].calculateAdditionalRefLevels(
s);
274 refLevels[oI] += refObjects[oI].additionalRefinementLevels();
281 refThickness[oI] = refObjects[oI].refinementThickness();
284 Info <<
"Ref level for object " << refObjects[i].name()
285 <<
" is " <<
label(refLevels[i])
286 <<
" refinement thickness " << refThickness[i] <<
endl;
291 label l = refLevels[oI];
305 const scalar startIter = omp_get_wtime();
312 bool useNLayers(
false);
316 # pragma omp parallel for if( leaves.size() > 1000 ) \
317 schedule(dynamic, 20)
339 if( refObjects[oI].intersectsObject(bb) )
342 Info <<
"Marking leaf " << leafI
343 <<
" for refinement" <<
endl;
346 if( oc.
level() < refLevels[oI] )
349 if( refThickness[oI] > VSMALL )
352 Foam::max(rThickness[leafI], refThickness[oI]);
361 refineCubes[leafI] = 1;
370 if( useNLayers && changed )
385 const scalar refTime = omp_get_wtime();
386 Info <<
"Time for refinement " << (refTime-startIter) <<
endl;
396 const scalar distTime = omp_get_wtime();
397 Info <<
"Time for distributing data to processors "
398 << (distTime-refTime) <<
endl;
404 Info <<
"Time for load distribution "
405 << (omp_get_wtime()-distTime) <<
endl;
415 Info <<
"Finished refinement of boxes inside objects" <<
endl;
428 Info <<
"Refining boxes intersecting surface meshes" <<
endl;
456 surfaceMeshesPtr.
set(surfI,
new triSurf(fName));
460 if(
dict.found(
"cellSize") )
469 if( cs <=
s * (1.+SMALL) )
477 }
while( nMarked != 0 );
479 else if(
dict.found(
"additionalRefinementLevels") )
485 if(
dict.found(
"refinementThickness") )
487 refThickness[surfI] =
492 refLevels[surfI] += addLevel;
498 label l = refLevels[oI];
514 const scalar startIter = omp_get_wtime();
522 bool useNLayers(
false);
525 forAll(surfaceMeshesPtr, surfI)
527 const triSurf& surf = surfaceMeshesPtr[surfI];
530 const direction surfLevel = refLevels[surfI];
531 const scalar sThickness = refThickness[surfI];
534 # pragma omp parallel for \
535 reduction( + : nMarked) schedule(dynamic, 10) private(leavesInBox)
543 for(
label pI=1;pI<3;++pI)
559 const label leafI = leavesInBox[i];
566 Info <<
"Marking leaf " << leafI
567 <<
" with coordinates " << oc
568 <<
" for refinement" <<
endl;
571 if( oc.
level() < surfLevel )
575 refineCubes[leafI] = 1;
578 if( sThickness > VSMALL )
582 const scalar cs = oc.
size(rootBox);
583 const label numLayers =
584 ceil(sThickness / cs);
594 max(rThickness[leafI], sThickness);
607 if( useNLayers && changed )
622 const scalar refTime = omp_get_wtime();
623 Info <<
"Time for refinement " << (refTime-startIter) <<
endl;
634 const scalar distTime = omp_get_wtime();
635 Info <<
"Time for distributing data to processors "
636 << (distTime-refTime) <<
endl;
642 Info <<
"Time for load distribution "
643 << (omp_get_wtime()-distTime) <<
endl;
649 Info <<
"Finished refinement of boxes intersecting surface meshes" <<
endl;
659 Info <<
"Refining boxes intersecting edge meshes" <<
endl;
671 forAll(edgeMeshNames, emI)
691 if(
dict.found(
"cellSize") )
700 if( cs <=
s * (1.+SMALL) )
708 }
while( nMarked != 0 );
710 else if(
dict.found(
"additionalRefinementLevels") )
716 if(
dict.found(
"refinementThickness") )
723 refLevels[emI] += addLevel;
729 label l = refLevels[oI];
747 const scalar startIter = omp_get_wtime();
752 bool useNLayers(
false);
755 forAll(edgeMeshNames, emI)
762 # pragma omp parallel for schedule(dynamic, 10) \
763 private(leavesInBox,intersectedLeaves)
768 const edge&
e = edges[edgeI];
783 intersectedLeaves.
clear();
786 const label leafI = leavesInBox[i];
792 intersectedLeaves.
append(leafI);
794 if( oc.
level() < refLevels[emI] )
797 Info <<
"Marking leaf " << leafI
798 <<
" with coordinates " << oc
799 <<
" for refinement" <<
endl;
802 refineCubes[leafI] = 1;
808 if( refThickness[emI] > VSMALL )
812 forAll(intersectedLeaves, i)
814 const label leafI = intersectedLeaves[i];
817 Foam::max(rThickness[leafI], refThickness[emI]);
827 if( useNLayers && changed )
842 const scalar refTime = omp_get_wtime();
843 Info <<
"Time for refinement " << (refTime-startIter) <<
endl;
853 const scalar distTime = omp_get_wtime();
854 Info <<
"Time for distributing data to processors "
855 << (distTime-refTime) <<
endl;
861 Info <<
"Time for load distribution "
862 << (omp_get_wtime()-distTime) <<
endl;
868 Info <<
"Finished refinement of boxes intersecting edge meshes" <<
endl;
874 const scalar
startTime = omp_get_wtime();
880 Info <<
"Refining boxes near DATA boxes" <<
endl;
888 Info <<
"Leaf " << leafI <<
" is " << *leaves[leafI]
889 <<
" type " <<
label(leaves[leafI]->cubeType()) <<
endl;
898 # pragma omp parallel for if( leaves.size() > 1000 ) \
899 schedule(dynamic, 20)
903 if( leaves[leafI]->hasContainedElements() )
908 Info <<
"Refining boxes near box " << leafI
909 <<
" with coordinates " << oc <<
endl;
914 const label neiLabel =
923 # pragma omp critical
926 if( !transferCoordinates.
found(leafI) )
928 transferCoordinates.
insert(leafI);
946 Info <<
"Adding neighbour " << *nei <<
" of type"
965 # pragma omp parallel for if( receivedCoordinates.size() > 1000 ) \
966 schedule(dynamic, 20)
968 forAll(receivedCoordinates, ccI)
973 const label neiLabel =
986 Info <<
"Adding neighbour " << *nei <<
" of type"
995 for(
label i=1;i<nLayers;i++)
999 checkCoordinates.
clear();
1000 transferCoordinates.
clear();
1004 # pragma omp parallel for if( leaves.size() > 1000 ) \
1005 schedule(dynamic, 20)
1009 if( refineBox[leafI] == i )
1014 Info <<
"Refining boxes near box " << leafI
1015 <<
" with coordinates " << oc <<
endl;
1020 const label neiLabel =
1029 # pragma omp critical
1032 if( !transferCoordinates.
found(leafI) )
1034 transferCoordinates.
insert(leafI);
1042 if( neiLabel == -1 )
1053 Info <<
"Adding neighbour " << *nei <<
" of type"
1072 # pragma omp parallel for if( receivedCoordinates.size() > 1000 ) \
1073 schedule(dynamic, 20)
1075 forAll(receivedCoordinates, ccI)
1081 const label neiLabel =
1094 Info <<
"Adding neighbour " << *nei <<
" of type"
1107 # ifdef OCTREETiming
1108 const scalar refTime = omp_get_wtime();
1118 # ifdef OCTREETiming
1119 const scalar distTime = omp_get_wtime();
1120 Info <<
"Time for load balancing " << (distTime-refTime) <<
endl;
1126 # ifdef OCTREETiming
1127 Info <<
"Time for calculation of inside/outside information "
1128 << (omp_get_wtime()-distTime) <<
endl;
1131 Info <<
"Finished refining boxes near DATA boxes" <<
endl;
1145 # ifdef OCTREETiming
1146 const scalar startIter = omp_get_wtime();
1156 # pragma omp parallel for if( leaves.size() > 1000 ) \
1157 reduction(+ : nRefined) schedule(dynamic, 20)
1165 refineCubes[leafI] = 1;
1173 # ifdef OCTREETiming
1174 const scalar refTime = omp_get_wtime();
1175 Info <<
"Time for refinement " << (refTime-startIter) <<
endl;
1185 # ifdef OCTREETiming
1186 const scalar distTime = omp_get_wtime();
1187 Info <<
"Time for distributing data to processors "
1188 << (distTime-refTime) <<
endl;
1193 # ifdef OCTREETiming
1194 Info <<
"Time for load distribution "
1195 << (omp_get_wtime()-distTime) <<
endl;
1200 }
while( nRefined != 0 );
A keyword and a list of tokens is an 'entry'.
void refineBoxesIntersectingSurfaces()
void append(const T &e)
Append an element at the end of the list.
const FixedList< meshOctreeCubeCoordinates, 26 > & regularityPositions() const
void refineSelectedBoxesAndAdditionalLayers(labelList &refineBox, const scalarList &refThickness)
refine selected boxes and the boxes within the given range
A class for handling file names.
const point & max() const
Maximum describing the bounding box.
const keyType & keyword() const
Return keyword.
#define forAll(list, i)
Loop across all elements in list.
Template functions to aid in the implementation of demand driven data.
const pointField & points() const
access to points
label cubeLabel() const
position of the cube in the list of leaves
bool hasContainedElements() const
return true if the box contains some triangles
void clear()
Clear the list, i.e. set next free to zero.
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.
void distributeLeavesToProcessors()
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const labelList & neiProcs() const
neighbour processors of the current one
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool intersectsLine(const boundBox &, const point &, const point &) const
check if the cube intersects a line
direction cubeType() const
return type
label size() const
Size of the active part of the list.
void findLeavesContainedInBox(const boundBox &, DynList< const meshOctreeCube *, 256 > &) const
find leaves contained in the box
const meshOctreeCubeCoordinates & coordinates() const
return coordinates in the octree
bool isDict(const word &) const
Check if entry is a sub-dictionary.
const edgeMesh * modifyGeometry() const
modify coordinates
void refineSelectedBoxes(labelList &refineBox, const bool hexRefinement=false)
vector span() const
The bounding box span (from minimum to maximum)
void deleteDemandDrivenData(DataPtr &dataPtr)
void refineBoxes(const direction refLevel, const direction cubeType)
refine boxes of the given flag to the given size
label findLeafLabelForPosition(const meshOctreeCubeCoordinates &) const
return leaf cube for the given position
void createInsideOutsideInformation()
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool set(const label) const
Is element set.
meshOctree & octree_
Reference to meshOctree.
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.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void exchangeRequestsWithNeighbourProcessors(const LongList< meshOctreeCubeCoordinates > &dataToSend, LongList< meshOctreeCubeCoordinates > &dataToReceive) const
exchange requests with other processors generating the octree
void refineBoxesNearDataBoxes(const label nLayers=1)
refine boxes near DATA boxes to get a nice smooth surface
bool intersectsTriangleExact(const triSurf &, const boundBox &, const label) const
const pointField & points() const
Return points.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
#define forAllRow(graph, rowI, index)
const point & min() const
Minimum describing the bounding box.
const meshOctreeSlot * slotPtr() const
return the pointer to the slot containing the cube
const edgeList & edges() const
Return edges.
A list of keyword definitions, which are a keyword followed by any number of values (e....
#define forAllReverse(list, i)
Reverse loop across all elements in list.
direction globalRefLevel_
ref level to achieve max cell size
bool found(const Key &) const
Return true if hashedEntry is found in table.
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
const double e
Elementary charge.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
void loadDistribution(const bool distributeUsed=false)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
scalar size(const boundBox &) const
return size
List< DynList< std::pair< direction, scalar > > > surfRefLevel_
this list contains ref level for each surface triangle
VRWGraph containedTriangles_
surface triangles contained in an octree cube
const IOdictionary * meshDictPtr_
Dictionary containing information necessary to perform refinement.
const boundBox & rootBox() const
return rootBox
direction level() const
return level
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
void clear()
Clear all entries from table.
const triSurf * modifyGeometry() const
modify coordinates
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void refineBoxesIntersectingEdgeMeshes()
static autoPtr< objectRefinement > New(const word &name, const dictionary &dict)
Select constructed from dictionary.
A 1D vector of objects of type <T> with a fixed size <Size>.
label k
Boltzmann constant.
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
label readLabel(Istream &is)
Triangle with additional region number.
A bounding box defined in terms of the points at its extremities.
void refineBoxesContainedInObjects()
refine boxes contained inside the objects for refinement
label containedElements() const
wordList toc() const
Return the table of contents.
void size(const label)
Override size to be inconsistent with allocated storage.
void cubeBox(const boundBox &, point &, point &) const
return min and max points
point backwardModifiedPoint(const point &) const
calculate the displacement vector for the backward modification
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Points connected by edges.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void clear()
Clear the list, i.e. set next free to zero.
bool hexRefinement_
hex refinement flag
LongList< meshOctreeCube * > & leavesAccess()
return leaves
void append(const T &e)
Append an element at the end of the list.