ENH: hexRef8: test more

This commit is contained in:
mattijs
2013-12-20 16:01:18 +00:00
parent 198a9a6adf
commit 80ef6e2392
2 changed files with 98 additions and 71 deletions

View File

@ -41,6 +41,7 @@ Description
#include "Random.H" #include "Random.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "calculatedPointPatchFields.H" #include "calculatedPointPatchFields.H"
#include "pointConstraints.H"
#include "fvcDiv.H" #include "fvcDiv.H"
using namespace Foam; using namespace Foam;
@ -63,6 +64,8 @@ int main(int argc, char *argv[])
# include "createMesh.H" # include "createMesh.H"
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
const Switch inflate(args.args()[1]); const Switch inflate(args.args()[1]);
if (inflate) if (inflate)
@ -188,89 +191,107 @@ int main(int argc, char *argv[])
} }
mesh.moving(false);
mesh.topoChanging(false);
// Mesh changing engine.
polyTopoChange meshMod(mesh);
if (rndGen.bit()) label action = rndGen.integer(0, 5);
if (action == 0)
{ {
// Refine Info<< nl << "-- moving only" << endl;
label nRefine = mesh.nCells()/20; mesh.movePoints(pointField(mesh.points()));
DynamicList<label> refineCandidates(nRefine);
for (label i=0; i<nRefine; i++)
{
refineCandidates.append(rndGen.integer(0, mesh.nCells()-1));
}
labelList cellsToRefine
(
meshCutter.consistentRefinement
(
refineCandidates,
true // buffer layer
)
);
Info<< nl << "-- selected "
<< returnReduce(cellsToRefine.size(), sumOp<label>())
<< " cells out of " << mesh.globalData().nTotalCells()
<< " for refinement" << endl;
// Play refinement commands into mesh changer.
meshCutter.setRefinement(cellsToRefine, meshMod);
} }
else else if (action == 1 || action == 2)
{ {
// Unrefine // Mesh changing engine.
labelList allSplitPoints(meshCutter.getSplitPoints()); polyTopoChange meshMod(mesh);
label nUnrefine = allSplitPoints.size()/20; if (action == 1)
labelHashSet candidates(2*nUnrefine);
for (label i=0; i<nUnrefine; i++)
{ {
candidates.insert // Refine
label nRefine = mesh.nCells()/20;
DynamicList<label> refineCandidates(nRefine);
for (label i=0; i<nRefine; i++)
{
refineCandidates.append(rndGen.integer(0, mesh.nCells()-1));
}
labelList cellsToRefine
( (
allSplitPoints[rndGen.integer(0, allSplitPoints.size()-1)] meshCutter.consistentRefinement
(
refineCandidates,
true // buffer layer
)
); );
Info<< nl << "-- selected "
<< returnReduce(cellsToRefine.size(), sumOp<label>())
<< " cells out of " << mesh.globalData().nTotalCells()
<< " for refinement" << endl;
// Play refinement commands into mesh changer.
meshCutter.setRefinement(cellsToRefine, meshMod);
}
else
{
// Unrefine
labelList allSplitPoints(meshCutter.getSplitPoints());
label nUnrefine = allSplitPoints.size()/20;
labelHashSet candidates(2*nUnrefine);
for (label i=0; i<nUnrefine; i++)
{
label index = rndGen.integer(0, allSplitPoints.size()-1);
candidates.insert(allSplitPoints[index]);
}
labelList splitPoints = meshCutter.consistentUnrefinement
(
candidates.toc(),
false
);
Info<< nl << "-- selected "
<< returnReduce(splitPoints.size(), sumOp<label>())
<< " points out of "
<< returnReduce(allSplitPoints.size(), sumOp<label>())
<< " for unrefinement" << endl;
// Play refinement commands into mesh changer.
meshCutter.setUnrefinement(splitPoints, meshMod);
} }
labelList splitPoints = meshCutter.consistentUnrefinement
(
candidates.toc(),
false
);
Info<< nl << "-- selected "
<< returnReduce(splitPoints.size(), sumOp<label>())
<< " points out of "
<< returnReduce(allSplitPoints.size(), sumOp<label>())
<< " for unrefinement" << endl;
// Play refinement commands into mesh changer.
meshCutter.setUnrefinement(splitPoints, meshMod);
// Create mesh, return map from old to new mesh.
Info<< nl << "-- actually changing mesh" << endl;
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, inflate);
// Update fields
Info<< nl << "-- mapping mesh data" << endl;
mesh.updateMesh(map);
// Inflate mesh
if (map().hasMotionPoints())
{
Info<< nl << "-- moving mesh" << endl;
mesh.movePoints(map().preMotionPoints());
}
// Update numbering of cells/vertices.
Info<< nl << "-- mapping hexRef8 data" << endl;
meshCutter.updateMesh(map);
} }
Info<< nl<< "-- Mesh : moving:" << mesh.moving()
<< " topoChanging:" << mesh.topoChanging()
// Create mesh, return map from old to new mesh. << " changing:" << mesh.changing()
Info<< nl << "-- actually changing mesh" << endl; << endl;
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, inflate);
// Update fields
Info<< nl << "-- mapping mesh data" << endl;
mesh.updateMesh(map);
// Inflate mesh
if (map().hasMotionPoints())
{
Info<< nl << "-- moving mesh" << endl;
mesh.movePoints(map().preMotionPoints());
}
// Update numbering of cells/vertices.
Info<< nl << "-- mapping hexRef8 data" << endl;
meshCutter.updateMesh(map);
@ -387,6 +408,9 @@ int main(int argc, char *argv[])
<< nl << endl; << nl << endl;
} }
Info<< "pc:" << pc.patchPatchPointConstraintPoints().size() << endl;
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -17,9 +17,12 @@ FoamFile
DebugSwitches DebugSwitches
{ {
primitiveMesh 1; primitiveMesh 1;
polyMesh 1; polyMesh 1;
fvMesh 1; fvMesh 1;
polyTopoChange 1;
pointMesh 1;
pointConstraints 1;
} }
application icoFoam; application icoFoam;