78 bool limitRefinementLevel
87 label oldNCells = refCells.
size();
91 const labelList& cCells = cellCells[cellI];
95 if (refLevel[cCells[i]] > (refLevel[cellI]+1))
105 if (refCells.
size() > oldNCells)
107 Info<<
"Added an additional " << refCells.
size() - oldNCells
108 <<
" cells to satisfy 1:2 refinement level"
122 int main(
int argc,
char *argv[])
130 Info<<
"Dividing cells into bins depending on cell volume.\nThis will"
131 <<
" correspond to refinement levels for a mesh with only 2x2x2"
133 <<
"The upper range for every bin is always 1.1 times the lower range"
134 <<
" to allow for some truncation error."
155 lowerLimits.
append(sortedVols[0]);
156 upperLimits.
append(1.1*lowerLimits[lowerLimits.
size()-1]);
160 if (sortedVols[i] > upperLimits[upperLimits.
size()-1])
169 Info<<
"Collected " << bin.
size() <<
" elements in bin "
170 << lowerLimits[lowerLimits.
size()-1] <<
" .. "
171 << upperLimits[upperLimits.
size()-1] <<
endl;
175 lowerLimits.
append(sortedVols[i]);
176 upperLimits.
append(1.1*lowerLimits[lowerLimits.
size()-1]);
178 Info<<
"Creating new bin " << lowerLimits[lowerLimits.
size()-1]
179 <<
" .. " << upperLimits[upperLimits.
size()-1]
186 bin.
append(sortedVols.indices()[i]);
200 Info<<
"Volume bins:" <<
nl;
209 cells.insert(bin[i]);
212 Info<<
" " << lowerLimits[binI] <<
" .. " << upperLimits[binI]
213 <<
" : writing " << bin.
size() <<
" cells to cellSet "
248 p[patchI] = patches[patchI].
clone(fMesh.boundaryMesh()).ptr();
251 fMesh.addFvPatches(
p);
263 if (!readLevel && refHeader.headerOk())
266 <<
"Detected " << refHeader.name() <<
" file in "
268 <<
" recreate it or use the -readLevel option to use it"
314 refLevel[bin[i]] = bins.
size() - binI - 1;
315 postRefLevel[bin[i]] = refLevel[bin[i]];
323 forAll(postRefLevel.boundaryField(), patchI)
329 Info<<
"Setting field for patch "<<
endl;
335 bField[faceI] = postRefLevel[own];
339 Info<<
"Determined current refinement level and writing to "
340 << postRefLevel.name() <<
" (as volScalarField; for post processing)"
343 <<
" (as labelIOList; for meshing)" << nl
347 postRefLevel.write();
353 cellSet refCells(mesh,
"refCells", 100);
368 Info<<
"Collected " << refCells.
size() <<
" cells that need to be"
369 <<
" refined to get closer to overall 2:1 refinement level limit"
371 <<
"Written cells to be refined to cellSet " << refCells.
name()
376 Info<<
"After refinement this tool can be run again to see if the 2:1"
377 <<
" limit is observed all over the mesh" << nl <<
endl;
381 Info<<
"All cells in the mesh observe the 2:1 refinement level limit"