added solutionD and geometricD
This commit is contained in:
@ -25,7 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshTools.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "polyMesh.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,
|
||||
|
||||
@ -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
|
||||
);
|
||||
// Normal handling
|
||||
|
||||
//- Calculate point normals on a 'box' mesh (all edges aligned with
|
||||
// coordinate axes)
|
||||
vectorField calcBoxPointNormals(const primitivePatch& pp);
|
||||
//- Check if n is in same direction as normals of all faceLabels
|
||||
bool visNormal
|
||||
(
|
||||
const vector& n,
|
||||
const vectorField& faceNormals,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
//- Normalized edge vector
|
||||
vector normEdgeVec(const primitiveMesh&, const label edgeI);
|
||||
//- Calculate point normals on a 'box' mesh (all edges aligned with
|
||||
// coordinate axes)
|
||||
vectorField calcBoxPointNormals(const primitivePatch& pp);
|
||||
|
||||
//- Write obj representation of point
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const point& pt
|
||||
);
|
||||
//- Normalized edge vector
|
||||
vector normEdgeVec(const primitiveMesh&, const label edgeI);
|
||||
|
||||
|
||||
//- Write obj representation of faces subset
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const faceList&,
|
||||
const pointField&,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
// OBJ writing
|
||||
|
||||
//- Write obj representation of faces
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const faceList&,
|
||||
const pointField&
|
||||
);
|
||||
//- Write obj representation of point
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const point& pt
|
||||
);
|
||||
|
||||
//- Write obj representation of cell subset
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const cellList&,
|
||||
const faceList&,
|
||||
const pointField&,
|
||||
const labelList& cellLabels
|
||||
);
|
||||
//- Write obj representation of faces subset
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const faceList&,
|
||||
const pointField&,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
//- Is edge used by cell
|
||||
bool edgeOnCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI
|
||||
);
|
||||
//- Write obj representation of faces
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const faceList&,
|
||||
const pointField&
|
||||
);
|
||||
|
||||
//- 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
|
||||
);
|
||||
//- Write obj representation of cell subset
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const cellList&,
|
||||
const faceList&,
|
||||
const pointField&,
|
||||
const labelList& cellLabels
|
||||
);
|
||||
|
||||
//- 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
|
||||
);
|
||||
// Cell/face/edge walking
|
||||
|
||||
//- 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
|
||||
);
|
||||
//- Is edge used by cell
|
||||
bool edgeOnCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI
|
||||
);
|
||||
|
||||
//- Get faces on cell using edgeI. Throws error if no two found.
|
||||
void getEdgeFaces
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI,
|
||||
label& face0,
|
||||
label& face1
|
||||
);
|
||||
//- Is edge used by face
|
||||
bool edgeOnFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label faceI,
|
||||
const label edgeI
|
||||
);
|
||||
|
||||
//- Return label of other edge (out of candidates edgeLabels)
|
||||
// connected to vertex but not edgeI. Throws error if none found.
|
||||
label otherEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const labelList& edgeLabels,
|
||||
const label edgeI,
|
||||
const label vertI
|
||||
);
|
||||
|
||||
//- Return face on cell using edgeI but not faceI. Throws error
|
||||
// if none found.
|
||||
label otherFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label faceI,
|
||||
const label edgeI
|
||||
);
|
||||
//- Is face used by cell
|
||||
bool faceOnCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label faceI
|
||||
);
|
||||
|
||||
//- Return cell on other side of face. Throws error
|
||||
// if face not internal.
|
||||
label otherCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label faceI
|
||||
);
|
||||
|
||||
//- Returns label of edge nEdges away from startEdge (in the direction
|
||||
// of startVertI)
|
||||
label walkFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label faceI,
|
||||
const label startEdgeI,
|
||||
const label startVertI,
|
||||
const label nEdges
|
||||
);
|
||||
//- 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
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI,
|
||||
label& face0,
|
||||
label& face1
|
||||
);
|
||||
|
||||
//- Return label of other edge (out of candidates edgeLabels)
|
||||
// connected to vertex but not edgeI. Throws error if none found.
|
||||
label otherEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const labelList& edgeLabels,
|
||||
const label edgeI,
|
||||
const label vertI
|
||||
);
|
||||
|
||||
//- Return face on cell using edgeI but not faceI. Throws error
|
||||
// if none found.
|
||||
label otherFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label faceI,
|
||||
const label edgeI
|
||||
);
|
||||
|
||||
//- Return cell on other side of face. Throws error
|
||||
// if face not internal.
|
||||
label otherCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label faceI
|
||||
);
|
||||
|
||||
//- Returns label of edge nEdges away from startEdge (in the direction
|
||||
// of startVertI)
|
||||
label walkFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label faceI,
|
||||
const label startEdgeI,
|
||||
const label startVertI,
|
||||
const label nEdges
|
||||
);
|
||||
|
||||
|
||||
// Constraints on position
|
||||
|
||||
//- Set the constrained components of position to mesh centre
|
||||
void constrainToMeshCentre(const polyMesh&, point&);
|
||||
void constrainToMeshCentre(const polyMesh&, pointField&);
|
||||
|
||||
//- Set the constrained components of directions/velocity to zero
|
||||
void constrainDirection(const polyMesh&, vector&);
|
||||
void constrainDirection(const polyMesh&, vectorField&);
|
||||
|
||||
|
||||
//
|
||||
// Hex only functionality.
|
||||
//
|
||||
|
||||
//- Given edge on hex find other 'parallel', non-connected edges.
|
||||
void getParallelEdges
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label e0,
|
||||
label&,
|
||||
label&,
|
||||
label&
|
||||
);
|
||||
//- Given edge on hex find other 'parallel', non-connected edges.
|
||||
void getParallelEdges
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label e0,
|
||||
label&,
|
||||
label&,
|
||||
label&
|
||||
);
|
||||
|
||||
//- Given edge on hex find all 'parallel' (i.e. non-connected)
|
||||
// edges and average direction of them
|
||||
vector edgeToCutDir
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI
|
||||
);
|
||||
//- Given edge on hex find all 'parallel' (i.e. non-connected)
|
||||
// edges and average direction of them
|
||||
vector edgeToCutDir
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const label edgeI
|
||||
);
|
||||
|
||||
//- Reverse of edgeToCutDir: given direction find edge bundle and
|
||||
// return one of them.
|
||||
label cutDirToEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const vector& cutDir
|
||||
);
|
||||
//- Reverse of edgeToCutDir: given direction find edge bundle and
|
||||
// return one of them.
|
||||
label cutDirToEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const label cellI,
|
||||
const vector& cutDir
|
||||
);
|
||||
|
||||
} // End namespace meshTools
|
||||
|
||||
|
||||
Reference in New Issue
Block a user