Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
da29c4f0
Commit
da29c4f0
authored
Jan 28, 2019
by
Andrew Heather
Browse files
Merge branch 'feature-snappyHexMesh-check' into 'develop'
Feature snappy hex mesh check See merge request
OpenFOAM-plus!229
parents
3b911600
47d29b1c
Changes
49
Expand all
Hide whitespace changes
Inline
Side-by-side
applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C
View file @
da29c4f0
This diff is collapsed.
Click to expand it.
src/OpenFOAM/db/error/error.C
View file @
da29c4f0
...
...
@@ -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
)
...
...
src/OpenFOAM/db/error/error.H
View file @
da29c4f0
...
...
@@ -114,6 +114,9 @@ public:
string
message
()
const
;
//- Clear any messages
void
clear
()
const
;
inline
const
string
&
functionName
()
const
{
return
functionName_
;
...
...
src/dynamicMesh/motionSmoother/motionSmoother.C
View file @
da29c4f0
...
...
@@ -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
)
{}
...
...
src/dynamicMesh/motionSmoother/motionSmoother.H
View file @
da29c4f0
...
...
@@ -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
);
};
...
...
src/dynamicMesh/motionSmoother/motionSmootherAlgo.C
View file @
da29c4f0
...
...
@@ -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
)
{
...
...
src/dynamicMesh/motionSmoother/motionSmootherAlgo.H
View file @
da29c4f0
...
...
@@ -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
// );
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C
View file @
da29c4f0
...
...
@@ -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
;
...
...
src/dynamicMesh/motionSmoother/motionSmootherAlgoTemplates.C
View file @
da29c4f0
...
...
@@ -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
;
}
// ************************************************************************* //
src/mesh/snappyHexMesh/Make/files
View file @
da29c4f0
...
...
@@ -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
...
...
src/mesh/snappyHexMesh/Make/options
View file @
da29c4f0
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
src/mesh/snappyHexMesh/externalDisplacementMeshMover/displacementMotionSolverMeshMover.C
View file @
da29c4f0
...
...
@@ -109,10 +109,11 @@ Foam::displacementMotionSolverMeshMover::displacementMotionSolverMeshMover
(
const
dictionary
&
dict
,
const
List
<
labelPair
>&
baffles
,
pointVectorField
&
pointDisplacement
pointVectorField
&
pointDisplacement
,
const
bool
dryRun
)
:
externalDisplacementMeshMover
(
dict
,
baffles
,
pointDisplacement
),
externalDisplacementMeshMover
(
dict
,
baffles
,
pointDisplacement
,
dryRun
),
solverPtr_
(
...
...
@@ -178,7 +179,8 @@ Foam::displacementMotionSolverMeshMover::displacementMotionSolverMeshMover
scale_
,
oldPoints_
,
adaptPatchIDs_
,
dict