82 static const scalar edgeTol = 1
E-3;
101 scalar maxZ = -GREAT;
104 scalar minOther = GREAT;
105 scalar maxOther = -GREAT;
111 const edge&
e = edges[edgeI];
115 scalar eMag =
mag(eVec);
119 if (
mag(eVec & x) > 1-edgeTol)
121 minX =
min(minX, eMag);
122 maxX =
max(maxX, eMag);
125 else if (
mag(eVec &
y) > 1-edgeTol)
127 minY =
min(minY, eMag);
128 maxY =
max(maxY, eMag);
131 else if (
mag(eVec & z) > 1-edgeTol)
133 minZ =
min(minZ, eMag);
134 maxZ =
max(maxZ, eMag);
139 minOther =
min(minOther, eMag);
140 maxOther =
max(maxOther, eMag);
144 Pout<<
"Mesh edge statistics:" <<
endl
145 <<
" x aligned : number:" << nX <<
"\tminLen:" << minX
146 <<
"\tmaxLen:" << maxX <<
endl
147 <<
" y aligned : number:" << nY <<
"\tminLen:" << minY
148 <<
"\tmaxLen:" << maxY <<
endl
149 <<
" z aligned : number:" << nZ <<
"\tminLen:" << minZ
150 <<
"\tmaxLen:" << maxZ <<
endl
151 <<
" other : number:" << mesh.
nEdges() - nX - nY - nZ
152 <<
"\tminLen:" << minOther
153 <<
"\tmaxLen:" << maxOther <<
endl <<
endl;
160 label axisIndex = -1;
162 if (
mag(normal &
point(1, 0, 0)) > (1-edgeTol))
166 else if (
mag(normal &
point(0, 1, 0)) > (1-edgeTol))
170 else if (
mag(normal &
point(0, 0, 1)) > (1-edgeTol))
181 label twoDNess(
const polyMesh& mesh)
196 vector vec10 = ctrs[1] - ctrs[0];
199 label otherCellI = -1;
201 for (label cellI = 2; cellI < ctrs.size(); cellI++)
203 vector vec(ctrs[cellI] - ctrs[0]);
206 if (
mag(vec & vec10) < 0.9)
215 if (otherCellI == -1)
222 plane cellPlane(ctrs[0], ctrs[1], ctrs[otherCellI]);
229 scalar minLen = GREAT;
236 if (cellPlane.distance(ctrs[cellI]) > 1
E-6*minLen)
243 label axisIndex = axis(cellPlane.normal());
263 const polyPatch& patch = patches[patchI];
267 const face&
f = patch[patchFaceI];
271 boundaryPoint[f[fp]] =
true;
281 const edge& e = edges[edgeI];
283 if (!boundaryPoint[e.
start()] && !boundaryPoint[e.
end()])
296 const polyPatch& patch = patches[patchI];
298 if (!isA<wedgePolyPatch>(patch))
304 if (
mag(
min(cosAngle) -
max(cosAngle)) > 1
E-6)
319 int main(
int argc,
char *argv[])
326 runTime.functionObjects().off();
330 printEdgeStats(mesh);
348 Info<<
"Refining according to refineMeshDict" <<
nl <<
endl;
371 refCells =
cells.toc();
382 refCells[cellI] = cellI;
387 label axisIndex = twoDNess(mesh);
391 Info<<
"3D case; refining all directions" <<
nl <<
endl;
400 refineDict.
add(
"useHexTopology",
"true");
408 Info<<
"2D case; refining in directions y,z\n" <<
endl;
412 else if (axisIndex == 1)
414 Info<<
"2D case; refining in directions x,z\n" <<
endl;
420 Info<<
"2D case; refining in directions x,y\n" <<
endl;
428 refineDict.
add(
"useHexTopology",
"false");
431 refineDict.
add(
"coordinateSystem",
"global");
436 refineDict.
add(
"globalCoeffs", coeffsDict);
438 refineDict.
add(
"geometricCut",
"false");
439 refineDict.
add(
"writeMesh",
"false");
443 string oldTimeName(runTime.timeName());
469 cellSet newCells(mesh,
"refinedCells", refCells.
size());
471 forAll(oldToNew, oldCellI)
473 const labelList& added = oldToNew[oldCellI];
477 newCells.insert(added[i]);
481 Pout<<
"Writing refined cells (" << newCells.size() <<
") to cellSet "
482 << newCells.instance()/newCells.local()/newCells.
name()
508 "From cells in mesh at "
510 +
" to cells in mesh at "
514 forAll(oldToNew, oldCellI)
516 const labelList& added = oldToNew[oldCellI];
522 newToOld[added[i]] = oldCellI;
528 newToOld[oldCellI] = oldCellI;
532 Info<<
"Writing map from new to old cell to "
533 << newToOld.objectPath() <<
nl <<
endl;
540 printEdgeStats(mesh);