Commit 748b1054 authored by Franjo's avatar Franjo

Some modification of smoothers

parent e9256aa5
......@@ -2106,13 +2106,19 @@ label findWorstQualityFaces
const scalar warnNonOrtho =
minNonOrtho + relativeThreshold * (1.0 - minNonOrtho);
Info << "Worst non-orthogonality " << Foam::acos(minNonOrtho) * 180.0 / M_PI
<< " selecting faces with non-orthogonality greater than "
<< (Foam::acos(warnNonOrtho) * 180.0 / M_PI) << endl;
forAll(checkValues, faceI)
{
if
(
activeFacePtr && activeFacePtr->operator[](faceI) &&
checkValues[faceI] < warnNonOrtho
)
badFaces.insert(faceI);
}
polyMeshGenChecks::checkFaceSkewness
(
......@@ -2131,9 +2137,12 @@ label findWorstQualityFaces
)
badFaces.insert(faceI);
Info << "Maximum skewness in the mesh is " << maxSkew
<< " selecting faces with skewness greater than " << warnSkew << endl;
const label nBadFaces = returnReduce(badFaces.size(), sumOp<label>());
Info << "Seleted " << nBadFaces
Info << "Selected " << nBadFaces
<< " out of " << returnReduce(checkValues.size(), sumOp<label>())
<< " faces" << endl;
......
......@@ -292,7 +292,8 @@ public:
//- greedy optimisation until the mesh can be improved
void optimizeMeshFVBestQuality
(
const label maxNumIterations = 50
const label maxNumIterations = 50,
const scalar threshold = 0.1
);
};
......
......@@ -543,7 +543,8 @@ void meshOptimizer::optimizeMeshFV
void meshOptimizer::optimizeMeshFVBestQuality
(
const label maxNumIterations
const label maxNumIterations,
const scalar threshold
)
{
label nBadFaces, nIter(0);
......@@ -570,7 +571,7 @@ void meshOptimizer::optimizeMeshFVBestQuality
lowQualityFaces,
false,
&changedFace,
0.1
threshold
);
changedFace = false;
......@@ -596,16 +597,12 @@ void meshOptimizer::optimizeMeshFVBestQuality
//- of points in the tet mesh
tetMeshOptimisation tmo(tetMesh);
tmo.optimiseUsingKnuppMetric();
tmo.optimiseUsingMeshUntangler();
tmo.optimiseUsingVolumeOptimizer();
tmo.optimiseUsingVolumeOptimizer(20);
//- update points in the mesh from the new coordinates in the tet mesh
tetMesh.updateOrigMesh(&changedFace);
} while( (nIter < minIter+2) && (++nIter < maxNumIterations) );
} while( ++nIter < maxNumIterations );
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -22,15 +22,15 @@ License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Ensures that all mesh points belonging to a symmetryPlane are
in a plane.
Performs point relocations in the mesh (smoothing) in order to
improve quality measures. It does not make the mesh invalied.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMeshGenModifier.H"
#include "symmetryPlaneOptimisation.H"
#include "meshOptimizer.H"
using namespace Foam;
......@@ -38,14 +38,97 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::validArgs.clear();
argList::validOptions.insert("nLoops", "int");
argList::validOptions.insert("nIterations", "int");
argList::validOptions.insert("nSurfaceIterations", "int");
argList::validOptions.insert("qualityThreshold", "scalar");
argList::validOptions.insert("constrainedCellsSet", "word");
# include "setRootCase.H"
# include "createTime.H"
//- read the settings
label nIterations(50);
label nLoops(10);
label nSurfaceIterations(2);
scalar qualityThreshold(0.1);
if( args.options().found("nLoops") )
{
nLoops = readLabel(IStringStream(args.options()["nLoops"])());
}
else
{
Info << "Default number of loops is 10" << endl;
}
if( args.options().found("nIterations") )
{
nIterations =
readLabel(IStringStream(args.options()["nIterations"])());
}
else
{
Info << "Default number of iterations is 50" << endl;
}
if( args.options().found("nSurfaceIterations") )
{
nSurfaceIterations =
readLabel(IStringStream(args.options()["nSurfaceIterations"])());
}
else
{
Info << "Default number of surface iterations is 2" << endl;
}
if( args.options().found("qualityThreshold") )
{
qualityThreshold =
readScalar(IStringStream(args.options()["qualityThreshold"])());
}
else
{
Info << "Using default quality threshold 0.1" << endl;
}
word constrainedCellSet;
if( args.options().found("constrainedCellsSet") )
{
constrainedCellSet = args.options()["constrainedCellsSet"];
}
else
{
Info << "No constraints pplied on the smoothing procedure" << endl;
}
//- load the mesh from disk
polyMeshGen pmg(runTime);
pmg.read();
Info << "Starting optimisation of symmetry planes" << endl;
symmetryPlaneOptimisation(pmg).optimizeSymmetryPlanes();
//- construct the smoother
meshOptimizer mOpt(pmg);
if( !constrainedCellSet.empty() )
mOpt.lockCells(constrainedCellSet);
//- perform optimisation using the laplace smoother and
mOpt.optimizeMeshFV
(
nLoops,
nLoops,
nIterations,
nSurfaceIterations
);
//- perform optimisation of worst quality faces
mOpt.optimizeMeshFVBestQuality(nLoops, qualityThreshold);
//- check the mesh again and untangl bad regions if any of them exist
mOpt.untangleMeshFV(nLoops, nIterations, nSurfaceIterations);
Info << "Writing mesh" << endl;
pmg.write();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment