Commit 1c6cf168 authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'feature-snappyHexMesh-check' into 'develop'

Feature snappy hex mesh check

See merge request !229
parents cc6e00bd 5235ed7b
......@@ -203,6 +203,12 @@ Foam::string Foam::error::message() const
}
void Foam::error::clear() const
{
return messageStreamPtr_->reset();
}
void Foam::error::exit(const int errNo)
{
if (!throwExceptions_ && JobInfo::constructed)
......
......@@ -114,6 +114,9 @@ public:
string message() const;
//- Clear any messages
void clear() const;
inline const string& functionName() const
{
return functionName_;
......
......@@ -41,7 +41,8 @@ Foam::motionSmoother::motionSmoother
pointMesh& pMesh,
indirectPrimitivePatch& pp,
const labelList& adaptPatchIDs,
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun
)
:
motionSmootherData(pMesh),
......@@ -54,7 +55,8 @@ Foam::motionSmoother::motionSmoother
motionSmootherData::scale_,
motionSmootherData::oldPoints_,
adaptPatchIDs,
paramDict
paramDict,
dryRun
)
{}
......@@ -65,7 +67,8 @@ Foam::motionSmoother::motionSmoother
indirectPrimitivePatch& pp,
const labelList& adaptPatchIDs,
const pointVectorField& displacement,
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun
)
:
motionSmootherData(displacement),
......@@ -78,7 +81,8 @@ Foam::motionSmoother::motionSmoother
motionSmootherData::scale_,
motionSmootherData::oldPoints_,
adaptPatchIDs,
paramDict
paramDict,
dryRun
)
{}
......
......@@ -107,7 +107,8 @@ public:
pointMesh& pMesh,
indirectPrimitivePatch& pp, //!< 'outside' points
const labelList& adaptPatchIDs, //!< patches forming 'outside'
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun = false
);
//- Construct from mesh, patches to work on and smoothing parameters and
......@@ -118,7 +119,8 @@ public:
indirectPrimitivePatch& pp, //!< 'outside' points
const labelList& adaptPatchIDs, //!< patches forming 'outside'
const pointVectorField& displacement,
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun = false
);
};
......
......@@ -328,7 +328,8 @@ Foam::motionSmootherAlgo::motionSmootherAlgo
pointScalarField& scale,
pointField& oldPoints,
const labelList& adaptPatchIDs,
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun
)
:
mesh_(mesh),
......@@ -339,6 +340,7 @@ Foam::motionSmootherAlgo::motionSmootherAlgo
oldPoints_(oldPoints),
adaptPatchIDs_(adaptPatchIDs),
paramDict_(paramDict),
dryRun_(dryRun),
isInternalPoint_(mesh_.nPoints(), true)
{
updateMesh();
......@@ -856,9 +858,14 @@ bool Foam::motionSmootherAlgo::scaleMesh
}
}
const scalar errorReduction = paramDict.get<scalar>("errorReduction");
const label nSmoothScale = paramDict.get<label>("nSmoothScale");
const scalar errorReduction = get<scalar>
(
paramDict, "errorReduction", dryRun_, keyType::REGEX_RECURSIVE
);
const label nSmoothScale = get<label>
(
paramDict, "nSmoothScale", dryRun_, keyType::REGEX_RECURSIVE
);
// Note: displacement_ should already be synced already from setDisplacement
// but just to make sure.
......@@ -885,7 +892,16 @@ bool Foam::motionSmootherAlgo::scaleMesh
// Check. Returns parallel number of incorrect faces.
faceSet wrongFaces(mesh_, "wrongFaces", mesh_.nFaces()/100+100);
checkMesh(false, mesh_, meshQualityDict, checkFaces, baffles, wrongFaces);
checkMesh
(
false,
mesh_,
meshQualityDict,
checkFaces,
baffles,
wrongFaces,
dryRun_
);
if (returnReduce(wrongFaces.size(), sumOp<label>()) <= nAllowableErrors)
{
......
......@@ -156,9 +156,12 @@ class motionSmootherAlgo
// displacement on.
const labelList adaptPatchIDs_;
// Smoothing and checking parameters
//- Smoothing and checking parameters
dictionary paramDict_;
//- In test/dry-run mode?
const bool dryRun_;
//- Is mesh point on boundary or not
bitSet isInternalPoint_;
......@@ -303,7 +306,8 @@ public:
pointScalarField& scale,
pointField& oldPoints,
const labelList& adaptPatchIDs, // patches forming 'outside'
const dictionary& paramDict
const dictionary& paramDict,
const bool dryRun = false
);
......@@ -442,7 +446,8 @@ public:
const bool report,
const polyMesh& mesh,
const dictionary& dict,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun = false
);
//- Check (subset of mesh) with mesh settings in dict.
......@@ -454,7 +459,8 @@ public:
const polyMesh& mesh,
const dictionary& dict,
const labelList& checkFaces,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun = false
);
//- Check (subset of mesh including baffles) with mesh settings
......@@ -467,7 +473,8 @@ public:
const dictionary& dict,
const labelList& checkFaces,
const List<labelPair>& baffles,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun = false
);
//- Check part of mesh with mesh settings in dict.
......@@ -480,7 +487,8 @@ public:
const polyMeshGeometry&,
const pointField&,
const labelList& checkFaces,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun = false
);
//- Check part of mesh including baffles with mesh settings in dict.
......@@ -494,7 +502,8 @@ public:
const pointField&,
const labelList& checkFaces,
const List<labelPair>& baffles,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun = false
);
// Helper functions to manipulate displacement vector.
......@@ -508,6 +517,28 @@ public:
const scalarField& edgeWeight,
GeometricField<Type, pointPatchField, pointMesh>& newFld
) const;
//- Wrapper around dictionary::get which does not exit
template<class Type>
static Type get
(
const dictionary& dict,
const word& keyword,
const bool noExit,
enum keyType::option matchOpt,
const Type& defaultValue = Zero
);
//
// //- Wrapper around dictionary::get which does not exit
// template<class Type>
// static Type get
// (
// const dictionary& dict,
// const word& keyword,
// const bool noExit,
// bool recursive,
// bool patternMatch
// );
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -35,7 +35,8 @@ bool Foam::motionSmootherAlgo::checkMesh
const polyMesh& mesh,
const dictionary& dict,
const labelList& checkFaces,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun
)
{
List<labelPair> emptyBaffles;
......@@ -46,7 +47,8 @@ bool Foam::motionSmootherAlgo::checkMesh
dict,
checkFaces,
emptyBaffles,
wrongFaces
wrongFaces,
dryRun
);
}
......@@ -57,54 +59,60 @@ bool Foam::motionSmootherAlgo::checkMesh
const dictionary& dict,
const labelList& checkFaces,
const List<labelPair>& baffles,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun
)
{
const scalar maxNonOrtho
(
dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxNonOrtho", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minVol
(
dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minVol", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTetQuality
(
dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTetQuality", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar maxConcave
(
dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxConcave", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minArea
(
dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minArea", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar maxIntSkew
(
dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
get<scalar>
(
dict, "maxInternalSkewness", dryRun, keyType::REGEX_RECURSIVE
)
);
const scalar maxBounSkew
(
dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
get<scalar>
(
dict, "maxBoundarySkewness", dryRun, keyType::REGEX_RECURSIVE
)
);
const scalar minWeight
(
dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minFaceWeight", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minVolRatio
(
dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minVolRatio", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTwist
(
dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTwist", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTriangleTwist
(
dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTriangleTwist", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minFaceFlatness
(
dict.lookupOrDefault<scalar>
......@@ -114,8 +122,38 @@ bool Foam::motionSmootherAlgo::checkMesh
);
const scalar minDet
(
dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minDeterminant", dryRun, keyType::REGEX_RECURSIVE)
);
if (dryRun)
{
string errorMsg(FatalError.message());
string IOerrorMsg(FatalIOError.message());
if (errorMsg.size() || IOerrorMsg.size())
{
//errorMsg = "[dryRun] " + errorMsg;
//errorMsg.replaceAll("\n", "\n[dryRun] ");
//IOerrorMsg = "[dryRun] " + IOerrorMsg;
//IOerrorMsg.replaceAll("\n", "\n[dryRun] ");
IOWarningInFunction(dict)
<< nl
<< "Missing/incorrect required dictionary entries:" << nl
<< nl
<< IOerrorMsg.c_str() << nl
<< errorMsg.c_str() << nl
//<< nl << "Exiting dry-run" << nl
<< endl;
FatalError.clear();
FatalIOError.clear();
}
return false;
}
label nWrongFaces = 0;
Info<< "Checking faces in error :" << endl;
......@@ -422,7 +460,8 @@ bool Foam::motionSmootherAlgo::checkMesh
const bool report,
const polyMesh& mesh,
const dictionary& dict,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun
)
{
return checkMesh
......@@ -431,7 +470,8 @@ bool Foam::motionSmootherAlgo::checkMesh
mesh,
dict,
identity(mesh.nFaces()),
wrongFaces
wrongFaces,
dryRun
);
}
......@@ -442,7 +482,8 @@ bool Foam::motionSmootherAlgo::checkMesh
const polyMeshGeometry& meshGeom,
const pointField& points,
const labelList& checkFaces,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun
)
{
List<labelPair> emptyBaffles;
......@@ -455,7 +496,8 @@ bool Foam::motionSmootherAlgo::checkMesh
points,
checkFaces,
emptyBaffles,
wrongFaces
wrongFaces,
dryRun
);
}
......@@ -468,64 +510,93 @@ bool Foam::motionSmootherAlgo::checkMesh
const pointField& points,
const labelList& checkFaces,
const List<labelPair>& baffles,
labelHashSet& wrongFaces
labelHashSet& wrongFaces,
const bool dryRun
)
{
const scalar maxNonOrtho
(
dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxNonOrtho", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minVol
(
dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minVol", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTetQuality
(
dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTetQuality", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar maxConcave
(
dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxConcave", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minArea
(
dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minArea", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar maxIntSkew
(
dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxInternalSkewness", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar maxBounSkew
(
dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "maxBoundarySkewness", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minWeight
(
dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minFaceWeight", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minVolRatio
(
dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minVolRatio", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTwist
(
dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTwist", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minTriangleTwist
(
dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minTriangleTwist", dryRun, keyType::REGEX_RECURSIVE)
);
const scalar minFaceFlatness
scalar minFaceFlatness = -1.0;
dict.readIfPresent
(
dict.lookupOrDefault<scalar>
(
"minFaceFlatness", -1, keyType::REGEX_RECURSIVE
)
"minFaceFlatness",
minFaceFlatness,
keyType::REGEX_RECURSIVE
);
const scalar minDet
(
dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
get<scalar>(dict, "minDeterminant", dryRun, keyType::REGEX_RECURSIVE)
);
if (dryRun)
{
string errorMsg(FatalError.message());
string IOerrorMsg(FatalIOError.message());
if (errorMsg.size() || IOerrorMsg.size())
{
//errorMsg = "[dryRun] " + errorMsg;
//errorMsg.replaceAll("\n", "\n[dryRun] ");
//IOerrorMsg = "[dryRun] " + IOerrorMsg;
//IOerrorMsg.replaceAll("\n", "\n[dryRun] ");
Perr<< nl
<< "Missing/incorrect required dictionary entries:" << nl
<< nl
<< IOerrorMsg.c_str() << nl
<< errorMsg.c_str() << nl
//<< nl << "Exiting dry-run" << nl
<< endl;
FatalError.clear();
FatalIOError.clear();
}
return false;
}
label nWrongFaces = 0;
Info<< "Checking faces in error :" << endl;
......
......@@ -287,4 +287,35 @@ void Foam::motionSmootherAlgo::testSyncField
}
template<class Type>
Type Foam::motionSmootherAlgo::get
(
const dictionary& dict,
const word& keyword,
const bool noExit,
enum keyType::option matchOpt,
const Type& defaultValue
)
{
Type val(defaultValue);
if
(
!dict.readEntry
(
keyword,
val,
matchOpt,
!noExit
)
)
{
FatalIOError
<< "Entry '" << keyword << "' not found in dictionary "
<< dict.name() << endl;
}
return val;
}
// ************************************************************************* //
......@@ -2,6 +2,7 @@ snappyHexMeshDriver/snappyLayerDriver.C
snappyHexMeshDriver/snappySnapDriver.C
snappyHexMeshDriver/snappySnapDriverFeature.C
snappyHexMeshDriver/snappyRefineDriver.C
snappyHexMeshDriver/snappyVoxelMeshDriver.C
snappyHexMeshDriver/layerParameters/layerParameters.C
snappyHexMeshDriver/refinementParameters/refinementParameters.C
......
EXE_INC = \
/* -g -DFULLDEBUG -O0 */ \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/overset/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
......@@ -14,4 +16,5 @@ LIB_LIBS = \
-llagrangian \
-lmeshTools \
-lfvMotionSolvers \
-loverset \
-ldistributed
......@@ -109,10 +109,11 @@ Foam::displacementMotionSolverMeshMover::displacementMotionSolverMeshMover
(
const dictionary& dict,
const List<labelPair>& baffles,
pointVectorField& pointDisplacement
pointVectorField& pointDisplacement,