Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
c49b302a
Commit
c49b302a
authored
Feb 24, 2009
by
mattijs
Browse files
added solutionD and geometricD
parent
c8944ce2
Changes
14
Hide whitespace changes
Inline
Side-by-side
applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C
View file @
c49b302a
...
...
@@ -23,16 +23,13 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
scalar
minDistSqr
=
magSqr
(
1e-6
*
globalBb
.
span
());
// Non-empty directions
const
Vector
<
label
>
validDirs
=
(
mesh
.
directions
()
+
Vector
<
label
>::
one
)
/
2
;
const
Vector
<
label
>
validDirs
=
(
mesh
.
geometricD
()
+
Vector
<
label
>::
one
)
/
2
;
Info
<<
" Mesh (non-empty, non-wedge) directions "
<<
validDirs
<<
endl
;
Info
<<
" Mesh (non-empty) directions "
<<
validDirs
<<
endl
;
const
Vector
<
label
>
solDirs
=
(
mesh
.
solutionD
()
+
Vector
<
label
>::
one
)
/
2
;
Info
<<
" Mesh (non-empty) directions "
<<
solDirs
<<
endl
;
scalar
nGeomDims
=
mesh
.
nGeometricD
();
Info
<<
" Mesh (non-empty, non-wedge) dimensions "
<<
nGeomDims
<<
endl
;
if
(
nGeomDims
<
3
)
if
(
mesh
.
nGeometricD
()
<
3
)
{
pointSet
nonAlignedPoints
(
mesh
,
"nonAlignedEdges"
,
mesh
.
nPoints
()
/
100
);
...
...
src/OpenFOAM/meshes/polyMesh/polyMesh.C
View file @
c49b302a
...
...
@@ -54,40 +54,79 @@ void Foam::polyMesh::calcDirections() const
{
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
direc
tion
s
_
[
cmpt
]
=
1
;
solu
tion
D
_
[
cmpt
]
=
1
;
}
// Knock out empty and wedge directions. Note:they will be present on all
// domains.
label
nEmptyPatches
=
0
;
label
nWedgePatches
=
0
;
vector
dirVec
=
vector
::
zero
;
vector
emptyDirVec
=
vector
::
zero
;
vector
wedgeDirVec
=
vector
::
zero
;
forAll
(
boundaryMesh
(),
patchi
)
{
if
(
isA
<
emptyPolyPatch
>
(
boundaryMesh
()[
patchi
]))
if
(
boundaryMesh
()[
patchi
]
.
size
(
))
{
if
(
boundaryMesh
()[
patchi
]
.
size
(
))
if
(
isA
<
emptyPolyPatch
>
(
boundaryMesh
()[
patchi
]))
{
nEmptyPatches
++
;
dirVec
+=
sum
(
cmptMag
(
boundaryMesh
()[
patchi
].
faceAreas
()));
emptyDirVec
+=
sum
(
cmptMag
(
boundaryMesh
()[
patchi
].
faceAreas
()));
}
else
if
(
isA
<
wedgePolyPatch
>
(
boundaryMesh
()[
patchi
]))
{
const
wedgePolyPatch
&
wpp
=
refCast
<
const
wedgePolyPatch
>
(
boundaryMesh
()[
patchi
]
);
nWedgePatches
++
;
wedgeDirVec
+=
cmptMag
(
wpp
.
centreNormal
());
}
}
}
if
(
nEmptyPatches
)
{
reduce
(
d
irVec
,
sumOp
<
vector
>
());
reduce
(
emptyD
irVec
,
sumOp
<
vector
>
());
d
irVec
/=
mag
(
d
irVec
);
emptyD
irVec
/=
mag
(
emptyD
irVec
);
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
d
irVec
[
cmpt
]
>
1e-6
)
if
(
emptyD
irVec
[
cmpt
]
>
1e-6
)
{
direc
tion
s
_
[
cmpt
]
=
-
1
;
solu
tion
D
_
[
cmpt
]
=
-
1
;
}
else
{
directions_
[
cmpt
]
=
1
;
solutionD_
[
cmpt
]
=
1
;
}
}
}
// Knock out wedge directions
geometricD_
=
solutionD_
;
if
(
nWedgePatches
)
{
reduce
(
wedgeDirVec
,
sumOp
<
vector
>
());
wedgeDirVec
/=
mag
(
wedgeDirVec
);
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
wedgeDirVec
[
cmpt
]
>
1e-6
)
{
geometricD_
[
cmpt
]
=
-
1
;
}
else
{
geometricD_
[
cmpt
]
=
1
;
}
}
}
...
...
@@ -163,7 +202,8 @@ Foam::polyMesh::polyMesh(const IOobject& io)
*
this
),
bounds_
(
points_
),
directions_
(
Vector
<
label
>::
zero
),
geometricD_
(
Vector
<
label
>::
zero
),
solutionD_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
...
...
@@ -350,7 +390,8 @@ Foam::polyMesh::polyMesh
0
),
bounds_
(
points_
,
syncPar
),
directions_
(
Vector
<
label
>::
zero
),
geometricD_
(
Vector
<
label
>::
zero
),
solutionD_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
...
...
@@ -505,7 +546,8 @@ Foam::polyMesh::polyMesh
0
),
bounds_
(
points_
,
syncPar
),
directions_
(
Vector
<
label
>::
zero
),
geometricD_
(
Vector
<
label
>::
zero
),
solutionD_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
...
...
@@ -766,44 +808,37 @@ const Foam::fileName& Foam::polyMesh::facesInstance() const
}
const
Foam
::
Vector
<
Foam
::
label
>&
Foam
::
polyMesh
::
directions
()
const
const
Foam
::
Vector
<
Foam
::
label
>&
Foam
::
polyMesh
::
geometricD
()
const
{
if
(
directions
_
.
x
()
==
0
)
if
(
geometricD
_
.
x
()
==
0
)
{
calcDirections
();
}
return
directions
_
;
return
geometricD
_
;
}
Foam
::
label
Foam
::
polyMesh
::
nGeometricD
()
const
{
label
nWedges
=
0
;
return
cmptSum
(
geometricD
()
+
Vector
<
label
>::
one
)
/
2
;
}
forAll
(
boundary_
,
patchi
)
{
if
(
isA
<
wedgePolyPatch
>
(
boundary_
[
patchi
]))
{
nWedges
++
;
}
}
if
(
nWedges
!=
0
&&
nWedges
!=
2
&&
nWedges
!=
4
)
const
Foam
::
Vector
<
Foam
::
label
>&
Foam
::
polyMesh
::
solutionD
()
const
{
if
(
solutionD_
.
x
()
==
0
)
{
FatalErrorIn
(
"label polyMesh::nGeometricD() const"
)
<<
"Number of wedge patches "
<<
nWedges
<<
" is incorrect, "
"should be 0, 2 or 4"
<<
exit
(
FatalError
);
calcDirections
();
}
return
nS
olutionD
()
-
nWedges
/
2
;
return
s
olutionD
_
;
}
Foam
::
label
Foam
::
polyMesh
::
nSolutionD
()
const
{
return
cmptSum
(
direc
tion
s
()
+
Vector
<
label
>::
one
)
/
2
;
return
cmptSum
(
solu
tion
D
()
+
Vector
<
label
>::
one
)
/
2
;
}
...
...
@@ -823,6 +858,10 @@ void Foam::polyMesh::addPatches
<<
abort
(
FatalError
);
}
// Reset valid directions
geometricD_
=
Vector
<
label
>::
zero
;
solutionD_
=
Vector
<
label
>::
zero
;
boundary_
.
setSize
(
p
.
size
());
// Copy the patch pointers
...
...
@@ -1037,6 +1076,10 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
faceZones_
.
movePoints
(
points_
);
cellZones_
.
movePoints
(
points_
);
// Reset valid directions (could change with rotation)
geometricD_
=
Vector
<
label
>::
zero
;
solutionD_
=
Vector
<
label
>::
zero
;
// Hack until proper callbacks. Below are all the polyMeh MeshObjects with a
// movePoints function.
...
...
src/OpenFOAM/meshes/polyMesh/polyMesh.H
View file @
c49b302a
...
...
@@ -120,9 +120,13 @@ private:
// Created from points on construction, updated when the mesh moves
boundBox
bounds_
;
//- vector of non-constrained directions in mesh
// defined according to the presence of empty and wedge patches
mutable
Vector
<
label
>
geometricD_
;
//- vector of valid directions in mesh
// defined according to the presence of empty patches
mutable
Vector
<
label
>
direc
tion
s
_
;
mutable
Vector
<
label
>
solu
tion
D
_
;
// Zoning information
...
...
@@ -309,17 +313,22 @@ public:
return
bounds_
;
}
//- Return the vector of valid directions in mesh.
// Defined according to the presence of empty patches.
// 1 indicates valid direction and -1 an invalid direction.
const
Vector
<
label
>&
directions
()
const
;
//- Return the vector of geometric directions in mesh.
// Defined according to the presence of empty and wedge patches.
// 1 indicates unconstrained direction and -1 a constrained
// direction.
const
Vector
<
label
>&
geometricD
()
const
;
//- Return the number of valid geometric dimensions in the mesh
label
nGeometricD
()
const
;
//- Return the number of valid solution dimensions in the mesh.
// For wedge cases this includes the circumferential direction
// in case of swirl.
//- Return the vector of solved-for directions in mesh.
// Differs from geometricD in that it includes for wedge cases
// the circumferential direction in case of swirl.
// 1 indicates valid direction and -1 an invalid direction.
const
Vector
<
label
>&
solutionD
()
const
;
//- Return the number of valid solved-for dimensions in the mesh
label
nSolutionD
()
const
;
//- Return point zone mesh
...
...
src/OpenFOAM/meshes/polyMesh/polyMeshClear.C
View file @
c49b302a
...
...
@@ -68,6 +68,10 @@ void Foam::polyMesh::clearGeom()
boundary_
[
patchI
].
clearGeom
();
}
// Reset valid directions (could change with rotation)
geometricD_
=
Vector
<
label
>::
zero
;
solutionD_
=
Vector
<
label
>::
zero
;
pointMesh
::
Delete
(
*
this
);
}
...
...
@@ -87,6 +91,10 @@ void Foam::polyMesh::clearAddressing()
// recalculation
deleteDemandDrivenData
(
globalMeshDataPtr_
);
// Reset valid directions
geometricD_
=
Vector
<
label
>::
zero
;
solutionD_
=
Vector
<
label
>::
zero
;
pointMesh
::
Delete
(
*
this
);
}
...
...
src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
View file @
c49b302a
...
...
@@ -217,7 +217,8 @@ Foam::polyMesh::polyMesh
boundaryFaces
.
size
()
+
1
// add room for a default patch
),
bounds_
(
points_
,
syncPar
),
directions_
(
Vector
<
label
>::
zero
),
geometricD_
(
Vector
<
label
>::
zero
),
solutionD_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
...
...
src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C
View file @
c49b302a
...
...
@@ -68,6 +68,11 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
newMotionPoints
.
map
(
oldMotionPoints
,
mpm
.
pointMap
());
}
// Reset valid directions (could change by faces put into empty patches)
geometricD_
=
Vector
<
label
>::
zero
;
solutionD_
=
Vector
<
label
>::
zero
;
// Hack until proper callbacks. Below are all the polyMesh-MeshObjects.
// pointMesh
...
...
src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C
View file @
c49b302a
...
...
@@ -140,11 +140,11 @@ void Foam::quadraticFitSnGradData::findFaceDirs
#ifndef SPHERICAL_GEOMETRY
if
(
mesh
.
nGeometricD
()
<=
2
)
// find the normal direcion
{
if
(
mesh
.
directions
()[
0
]
==
-
1
)
if
(
mesh
.
geometricD
()[
0
]
==
-
1
)
{
kdir
=
vector
(
1
,
0
,
0
);
}
else
if
(
mesh
.
directions
()[
1
]
==
-
1
)
else
if
(
mesh
.
geometricD
()[
1
]
==
-
1
)
{
kdir
=
vector
(
0
,
1
,
0
);
}
...
...
@@ -153,7 +153,7 @@ void Foam::quadraticFitSnGradData::findFaceDirs
kdir
=
vector
(
0
,
0
,
1
);
}
}
else
// 3D so find a direction in the pla
c
e of the face
else
// 3D so find a direction in the pla
n
e of the face
{
const
face
&
f
=
mesh
.
faces
()[
faci
];
kdir
=
mesh
.
points
()[
f
[
0
]]
-
mesh
.
points
()[
f
[
1
]];
...
...
src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
View file @
c49b302a
...
...
@@ -713,7 +713,7 @@ Foam::fvMatrix<Type>::H() const
(
pow
(
psi_
.
mesh
().
direc
tion
s
(),
psi_
.
mesh
().
solu
tion
D
(),
pTraits
<
typename
powProduct
<
Vector
<
label
>
,
Type
::
rank
>::
type
>::
zero
)
);
...
...
src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C
View file @
c49b302a
...
...
@@ -82,7 +82,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
(
pow
(
psi_
.
mesh
().
direc
tion
s
(),
psi_
.
mesh
().
solu
tion
D
(),
pTraits
<
typename
powProduct
<
Vector
<
label
>
,
Type
::
rank
>::
type
>::
zero
)
);
...
...
src/finiteVolume/interpolation/surfaceInterpolation/schemes/FitData/FitData.C
View file @
c49b302a
...
...
@@ -83,11 +83,11 @@ void Foam::FitData<FitDataType, ExtendedStencil, Polynomial>::findFaceDirs
# ifndef SPHERICAL_GEOMETRY
if
(
mesh
.
nGeometricD
()
<=
2
)
// find the normal direction
{
if
(
mesh
.
directions
()[
0
]
==
-
1
)
if
(
mesh
.
geometricD
()[
0
]
==
-
1
)
{
kdir
=
vector
(
1
,
0
,
0
);
}
else
if
(
mesh
.
directions
()[
1
]
==
-
1
)
else
if
(
mesh
.
geometricD
()[
1
]
==
-
1
)
{
kdir
=
vector
(
0
,
1
,
0
);
}
...
...
@@ -115,7 +115,7 @@ void Foam::FitData<FitDataType, ExtendedStencil, Polynomial>::findFaceDirs
if
(
magk
<
SMALL
)
{
FatalErrorIn
(
"findFaceDirs"
)
<<
" calculated kdir = zero"
FatalErrorIn
(
"findFaceDirs
(..)
"
)
<<
" calculated kdir = zero"
<<
exit
(
FatalError
);
}
else
...
...
src/meshTools/meshTools/meshTools.C
View file @
c49b302a
...
...
@@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include
"meshTools.H"
#include
"p
rimitive
Mesh.H"
#include
"p
oly
Mesh.H"
#include
"hexMatcher.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
...
...
@@ -635,6 +635,103 @@ Foam::label Foam::meshTools::walkFace
}
void
Foam
::
meshTools
::
constrainToMeshCentre
(
const
polyMesh
&
mesh
,
point
&
pt
)
{
const
Vector
<
label
>&
dirs
=
mesh
.
geometricD
();
const
point
&
min
=
mesh
.
bounds
().
min
();
const
point
&
max
=
mesh
.
bounds
().
max
();
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
pt
[
cmpt
]
=
0
.
5
*
(
min
[
cmpt
]
+
max
[
cmpt
]);
}
}
}
void
Foam
::
meshTools
::
constrainToMeshCentre
(
const
polyMesh
&
mesh
,
pointField
&
pts
)
{
const
Vector
<
label
>&
dirs
=
mesh
.
geometricD
();
const
point
&
min
=
mesh
.
bounds
().
min
();
const
point
&
max
=
mesh
.
bounds
().
max
();
bool
isConstrained
=
false
;
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
isConstrained
=
true
;
break
;
}
}
if
(
isConstrained
)
{
forAll
(
pts
,
i
)
{
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
pts
[
i
][
cmpt
]
=
0
.
5
*
(
min
[
cmpt
]
+
max
[
cmpt
]);
}
}
}
}
}
//- Set the constrained components of directions/velocity to zero
void
Foam
::
meshTools
::
constrainDirection
(
const
polyMesh
&
mesh
,
vector
&
d
)
{
const
Vector
<
label
>&
dirs
=
mesh
.
geometricD
();
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
d
[
cmpt
]
=
0
.
0
;
}
}
}
void
Foam
::
meshTools
::
constrainDirection
(
const
polyMesh
&
mesh
,
vectorField
&
d
)
{
const
Vector
<
label
>&
dirs
=
mesh
.
geometricD
();
bool
isConstrained
=
false
;
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
isConstrained
=
true
;
break
;
}
}
if
(
isConstrained
)
{
forAll
(
d
,
i
)
{
for
(
direction
cmpt
=
0
;
cmpt
<
vector
::
nComponents
;
cmpt
++
)
{
if
(
dirs
[
cmpt
]
==
-
1
)
{
d
[
i
][
cmpt
]
=
0
.
0
;
}
}
}
}
}
void
Foam
::
meshTools
::
getParallelEdges
(
const
primitiveMesh
&
mesh
,
...
...
src/meshTools/meshTools/meshTools.H
View file @
c49b302a
...
...
@@ -50,7 +50,7 @@ namespace Foam
{
class
primitiveMesh
;
class
polyMesh
;
/*---------------------------------------------------------------------------*\
Namespace meshTools Declaration
...
...
@@ -81,196 +81,212 @@ namespace meshTools
static
const
label
pXpYpZMask
=
1
<<
pXpYpZ
;
//- Check if n is in same direction as normals of all faceLabels
bool
visNormal
(
const
vector
&
n
,
const
vectorField
&
faceNormals
,
const
labelList
&
faceLabels
);
//- Calculate point normals on a 'box' mesh (all edges aligned with
// coordinate axes)
vectorField
calcBoxPointNormals
(
const
primitivePatch
&
pp
);
//- Normalized edge vector
vector
normEdgeVec
(
const
primitiveMesh
&
,
const
label
edgeI
);
//- Write obj representation of point
void
writeOBJ
(
Ostream
&
os
,
const
point
&
pt
);
//- Write obj representation of faces subset
void
writeOBJ
(
Ostream
&
os
,
const
faceList
&
,
const
pointField
&
,
const
labelList
&
faceLabels
);
//- Write obj representation of faces
void
writeOBJ
(
Ostream
&
os
,
const
faceList
&
,
const
pointField
&
);
//- Write obj representation of cell subset
void
writeOBJ
(
Ostream
&
os
,
const
cellList
&
,
const
faceList
&
,
const
pointField
&
,
const
labelList
&
cellLabels
);
//- Is edge used by cell
bool
edgeOnCell
(
const
primitiveMesh
&
,
const
label
cellI
,
const
label
edgeI
);
//- Is edge used by face
bool
edgeOnFace
(
const
primitiveMesh
&
,
const
label
faceI
,
const
label
edgeI
);
//- Is face used by cell
bool
faceOnCell
(
const
primitiveMesh
&
,
const
label
cellI
,
const
label
faceI
);
//- Return edge among candidates that uses the two vertices.
label
findEdge
(
const
edgeList
&
edges
,
const
labelList
&
candidates
,
const
label
v0
,
const
label
v1
);
//- Return edge between two vertices. Returns -1 if no edge.
label
findEdge
(
const
primitiveMesh
&
,
const
label
v0
,
const
label
v1
);
//- Return edge shared by two faces. Throws error if no edge found.
label
getSharedEdge
(
const
primitiveMesh
&
,
const
label
f0
,
const
label
f1
);
//- Return face shared by two cells. Throws error if none found.
label
getSharedFace
(
const
primitiveMesh
&
,
const
label
cell0
,
const
label
cell1
);
//- Get faces on cell using edgeI. Throws error if no two found.
void
getEdgeFaces