mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
reworked surfMesh and PrimitivePatchExtra
- ditched PrimitivePatchExtra in favour of a PatchTools class that is currently just a collection of static functions. They could equally well live within PrimitivePatch itself, but isolated also has its advantages. - MeshedSurface, UnsortedMeshedSurface now have 'regions' instead of 'patches' since they are more like a faceZone for meshed surfaces than patches. This might avoid confusion at a later stage.
This commit is contained in:
@ -56,6 +56,7 @@ Note
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triSurface.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
@ -115,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -230,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -60,8 +60,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class patchZones;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cyclicPolyPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -26,11 +26,6 @@ License
|
||||
|
||||
#include "Map.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
@ -41,7 +36,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
const FaceList<Face>& faces,
|
||||
const Field<PointType>& points
|
||||
@ -76,7 +73,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
FaceList<Face>& faces,
|
||||
Field<PointType>& points,
|
||||
@ -112,7 +111,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
|
||||
)
|
||||
@ -148,7 +149,8 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
@ -164,7 +166,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::movePoints
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
movePoints
|
||||
(
|
||||
const Field<PointType>&
|
||||
)
|
||||
@ -188,8 +193,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const edgeList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edges() const
|
||||
|
||||
const Foam::edgeList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edges() const
|
||||
{
|
||||
if (!edgesPtr_)
|
||||
{
|
||||
@ -207,8 +214,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::nInternalEdges()
|
||||
const
|
||||
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
nInternalEdges() const
|
||||
{
|
||||
if (!edgesPtr_)
|
||||
{
|
||||
@ -226,8 +235,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::boundaryPoints() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
boundaryPoints() const
|
||||
{
|
||||
if (!boundaryPointsPtr_)
|
||||
{
|
||||
@ -245,8 +256,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::faceFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
faceFaces() const
|
||||
{
|
||||
if (!faceFacesPtr_)
|
||||
{
|
||||
@ -264,8 +277,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edgeFaces() const
|
||||
{
|
||||
if (!edgeFacesPtr_)
|
||||
{
|
||||
@ -283,8 +298,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::faceEdges() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
faceEdges() const
|
||||
{
|
||||
if (!faceEdgesPtr_)
|
||||
{
|
||||
@ -302,8 +319,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::pointEdges() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
pointEdges() const
|
||||
{
|
||||
if (!pointEdgesPtr_)
|
||||
{
|
||||
@ -321,8 +340,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::pointFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
pointFaces() const
|
||||
{
|
||||
if (!pointFacesPtr_)
|
||||
{
|
||||
@ -340,8 +361,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const List<Face>&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::localFaces() const
|
||||
|
||||
const Foam::List<Face>&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
localFaces() const
|
||||
{
|
||||
if (!localFacesPtr_)
|
||||
{
|
||||
@ -359,8 +382,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::meshPoints() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshPoints() const
|
||||
{
|
||||
if (!meshPointsPtr_)
|
||||
{
|
||||
@ -378,8 +403,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Map<label>&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::meshPointMap() const
|
||||
|
||||
const Foam::Map<Foam::label>&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshPointMap() const
|
||||
{
|
||||
if (!meshPointMapPtr_)
|
||||
{
|
||||
@ -397,8 +424,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Field<PointType>&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::localPoints() const
|
||||
|
||||
const Foam::Field<PointType>&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
localPoints() const
|
||||
{
|
||||
if (!localPointsPtr_)
|
||||
{
|
||||
@ -416,8 +445,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::localPointOrder() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
localPointOrder() const
|
||||
{
|
||||
if (!localPointOrderPtr_)
|
||||
{
|
||||
@ -435,16 +466,19 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichPoint
|
||||
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
whichPoint
|
||||
(
|
||||
const label gp
|
||||
) const
|
||||
{
|
||||
Map<label>::const_iterator gpIter = meshPointMap().find(gp);
|
||||
Map<label>::const_iterator fnd = meshPointMap().find(gp);
|
||||
|
||||
if (gpIter != meshPointMap().end())
|
||||
if (fnd != meshPointMap().end())
|
||||
{
|
||||
return gpIter();
|
||||
return fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -461,8 +495,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Field<PointType>&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::faceNormals() const
|
||||
|
||||
const Foam::Field<PointType>&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
faceNormals() const
|
||||
{
|
||||
if (!faceNormalsPtr_)
|
||||
{
|
||||
@ -480,8 +516,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Field<PointType>&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::pointNormals() const
|
||||
|
||||
const Foam::Field<PointType>&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
pointNormals() const
|
||||
{
|
||||
if (!pointNormalsPtr_)
|
||||
{
|
||||
@ -501,7 +539,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
operator=
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
|
||||
)
|
||||
@ -511,11 +552,6 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
|
||||
FaceList<Face>::operator=(pp);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PrimitivePatchAddressing.C"
|
||||
|
||||
@ -28,10 +28,10 @@ Class
|
||||
Description
|
||||
A list of faces which address into the list of points.
|
||||
|
||||
The class is templated on the form of the face (e.g. triangle, polygon
|
||||
etc.) and on the form of list for faces and points so that it can
|
||||
refer to existing lists using UList and const pointField& or hold the
|
||||
storage using List and pointField.
|
||||
The class is templated on the face type (e.g. triangle, polygon etc.)
|
||||
and on the list type of faces and points so that it can refer to
|
||||
existing lists using UList and const pointField& or hold the storage
|
||||
using List and pointField.
|
||||
|
||||
SourceFiles
|
||||
PrimitivePatchAddressing.C
|
||||
@ -211,9 +211,12 @@ private:
|
||||
//- Calculate unit point normals
|
||||
void calcPointNormals() const;
|
||||
|
||||
//- Calculate edge owner
|
||||
void calcEdgeOwner() const;
|
||||
|
||||
|
||||
//- Face-edge-face walk while remaining on a patch point.
|
||||
// Used to determine if surface multiply connected through point.
|
||||
// Used to determine if surface multiply connected through point.
|
||||
void visitPointRegion
|
||||
(
|
||||
const label pointI,
|
||||
@ -265,175 +268,175 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Return reference to global points
|
||||
const Field<PointType>& points() const
|
||||
//- Return reference to global points
|
||||
const Field<PointType>& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
|
||||
// Access functions for demand driven data
|
||||
|
||||
// Topological data; no mesh required.
|
||||
|
||||
//- Return number of points supporting patch faces
|
||||
label nPoints() const
|
||||
{
|
||||
return points_;
|
||||
return meshPoints().size();
|
||||
}
|
||||
|
||||
//- Return number of edges in patch
|
||||
label nEdges() const
|
||||
{
|
||||
return edges().size();
|
||||
}
|
||||
|
||||
// Access functions for demand driven data
|
||||
//- Return list of edges, address into LOCAL point list
|
||||
const edgeList& edges() const;
|
||||
|
||||
// Topological data; no mesh required.
|
||||
//- Number of internal edges
|
||||
label nInternalEdges() const;
|
||||
|
||||
//- Return number of points supporting patch faces
|
||||
label nPoints() const
|
||||
{
|
||||
return meshPoints().size();
|
||||
}
|
||||
//- Is internal edge?
|
||||
bool isInternalEdge(const label edgeI) const
|
||||
{
|
||||
return edgeI < nInternalEdges();
|
||||
}
|
||||
|
||||
//- Return number of edges in patch
|
||||
label nEdges() const
|
||||
{
|
||||
return edges().size();
|
||||
}
|
||||
//- Return list of boundary points,
|
||||
// address into LOCAL point list
|
||||
const labelList& boundaryPoints() const;
|
||||
|
||||
//- Return list of edges, address into LOCAL point list
|
||||
const edgeList& edges() const;
|
||||
//- Return face-face addressing
|
||||
const labelListList& faceFaces() const;
|
||||
|
||||
//- Number of internal edges
|
||||
label nInternalEdges() const;
|
||||
//- Return edge-face addressing
|
||||
const labelListList& edgeFaces() const;
|
||||
|
||||
//- Is internal edge?
|
||||
bool isInternalEdge(const label edgeI) const
|
||||
{
|
||||
return edgeI < nInternalEdges();
|
||||
}
|
||||
//- Return face-edge addressing
|
||||
const labelListList& faceEdges() const;
|
||||
|
||||
//- Return list of boundary points,
|
||||
// address into LOCAL point list
|
||||
const labelList& boundaryPoints() const;
|
||||
//- Return point-edge addressing
|
||||
const labelListList& pointEdges() const;
|
||||
|
||||
//- Return face-face addressing
|
||||
const labelListList& faceFaces() const;
|
||||
//- Return point-face addressing
|
||||
const labelListList& pointFaces() const;
|
||||
|
||||
//- Return edge-face addressing
|
||||
const labelListList& edgeFaces() const;
|
||||
|
||||
//- Return face-edge addressing
|
||||
const labelListList& faceEdges() const;
|
||||
|
||||
//- Return point-edge addressing
|
||||
const labelListList& pointEdges() const;
|
||||
|
||||
//- Return point-face addressing
|
||||
const labelListList& pointFaces() const;
|
||||
|
||||
//- Return patch faces addressing into local point list
|
||||
const List<Face>& localFaces() const;
|
||||
//- Return patch faces addressing into local point list
|
||||
const List<Face>& localFaces() const;
|
||||
|
||||
|
||||
// Addressing into mesh
|
||||
// Addressing into mesh
|
||||
|
||||
//- Return labelList of mesh points in patch
|
||||
const labelList& meshPoints() const;
|
||||
//- Return labelList of mesh points in patch
|
||||
const labelList& meshPoints() const;
|
||||
|
||||
//- Mesh point map. Given the global point index find its
|
||||
// location in the patch
|
||||
const Map<label>& meshPointMap() const;
|
||||
//- Mesh point map. Given the global point index find its
|
||||
// location in the patch
|
||||
const Map<label>& meshPointMap() const;
|
||||
|
||||
//- Return pointField of points in patch
|
||||
const Field<PointType>& localPoints() const;
|
||||
//- Return pointField of points in patch
|
||||
const Field<PointType>& localPoints() const;
|
||||
|
||||
//- Return orders the local points for most efficient search
|
||||
const labelList& localPointOrder() const;
|
||||
//- Return orders the local points for most efficient search
|
||||
const labelList& localPointOrder() const;
|
||||
|
||||
//- Given a global point index, return the local point
|
||||
//index. If the point is not found, return -1
|
||||
label whichPoint(const label gp) const;
|
||||
//- Given a global point index, return the local point index.
|
||||
// If the point is not found, return -1
|
||||
label whichPoint(const label gp) const;
|
||||
|
||||
//- Given an edge in local point labels, return its
|
||||
// index in the edge list. If the edge is not found, return -1
|
||||
label whichEdge(const edge& e) const;
|
||||
//- Given an edge in local point labels, return its
|
||||
// index in the edge list. If the edge is not found, return -1
|
||||
label whichEdge(const edge&) const;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// cell addressing
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
const labelList& faceCells
|
||||
) const;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// basic edge addressing.
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
) const;
|
||||
|
||||
//- Return face normals for patch
|
||||
const Field<PointType>& faceNormals() const;
|
||||
|
||||
//- Return point normals for patch
|
||||
const Field<PointType>& pointNormals() const;
|
||||
|
||||
|
||||
// Other patch operations
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Return list of closed loops of boundary vertices.
|
||||
// Edge loops are given as ordered lists of vertices
|
||||
// in local addressing
|
||||
const labelListList& edgeLoops() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Calculate surface type formed by patch.
|
||||
// - all edges have two neighbours (manifold)
|
||||
// - some edges have more than two neighbours (illegal)
|
||||
// - other (open)
|
||||
surfaceTopo surfaceType() const;
|
||||
|
||||
//- Check surface formed by patch for manifoldness (see above).
|
||||
// Insert vertices of incorrect
|
||||
// edges set. Return true if any incorrect edge found.
|
||||
bool checkTopology
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// cell addressing
|
||||
labelList meshEdges
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
const labelList& faceCells
|
||||
) const;
|
||||
|
||||
//- Checks primitivePatch for faces sharing point but not edge.
|
||||
// This denotes a surface that is pinched at a single point
|
||||
// (test for pinched at single edge is already in PrimitivePatch)
|
||||
// Returns true if this situation found and puts conflicting
|
||||
// (mesh)point in set. Based on all the checking routines in
|
||||
// primitiveMesh.
|
||||
bool checkPointManifold
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// basic edge addressing.
|
||||
labelList meshEdges
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
) const;
|
||||
|
||||
//- Return face normals for patch
|
||||
const Field<PointType>& faceNormals() const;
|
||||
|
||||
// Edit
|
||||
//- Return point normals for patch
|
||||
const Field<PointType>& pointNormals() const;
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const Field<PointType>&);
|
||||
|
||||
// Other patch operations
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Return list of closed loops of boundary vertices.
|
||||
// Edge loops are given as ordered lists of vertices
|
||||
// in local addressing
|
||||
const labelListList& edgeLoops() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Calculate surface type formed by patch.
|
||||
// - all edges have two neighbours (manifold)
|
||||
// - some edges have more than two neighbours (illegal)
|
||||
// - other (open)
|
||||
surfaceTopo surfaceType() const;
|
||||
|
||||
//- Check surface formed by patch for manifoldness (see above).
|
||||
// Return true if any incorrect edges are found.
|
||||
// Insert vertices of incorrect edges into set.
|
||||
bool checkTopology
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
) const;
|
||||
|
||||
//- Checks primitivePatch for faces sharing point but not edge.
|
||||
// This denotes a surface that is pinched at a single point
|
||||
// (test for pinched at single edge is already in PrimitivePatch)
|
||||
// Returns true if this situation found and puts conflicting
|
||||
// (mesh)point in set. Based on all the checking routines in
|
||||
// primitiveMesh.
|
||||
bool checkPointManifold
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const Field<PointType>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -39,11 +39,6 @@ Description
|
||||
#include "DynamicList.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -53,8 +48,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcAddressing() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -311,8 +308,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,10 +29,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -43,8 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcBdryPoints() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -91,8 +89,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -31,10 +31,6 @@ Description
|
||||
#include "Map.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -45,7 +41,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::visitPointRegion
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
visitPointRegion
|
||||
(
|
||||
const label pointI,
|
||||
const labelList& pFaces,
|
||||
@ -121,8 +120,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
typename PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceType() const
|
||||
|
||||
typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
surfaceType() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -173,7 +174,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
bool PrimitivePatch<Face, FaceList, PointField, PointType>::checkTopology
|
||||
|
||||
bool
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
checkTopology
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -241,8 +245,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
|
||||
bool
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
checkPointManifold
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -327,12 +333,8 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold
|
||||
}
|
||||
}
|
||||
|
||||
return foundError;
|
||||
return foundError;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,10 +29,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,7 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearGeom()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearGeom()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -65,7 +64,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearTopology()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -91,10 +93,8 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
|
||||
}
|
||||
|
||||
deleteDemandDrivenData(boundaryPointsPtr_);
|
||||
|
||||
deleteDemandDrivenData(pointEdgesPtr_);
|
||||
deleteDemandDrivenData(pointFacesPtr_);
|
||||
|
||||
deleteDemandDrivenData(edgeLoopsPtr_);
|
||||
}
|
||||
|
||||
@ -106,7 +106,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearPatchMeshAddr()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearPatchMeshAddr()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -129,7 +132,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearOut()
|
||||
{
|
||||
clearGeom();
|
||||
clearTopology();
|
||||
@ -137,8 +143,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,10 +30,7 @@ Description
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -44,8 +41,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcEdgeLoops() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -95,7 +94,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
|
||||
// Current loop number.
|
||||
label loopI = 0;
|
||||
|
||||
for (;;)
|
||||
while (true)
|
||||
{
|
||||
// Find edge not yet given a loop number.
|
||||
label currentEdgeI = -1;
|
||||
@ -175,8 +174,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edgeLoops() const
|
||||
{
|
||||
if (!edgeLoopsPtr_)
|
||||
{
|
||||
@ -186,8 +187,5 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const
|
||||
return *edgeLoopsPtr_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,11 +30,6 @@ Description
|
||||
#include "SLList.H"
|
||||
#include "boolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -44,8 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPointOrder() const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPointOrder() const
|
||||
{
|
||||
// Note: Cannot use bandCompressing as point-point addressing does
|
||||
// not exist and is not considered generally useful.
|
||||
@ -140,9 +137,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,10 +27,7 @@ License
|
||||
#include "PrimitivePatch.H"
|
||||
#include "Map.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -42,7 +39,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshData() const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcMeshData() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -128,8 +127,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshPointMap()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcMeshPointMap() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -179,8 +179,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcLocalPoints()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPoints() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -231,8 +232,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointNormals()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointNormals() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -298,8 +300,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcFaceNormals() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -341,8 +344,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,10 +28,6 @@ Description
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -43,7 +39,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
Foam::labelList
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
@ -119,7 +117,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
Foam::labelList
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
@ -133,7 +133,7 @@ labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// get reference to the list of edges on the patch
|
||||
// get reference to the list of edges on the patch
|
||||
const edgeList& PatchEdges = edges();
|
||||
|
||||
// create the storage
|
||||
@ -157,7 +157,7 @@ labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
{
|
||||
meshEdges[edgeI] = pe[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +175,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
whichEdge
|
||||
(
|
||||
const edge& e
|
||||
) const
|
||||
@ -201,8 +203,4 @@ label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,10 +30,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "SLList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -45,8 +41,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointEdges()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointEdges() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -116,8 +113,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointFaces() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -183,8 +181,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -33,11 +33,6 @@ Description
|
||||
#include "objectHit.H"
|
||||
#include "bandCompression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -49,7 +44,8 @@ template
|
||||
>
|
||||
|
||||
template <class ToPatch>
|
||||
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
Foam::List<Foam::objectHit>
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
@ -59,7 +55,6 @@ projectPoints
|
||||
) const
|
||||
{
|
||||
// The current patch is slave, i.e. it is being projected onto the target
|
||||
//
|
||||
|
||||
if (projectionDirection.size() != nPoints())
|
||||
{
|
||||
@ -101,8 +96,8 @@ projectPoints
|
||||
// Loop through all points of the slave side. For every point find the
|
||||
// radius for the current contact face. If the contact point falls inside
|
||||
// the face and the radius is smaller than for all neighbouring faces,
|
||||
// the contact is found. If not, visit the neighbour closest to the
|
||||
// calculated contact point. If a single master face is visited more than
|
||||
// the contact is found. If not, visit the neighbour closest to the
|
||||
// calculated contact point. If a single master face is visited more than
|
||||
// twice, initiate n-squared search.
|
||||
|
||||
label curFace = 0;
|
||||
@ -177,7 +172,7 @@ projectPoints
|
||||
// Calculate the miss point on the plane of the
|
||||
// face. This is cooked (illogical!) for fastest
|
||||
// surface walk.
|
||||
//
|
||||
//
|
||||
PointType missPlanePoint =
|
||||
curPoint + curProjectionDir*curHit.distance();
|
||||
|
||||
@ -216,7 +211,7 @@ projectPoints
|
||||
} while (closer);
|
||||
}
|
||||
|
||||
if
|
||||
if
|
||||
(
|
||||
doNSquaredSearch || !foundEligible
|
||||
)
|
||||
@ -297,7 +292,8 @@ template
|
||||
>
|
||||
|
||||
template <class ToPatch>
|
||||
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
Foam::List<Foam::objectHit>
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
@ -307,7 +303,6 @@ projectFaceCentres
|
||||
) const
|
||||
{
|
||||
// The current patch is slave, i.e. it is being projected onto the target
|
||||
//
|
||||
|
||||
if (projectionDirection.size() != this->size())
|
||||
{
|
||||
@ -349,8 +344,8 @@ projectFaceCentres
|
||||
// Loop through all points of the slave side. For every point find the
|
||||
// radius for the current contact face. If the contact point falls inside
|
||||
// the face and the radius is smaller than for all neighbouring faces,
|
||||
// the contact is found. If not, visit the neighbour closest to the
|
||||
// calculated contact point. If a single master face is visited more than
|
||||
// the contact is found. If not, visit the neighbour closest to the
|
||||
// calculated contact point. If a single master face is visited more than
|
||||
// twice, initiate n-squared search.
|
||||
|
||||
label curFace = 0;
|
||||
@ -424,11 +419,11 @@ projectFaceCentres
|
||||
|
||||
// Calculate the miss point. This is
|
||||
// cooked (illogical!) for fastest surface walk.
|
||||
//
|
||||
//
|
||||
PointType missPlanePoint =
|
||||
curFaceCentre + curProjectionDir*curHit.distance();
|
||||
|
||||
sqrDistance =
|
||||
sqrDistance =
|
||||
magSqr(missPlanePoint - masterFaceCentres[curFace]);
|
||||
|
||||
const labelList& masterNbrs = masterFaceFaces[curFace];
|
||||
@ -532,8 +527,4 @@ projectFaceCentres
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,173 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatchExtra
|
||||
(
|
||||
const FaceList<Face>& faces,
|
||||
const Field<PointType>& points
|
||||
)
|
||||
:
|
||||
ParentType(faces, points),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// Construct as copy
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatchExtra
|
||||
(
|
||||
const PrimitivePatchExtra<Face, FaceList, PointField, PointType>& pp
|
||||
)
|
||||
:
|
||||
ParentType(pp),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
~PrimitivePatchExtra()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
clearOut()
|
||||
{
|
||||
ParentType::clearOut();
|
||||
clearTopology();
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
clearTopology()
|
||||
{
|
||||
ParentType::clearTopology();
|
||||
deleteDemandDrivenData(sortedEdgeFacesPtr_);
|
||||
deleteDemandDrivenData(edgeOwnerPtr_);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
sortedEdgeFaces() const
|
||||
{
|
||||
if (!sortedEdgeFacesPtr_)
|
||||
{
|
||||
calcSortedEdgeFaces();
|
||||
}
|
||||
|
||||
return *sortedEdgeFacesPtr_;
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
edgeOwner() const
|
||||
{
|
||||
if (!edgeOwnerPtr_)
|
||||
{
|
||||
calcEdgeOwner();
|
||||
}
|
||||
|
||||
return *edgeOwnerPtr_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PrimitivePatchExtraAddressing.C"
|
||||
#include "PrimitivePatchExtraCleanup.C"
|
||||
#include "PrimitivePatchExtraSearch.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,205 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::PrimitivePatchExtra
|
||||
|
||||
Description
|
||||
PrimitivePatch with some extra functionality.
|
||||
|
||||
SourceFiles
|
||||
PrimitivePatchExtra.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PrimitivePatchExtra_H
|
||||
#define PrimitivePatchExtra_H
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PrimitivePatchExtra Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType=point
|
||||
>
|
||||
class PrimitivePatchExtra
|
||||
:
|
||||
public PrimitivePatch<Face, FaceList, PointField, PointType>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public typedefs
|
||||
|
||||
typedef Face FaceType;
|
||||
typedef FaceList<Face> FaceListType;
|
||||
typedef PointField PointFieldType;
|
||||
|
||||
private:
|
||||
|
||||
// Private typedefs
|
||||
typedef PrimitivePatch<Face, FaceList, PointField, PointType> ParentType;
|
||||
|
||||
// Private data
|
||||
|
||||
// Demand driven private data
|
||||
|
||||
//- Edge-face addressing (sorted)
|
||||
mutable labelListList* sortedEdgeFacesPtr_;
|
||||
|
||||
//- Label of face that 'owns' edge
|
||||
// i.e. e.vec() is righthanded walk along face
|
||||
mutable labelList* edgeOwnerPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate sorted edgeFaces
|
||||
void calcSortedEdgeFaces() const;
|
||||
|
||||
//- Calculate owner
|
||||
void calcEdgeOwner() const;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
PrimitivePatchExtra
|
||||
(
|
||||
const FaceList<Face>& faces,
|
||||
const Field<PointType>& points
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
PrimitivePatchExtra
|
||||
(
|
||||
const PrimitivePatchExtra<Face, FaceList, PointField, PointType>&
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~PrimitivePatchExtra();
|
||||
|
||||
void clearOut();
|
||||
|
||||
void clearTopology();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access functions for demand driven data
|
||||
|
||||
// Topological data; no mesh required.
|
||||
|
||||
//- Return edge-face addressing sorted by angle around the edge.
|
||||
// Orientation is anticlockwise looking from edge.vec(localPoints())
|
||||
const labelListList& sortedEdgeFaces() const;
|
||||
|
||||
//- If 2 face neighbours: label of face where ordering of edge
|
||||
// is consistent with righthand walk.
|
||||
// If 1 neighbour: label of only face.
|
||||
// If >2 neighbours: undetermined.
|
||||
const labelList& edgeOwner() const;
|
||||
|
||||
|
||||
// Addressing into mesh
|
||||
|
||||
|
||||
// Other patch operations
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Check multiply-connected edges.
|
||||
void checkEdges(const bool verbose) const;
|
||||
|
||||
//- Check orientation (normals) and normals of neighbouring faces
|
||||
boolList checkOrientation(const bool verbose) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Fill faceZone with currentZone for every face reachable
|
||||
// from faceI without crossing edge marked in borderEdge.
|
||||
// Note: faceZone has to be sized nFaces before calling.
|
||||
void markZone
|
||||
(
|
||||
const UList<bool>& borderEdge,
|
||||
const label faceI,
|
||||
const label currentZone,
|
||||
labelList& faceZone
|
||||
) const;
|
||||
|
||||
//- (size and) fills faceZone with zone of face.
|
||||
// Zone is area reachable by edge crossing without crossing borderEdge
|
||||
// (bool for every edge in surface). Returns number of zones.
|
||||
label markZones
|
||||
(
|
||||
const UList<bool>& borderEdge,
|
||||
labelList& faceZone
|
||||
) const;
|
||||
|
||||
//- Determine the mapping for a sub-mesh.
|
||||
// Only include faces for which bool List entry is true
|
||||
// @param[out] pointMap mapping new to old localPoints
|
||||
// @param[out] faceMap mapping new to old faces
|
||||
void subsetMap
|
||||
(
|
||||
const UList<bool>& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "PrimitivePatchExtra.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,218 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Contains fix for PrimitivePatch addressing (which doesn't work if surface
|
||||
is non-manifold). Should be moved into PrimitivePatch.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "HashTable.H"
|
||||
#include "SortableList.H"
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
calcSortedEdgeFaces() const
|
||||
{
|
||||
if (sortedEdgeFacesPtr_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::"
|
||||
"calcSortedEdgeFaces()"
|
||||
)
|
||||
<< "sortedEdgeFacesPtr_ already set"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
const edgeList& edgeLst = this->edges();
|
||||
const Field<PointType>& locPointLst = this->localPoints();
|
||||
const List<Face>& locFaceLst = this->localFaces();
|
||||
|
||||
// create the lists for the various results. (resized on completion)
|
||||
sortedEdgeFacesPtr_ = new labelListList(eFaces.size());
|
||||
labelListList& sortedEdgeFaces = *sortedEdgeFacesPtr_;
|
||||
|
||||
forAll(eFaces, edgeI)
|
||||
{
|
||||
const labelList& myFaceNbs = eFaces[edgeI];
|
||||
|
||||
if (myFaceNbs.size() > 2)
|
||||
{
|
||||
// Get point on edge and normalized direction of edge (= e2 base
|
||||
// of our coordinate system)
|
||||
const edge& e = edgeLst[edgeI];
|
||||
|
||||
const point& edgePt = locPointLst[e.start()];
|
||||
|
||||
vector e2 = e.vec(locPointLst);
|
||||
e2 /= mag(e2) + VSMALL;
|
||||
|
||||
// Get opposite vertex for 0th face
|
||||
const Face& f = locFaceLst[myFaceNbs[0]];
|
||||
|
||||
label fp0 = findIndex(f, e[0]);
|
||||
label fp1 = f.fcIndex(fp0);
|
||||
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
|
||||
|
||||
// Get vector normal both to e2 and to edge from opposite vertex
|
||||
// to edge (will be x-axis of our coordinate system)
|
||||
vector e0 = e2 ^ (locPointLst[vertI] - edgePt);
|
||||
e0 /= mag(e0) + VSMALL;
|
||||
|
||||
// Get y-axis of coordinate system
|
||||
vector e1 = e2 ^ e0;
|
||||
|
||||
SortableList<scalar> faceAngles(myFaceNbs.size());
|
||||
|
||||
// e0 is reference so angle is 0
|
||||
faceAngles[0] = 0;
|
||||
|
||||
for (label nbI = 1; nbI < myFaceNbs.size(); nbI++)
|
||||
{
|
||||
// Get opposite vertex
|
||||
const Face& f = locFaceLst[myFaceNbs[nbI]];
|
||||
label fp0 = findIndex(f, e[0]);
|
||||
label fp1 = f.fcIndex(fp0);
|
||||
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
|
||||
|
||||
vector vec = e2 ^ (locPointLst[vertI] - edgePt);
|
||||
vec /= mag(vec) + VSMALL;
|
||||
|
||||
faceAngles[nbI] = pseudoAngle
|
||||
(
|
||||
e0,
|
||||
e1,
|
||||
vec
|
||||
);
|
||||
}
|
||||
|
||||
faceAngles.sort();
|
||||
|
||||
sortedEdgeFaces[edgeI] = IndirectList<label>
|
||||
(
|
||||
myFaceNbs,
|
||||
faceAngles.indices()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No need to sort. Just copy.
|
||||
sortedEdgeFaces[edgeI] = myFaceNbs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
calcEdgeOwner() const
|
||||
{
|
||||
if (edgeOwnerPtr_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::"
|
||||
"calcEdgeOwner()"
|
||||
)
|
||||
<< "edgeOwnerPtr_ already set"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// create the owner list
|
||||
edgeOwnerPtr_ = new labelList(this->nEdges());
|
||||
labelList& edgeOwner = *edgeOwnerPtr_;
|
||||
|
||||
const edgeList& edgeLst = this->edges();
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
const List<Face>& locFaceLst = this->localFaces();
|
||||
|
||||
|
||||
forAll(edgeLst, edgeI)
|
||||
{
|
||||
const edge& e = edgeLst[edgeI];
|
||||
const labelList& neighbouringFaces = eFaces[edgeI];
|
||||
|
||||
if (neighbouringFaces.size() == 1)
|
||||
{
|
||||
edgeOwner[edgeI] = neighbouringFaces[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the first face whose vertices are aligned with the edge.
|
||||
// with multiply connected edges, this is the best we can do
|
||||
edgeOwner[edgeI] = -1;
|
||||
|
||||
forAll(neighbouringFaces, i)
|
||||
{
|
||||
const Face& f = locFaceLst[neighbouringFaces[i]];
|
||||
|
||||
if (f.edgeDirection(e) > 0)
|
||||
{
|
||||
edgeOwner[edgeI] = neighbouringFaces[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (edgeOwner[edgeI] == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::"
|
||||
"calcEdgeOwner()"
|
||||
)
|
||||
<< "Edge " << edgeI << " vertices:" << e
|
||||
<< " is used by faces " << neighbouringFaces
|
||||
<< " vertices:"
|
||||
<< IndirectList<Face>(locFaceLst, neighbouringFaces)()
|
||||
<< " none of which use the edge vertices in the same order"
|
||||
<< nl << "I give up" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,239 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Check/fix edges with more than two faces
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
checkEdges
|
||||
(
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
const edgeList& edgeLst = this->edges();
|
||||
|
||||
forAll(eFaces, edgeI)
|
||||
{
|
||||
const labelList& myFaces = eFaces[edgeI];
|
||||
|
||||
// boundary edges have one face
|
||||
// interior edges have two faces
|
||||
if (myFaces.empty())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkEdges(bool verbose)"
|
||||
)
|
||||
<< "Edge " << edgeI << " with vertices " << edgeLst[edgeI]
|
||||
<< " has no edgeFaces"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else if (myFaces.size() > 2)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkEdges(bool verbose)"
|
||||
)
|
||||
<< "Edge " << edgeI << " with vertices " << edgeLst[edgeI]
|
||||
<< " has more than 2 faces connected to it : " << myFaces
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check normals and orientation
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
Foam::boolList
|
||||
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
checkOrientation
|
||||
(
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
const FaceList<Face>& faceLst = *this;
|
||||
const edgeList& edgeLst = this->edges();
|
||||
const labelListList& faceEs = this->faceEdges();
|
||||
const label numEdges = this->nEdges();
|
||||
const Field<PointType>& pointLst = this->points();
|
||||
const vectorField& normLst = this->faceNormals();
|
||||
|
||||
if (ParentType::debug)
|
||||
{
|
||||
Info<<"checkOrientation:::checkOrientation(bool)" << endl;
|
||||
}
|
||||
|
||||
// Check edge normals, face normals, point normals.
|
||||
forAll(faceEs, faceI)
|
||||
{
|
||||
const labelList& edgeLabels = faceEs[faceI];
|
||||
|
||||
if (edgeLabels.size() < 3)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkOrientation(bool)"
|
||||
)
|
||||
<< "face " << faceLst[faceI]
|
||||
<< " has fewer than 3 edges. Edges:" << edgeLabels
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
forAll(edgeLabels, i)
|
||||
{
|
||||
if (edgeLabels[i] < 0 || edgeLabels[i] >= numEdges)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkOrientation(bool)"
|
||||
)
|
||||
<< "edge number " << edgeLabels[i] << " on face " << faceI
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means the input surface has "
|
||||
<< "edges with more than 2 faces connected.\n"
|
||||
<< endl;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (!valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//- Compute normal from 3 points, use the first as the origin
|
||||
// minor warpage should not be a problem
|
||||
const Face& f = faceLst[faceI];
|
||||
const point p0(pointLst[f[0]]);
|
||||
const point p1(pointLst[f[1]]);
|
||||
const point p2(pointLst[f[f.size()-1]]);
|
||||
|
||||
const vector pointNormal((p1 - p0) ^ (p2 - p0));
|
||||
if ((pointNormal & normLst[faceI]) < 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkOrientation(bool)"
|
||||
)
|
||||
<< "Normal calculated from points inconsistent with faceNormal"
|
||||
<< nl
|
||||
<< "face: " << f << nl
|
||||
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
|
||||
<< "pointNormal:" << pointNormal << nl
|
||||
<< "faceNormal:" << normLst[faceI]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
const pointField& locPointsLst = this->localPoints();
|
||||
|
||||
// Storage for holding status of edge.
|
||||
// True if normal flips across this edge
|
||||
boolList borderEdge(numEdges, false);
|
||||
|
||||
forAll(edgeLst, edgeI)
|
||||
{
|
||||
const edge& e = edgeLst[edgeI];
|
||||
const labelList& neighbouringFaces = eFaces[edgeI];
|
||||
|
||||
if (neighbouringFaces.size() == 2)
|
||||
{
|
||||
// we use localFaces() since edges() are LOCAL
|
||||
// these are both already available
|
||||
const Face& faceA = this->localFaces()[neighbouringFaces[0]];
|
||||
const Face& faceB = this->localFaces()[neighbouringFaces[1]];
|
||||
|
||||
// If the faces are correctly oriented, the edges must go in
|
||||
// different directions on connected faces.
|
||||
if (faceA.edgeDirection(e) == faceB.edgeDirection(e))
|
||||
{
|
||||
borderEdge[edgeI] = true;
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkOrientation(bool)"
|
||||
)
|
||||
<< "face orientation incorrect." << nl
|
||||
<< "localEdge[" << edgeI << "] " << e
|
||||
<< " between faces:" << nl
|
||||
<< " face[" << neighbouringFaces[0] << "] "
|
||||
<< faceLst[neighbouringFaces[0]]
|
||||
<< " localFace: " << faceA
|
||||
<< nl
|
||||
<< " face[" << neighbouringFaces[1] << "] "
|
||||
<< faceLst[neighbouringFaces[1]]
|
||||
<< " localFace: " << faceB
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (neighbouringFaces.size() != 1)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"PrimitivePatchExtra::checkOrientation(bool)"
|
||||
)
|
||||
<< "Wrong number of edge neighbours." << nl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< " with points:" << locPointsLst[e.start()]
|
||||
<< ' ' << locPointsLst[e.end()]
|
||||
<< " has neighbouringFaces:" << neighbouringFaces << endl;
|
||||
}
|
||||
borderEdge[edgeI] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return borderEdge;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchTools.H"
|
||||
|
||||
#include "PrimitivePatchToolsCheck.C"
|
||||
#include "PrimitivePatchToolsEdgeOwner.C"
|
||||
#include "PrimitivePatchToolsSearch.C"
|
||||
#include "PrimitivePatchToolsSortEdges.C"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,181 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::PrimitivePatchTools
|
||||
|
||||
Description
|
||||
A collect of tools for searching, sort PrimitivePatch information.
|
||||
|
||||
SourceFiles
|
||||
PrimitivePatchTools.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PrimitivePatchTools_H
|
||||
#define PrimitivePatchTools_H
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PatchTools Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PatchTools
|
||||
{
|
||||
public:
|
||||
|
||||
//- Check for orientation issues.
|
||||
// Returns true if problems were found.
|
||||
// If a normal flips across an edge, places it in the HashSet
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static bool checkOrientation
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
||||
const bool report = false,
|
||||
labelHashSet* marked = 0
|
||||
);
|
||||
|
||||
|
||||
//- Fill faceZone with currentZone for every face reachable
|
||||
// from faceI without crossing edge marked in borderEdge.
|
||||
// Note: faceZone has to be sized nFaces before calling.
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static void markZone
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
||||
const BoolListType& borderEdge,
|
||||
const label faceI,
|
||||
const label currentZone,
|
||||
labelList& faceZone
|
||||
);
|
||||
|
||||
//- Size and fills faceZone with zone of face.
|
||||
// Zone is area reachable by edge crossing without crossing borderEdge.
|
||||
// Returns number of zones.
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static label markZones
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
||||
const BoolListType& borderEdge,
|
||||
labelList& faceZone
|
||||
);
|
||||
|
||||
//- Determine the mapping for a sub-patch.
|
||||
// Only include faces for which bool-list entry is true.
|
||||
// @param[in] includeFaces faces to include
|
||||
// @param[out] pointMap mapping new to old localPoints
|
||||
// @param[out] faceMap mapping new to old faces
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static void subsetMap
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
||||
const BoolListType& includeFaces,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
);
|
||||
|
||||
//- Return edge-face addressing sorted by angle around the edge.
|
||||
// Orientation is anticlockwise looking from edge.vec(localPoints())
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static labelListList sortedEdgeFaces
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&
|
||||
);
|
||||
|
||||
|
||||
//- If 2 face neighbours: label of face where ordering of edge
|
||||
// is consistent with righthand walk.
|
||||
// If 1 neighbour: label of only face.
|
||||
// If >2 neighbours: undetermined.
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static labelList edgeOwner
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "PrimitivePatchTools.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
|
||||
bool
|
||||
Foam::PatchTools::checkOrientation
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
)
|
||||
{
|
||||
bool foundError = false;
|
||||
|
||||
// Check edge normals, face normals, point normals.
|
||||
forAll(p.faceEdges(), faceI)
|
||||
{
|
||||
const labelList& edgeLabels = p.faceEdges()[faceI];
|
||||
bool valid = true;
|
||||
|
||||
if (edgeLabels.size() < 3)
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info<< "Face[" << faceI << "] " << p[faceI]
|
||||
<< " has fewer than 3 edges. Edges: " << edgeLabels
|
||||
<< nl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(edgeLabels, i)
|
||||
{
|
||||
if (edgeLabels[i] < 0 || edgeLabels[i] >= p.nEdges())
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info<< "edge number " << edgeLabels[i] << " on face " << faceI
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means the input surface has "
|
||||
<< "edges with more than 2 faces connected." << nl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
foundError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//- Compute normal from 3 points, use the first as the origin
|
||||
// minor warpage should not be a problem
|
||||
const Face& f = p[faceI];
|
||||
const point p0(p.points()[f[0]]);
|
||||
const point p1(p.points()[f[1]]);
|
||||
const point p2(p.points()[f[f.size()-1]]);
|
||||
|
||||
const vector pointNormal((p1 - p0) ^ (p2 - p0));
|
||||
if ((pointNormal & p.faceNormals()[faceI]) < 0)
|
||||
{
|
||||
foundError = false;
|
||||
|
||||
if (report)
|
||||
{
|
||||
Info
|
||||
<< "Normal calculated from points inconsistent with faceNormal"
|
||||
<< nl
|
||||
<< "face: " << f << nl
|
||||
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
|
||||
<< "pointNormal:" << pointNormal << nl
|
||||
<< "faceNormal:" << p.faceNormals()[faceI] << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forAll(p.edges(), edgeI)
|
||||
{
|
||||
const edge& e = p.edges()[edgeI];
|
||||
const labelList& neighbouringFaces = p.edgeFaces()[edgeI];
|
||||
|
||||
if (neighbouringFaces.size() == 2)
|
||||
{
|
||||
// we use localFaces() since edges() are LOCAL
|
||||
// these are both already available
|
||||
const Face& faceA = p.localFaces()[neighbouringFaces[0]];
|
||||
const Face& faceB = p.localFaces()[neighbouringFaces[1]];
|
||||
|
||||
// If the faces are correctly oriented, the edges must go in
|
||||
// different directions on connected faces.
|
||||
if (faceA.edgeDirection(e) == faceB.edgeDirection(e))
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info<< "face orientation incorrect." << nl
|
||||
<< "localEdge[" << edgeI << "] " << e
|
||||
<< " between faces:" << nl
|
||||
<< " face[" << neighbouringFaces[0] << "] "
|
||||
<< p[neighbouringFaces[0]]
|
||||
<< " localFace: " << faceA
|
||||
<< nl
|
||||
<< " face[" << neighbouringFaces[1] << "] "
|
||||
<< p[neighbouringFaces[1]]
|
||||
<< " localFace: " << faceB
|
||||
<< endl;
|
||||
}
|
||||
if (setPtr)
|
||||
{
|
||||
setPtr->insert(edgeI);
|
||||
}
|
||||
|
||||
foundError = true;
|
||||
}
|
||||
}
|
||||
else if (neighbouringFaces.size() != 1)
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info
|
||||
<< "Wrong number of edge neighbours." << nl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< " with points:" << p.localPoints()[e.start()]
|
||||
<< ' ' << p.localPoints()[e.end()]
|
||||
<< " has neighbouringFaces:" << neighbouringFaces << endl;
|
||||
}
|
||||
|
||||
if (setPtr)
|
||||
{
|
||||
setPtr->insert(edgeI);
|
||||
}
|
||||
|
||||
foundError = true;
|
||||
}
|
||||
}
|
||||
|
||||
return foundError;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
|
||||
Foam::labelList
|
||||
Foam::PatchTools::edgeOwner
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
|
||||
)
|
||||
{
|
||||
const edgeList& edges = p.edges();
|
||||
const labelListList& edgeFaces = p.edgeFaces();
|
||||
const List<Face>& localFaces = p.localFaces();
|
||||
|
||||
// create the owner list
|
||||
labelList edgeOwner(edges.size(), -1);
|
||||
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
const labelList& nbrFaces = edgeFaces[edgeI];
|
||||
|
||||
if (nbrFaces.size() == 1)
|
||||
{
|
||||
edgeOwner[edgeI] = nbrFaces[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the first face whose vertices are aligned with the edge.
|
||||
// with multiply connected edges, this is the best we can do
|
||||
forAll(nbrFaces, i)
|
||||
{
|
||||
const Face& f = localFaces[nbrFaces[i]];
|
||||
|
||||
if (f.edgeDirection(edges[edgeI]) > 0)
|
||||
{
|
||||
edgeOwner[edgeI] = nbrFaces[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (edgeOwner[edgeI] == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PatchTools::edgeOwner()"
|
||||
)
|
||||
<< "Edge " << edgeI << " vertices:" << edges[edgeI]
|
||||
<< " is used by faces " << nbrFaces
|
||||
<< " vertices:"
|
||||
<< IndirectList<Face>(localFaces, nbrFaces)()
|
||||
<< " none of which use the edge vertices in the same order"
|
||||
<< nl << "I give up" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return edgeOwner;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -22,35 +22,42 @@ License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Searching and marking zones of the patch.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "PrimitivePatchTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Finds area, starting at faceI, delimited by borderEdge. Marks all visited
|
||||
// faces (from face-edge-face walk) with currentZone.
|
||||
// Finds area, starting at faceI, delimited by borderEdge.
|
||||
// Marks all visited faces (from face-edge-face walk) with currentZone.
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
|
||||
void
|
||||
Foam::PatchTools::markZone
|
||||
(
|
||||
const UList<bool>& borderEdge,
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||
const BoolListType& borderEdge,
|
||||
const label faceI,
|
||||
const label currentZone,
|
||||
labelList& faceZone
|
||||
) const
|
||||
labelList& faceZone
|
||||
)
|
||||
{
|
||||
const labelListList& faceEdges = p.faceEdges();
|
||||
const labelListList& edgeFaces = p.edgeFaces();
|
||||
|
||||
// List of faces whose faceZone has been set.
|
||||
labelList changedFaces(1, faceI);
|
||||
|
||||
const labelListList& faceEs = this->faceEdges();
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Pick up neighbours of changedFaces
|
||||
@ -60,7 +67,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
{
|
||||
label faceI = changedFaces[i];
|
||||
|
||||
const labelList& fEdges = faceEs[faceI];
|
||||
const labelList& fEdges = faceEdges[faceI];
|
||||
|
||||
forAll(fEdges, fEdgeI)
|
||||
{
|
||||
@ -68,7 +75,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
|
||||
if (!borderEdge[edgeI])
|
||||
{
|
||||
const labelList& eFaceLst = eFaces[edgeI];
|
||||
const labelList& eFaceLst = edgeFaces[edgeI];
|
||||
|
||||
forAll(eFaceLst, j)
|
||||
{
|
||||
@ -83,8 +90,8 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::markZone"
|
||||
"(const boolList&, const label, const label, labelList&) const"
|
||||
"PatchTools::markZone"
|
||||
"(const boolList&, const label, const label, labelList&)"
|
||||
)
|
||||
<< "Zones " << faceZone[nbrFaceI]
|
||||
<< " at face " << nbrFaceI
|
||||
@ -112,60 +119,38 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
// Fills faceZone accordingly
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
Foam::label Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
markZones
|
||||
|
||||
Foam::label
|
||||
Foam::PatchTools::markZones
|
||||
(
|
||||
const UList<bool>& borderEdge,
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||
const BoolListType& borderEdge,
|
||||
labelList& faceZone
|
||||
) const
|
||||
)
|
||||
{
|
||||
const label numEdges = this->nEdges();
|
||||
const label numFaces = this->size();
|
||||
|
||||
if (borderEdge.size() != numEdges)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::markZones"
|
||||
"(const boolList&, labelList&)"
|
||||
)
|
||||
<< "borderEdge boolList not same size as number of edges" << endl
|
||||
<< "borderEdge:" << borderEdge.size() << endl
|
||||
<< "nEdges :" << numEdges
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceZone.setSize(numFaces);
|
||||
faceZone.setSize(p.size());
|
||||
faceZone = -1;
|
||||
|
||||
label zoneI = 0;
|
||||
label startFaceI = 0;
|
||||
|
||||
while (true)
|
||||
for (label startFaceI = 0; startFaceI < faceZone.size();)
|
||||
{
|
||||
// Find first non-visited face
|
||||
for (; startFaceI < numFaces; startFaceI++)
|
||||
// Find next non-visited face
|
||||
for (; startFaceI < faceZone.size(); ++startFaceI)
|
||||
{
|
||||
if (faceZone[startFaceI] == -1)
|
||||
{
|
||||
faceZone[startFaceI] = zoneI;
|
||||
markZone(borderEdge, startFaceI, zoneI, faceZone);
|
||||
markZone(p, borderEdge, startFaceI, zoneI, faceZone);
|
||||
zoneI++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (startFaceI >= numFaces)
|
||||
{
|
||||
// Finished
|
||||
break;
|
||||
}
|
||||
|
||||
zoneI++;
|
||||
}
|
||||
|
||||
return zoneI;
|
||||
@ -177,46 +162,48 @@ markZones
|
||||
// Fills faceZone accordingly
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
|
||||
subsetMap
|
||||
|
||||
void
|
||||
Foam::PatchTools::subsetMap
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||
const BoolListType& includeFaces,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
)
|
||||
{
|
||||
const List<Face>& locFaces = this->localFaces();
|
||||
const label numPoints = this->nPoints();
|
||||
|
||||
label faceI = 0;
|
||||
label faceI = 0;
|
||||
label pointI = 0;
|
||||
|
||||
faceMap.setSize(locFaces.size());
|
||||
pointMap.setSize(numPoints);
|
||||
const List<Face>& localFaces = p.localFaces();
|
||||
|
||||
boolList pointHad(numPoints, false);
|
||||
faceMap.setSize(localFaces.size());
|
||||
pointMap.setSize(p.nPoints());
|
||||
|
||||
forAll(include, oldFaceI)
|
||||
boolList pointHad(pointMap.size(), false);
|
||||
|
||||
forAll(p, oldFaceI)
|
||||
{
|
||||
if (include[oldFaceI])
|
||||
if (includeFaces[oldFaceI])
|
||||
{
|
||||
// Store new faces compact
|
||||
faceMap[faceI++] = oldFaceI;
|
||||
|
||||
// Renumber labels for face
|
||||
const Face& f = locFaces[oldFaceI];
|
||||
const Face& f = localFaces[oldFaceI];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
const label ptLabel = f[fp];
|
||||
if (!pointHad[ptLabel])
|
||||
{
|
||||
pointHad[ptLabel] = true;
|
||||
pointHad[ptLabel] = true;
|
||||
pointMap[pointI++] = ptLabel;
|
||||
}
|
||||
}
|
||||
@ -229,6 +216,4 @@ subsetMap
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PrimitivePatchTools.H"
|
||||
#include "SortableList.H"
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
|
||||
Foam::labelListList
|
||||
Foam::PatchTools::sortedEdgeFaces
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
|
||||
)
|
||||
{
|
||||
const edgeList& edges = p.edges();
|
||||
const labelListList& edgeFaces = p.edgeFaces();
|
||||
const List<Face>& localFaces = p.localFaces();
|
||||
const Field<PointType>& localPoints = p.localPoints();
|
||||
|
||||
// create the lists for the various results. (resized on completion)
|
||||
labelListList& sortedEdgeFaces = labelListList(edgeFaces.size());
|
||||
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const labelList& faceNbs = edgeFaces[edgeI];
|
||||
|
||||
if (faceNbs.size() > 2)
|
||||
{
|
||||
// Get point on edge and normalized direction of edge (= e2 base
|
||||
// of our coordinate system)
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
const point& edgePt = localPoints[e.start()];
|
||||
|
||||
vector e2 = e.vec(localPoints);
|
||||
e2 /= mag(e2) + VSMALL;
|
||||
|
||||
// Get opposite vertex for 0th face
|
||||
const Face& f = localFaces[faceNbs[0]];
|
||||
|
||||
label fp0 = findIndex(f, e[0]);
|
||||
label fp1 = f.fcIndex(fp0);
|
||||
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
|
||||
|
||||
// Get vector normal both to e2 and to edge from opposite vertex
|
||||
// to edge (will be x-axis of our coordinate system)
|
||||
vector e0 = e2 ^ (localPoints[vertI] - edgePt);
|
||||
e0 /= mag(e0) + VSMALL;
|
||||
|
||||
// Get y-axis of coordinate system
|
||||
vector e1 = e2 ^ e0;
|
||||
|
||||
SortableList<scalar> faceAngles(faceNbs.size());
|
||||
|
||||
// e0 is reference so angle is 0
|
||||
faceAngles[0] = 0;
|
||||
|
||||
for (label nbI = 1; nbI < faceNbs.size(); nbI++)
|
||||
{
|
||||
// Get opposite vertex
|
||||
const Face& f = localFaces[faceNbs[nbI]];
|
||||
label fp0 = findIndex(f, e[0]);
|
||||
label fp1 = f.fcIndex(fp0);
|
||||
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
|
||||
|
||||
vector vec = e2 ^ (localPoints[vertI] - edgePt);
|
||||
vec /= mag(vec) + VSMALL;
|
||||
|
||||
faceAngles[nbI] = pseudoAngle
|
||||
(
|
||||
e0,
|
||||
e1,
|
||||
vec
|
||||
);
|
||||
}
|
||||
|
||||
faceAngles.sort();
|
||||
|
||||
sortedEdgeFaces[edgeI] = IndirectList<label>
|
||||
(
|
||||
faceNbs,
|
||||
faceAngles.indices()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No need to sort. Just copy.
|
||||
sortedEdgeFaces[edgeI] = faceNbs;
|
||||
}
|
||||
}
|
||||
|
||||
return sortedEdgeFaces;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "boundBox.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -162,7 +163,7 @@ void Foam::BasicMeshedSurface<Face>::cleanup(const bool verbose)
|
||||
stitchFaces(SMALL, verbose);
|
||||
|
||||
checkFaces(verbose);
|
||||
this->checkEdges(verbose);
|
||||
this->checkTopology(verbose);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,7 +36,8 @@ SourceFiles
|
||||
#ifndef BasicMeshedSurface_H
|
||||
#define BasicMeshedSurface_H
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "PrimitivePatch.H"
|
||||
#include "PrimitivePatchTools.H"
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
@ -55,11 +56,11 @@ namespace Foam
|
||||
template<class Face>
|
||||
class BasicMeshedSurface
|
||||
:
|
||||
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>
|
||||
public PrimitivePatch<Face, ::Foam::List, pointField, point>
|
||||
{
|
||||
|
||||
//- Typedefs for convenience
|
||||
typedef PrimitivePatchExtra
|
||||
typedef PrimitivePatch
|
||||
<
|
||||
Face,
|
||||
::Foam::List,
|
||||
@ -83,7 +84,7 @@ protected:
|
||||
return static_cast<List<Face> &>(*this);
|
||||
}
|
||||
|
||||
//- Set new regions/patches from faceMap
|
||||
//- Set new regions from faceMap
|
||||
virtual void remapFaces(const UList<label>& faceMap);
|
||||
|
||||
public:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
surfGroup/surfGroup.C
|
||||
surfGroup/surfGroupIOList.C
|
||||
surfPatchIdentifier/surfPatchIdentifier.C
|
||||
surfRegion/surfRegion/surfRegion.C
|
||||
surfRegion/surfRegion/surfRegionIOList.C
|
||||
surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
|
||||
|
||||
MeshedSurface/MeshedSurfaces.C
|
||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "PrimitivePatchTools.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
@ -166,11 +167,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const Xfer<surfGroupList>& patchLst
|
||||
const Xfer<surfRegionList>& regionLst
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst),
|
||||
patches_(patchLst)
|
||||
regions_(regionLst)
|
||||
{}
|
||||
|
||||
|
||||
@ -179,26 +180,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames
|
||||
const UList<label>& regionSizes,
|
||||
const UList<word>& regionNames
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst)
|
||||
{
|
||||
if (&patchSizes)
|
||||
if (®ionSizes)
|
||||
{
|
||||
if (&patchNames)
|
||||
if (®ionNames)
|
||||
{
|
||||
addPatches(patchSizes, patchNames);
|
||||
addRegions(regionSizes, regionNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
addPatches(patchSizes);
|
||||
addRegions(regionSizes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,15 +239,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
);
|
||||
|
||||
|
||||
// create patch list
|
||||
surfGroupList newPatches(bPatches.size());
|
||||
// create region list
|
||||
surfRegionList newRegions(bPatches.size());
|
||||
|
||||
label startFaceI = 0;
|
||||
forAll(bPatches, patchI)
|
||||
{
|
||||
const polyPatch& p = bPatches[patchI];
|
||||
|
||||
newPatches[patchI] = surfGroup
|
||||
newRegions[patchI] = surfRegion
|
||||
(
|
||||
p.name(),
|
||||
p.size(),
|
||||
@ -262,7 +263,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
xferCopy(bPoints),
|
||||
xferCopy(bFaces),
|
||||
xferMove(newPatches)
|
||||
xferMove(newRegions)
|
||||
);
|
||||
|
||||
|
||||
@ -285,7 +286,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
origFaces.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
patches_.transfer(surf.patches_);
|
||||
regions_.transfer(surf.regions_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -305,15 +306,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
{
|
||||
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
||||
|
||||
// create patch list
|
||||
List<surfGroup> newPatches(sPatches.size());
|
||||
// create regions list
|
||||
List<surfRegion> newRegions(sPatches.size());
|
||||
|
||||
label startFaceI = 0;
|
||||
forAll(sPatches, patchI)
|
||||
{
|
||||
const surfPatch& p = sPatches[patchI];
|
||||
|
||||
newPatches[patchI] = surfGroup
|
||||
newRegions[patchI] = surfRegion
|
||||
(
|
||||
p.name(),
|
||||
p.size(),
|
||||
@ -324,7 +325,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
startFaceI += p.size();
|
||||
}
|
||||
|
||||
patches_.transfer(newPatches);
|
||||
regions_.transfer(newRegions);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -336,8 +337,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
)
|
||||
{
|
||||
labelList faceMap;
|
||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(patchLst);
|
||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
||||
regions_.transfer(regionLst);
|
||||
|
||||
const List<Face>& origFaces = surf.faces();
|
||||
List<Face> newFaces(origFaces.size());
|
||||
@ -388,7 +389,7 @@ template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
|
||||
:
|
||||
ParentType(surf),
|
||||
patches_(surf.patches_)
|
||||
regions_(surf.regions_)
|
||||
{}
|
||||
|
||||
|
||||
@ -420,70 +421,70 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::onePatch(const word& name)
|
||||
void Foam::MeshedSurface<Face>::oneRegion(const word& name)
|
||||
{
|
||||
word patchName(name);
|
||||
if (patchName.empty())
|
||||
word regionName(name);
|
||||
if (regionName.empty())
|
||||
{
|
||||
if (patches_.size())
|
||||
if (regions_.size())
|
||||
{
|
||||
patchName = patches_[0].name();
|
||||
regionName = regions_[0].name();
|
||||
}
|
||||
if (patchName.empty())
|
||||
if (regionName.empty())
|
||||
{
|
||||
patchName = "patch0";
|
||||
regionName = "region0";
|
||||
}
|
||||
}
|
||||
|
||||
// set single default patch
|
||||
patches_.setSize(1);
|
||||
patches_[0] = surfGroup
|
||||
// set single default region
|
||||
regions_.setSize(1);
|
||||
regions_[0] = surfRegion
|
||||
(
|
||||
patchName,
|
||||
size(), // patch size
|
||||
0, // patch start
|
||||
0 // patch index
|
||||
regionName,
|
||||
size(), // region size
|
||||
0, // region start
|
||||
0 // region index
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::checkPatches()
|
||||
void Foam::MeshedSurface<Face>::checkRegions()
|
||||
{
|
||||
// extra safety, ensure we have at some patches,
|
||||
// extra safety, ensure we have at some regions
|
||||
// and they cover all the faces - fix start silently
|
||||
if (patches_.size() <= 1)
|
||||
if (regions_.size() <= 1)
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
else
|
||||
{
|
||||
label count = 0;
|
||||
forAll(patches_, patchI)
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
patches_[patchI].start() = count;
|
||||
count += patches_[patchI].size();
|
||||
regions_[regionI].start() = count;
|
||||
count += regions_[regionI].size();
|
||||
}
|
||||
|
||||
if (count < size())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkRegions()\n"
|
||||
)
|
||||
<< "more face " << size() << " than patches " << count
|
||||
<< " ... extending final patch"
|
||||
<< "more face " << size() << " than regions " << count
|
||||
<< " ... extending final region"
|
||||
<< endl;
|
||||
|
||||
patches_[patches_.size()-1].size() += count - size();
|
||||
regions_[regions_.size()-1].size() += count - size();
|
||||
}
|
||||
else if (count > size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkRegions()\n"
|
||||
)
|
||||
<< "more patches " << count << " than faces " << size()
|
||||
<< "more regions " << count << " than faces " << size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -534,33 +535,33 @@ void Foam::MeshedSurface<Face>::remapFaces
|
||||
const UList<label>& faceMap
|
||||
)
|
||||
{
|
||||
// recalculate the patch start/size
|
||||
// recalculate the region start/size
|
||||
if (&faceMap && faceMap.size())
|
||||
{
|
||||
if (patches_.empty())
|
||||
if (regions_.empty())
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
else if (patches_.size() == 1)
|
||||
else if (regions_.size() == 1)
|
||||
{
|
||||
// optimized for one-patch case
|
||||
patches_[0].size() = faceMap.size();
|
||||
// optimized for single region case
|
||||
regions_[0].size() = faceMap.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
label newFaceI = 0;
|
||||
label oldPatchEnd = 0;
|
||||
forAll(patches_, patchI)
|
||||
label origEndI = 0;
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
surfGroup& p = patches_[patchI];
|
||||
surfRegion& reg = regions_[regionI];
|
||||
|
||||
// adjust patch start
|
||||
p.start() = newFaceI;
|
||||
oldPatchEnd += p.size();
|
||||
// adjust region start
|
||||
reg.start() = newFaceI;
|
||||
origEndI += reg.size();
|
||||
|
||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||
{
|
||||
if (faceMap[faceI] < oldPatchEnd)
|
||||
if (faceMap[faceI] < origEndI)
|
||||
{
|
||||
++newFaceI;
|
||||
}
|
||||
@ -570,8 +571,8 @@ void Foam::MeshedSurface<Face>::remapFaces
|
||||
}
|
||||
}
|
||||
|
||||
// adjust patch size
|
||||
p.size() = newFaceI - p.start();
|
||||
// adjust region size
|
||||
reg.size() = newFaceI - reg.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -586,14 +587,14 @@ template<class Face>
|
||||
void Foam::MeshedSurface<Face>::clear()
|
||||
{
|
||||
ParentType::clear();
|
||||
patches_.clear();
|
||||
regions_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
@ -603,7 +604,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
this->subsetMap(include, pointMap, faceMap);
|
||||
PatchTools::subsetMap(*this, include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -614,11 +615,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
oldToNew[pointMap[pointI]] = pointI;
|
||||
}
|
||||
|
||||
// create/copy a new patch list, each patch with zero size
|
||||
surfGroupList newPatches(patches_);
|
||||
forAll(newPatches, patchI)
|
||||
// create/copy a new region list, each region with zero size
|
||||
surfRegionList newRegions(regions_);
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI].size() = 0;
|
||||
newRegions[regionI].size() = 0;
|
||||
}
|
||||
|
||||
// Renumber face node labels
|
||||
@ -637,22 +638,22 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
}
|
||||
oldToNew.clear();
|
||||
|
||||
// recalculate the patch start/size
|
||||
// recalculate the region start/size
|
||||
label newFaceI = 0;
|
||||
label oldPatchEnd = 0;
|
||||
label origEndI = 0;
|
||||
|
||||
// adjust patch sizes
|
||||
forAll(newPatches, patchI)
|
||||
// adjust region sizes
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
surfGroup& p = newPatches[patchI];
|
||||
surfRegion& reg = newRegions[regionI];
|
||||
|
||||
// adjust patch start
|
||||
p.start() = newFaceI;
|
||||
oldPatchEnd += p.size();
|
||||
// adjust region start
|
||||
reg.start() = newFaceI;
|
||||
origEndI += reg.size();
|
||||
|
||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||
{
|
||||
if (faceMap[faceI] < oldPatchEnd)
|
||||
if (faceMap[faceI] < origEndI)
|
||||
{
|
||||
++newFaceI;
|
||||
}
|
||||
@ -662,8 +663,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
}
|
||||
}
|
||||
|
||||
// adjust patch size
|
||||
p.size() = newFaceI - p.start();
|
||||
// adjust region size
|
||||
reg.size() = newFaceI - reg.start();
|
||||
}
|
||||
|
||||
|
||||
@ -672,15 +673,16 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
xferMove(newPatches)
|
||||
xferMove(newRegions)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
Foam::MeshedSurface<Face>
|
||||
Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const
|
||||
{
|
||||
labelList pointMap, faceMap;
|
||||
@ -689,85 +691,85 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<surfGroup>& patches,
|
||||
const UList<surfRegion>& regions,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label nPatch = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(patches.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(regions.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (patches[patchI].size() || !cullEmpty)
|
||||
if (regions[regionI].size() || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup(patches[patchI], nPatch);
|
||||
nPatch++;
|
||||
regions_[nRegion] = surfRegion(regions[regionI], nRegion);
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label nPatch = 0;
|
||||
label start = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(sizes.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(sizes.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (sizes[patchI] || !cullEmpty)
|
||||
if (sizes[regionI] || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup
|
||||
regions_[nRegion] = surfRegion
|
||||
(
|
||||
names[patchI],
|
||||
sizes[patchI],
|
||||
names[regionI],
|
||||
sizes[regionI],
|
||||
start,
|
||||
nPatch
|
||||
nRegion
|
||||
);
|
||||
start += sizes[patchI];
|
||||
nPatch++;
|
||||
start += sizes[regionI];
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label nPatch = 0;
|
||||
label start = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(sizes.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(sizes.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (sizes[patchI] || !cullEmpty)
|
||||
if (sizes[regionI] || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup
|
||||
regions_[nRegion] = surfRegion
|
||||
(
|
||||
word("patch") + ::Foam::name(nPatch),
|
||||
sizes[patchI],
|
||||
word("region") + ::Foam::name(nRegion),
|
||||
sizes[regionI],
|
||||
start,
|
||||
nPatch
|
||||
nRegion
|
||||
);
|
||||
start += sizes[patchI];
|
||||
nPatch++;
|
||||
start += sizes[regionI];
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
@ -778,7 +780,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
)
|
||||
{
|
||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||
patches_.transfer(surf.patches_);
|
||||
regions_.transfer(surf.regions_);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -793,7 +795,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
clear();
|
||||
|
||||
labelList faceMap;
|
||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
||||
List<Face>& oldFaces = surf.storedFaces();
|
||||
|
||||
List<Face> newFaces(faceMap.size());
|
||||
@ -804,7 +806,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
faceMap.clear();
|
||||
|
||||
reset(xferMove(surf.storedPoints()), xferMove(newFaces));
|
||||
patches_.transfer(patchLst);
|
||||
regions_.transfer(regionLst);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -864,7 +866,7 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
|
||||
|
||||
this->storedPoints() = surf.points();
|
||||
this->storedFaces() = surf.faces();
|
||||
patches_ = surf.patches_;
|
||||
regions_ = surf.regions_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,13 +26,13 @@ Class
|
||||
Foam::MeshedSurface
|
||||
|
||||
Description
|
||||
A surface geometry mesh with patch information, not to be confused
|
||||
A surface geometry mesh with region information, not to be confused
|
||||
with a similarily named surfaceMesh, which actually refers to
|
||||
the cell faces of a volume mesh.
|
||||
|
||||
The MeshedSurface is intended to surfaces from a variety of sources.
|
||||
- A set of points and faces without any patch information.
|
||||
- A set of points and faces with randomly sorted patch information.
|
||||
- A set of points and faces without any region information.
|
||||
- A set of points and faces with randomly sorted region information.
|
||||
This could arise, for example, from reading external file formats
|
||||
such as STL, etc.
|
||||
|
||||
@ -45,7 +45,7 @@ SourceFiles
|
||||
#define MeshedSurface_H
|
||||
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
@ -88,9 +88,9 @@ private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- Patch information (face ordering nFaces/startFace only used
|
||||
// during reading and writing)
|
||||
List<surfGroup> patches_;
|
||||
//- Region information
|
||||
// (face ordering nFaces/startFace only used during reading/writing)
|
||||
List<surfRegion> regions_;
|
||||
|
||||
// Private member functions
|
||||
|
||||
@ -101,8 +101,8 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- basic sanity check on patches
|
||||
void checkPatches();
|
||||
//- basic sanity check on regions
|
||||
void checkRegions();
|
||||
|
||||
//- sort faces by regions and store sorted faces
|
||||
void sortFacesAndStore
|
||||
@ -139,22 +139,22 @@ public:
|
||||
//- Construct null
|
||||
MeshedSurface();
|
||||
|
||||
//- Construct by transferring components (points, faces, patches).
|
||||
//- Construct by transferring components (points, faces, regions).
|
||||
MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const Xfer<surfGroupList>&
|
||||
const Xfer<surfRegionList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Use patch information, or set single default patch.
|
||||
// Use region information, or set single default region.
|
||||
MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const UList<label>& patchSizes = UList<label>::null(),
|
||||
const UList<word>& patchNames = UList<word>::null()
|
||||
const UList<label>& regionSizes = UList<label>::null(),
|
||||
const UList<word>& regionNames = UList<word>::null()
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
@ -250,31 +250,31 @@ public:
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
const List<surfGroup>& patches() const
|
||||
const List<surfRegion>& regions() const
|
||||
{
|
||||
return patches_;
|
||||
return regions_;
|
||||
}
|
||||
|
||||
//- set a single patch, optionally with a specific name
|
||||
void onePatch(const word& name = word::null);
|
||||
//- set a single region, optionally with a specific name
|
||||
void oneRegion(const word& name = word::null);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<surfGroup>&,
|
||||
const UList<surfRegion>&,
|
||||
const bool cullEmpty=false
|
||||
);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names,
|
||||
const bool cullEmpty=false
|
||||
);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const bool cullEmpty=false
|
||||
@ -289,7 +289,7 @@ public:
|
||||
// Returns return pointMap, faceMap from subsetMeshMap
|
||||
MeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const;
|
||||
@ -297,7 +297,7 @@ public:
|
||||
//- Return new surface.
|
||||
MeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const;
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
|
||||
@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
||||
{
|
||||
clear();
|
||||
|
||||
List<surfGroup> patchLst(is);
|
||||
List<surfRegion> regionLst(is);
|
||||
|
||||
// copy and set the indices
|
||||
patches_.setSize(patchLst.size());
|
||||
forAll(patchLst, patchI)
|
||||
regions_.setSize(regionLst.size());
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
patches_[patchI] = surfGroup
|
||||
regions_[regionI] = surfRegion
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
regionLst[regionI],
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
||||
Xfer<pointField>::null(),
|
||||
faceLst.xfer()
|
||||
);
|
||||
surf.addPatches(patches_);
|
||||
surf.addRegions(regions_);
|
||||
|
||||
// this will break if the triangulation needed points
|
||||
surf.triangulate();
|
||||
patches_ = surf.patches();
|
||||
regions_ = surf.regions();
|
||||
|
||||
// transcribe from face -> triFace (Face)
|
||||
const List<face>& origFaces = surf.faces();
|
||||
@ -102,11 +102,11 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
|
||||
os << "// OpenFOAM Surface Format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
<< regions_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patches_, patchI)
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
patches_[patchI].writeDict(os);
|
||||
regions_[regionI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "PrimitivePatchTools.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
@ -164,12 +165,12 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const Xfer<List<label> >& regionIds,
|
||||
const Xfer<surfPatchIdentifierList>& patchLst
|
||||
const Xfer<surfRegionIdentifierList>& regionTofc
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst),
|
||||
regions_(regionIds),
|
||||
patches_(patchLst)
|
||||
regionIds_(regionIds),
|
||||
regionToc_(regionTofc)
|
||||
{}
|
||||
|
||||
|
||||
@ -178,26 +179,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames
|
||||
const UList<label>& regionSizes,
|
||||
const UList<word>& regionNames
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst)
|
||||
{
|
||||
if (&patchSizes)
|
||||
if (®ionSizes)
|
||||
{
|
||||
if (&patchNames)
|
||||
if (®ionNames)
|
||||
{
|
||||
setPatches(patchSizes, patchNames);
|
||||
setRegions(regionSizes, regionNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
setPatches(patchSizes);
|
||||
setRegions(regionSizes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +224,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
:
|
||||
ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
|
||||
{
|
||||
setPatches(surf.patches());
|
||||
setRegions(surf.regions());
|
||||
}
|
||||
|
||||
|
||||
@ -266,8 +267,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
)
|
||||
:
|
||||
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
|
||||
regions_(surf.regions_),
|
||||
patches_(surf.patches_)
|
||||
regionIds_(surf.regionIds_),
|
||||
regionToc_(surf.regionToc_)
|
||||
{}
|
||||
|
||||
|
||||
@ -296,101 +297,105 @@ template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::onePatch(const word& name)
|
||||
void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
regions_ = 0;
|
||||
regionIds_.setSize(size());
|
||||
regionIds_ = 0;
|
||||
|
||||
word patchName(name);
|
||||
if (patchName.empty())
|
||||
word regionName(name);
|
||||
if (regionName.empty())
|
||||
{
|
||||
if (patches_.size())
|
||||
if (regionToc_.size())
|
||||
{
|
||||
patchName = patches_[0].name();
|
||||
regionName = regionToc_[0].name();
|
||||
}
|
||||
if (patchName.empty())
|
||||
if (regionName.empty())
|
||||
{
|
||||
patchName = "patch0";
|
||||
regionName = "region0";
|
||||
}
|
||||
}
|
||||
|
||||
// set single default patch
|
||||
patches_.setSize(1);
|
||||
patches_[0] = surfPatchIdentifier(patchName, 0);
|
||||
// set single default region
|
||||
regionToc_.setSize(1);
|
||||
regionToc_[0] = surfRegionIdentifier(regionName, 0);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const surfGroupList& patches
|
||||
const surfRegionList& regionLst
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(patches.size());
|
||||
regionIds_.setSize(size());
|
||||
regionToc_.setSize(regionLst.size());
|
||||
|
||||
forAll(patches, patchI)
|
||||
forAll(regionToc_, regionI)
|
||||
{
|
||||
const surfGroup& p = patches[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
patches_[patchI] = p;
|
||||
regionToc_[regionI] = reg;
|
||||
|
||||
SubList<label> subRegion(regions_, p.size(), p.start());
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
SubList<label> subRegion(regionIds_, reg.size(), reg.start());
|
||||
subRegion = regionI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(sizes.size());
|
||||
regionIds_.setSize(size());
|
||||
regionToc_.setSize(sizes.size());
|
||||
|
||||
label start = 0;
|
||||
forAll(patches_, patchI)
|
||||
forAll(regionToc_, regionI)
|
||||
{
|
||||
patches_[patchI] = surfPatchIdentifier(names[patchI], patchI);
|
||||
regionToc_[regionI] = surfRegionIdentifier(names[regionI], regionI);
|
||||
|
||||
SubList<label> subRegion(regions_, sizes[patchI], start);
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
SubList<label> subRegion(regionIds_, sizes[regionI], start);
|
||||
subRegion = regionI;
|
||||
|
||||
start += sizes[patchI];
|
||||
start += sizes[regionI];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const UList<label>& sizes
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(sizes.size());
|
||||
regionIds_.setSize(size());
|
||||
regionToc_.setSize(sizes.size());
|
||||
|
||||
label start = 0;
|
||||
forAll(patches_, patchI)
|
||||
forAll(regionToc_, regionI)
|
||||
{
|
||||
patches_[patchI] = surfPatchIdentifier
|
||||
regionToc_[regionI] = surfRegionIdentifier
|
||||
(
|
||||
word("patch") + ::Foam::name(patchI),
|
||||
patchI
|
||||
word("region") + ::Foam::name(regionI),
|
||||
regionI
|
||||
);
|
||||
|
||||
SubList<label> subRegion(regions_, sizes[patchI], start);
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
SubList<label> subRegion(regionIds_, sizes[regionI], start);
|
||||
subRegion = regionI;
|
||||
|
||||
start += sizes[patchI];
|
||||
start += sizes[regionI];
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,14 +409,14 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
|
||||
// re-assign the region Ids
|
||||
if (&faceMap && faceMap.size())
|
||||
{
|
||||
if (patches_.empty())
|
||||
if (regionToc_.empty())
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
else if (patches_.size() == 1)
|
||||
else if (regionToc_.size() == 1)
|
||||
{
|
||||
// optimized for one-patch case
|
||||
regions_ = 0;
|
||||
// optimized for single-region case
|
||||
regionIds_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -419,9 +424,9 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
|
||||
|
||||
forAll(faceMap, faceI)
|
||||
{
|
||||
newRegions[faceI] = regions_[faceMap[faceI]];
|
||||
newRegions[faceI] = regionIds_[faceMap[faceI]];
|
||||
}
|
||||
regions_.transfer(newRegions);
|
||||
regionIds_.transfer(newRegions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -433,8 +438,8 @@ template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
|
||||
{
|
||||
ParentType::setSize(s);
|
||||
// if regions extend: set with last patchId
|
||||
regions_.setSize(s, patches_.size() - 1);
|
||||
// if regions extend: set with last regionId
|
||||
regionIds_.setSize(s, regionToc_.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
@ -442,32 +447,32 @@ template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::clear()
|
||||
{
|
||||
ParentType::clear();
|
||||
regions_.clear();
|
||||
patches_.clear();
|
||||
regionIds_.clear();
|
||||
regionToc_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
(
|
||||
labelList& faceMap
|
||||
) const
|
||||
{
|
||||
// supply some patch names
|
||||
Map<word> patchNames;
|
||||
forAll(patches_, patchI)
|
||||
// supply some region names
|
||||
Map<word> regionNames;
|
||||
forAll(regionToc_, regionI)
|
||||
{
|
||||
patchNames.insert(patchI, patches_[patchI].name());
|
||||
regionNames.insert(regionI, regionToc_[regionI].name());
|
||||
}
|
||||
|
||||
return sortedPatchRegions(regions_, patchNames, faceMap);
|
||||
return sortedRegionsById(regionIds_, regionNames, faceMap);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
@ -476,7 +481,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
const List<Face>& locFaces = this->localFaces();
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
this->subsetMap(include, pointMap, faceMap);
|
||||
PatchTools::subsetMap(*this, include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -503,7 +508,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
f[fp] = oldToNew[f[fp]];
|
||||
}
|
||||
|
||||
newRegions[faceI] = regions_[origFaceI];
|
||||
newRegions[faceI] = regionIds_[origFaceI];
|
||||
}
|
||||
oldToNew.clear();
|
||||
|
||||
@ -513,7 +518,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
xferMove(newRegions),
|
||||
xferCopy(patches_)
|
||||
xferCopy(regionToc_)
|
||||
);
|
||||
}
|
||||
|
||||
@ -521,7 +526,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const
|
||||
{
|
||||
labelList pointMap, faceMap;
|
||||
@ -541,7 +546,7 @@ void Foam::UnsortedMeshedSurface<Face>::reset
|
||||
|
||||
if (®ionIds)
|
||||
{
|
||||
regions_.transfer(regionIds());
|
||||
regionIds_.transfer(regionIds());
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,9 +561,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
(
|
||||
xferMove(surf.storedPoints()),
|
||||
xferMove(surf.storedFaces()),
|
||||
xferMove(surf.regions_)
|
||||
xferMove(surf.regionIds_)
|
||||
);
|
||||
patches_.transfer(surf.patches_);
|
||||
regionToc_.transfer(surf.regionToc_);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -571,7 +576,7 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
)
|
||||
{
|
||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||
setPatches(surf.patches());
|
||||
setRegions(surf.regions());
|
||||
surf.clear();
|
||||
}
|
||||
|
||||
@ -634,8 +639,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
|
||||
|
||||
this->storedPoints() = surf.points();
|
||||
this->storedFaces() = surf.faces();
|
||||
regions_ = surf.regions_;
|
||||
patches_ = surf.patches_;
|
||||
regionIds_ = surf.regionIds_;
|
||||
regionToc_ = surf.regionToc_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,18 +26,18 @@ Class
|
||||
Foam::UnsortedMeshedSurface
|
||||
|
||||
Description
|
||||
A surface geometry mesh, in which the patch information is conveyed by
|
||||
the 'region' associated with each face.
|
||||
A surface geometry mesh, in which the region information is conveyed by
|
||||
the 'regionId' associated with each face.
|
||||
|
||||
This form of surface description is particularly useful for reading in
|
||||
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
|
||||
can also be particularly useful for situations in which the surface
|
||||
many be adjusted in an arbitrary manner without worrying about needed
|
||||
to adjust the patch information (eg, surface refinement).
|
||||
to adjust the region information (eg, surface refinement).
|
||||
|
||||
See Also
|
||||
The Foam::meshedSurface - which is organized as a surface mesh, but
|
||||
with independent patch information.
|
||||
The Foam::MeshedSurface - which is organized as a surface mesh, but
|
||||
with independent region information.
|
||||
|
||||
SourceFiles
|
||||
UnsortedMeshedSurface.C
|
||||
@ -48,8 +48,8 @@ SourceFiles
|
||||
#define UnsortedMeshedSurface_H
|
||||
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "surfPatchIdentifierList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
@ -70,7 +70,7 @@ template<class Face> class MeshedSurface;
|
||||
class polyBoundaryMesh;
|
||||
|
||||
template<class Face>
|
||||
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -93,12 +93,12 @@ private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- The regions associated with the faces
|
||||
labelList regions_;
|
||||
//- The region Ids associated with the faces
|
||||
labelList regionIds_;
|
||||
|
||||
//- Patch information (face ordering nFaces/startFace only used
|
||||
//- Region information (face ordering nFaces/startFace only used
|
||||
// during reading and writing)
|
||||
List<surfPatchIdentifier> patches_;
|
||||
List<surfRegionIdentifier> regionToc_;
|
||||
|
||||
// Private member functions
|
||||
|
||||
@ -115,16 +115,16 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- Return non-const access to the faces
|
||||
List<label>& storedRegions()
|
||||
//- Return non-const access to the region Ids
|
||||
List<label>& storedRegionIds()
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the patches
|
||||
List<surfPatchIdentifier>& storedPatches()
|
||||
//- Return non-const access to the region table-of-contents
|
||||
List<surfRegionIdentifier>& storedRegionToc()
|
||||
{
|
||||
return patches_;
|
||||
return regionToc_;
|
||||
}
|
||||
|
||||
//- Set new regions from faceMap
|
||||
@ -155,23 +155,23 @@ public:
|
||||
UnsortedMeshedSurface();
|
||||
|
||||
//- Construct by transferring components
|
||||
// (points, faces, region ids, patches).
|
||||
// (points, faces, region ids, region info).
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const Xfer<List<label> >& regionIds,
|
||||
const Xfer<surfPatchIdentifierList>&
|
||||
const Xfer<surfRegionIdentifierList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Use patch information, or set single default patch
|
||||
// Use region information, or set single default region
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const UList<label>& patchSizes = UList<label>::null(),
|
||||
const UList<word>& patchNames = UList<word>::null()
|
||||
const UList<label>& regionSizes = UList<label>::null(),
|
||||
const UList<word>& regionNames = UList<word>::null()
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
@ -267,34 +267,34 @@ public:
|
||||
//- Reset size of face and region list
|
||||
void setSize(const label);
|
||||
|
||||
//- Return const access to the regions
|
||||
const List<label>& regions() const
|
||||
//- Return const access to the regions ids
|
||||
const List<label>& regionIds() const
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- Return const access to the patches
|
||||
const List<surfPatchIdentifier>& patches() const
|
||||
//- Return const access to the region table-of-contents
|
||||
const List<surfRegionIdentifier>& regionToc() const
|
||||
{
|
||||
return patches_;
|
||||
return regionToc_;
|
||||
}
|
||||
|
||||
//- Sort faces according to region.
|
||||
// Returns patch list and sets faceMap to index within faces()
|
||||
List<surfGroup> sortedRegions(labelList& faceMap) const;
|
||||
// Returns a surfRegionList and sets faceMap to index within faces()
|
||||
surfRegionList sortedRegions(labelList& faceMap) const;
|
||||
|
||||
//- Set regions to 0 and set a single patch
|
||||
//- Set regions to 0 and set a single region
|
||||
// Optionally with a specific name
|
||||
void onePatch(const word& name = word::null);
|
||||
void oneRegion(const word& name = word::null);
|
||||
|
||||
//- Set regions and patches
|
||||
void setPatches(const surfGroupList&);
|
||||
//- Set region ids and regions
|
||||
void setRegions(const surfRegionList&);
|
||||
|
||||
//- Set regions and patches
|
||||
void setPatches(const UList<label>& sizes, const UList<word>& names);
|
||||
//- Set region ids and regions
|
||||
void setRegions(const UList<label>& sizes, const UList<word>& names);
|
||||
|
||||
//- Set regions and patches with default names
|
||||
void setPatches(const UList<label>& sizes);
|
||||
//- Set region ids and set regions with default names
|
||||
void setRegions(const UList<label>& sizes);
|
||||
|
||||
|
||||
// Edit
|
||||
@ -306,7 +306,7 @@ public:
|
||||
// Returns return pointMap, faceMap from subsetMeshMap
|
||||
UnsortedMeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const;
|
||||
@ -314,7 +314,7 @@ public:
|
||||
//- Return new surface.
|
||||
UnsortedMeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const;
|
||||
|
||||
//- Transfer components (points, faces, region ids).
|
||||
|
||||
@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
||||
const List<Face>& faceLst = this->faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = sortedRegions(faceMap);
|
||||
surfRegionList regionLst = sortedRegions(faceMap);
|
||||
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface Format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
<< regionLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
patchLst[patchI].writeDict(os);
|
||||
regionLst[regionI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
@ -74,12 +74,12 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
||||
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
label faceI = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
os << faceLst[faceMap[faceI++]] << nl;
|
||||
}
|
||||
|
||||
@ -26,28 +26,28 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfGroup.H"
|
||||
#include "surfRegion.H"
|
||||
#include "dictionary.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::surfGroup, 0);
|
||||
defineTypeNameAndDebug(Foam::surfRegion, 0);
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroup::surfGroup()
|
||||
Foam::surfRegion::surfRegion()
|
||||
:
|
||||
surfPatchIdentifier(),
|
||||
surfRegionIdentifier(),
|
||||
size_(0),
|
||||
start_(0)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup
|
||||
Foam::surfRegion::surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
@ -56,68 +56,68 @@ Foam::surfGroup::surfGroup
|
||||
const word& geometricType
|
||||
)
|
||||
:
|
||||
surfPatchIdentifier(name, index, geometricType),
|
||||
surfRegionIdentifier(name, index, geometricType),
|
||||
size_(size),
|
||||
start_(start)
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(Istream& is, const label index)
|
||||
Foam::surfRegion::surfRegion(Istream& is, const label index)
|
||||
:
|
||||
surfPatchIdentifier(),
|
||||
surfRegionIdentifier(),
|
||||
size_(0),
|
||||
start_(0)
|
||||
{
|
||||
word name(is);
|
||||
dictionary dict(is);
|
||||
|
||||
operator=(surfGroup(name, dict, index));
|
||||
operator=(surfRegion(name, dict, index));
|
||||
}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup
|
||||
Foam::surfRegion::surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
surfPatchIdentifier(name, dict, index),
|
||||
surfRegionIdentifier(name, dict, index),
|
||||
size_(readLabel(dict.lookup("nFaces"))),
|
||||
start_(readLabel(dict.lookup("startFace")))
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p)
|
||||
Foam::surfRegion::surfRegion(const surfRegion& reg)
|
||||
:
|
||||
surfPatchIdentifier(p, p.index()),
|
||||
size_(p.size()),
|
||||
start_(p.start())
|
||||
surfRegionIdentifier(reg, reg.index()),
|
||||
size_(reg.size()),
|
||||
start_(reg.start())
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p, const label index)
|
||||
Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
|
||||
:
|
||||
surfPatchIdentifier(p, index),
|
||||
size_(p.size()),
|
||||
start_(p.start())
|
||||
surfRegionIdentifier(reg, index),
|
||||
size_(reg.size()),
|
||||
start_(reg.start())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfGroup::write(Ostream& os) const
|
||||
void Foam::surfRegion::write(Ostream& os) const
|
||||
{
|
||||
writeDict(os);
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfGroup::writeDict(Ostream& os) const
|
||||
void Foam::surfRegion::writeDict(Ostream& os) const
|
||||
{
|
||||
os << indent << name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
surfPatchIdentifier::write(os);
|
||||
surfRegionIdentifier::write(os);
|
||||
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
|
||||
|
||||
@ -127,38 +127,38 @@ void Foam::surfGroup::writeDict(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::surfGroup::operator!=(const surfGroup& p) const
|
||||
bool Foam::surfRegion::operator!=(const surfRegion& reg) const
|
||||
{
|
||||
return !(*this == p);
|
||||
return !(*this == reg);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfGroup::operator==(const surfGroup& p) const
|
||||
bool Foam::surfRegion::operator==(const surfRegion& reg) const
|
||||
{
|
||||
return
|
||||
(
|
||||
(geometricType() == p.geometricType())
|
||||
&& (size() == p.size())
|
||||
&& (start() == p.start())
|
||||
(geometricType() == reg.geometricType())
|
||||
&& (size() == reg.size())
|
||||
&& (start() == reg.start())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, surfGroup& p)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, surfRegion& reg)
|
||||
{
|
||||
p = surfGroup(is, 0);
|
||||
reg = surfRegion(is, 0);
|
||||
|
||||
is.check("Istream& operator>>(Istream&, surfGroup&)");
|
||||
is.check("Istream& operator>>(Istream&, surfRegion&)");
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroup& p)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
|
||||
{
|
||||
p.write(os);
|
||||
os.check("Ostream& operator<<(Ostream& f, const surfGroup& p");
|
||||
reg.write(os);
|
||||
os.check("Ostream& operator<<(Ostream&, const surfRegion&");
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -23,23 +23,24 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfGroup
|
||||
Foam::surfRegion
|
||||
|
||||
Description
|
||||
'Patch' on surface as subset of triSurface.
|
||||
A region on a meshed surface.
|
||||
Similar in concept to a faceZone on the surface.
|
||||
|
||||
SourceFiles
|
||||
surfGroup.C
|
||||
surfRegion.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroup_H
|
||||
#define surfGroup_H
|
||||
#ifndef surfRegion_H
|
||||
#define surfRegion_H
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
#include "className.H"
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "autoPtr.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
@ -50,18 +51,18 @@ namespace Foam
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfGroup;
|
||||
class surfRegion;
|
||||
|
||||
Istream& operator>>(Istream&, surfGroup&);
|
||||
Ostream& operator<<(Ostream&, const surfGroup&);
|
||||
Istream& operator>>(Istream&, surfRegion&);
|
||||
Ostream& operator<<(Ostream&, const surfRegion&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfGroup Declaration
|
||||
Class surfRegion Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfGroup
|
||||
class surfRegion
|
||||
:
|
||||
public surfPatchIdentifier
|
||||
public surfRegionIdentifier
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -74,16 +75,16 @@ class surfGroup
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("surfGroup");
|
||||
ClassName("surfRegion");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfGroup();
|
||||
surfRegion();
|
||||
|
||||
//- Construct from components
|
||||
surfGroup
|
||||
surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
@ -93,10 +94,10 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
surfGroup(Istream& is, const label index);
|
||||
surfRegion(Istream& is, const label index);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfGroup
|
||||
surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
@ -104,48 +105,48 @@ public:
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
surfGroup(const surfGroup&);
|
||||
surfRegion(const surfRegion&);
|
||||
|
||||
//- Construct from another patch, resetting the index
|
||||
surfGroup(const surfGroup&, const label index);
|
||||
//- Construct from another region, resetting the index
|
||||
surfRegion(const surfRegion&, const label index);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<surfGroup> clone() const
|
||||
autoPtr<surfRegion> clone() const
|
||||
{
|
||||
notImplemented("autoPtr<surfGroup> clone() const");
|
||||
return autoPtr<surfGroup>(NULL);
|
||||
notImplemented("autoPtr<surfRegion> clone() const");
|
||||
return autoPtr<surfRegion>(NULL);
|
||||
}
|
||||
|
||||
static autoPtr<surfGroup> New(Istream& is)
|
||||
static autoPtr<surfRegion> New(Istream& is)
|
||||
{
|
||||
word name(is);
|
||||
dictionary dict(is);
|
||||
|
||||
return autoPtr<surfGroup>(new surfGroup(name, dict, 0));
|
||||
return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return start label of this patch in the face list
|
||||
//- Return start label of this region in the face list
|
||||
label start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return start label of this patch in the face list
|
||||
//- Return start label of this region in the face list
|
||||
label& start()
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return size of this patch in the face list
|
||||
//- Return size of this region in the face list
|
||||
label size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
//- Return size of this patch in the face list
|
||||
//- Return size of this region in the face list
|
||||
label& size()
|
||||
{
|
||||
return size_;
|
||||
@ -160,15 +161,15 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
bool operator!=(const surfGroup&) const;
|
||||
bool operator!=(const surfRegion&) const;
|
||||
|
||||
//- compare.
|
||||
bool operator==(const surfGroup&) const;
|
||||
bool operator==(const surfRegion&) const;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, surfGroup&);
|
||||
friend Ostream& operator<<(Ostream&, const surfGroup&);
|
||||
friend Istream& operator>>(Istream&, surfRegion&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegion&);
|
||||
};
|
||||
|
||||
|
||||
@ -24,71 +24,71 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfGroupIOList.H"
|
||||
#include "surfRegionIOList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::surfGroupIOList, 0);
|
||||
defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroupIOList::surfGroupIOList
|
||||
Foam::surfRegionIOList::surfRegionIOList
|
||||
(
|
||||
const IOobject& io
|
||||
)
|
||||
:
|
||||
surfGroupList(),
|
||||
surfRegionList(),
|
||||
regIOobject(io)
|
||||
{
|
||||
Foam::string functionName =
|
||||
"surfGroupIOList::surfGroupIOList"
|
||||
"surfRegionIOList::surfRegionIOList"
|
||||
"(const IOobject& io)";
|
||||
|
||||
|
||||
if (readOpt() == IOobject::MUST_READ)
|
||||
{
|
||||
surfGroupList& patches = *this;
|
||||
surfRegionList& regions = *this;
|
||||
|
||||
// read polyPatchList
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
PtrList<entry> patchEntries(is);
|
||||
patches.setSize(patchEntries.size());
|
||||
PtrList<entry> dictEntries(is);
|
||||
regions.setSize(dictEntries.size());
|
||||
|
||||
label faceI = 0;
|
||||
forAll(patches, patchI)
|
||||
forAll(regions, regionI)
|
||||
{
|
||||
const dictionary& dict = patchEntries[patchI].dict();
|
||||
const dictionary& dict = dictEntries[regionI].dict();
|
||||
|
||||
label patchSize = readLabel(dict.lookup("nFaces"));
|
||||
label regionSize = readLabel(dict.lookup("nFaces"));
|
||||
label startFaceI = readLabel(dict.lookup("startFace"));
|
||||
|
||||
patches[patchI] = surfGroup
|
||||
regions[regionI] = surfRegion
|
||||
(
|
||||
patchEntries[patchI].keyword(),
|
||||
patchSize,
|
||||
dictEntries[regionI].keyword(),
|
||||
regionSize,
|
||||
startFaceI,
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
word geoType;
|
||||
if (dict.readIfPresent("geometricType", geoType))
|
||||
{
|
||||
patches[patchI].geometricType() = geoType;
|
||||
regions[regionI].geometricType() = geoType;
|
||||
}
|
||||
|
||||
if (startFaceI != faceI)
|
||||
{
|
||||
FatalErrorIn(functionName)
|
||||
<< "Patches are not ordered. Start of patch " << patchI
|
||||
<< " does not correspond to sum of preceding patches."
|
||||
<< "Regions are not ordered. Start of region " << regionI
|
||||
<< " does not correspond to sum of preceding regions."
|
||||
<< endl
|
||||
<< "while reading " << io.objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceI += patchSize;
|
||||
faceI += regionSize;
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
@ -99,20 +99,20 @@ Foam::surfGroupIOList::surfGroupIOList
|
||||
}
|
||||
|
||||
// Construct from IOObject
|
||||
Foam::surfGroupIOList::surfGroupIOList
|
||||
Foam::surfRegionIOList::surfRegionIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
const surfGroupList& patches
|
||||
const surfRegionList& regions
|
||||
)
|
||||
:
|
||||
surfGroupList(patches),
|
||||
surfRegionList(regions),
|
||||
regIOobject(io)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroupIOList::~surfGroupIOList()
|
||||
Foam::surfRegionIOList::~surfRegionIOList()
|
||||
{}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ Foam::surfGroupIOList::~surfGroupIOList()
|
||||
|
||||
|
||||
// writeData member function required by regIOobject
|
||||
bool Foam::surfGroupIOList::writeData(Ostream& os) const
|
||||
bool Foam::surfRegionIOList::writeData(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
return os.good();
|
||||
@ -129,13 +129,13 @@ bool Foam::surfGroupIOList::writeData(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroupIOList& patches)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIOList& L)
|
||||
{
|
||||
os << patches.size() << nl << token::BEGIN_LIST;
|
||||
os << L.size() << nl << token::BEGIN_LIST;
|
||||
|
||||
forAll(patches, patchI)
|
||||
forAll(L, i)
|
||||
{
|
||||
patches[patchI].writeDict(os);
|
||||
L[i].writeDict(os);
|
||||
}
|
||||
|
||||
os << token::END_LIST;
|
||||
@ -23,20 +23,20 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfGroupIOList
|
||||
Foam::surfRegionIOList
|
||||
|
||||
Description
|
||||
IOobject for a surfGroupList
|
||||
IOobject for a surfRegionList
|
||||
|
||||
SourceFiles
|
||||
surfGroupIOList.C
|
||||
surfRegionIOList.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroupIOList_H
|
||||
#define surfGroupIOList_H
|
||||
#ifndef surfRegionIOList_H
|
||||
#define surfRegionIOList_H
|
||||
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "regIOobject.H"
|
||||
#include "faceList.H"
|
||||
#include "className.H"
|
||||
@ -49,12 +49,12 @@ namespace Foam
|
||||
// Forward declaration of classes
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfGroupIOList Declaration
|
||||
Class surfRegionIOList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfGroupIOList
|
||||
class surfRegionIOList
|
||||
:
|
||||
public surfGroupList,
|
||||
public surfRegionList,
|
||||
public regIOobject
|
||||
{
|
||||
// Private data
|
||||
@ -63,29 +63,29 @@ class surfGroupIOList
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
surfGroupIOList(const surfGroupIOList&);
|
||||
surfRegionIOList(const surfRegionIOList&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfGroupIOList&);
|
||||
void operator=(const surfRegionIOList&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfGroupIOList");
|
||||
TypeName("surfRegionIOList");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
explicit surfGroupIOList(const IOobject& io);
|
||||
explicit surfRegionIOList(const IOobject&);
|
||||
|
||||
//- Construct from IOobject
|
||||
surfGroupIOList(const IOobject& io, const surfGroupList&);
|
||||
surfRegionIOList(const IOobject&, const surfRegionList&);
|
||||
|
||||
// Destructor
|
||||
|
||||
~surfGroupIOList();
|
||||
~surfRegionIOList();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -102,7 +102,7 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const surfGroupIOList&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
|
||||
};
|
||||
|
||||
|
||||
@ -23,17 +23,18 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
Foam::surfGroupList
|
||||
Foam::surfRegionList
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroupList_H
|
||||
#define surfGroupList_H
|
||||
#ifndef surfRegionList_H
|
||||
#define surfRegionList_H
|
||||
|
||||
#include "surfGroup.H"
|
||||
#include "surfRegion.H"
|
||||
#include "List.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -42,7 +43,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef List<surfGroup> surfGroupList;
|
||||
typedef List<surfRegion> surfRegionList;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -24,14 +24,14 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier()
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier()
|
||||
:
|
||||
name_(word::null),
|
||||
boundaryIndex_(0),
|
||||
@ -39,7 +39,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier()
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
@ -52,7 +52,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
@ -66,9 +66,9 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
}
|
||||
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
||||
(
|
||||
const surfPatchIdentifier& p,
|
||||
const surfRegionIdentifier& p,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
@ -79,14 +79,14 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfPatchIdentifier::~surfPatchIdentifier()
|
||||
Foam::surfRegionIdentifier::~surfRegionIdentifier()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
void Foam::surfRegionIdentifier::write(Ostream& os) const
|
||||
{
|
||||
if (geometricType_.size())
|
||||
{
|
||||
@ -98,18 +98,18 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
// bool Foam::surfPatchIdentifier::operator!=
|
||||
// bool Foam::surfRegionIdentifier::operator!=
|
||||
// (
|
||||
// const surfPatchIdentifier& p
|
||||
// const surfRegionIdentifier& p
|
||||
// ) const
|
||||
// {
|
||||
// return !(*this == p);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// bool Foam::surfPatchIdentifier::operator==
|
||||
// bool Foam::surfRegionIdentifier::operator==
|
||||
// (
|
||||
// const surfPatchIdentifier& p
|
||||
// const surfRegionIdentifier& p
|
||||
// ) const
|
||||
// {
|
||||
// return geometricType() == p.geometricType() && name() == p.name();
|
||||
@ -118,7 +118,7 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// Foam::Istream& Foam::operator>>(Istream& is, surfPatchIdentifier& p)
|
||||
// Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
|
||||
// {
|
||||
// is >> p.name_ >> p.geometricType_;
|
||||
//
|
||||
@ -126,12 +126,12 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
// }
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfPatchIdentifier& p)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIdentifier& p)
|
||||
{
|
||||
p.write(os);
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const surfPatchIdentifier&)"
|
||||
"Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
|
||||
);
|
||||
return os;
|
||||
}
|
||||
@ -23,19 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier
|
||||
|
||||
Description
|
||||
Like patchIdentifier but for surfaces with "geometricType" rather
|
||||
than "physicalType".
|
||||
An identifier for a region on a meshed surface.
|
||||
|
||||
Similar in concept to a faceZone on the surface, but can also have a
|
||||
"geometricType" rather. Despite the similarity to a 'patch' for
|
||||
volume meshes (with a "physicalType"), the region does not have any
|
||||
patch information per se.
|
||||
|
||||
SourceFiles
|
||||
surfPatchIdentifier.C
|
||||
surfRegionIdentifier.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfPatchIdentifier_H
|
||||
#define surfPatchIdentifier_H
|
||||
#ifndef surfRegionIdentifier_H
|
||||
#define surfRegionIdentifier_H
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
@ -50,24 +54,24 @@ class dictionary;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfPatchIdentifier;
|
||||
Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
|
||||
class surfRegionIdentifier;
|
||||
Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfPatchIdentifier Declaration
|
||||
Class surfRegionIdentifier Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfPatchIdentifier
|
||||
class surfRegionIdentifier
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of patch
|
||||
//- Name of region
|
||||
word name_;
|
||||
|
||||
//- Index of patch in boundary
|
||||
//- Index of region in surface mesh
|
||||
label boundaryIndex_;
|
||||
|
||||
//- Type name of patch
|
||||
//- Type name of region
|
||||
mutable word geometricType_;
|
||||
|
||||
public:
|
||||
@ -75,10 +79,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfPatchIdentifier();
|
||||
surfRegionIdentifier();
|
||||
|
||||
//- Construct from components
|
||||
surfPatchIdentifier
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
@ -87,24 +91,24 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfPatchIdentifier
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const dictionary&,
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct from another patch, resetting the index
|
||||
surfPatchIdentifier
|
||||
//- Construct from another region identifier, resetting the index
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const surfPatchIdentifier&,
|
||||
const surfRegionIdentifier&,
|
||||
const label index
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~surfPatchIdentifier();
|
||||
virtual ~surfRegionIdentifier();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -121,42 +125,42 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the geometric type of the patch
|
||||
//- Return the geometric type of the region
|
||||
const word& geometricType() const
|
||||
{
|
||||
return geometricType_;
|
||||
}
|
||||
|
||||
//- Return the geometric type of the patch for modification
|
||||
//- Return the geometric type of the region for modification
|
||||
word& geometricType()
|
||||
{
|
||||
return geometricType_;
|
||||
}
|
||||
|
||||
//- Return the index of this patch in the boundaryMesh
|
||||
//- Return the index of this region in the surface mesh
|
||||
label index() const
|
||||
{
|
||||
return boundaryIndex_;
|
||||
}
|
||||
|
||||
//- Write surfPatchIdentifier as a dictionary
|
||||
//- Write surfRegionIdentifier as a dictionary
|
||||
void write(Ostream&) const;
|
||||
|
||||
//- Write surfPatchIdentifier as a dictionary
|
||||
//- Write surfRegionIdentifier as a dictionary
|
||||
// void writeDict(Ostream&) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
// bool operator!=(const surfPatchIdentifier&) const;
|
||||
// bool operator!=(const surfRegionIdentifier&) const;
|
||||
//
|
||||
// //- compare.
|
||||
// bool operator==(const surfPatchIdentifier&) const;
|
||||
// bool operator==(const surfRegionIdentifier&) const;
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
|
||||
// friend Istream& operator>>(Istream&, surfPatchIdentifier&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
||||
// friend Istream& operator>>(Istream&, surfRegionIdentifier&);
|
||||
};
|
||||
|
||||
|
||||
@ -23,16 +23,16 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
Foam::surfPatchIdentifierList
|
||||
Foam::surfRegionIdentifierList
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfPatchIdentifierList_H
|
||||
#define surfPatchIdentifierList_H
|
||||
#ifndef surfRegionIdentifierList_H
|
||||
#define surfRegionIdentifierList_H
|
||||
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -42,7 +42,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef List<surfPatchIdentifier> surfPatchIdentifierList;
|
||||
typedef List<surfRegionIdentifier> surfRegionIdentifierList;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// # of kids is the # of patches
|
||||
// # of kids is the # of regions
|
||||
args = cueToOrDie(is, "kids");
|
||||
label nPatches = parse<int>(args);
|
||||
label nRegions = parse<int>(args);
|
||||
|
||||
// Start of vertices for object/patch
|
||||
label patchVertOffset = 0;
|
||||
// Start of vertices for object/region
|
||||
label vertexOffset = 0;
|
||||
|
||||
DynamicList<point> dynPoints;
|
||||
DynamicList<Face> dynFaces;
|
||||
List<word> names(nPatches);
|
||||
List<label> sizes(nPatches, 0);
|
||||
List<word> names(nRegions);
|
||||
List<label> sizes(nRegions, 0);
|
||||
|
||||
for (label patchI = 0; patchI < nPatches; ++patchI)
|
||||
for (label regionI = 0; regionI < nRegions; ++regionI)
|
||||
{
|
||||
names[patchI] = word("patch") + Foam::name(patchI);
|
||||
names[regionI] = word("region") + Foam::name(regionI);
|
||||
|
||||
args = cueToOrDie(is, "OBJECT", "while reading " + names[patchI]);
|
||||
args = cueToOrDie(is, "OBJECT", "while reading " + names[regionI]);
|
||||
|
||||
// number of vertices for this patch
|
||||
label nPatchPoints = 0;
|
||||
// number of vertices for this region
|
||||
label nRegionPoints = 0;
|
||||
vector location(pTraits<vector>::zero);
|
||||
// tensor rotation(I);
|
||||
|
||||
// Read all info for current patch
|
||||
// Read all info for current region
|
||||
while (is.good())
|
||||
{
|
||||
// Read line and get first word. If end of file break since
|
||||
// patch should always end with 'kids' command ?not sure.
|
||||
// region should always end with 'kids' command ?not sure.
|
||||
if (!readCmd(is, cmd, args))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Did not read up to \"kids 0\" while reading patch "
|
||||
<< patchI << " from file " << filename
|
||||
<< "Did not read up to \"kids 0\" while reading region "
|
||||
<< regionI << " from file " << filename
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
string str = parse<string>(args);
|
||||
string::stripInvalid<word>(str);
|
||||
|
||||
names[patchI] = str;
|
||||
names[regionI] = str;
|
||||
}
|
||||
else if (cmd == "rot")
|
||||
{
|
||||
@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
)
|
||||
<< "rot (rotation tensor) command not implemented"
|
||||
<< "Line:" << cmd << ' ' << args << endl
|
||||
<< "while reading patch " << patchI << endl;
|
||||
<< "while reading region " << regionI << endl;
|
||||
}
|
||||
else if (cmd == "loc")
|
||||
{
|
||||
@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
else if (cmd == "numvert")
|
||||
{
|
||||
// numvert %d
|
||||
nPatchPoints = parse<int>(args);
|
||||
nRegionPoints = parse<int>(args);
|
||||
|
||||
for (label vertI = 0; vertI < nPatchPoints; ++vertI)
|
||||
for (label vertI = 0; vertI < nRegionPoints; ++vertI)
|
||||
{
|
||||
is.getLine(line);
|
||||
IStringStream lineStream(line);
|
||||
@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
{
|
||||
static string errorMsg =
|
||||
string(" while reading face ")
|
||||
+ Foam::name(faceI) + " on patch "
|
||||
+ Foam::name(patchI)
|
||||
+ Foam::name(faceI) + " on region "
|
||||
+ Foam::name(regionI)
|
||||
+ " from file " + filename;
|
||||
|
||||
cueToOrDie(is, "SURF", errorMsg);
|
||||
@ -216,7 +216,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
forAll(verts, vertI)
|
||||
{
|
||||
is.getLine(line);
|
||||
verts[vertI] = parse<int>(line) + patchVertOffset;
|
||||
verts[vertI] = parse<int>(line) + vertexOffset;
|
||||
}
|
||||
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
@ -230,23 +230,23 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||
sizes[patchI]++;
|
||||
sizes[regionI]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dynFaces.append(Face(f));
|
||||
sizes[patchI]++;
|
||||
sizes[regionI]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Done the current patch.
|
||||
// Done the current region.
|
||||
// Increment the offset vertices are stored at
|
||||
patchVertOffset += nPatchPoints;
|
||||
vertexOffset += nRegionPoints;
|
||||
}
|
||||
else if (cmd == "kids")
|
||||
{
|
||||
// 'kids' denotes the end of the current patch.
|
||||
// 'kids' denotes the end of the current region.
|
||||
label nKids = parse<int>(args);
|
||||
|
||||
if (nKids != 0)
|
||||
@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
)
|
||||
<< "Can only read objects without kids."
|
||||
<< " Encountered " << nKids << " kids when"
|
||||
<< " reading patch " << patchI
|
||||
<< " reading region " << regionI
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Done reading current patch
|
||||
// Done reading current region
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
this->storedPoints().transfer(dynPoints);
|
||||
this->storedFaces().transfer(dynFaces);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(sizes, names, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(sizes, names, true);
|
||||
this->stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
@ -287,16 +287,16 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, patchLst);
|
||||
writeHeader(os, regionLst);
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& p = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << p.name() << '"' << endl;
|
||||
<< "name \"" << reg.name() << '"' << endl;
|
||||
|
||||
// Temporary PrimitivePatch to calculate compact points & faces
|
||||
// use 'UList' to avoid allocations!
|
||||
@ -317,12 +317,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
os << "numsurf " << patch.localFaces().size() << endl;
|
||||
|
||||
forAll(patch.localFaces(), faceI)
|
||||
forAll(patch.localFaces(), localFaceI)
|
||||
{
|
||||
const Face& f = patch.localFaces()[faceI];
|
||||
const Face& f = patch.localFaces()[localFaceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
<< "mat " << regionI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
@ -344,25 +344,25 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHeader(os, patchLst);
|
||||
writeHeader(os, regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& p = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << p.name() << '"' << endl;
|
||||
<< "name \"" << reg.name() << '"' << endl;
|
||||
|
||||
// Create patch with only patch faces included for ease of addressing
|
||||
boolList include(surf.size(), false);
|
||||
// Create region with only region faces included for ease of addressing
|
||||
labelHashSet include(surf.size());
|
||||
|
||||
forAll(p, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
include[faceI] = true;
|
||||
include.insert(faceI);
|
||||
}
|
||||
|
||||
UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
|
||||
@ -379,12 +379,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
os << "numsurf " << subm.localFaces().size() << endl;
|
||||
|
||||
forAll(subm.localFaces(), faceI)
|
||||
forAll(subm.localFaces(), localFaceI)
|
||||
{
|
||||
const Face& f = subm.localFaces()[faceI];
|
||||
const Face& f = subm.localFaces()[localFaceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
<< "mat " << regionI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
http://www.inivis.com/ac3d/man/ac3dfileformat.html
|
||||
|
||||
Note
|
||||
The faces are already organized as patches.
|
||||
The faces are already organized as regions.
|
||||
The output is always sorted by regions.
|
||||
|
||||
SourceFiles
|
||||
|
||||
@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
|
||||
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
// Write with patches as separate objects under "world" object.
|
||||
// Write with regions as separate objects under "world" object.
|
||||
// Header is taken over from sample file.
|
||||
// Defines separate materials for all patches. Recycle colours.
|
||||
// Defines separate materials for all regions. Recycle colours.
|
||||
|
||||
// Define 8 standard colours as r,g,b components
|
||||
static scalar colourMap[] =
|
||||
@ -139,14 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||
// Write header. Define materials.
|
||||
os << "AC3Db" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const word& pName = patchLst[patchI].name();
|
||||
|
||||
label colourI = patchI % 8;
|
||||
label colourI = regionI % 8;
|
||||
label colourCompI = 3 * colourI;
|
||||
|
||||
os << "MATERIAL \"" << pName << "Mat\" rgb "
|
||||
os << "MATERIAL \"" << regionLst[regionI].name() << "Mat\" rgb "
|
||||
<< colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
|
||||
<< ' ' << colourMap[colourCompI+2]
|
||||
<< " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
|
||||
@ -155,7 +153,7 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||
}
|
||||
|
||||
os << "OBJECT world" << nl
|
||||
<< "kids " << patchLst.size() << endl;
|
||||
<< "kids " << regionLst.size() << endl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
Class AC3DfileFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AC3DsurfaceFormatCore
|
||||
@ -77,7 +77,7 @@ protected:
|
||||
);
|
||||
|
||||
//- Write header with materials
|
||||
static void writeHeader(Ostream&, const List<surfGroup>&);
|
||||
static void writeHeader(Ostream&, const UList<surfRegion>&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -63,40 +63,40 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
List<ftrPatch> readPatches(is);
|
||||
List<ftrPatch> ftrPatches(is);
|
||||
|
||||
// read points directly
|
||||
is >> this->storedPoints();
|
||||
|
||||
// read faces with keys
|
||||
List<Keyed<triFace> > readFaces(is);
|
||||
// faces read with keys
|
||||
List<Keyed<triFace> > facesRead(is);
|
||||
|
||||
List<Face> faceLst(readFaces.size());
|
||||
List<label> regionLst(readFaces.size());
|
||||
List<Face> faceLst(facesRead.size());
|
||||
List<label> regionIds(facesRead.size());
|
||||
|
||||
// disentangle faces/keys - already triangulated
|
||||
forAll(readFaces, faceI)
|
||||
forAll(facesRead, faceI)
|
||||
{
|
||||
// unfortunately cannot transfer to save memory
|
||||
faceLst[faceI] = readFaces[faceI];
|
||||
regionLst[faceI] = readFaces[faceI].key();
|
||||
faceLst[faceI] = facesRead[faceI];
|
||||
regionIds[faceI] = facesRead[faceI].key();
|
||||
}
|
||||
|
||||
this->storedFaces().transfer(faceLst);
|
||||
this->storedRegions().transfer(regionLst);
|
||||
this->storedRegionIds().transfer(regionIds);
|
||||
|
||||
// cast ftrPatch into new form
|
||||
List<surfPatchIdentifier> newPatches(readPatches.size());
|
||||
forAll(newPatches, patchI)
|
||||
// change ftrPatch into surfRegionIdentifier
|
||||
List<surfRegionIdentifier> newRegions(ftrPatches.size());
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI] = surfPatchIdentifier
|
||||
newRegions[regionI] = surfRegionIdentifier
|
||||
(
|
||||
readPatches[patchI].name(),
|
||||
patchI
|
||||
ftrPatches[regionI].name(),
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
this->storedPatches().transfer(newPatches);
|
||||
this->storedRegionToc().transfer(newRegions);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -80,13 +80,13 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = this->storedPoints();
|
||||
List<Face>& faceLst = this->storedFaces();
|
||||
List<label>& regionLst = this->storedRegions();
|
||||
pointField& pointLst = this->storedPoints();
|
||||
List<Face>& faceLst = this->storedFaces();
|
||||
List<label>& regionIds = this->storedRegionIds();
|
||||
|
||||
pointLst.setSize(nPoints);
|
||||
faceLst.setSize(nElems);
|
||||
regionLst.setSize(nElems);
|
||||
regionIds.setSize(nElems);
|
||||
|
||||
// Read points
|
||||
forAll(pointLst, pointI)
|
||||
@ -118,7 +118,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
|
||||
|
||||
// Read triangles. Convert references to edges into pointlabels
|
||||
label maxPatch = 0;
|
||||
label maxRegion = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
label e0Label, e1Label, e2Label;
|
||||
@ -138,9 +138,9 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
if (!lineStream.bad())
|
||||
{
|
||||
regionI = num;
|
||||
if (maxPatch < regionI)
|
||||
if (maxRegion < regionI)
|
||||
{
|
||||
maxPatch = regionI;
|
||||
maxRegion = regionI;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,21 +202,21 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
faceLst[faceI] = triFace(e0Far, common01, e1Far);
|
||||
regionLst[faceI] = regionI;
|
||||
regionIds[faceI] = regionI;
|
||||
}
|
||||
|
||||
|
||||
List<surfPatchIdentifier> newPatches(maxPatch+1);
|
||||
forAll(newPatches, patchI)
|
||||
List<surfRegionIdentifier> newRegions(maxRegion+1);
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI] = surfPatchIdentifier
|
||||
newRegions[regionI] = surfRegionIdentifier
|
||||
(
|
||||
"patch" + ::Foam::name(patchI),
|
||||
patchI
|
||||
"region" + ::Foam::name(regionI),
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
this->storedPatches().transfer(newPatches);
|
||||
this->storedRegionToc().transfer(newRegions);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -230,13 +230,12 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
|
||||
// check if output triangulation would be required
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
//
|
||||
if (!surf.isTri())
|
||||
{
|
||||
label nNonTris = 0;
|
||||
@ -261,14 +260,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
}
|
||||
}
|
||||
|
||||
// Write header, print patch names as comment
|
||||
// Write header, print region names as comment
|
||||
os << "# GTS file" << nl
|
||||
<< "# Regions:" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " "
|
||||
<< patchLst[patchI].name() << nl;
|
||||
os << "# " << regionI << " "
|
||||
<< regionLst[regionI].name() << nl;
|
||||
}
|
||||
os << "#" << endl;
|
||||
|
||||
@ -301,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
const labelListList& faceEs = surf.faceEdges();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const labelList& fEdges = faceEs[faceIndex++];
|
||||
|
||||
os << fEdges[0] + 1 << ' '
|
||||
<< fEdges[1] + 1 << ' '
|
||||
<< fEdges[2] + 1 << ' '
|
||||
<< patchI << endl;
|
||||
<< regionI << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const List<surfPatchIdentifier>& patchInfo = surf.patches();
|
||||
const List<label>& regionIds = surf.regionIds();
|
||||
const List<surfRegionIdentifier>& regionToc = surf.regionToc();
|
||||
|
||||
// check if output triangulation would be required
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
@ -357,18 +356,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
}
|
||||
}
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
|
||||
// Write header, print patch names as comment
|
||||
// Write header, print region names as comment
|
||||
os << "# GTS file" << nl
|
||||
<< "# Regions:" << nl;
|
||||
|
||||
forAll(patchInfo, patchI)
|
||||
forAll(regionToc, regionI)
|
||||
{
|
||||
os << "# " << patchI << " "
|
||||
<< patchInfo[patchI].name() << nl;
|
||||
os << "# " << regionI << " "
|
||||
<< regionToc[regionI].name() << nl;
|
||||
}
|
||||
os << "#" << endl;
|
||||
|
||||
@ -409,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
os << fEdges[0] + 1 << ' '
|
||||
<< fEdges[1] + 1 << ' '
|
||||
<< fEdges[2] + 1 << ' '
|
||||
<< regionLst[faceI] << endl;
|
||||
<< regionIds[faceI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing GTS format.
|
||||
The output is never sorted by patch.
|
||||
The output is never sorted by region.
|
||||
|
||||
SourceFiles
|
||||
GTSsurfaceFormat.C
|
||||
|
||||
@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
// Ansa tags. Denoted by $ANSA_NAME.
|
||||
// These will appear just before the first use of a type.
|
||||
// We read them and store the PSHELL types which are used to name
|
||||
// the patches.
|
||||
// the regions.
|
||||
label ansaId = -1;
|
||||
word ansaType, ansaName;
|
||||
|
||||
@ -211,7 +211,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
fTri[1] = readLabel(IStringStream(line.substr(32,8))());
|
||||
fTri[2] = readLabel(IStringStream(line.substr(40,8))());
|
||||
|
||||
// Convert groupID into patchID
|
||||
// Convert groupID into regionId
|
||||
Map<label>::const_iterator fnd = lookup.find(groupId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -227,7 +227,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
regionI = dynSizes.size();
|
||||
lookup.insert(groupId, regionI);
|
||||
dynSizes.append(0);
|
||||
// Info<< "patch" << regionI << " => group " << groupId <<endl;
|
||||
// Info<< "region" << regionI << " => group " << groupId <<endl;
|
||||
}
|
||||
|
||||
dynFaces.append(fTri);
|
||||
@ -245,7 +245,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
|
||||
fQuad[3] = readLabel(IStringStream(line.substr(48,8))());
|
||||
|
||||
// Convert groupID into patchID
|
||||
// Convert groupID into regionId
|
||||
Map<label>::const_iterator fnd = lookup.find(groupId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -261,7 +261,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
regionI = dynSizes.size();
|
||||
lookup.insert(groupId, regionI);
|
||||
dynSizes.append(0);
|
||||
// Info<< "patch" << regionI << " => group " << groupId <<endl;
|
||||
// Info<< "region" << regionI << " => group " << groupId <<endl;
|
||||
}
|
||||
|
||||
|
||||
@ -322,7 +322,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
}
|
||||
else if (cmd == "PSHELL")
|
||||
{
|
||||
// pshell type for patch names with the Ansa extension
|
||||
// pshell type for region names with the Ansa extension
|
||||
label groupId = readLabel(IStringStream(line.substr(8,8))());
|
||||
|
||||
if (groupId == ansaId && ansaType == "PSHELL")
|
||||
@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
mapPointId.clear();
|
||||
|
||||
|
||||
// create default patch names, or from ANSA/Hypermesh information
|
||||
// create default region names, or from ANSA/Hypermesh information
|
||||
List<word> names(dynSizes.size());
|
||||
forAllConstIter(Map<label>, lookup, iter)
|
||||
{
|
||||
const label patchI = iter();
|
||||
const label groupI = iter.key();
|
||||
const label regionI = iter();
|
||||
const label groupI = iter.key();
|
||||
|
||||
Map<word>::const_iterator fnd = nameLookup.find(groupI);
|
||||
if (fnd != nameLookup.end())
|
||||
{
|
||||
names[patchI] = fnd();
|
||||
names[regionI] = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
names[patchI] = word("patch") + ::Foam::name(patchI);
|
||||
names[regionI] = word("region") + ::Foam::name(regionI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, names, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, names, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
Nastran surface reader.
|
||||
|
||||
- Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
|
||||
to obtain patch names.
|
||||
to obtain region names.
|
||||
- Handles Nastran short and long formats, but not free format.
|
||||
- Properly handles the Nastran compact floating point notation: \n
|
||||
@verbatim
|
||||
|
||||
@ -49,7 +49,7 @@ Foam::scalar Foam::fileFormats::NASsurfaceFormatCore::parseNASCoord
|
||||
{
|
||||
exponent = -exponent;
|
||||
}
|
||||
return mantissa*pow(10, exponent);
|
||||
return mantissa * pow(10, exponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -75,10 +75,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
DynamicList<label> dynSizes;
|
||||
HashTable<label> lookup;
|
||||
|
||||
// place faces without a group in patch0
|
||||
// place faces without a group in region0
|
||||
label regionI = 0;
|
||||
lookup.insert("patch0", regionI);
|
||||
dynNames.append("patch0");
|
||||
lookup.insert("region0", regionI);
|
||||
dynNames.append("region0");
|
||||
dynSizes.append(0);
|
||||
|
||||
while (is.good())
|
||||
@ -204,8 +204,8 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, dynNames, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, dynNames, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -218,18 +218,18 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "g " << patch.name() << endl;
|
||||
os << "g " << reg.name() << endl;
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
@ -255,19 +255,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "g " << patch.name() << endl;
|
||||
os << "g " << reg.name() << endl;
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
|
||||
@ -63,14 +63,6 @@ class OBJsurfaceFormat
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
<< "# region : " << regionLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
// Print region names as comment
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
|
||||
@ -63,7 +63,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -146,7 +146,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
reset(pointLst.xfer(), dynFaces.xfer());
|
||||
|
||||
// no region information
|
||||
this->onePatch();
|
||||
this->oneRegion();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -161,16 +161,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# <patch name=\"" << patchLst[patchI].name() << "\">" << endl;
|
||||
os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
@ -181,9 +181,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
}
|
||||
|
||||
// add optional region information
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
os << "# </patch>" << endl;
|
||||
os << "# </region>" << endl;
|
||||
}
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
@ -197,16 +197,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# <patch name=\"" << patchLst[patchI].name() << "\">" << endl;
|
||||
os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
@ -217,9 +217,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
}
|
||||
|
||||
// add optional region information
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
os << "# </patch>" << endl;
|
||||
os << "# </region>" << endl;
|
||||
}
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
|
||||
@ -71,14 +71,6 @@ class OFFsurfaceFormat
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OFFsurfaceFormat(const OFFsurfaceFormat&);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
<< "# regions: " << regionLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
// Print region names as comment
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
|
||||
@ -63,7 +63,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -46,14 +46,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
@ -62,7 +62,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
{
|
||||
os << ' ' << f[fp];
|
||||
}
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,12 +82,12 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
@ -96,7 +96,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
{
|
||||
os << ' ' << f[fp];
|
||||
}
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
const label cellTableId
|
||||
)
|
||||
{
|
||||
os
|
||||
<< cellId // includes 1 offset
|
||||
os << cellId // includes 1 offset
|
||||
<< " " << starcdShellShape_ // 3(shell) shape
|
||||
<< " " << f.size()
|
||||
<< " " << cellTableId
|
||||
@ -54,9 +53,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
{
|
||||
if ((count % 8) == 0)
|
||||
{
|
||||
os
|
||||
<< nl
|
||||
<< " " << cellId;
|
||||
os << nl << " " << cellId;
|
||||
}
|
||||
os << " " << f[fp] + 1;
|
||||
count++;
|
||||
@ -160,7 +157,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
|
||||
if (typeId == starcdShellType_)
|
||||
{
|
||||
// Convert groupID into patchID
|
||||
// Convert groupID into regionID
|
||||
Map<label>::const_iterator fnd = lookup.find(cellTableId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -214,8 +211,8 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, dynNames, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, dynNames, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -234,17 +231,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
writeHeader(os, "CELL");
|
||||
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
writeShell(os, f, faceIndex, patchI + 1);
|
||||
writeShell(os, f, faceIndex, regionI + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +251,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
OFstream(baseName + ".inp")(),
|
||||
surf.points(),
|
||||
surf.size(),
|
||||
patchLst
|
||||
regionLst
|
||||
);
|
||||
}
|
||||
|
||||
@ -275,17 +272,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
writeShell(os, f, faceIndex, patchI + 1);
|
||||
writeShell(os, f, faceIndex, regionI + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,7 +292,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
OFstream(baseName + ".inp")(),
|
||||
surf.points(),
|
||||
surf.size(),
|
||||
patchLst
|
||||
regionLst
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
word caseName = os.name().lessExt().name();
|
||||
@ -176,10 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||
<< "! case " << caseName << nl
|
||||
<< "! ------------------------------" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "ctable " << patchI + 1 << " shell" << nl
|
||||
<< "ctname " << patchI + 1 << " " << patchLst[patchI].name() << nl;
|
||||
os << "ctable " << regionI + 1 << " shell" << nl
|
||||
<< "ctname " << regionI + 1 << " "
|
||||
<< regionLst[regionI].name() << nl;
|
||||
}
|
||||
|
||||
os << "! ------------------------------" << nl
|
||||
|
||||
@ -70,7 +70,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm,
|
||||
const label patchI
|
||||
const label regionI
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
@ -86,7 +86,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]],
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
stlTri.write(os);
|
||||
@ -104,22 +104,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
forAll(patch, patchFaceI)
|
||||
os << "solid " << reg.name() << endl;
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceIndex++;
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
os << "endsolid " << reg.name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,34 +136,34 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
if (surf.patches().size() == 1)
|
||||
if (surf.regionToc().size() == 1)
|
||||
{
|
||||
// a single region - we can skip sorting
|
||||
os << "solid " << surf.patches()[0].name() << endl;
|
||||
os << "solid " << surf.regionToc()[0].name() << endl;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
os << "endsolid " << surf.patches()[0].name() << endl;
|
||||
os << "endsolid " << surf.regionToc()[0].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
forAll(patch, patchFaceI)
|
||||
os << "solid " << reg.name() << endl;
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
os << "endsolid " << reg.name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,10 +177,10 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
if (surf.isTri())
|
||||
@ -200,9 +200,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], regionFaceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
@ -210,7 +210,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
pointLst,
|
||||
faceLst[faceIndex],
|
||||
normLst[faceIndex],
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
++faceIndex;
|
||||
@ -227,9 +227,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const List<label>& regionIds = surf.regionIds();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
@ -258,7 +258,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
regionLst[faceI]
|
||||
regionIds[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -295,10 +295,10 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
// retrieve the original region information
|
||||
List<word> names(reader.names().xfer());
|
||||
List<label> sizes(reader.sizes().xfer());
|
||||
List<label> regions(reader.regions().xfer());
|
||||
List<label> regionIds(reader.regionIds().xfer());
|
||||
|
||||
// generate the (sorted) faces
|
||||
List<Face> faceLst(regions.size());
|
||||
List<Face> faceLst(regionIds.size());
|
||||
|
||||
if (reader.sorted())
|
||||
{
|
||||
@ -314,7 +314,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
// unsorted - determine the sorted order:
|
||||
// avoid SortableList since we discard the main list anyhow
|
||||
List<label> faceMap;
|
||||
sortedOrder(regions, faceMap);
|
||||
sortedOrder(regionIds, faceMap);
|
||||
|
||||
// generate sorted faces
|
||||
forAll(faceMap, faceI)
|
||||
@ -323,18 +323,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
||||
}
|
||||
}
|
||||
regions.clear();
|
||||
regionIds.clear();
|
||||
|
||||
// transfer:
|
||||
this->storedFaces().transfer(faceLst);
|
||||
|
||||
if (names.size())
|
||||
{
|
||||
this->addPatches(sizes, names);
|
||||
this->addRegions(sizes, names);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->addPatches(sizes);
|
||||
this->addRegions(sizes);
|
||||
}
|
||||
|
||||
this->stitchFaces(SMALL);
|
||||
|
||||
@ -79,7 +79,7 @@ class STLsurfaceFormat
|
||||
const pointField&,
|
||||
const Face&,
|
||||
const vector&,
|
||||
const label patchI
|
||||
const label regionI
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||
|
||||
// transfer to normal lists
|
||||
points_.transfer(lexer.points());
|
||||
regions_.transfer(lexer.facets());
|
||||
regionIds_.transfer(lexer.facets());
|
||||
names_.transfer(lexer.names());
|
||||
sizes_.transfer(lexer.sizes());
|
||||
|
||||
|
||||
@ -142,14 +142,14 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
#endif
|
||||
|
||||
points_.setSize(3*nTris);
|
||||
regions_.setSize(nTris);
|
||||
regionIds_.setSize(nTris);
|
||||
|
||||
Map<label> lookup;
|
||||
DynamicList<label> dynSizes;
|
||||
|
||||
label ptI = 0;
|
||||
label regionI = -1;
|
||||
forAll(regions_, faceI)
|
||||
forAll(regionIds_, faceI)
|
||||
{
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
@ -179,7 +179,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
dynSizes.append(0);
|
||||
}
|
||||
|
||||
regions_[faceI] = regionI;
|
||||
regionIds_[faceI] = regionI;
|
||||
dynSizes[regionI]++;
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
@ -220,7 +220,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
|
||||
:
|
||||
sorted_(true),
|
||||
points_(0),
|
||||
regions_(0),
|
||||
regionIds_(0),
|
||||
names_(0),
|
||||
sizes_(0)
|
||||
{
|
||||
|
||||
@ -65,7 +65,7 @@ class STLsurfaceFormatCore
|
||||
pointField points_;
|
||||
|
||||
//- The regions associated with the faces
|
||||
List<label> regions_;
|
||||
List<label> regionIds_;
|
||||
|
||||
//- The solid names, in the order of their first appearance
|
||||
List<word> names_;
|
||||
@ -124,7 +124,7 @@ public:
|
||||
{
|
||||
sorted_ = true;
|
||||
points_.clear();
|
||||
regions_.clear();
|
||||
regionIds_.clear();
|
||||
names_.clear();
|
||||
sizes_.clear();
|
||||
}
|
||||
@ -135,10 +135,10 @@ public:
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Return full access to the regions
|
||||
List<label>& regions()
|
||||
//- Return full access to the regionIds
|
||||
List<label>& regionIds()
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- The list of solid names in the order of their first appearance
|
||||
|
||||
@ -37,7 +37,6 @@ Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
//- Check if file extension corresponds to 'native' surface format
|
||||
bool
|
||||
Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext)
|
||||
{
|
||||
@ -75,11 +74,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
// closest to and lower than current time
|
||||
|
||||
instantList ts = d.times();
|
||||
label i;
|
||||
label instanceI;
|
||||
|
||||
for (i=ts.size()-1; i>=0; i--)
|
||||
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
|
||||
{
|
||||
if (ts[i].value() <= d.timeOutputValue())
|
||||
if (ts[instanceI].value() <= d.timeOutputValue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -88,13 +87,13 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
// Noting that the current directory has already been searched
|
||||
// for mesh data, start searching from the previously stored time directory
|
||||
|
||||
if (i>=0)
|
||||
if (instanceI >= 0)
|
||||
{
|
||||
for (label j=i; j>=0; j--)
|
||||
for (label i = instanceI; i >= 0; --i)
|
||||
{
|
||||
if (file(d.path()/ts[j].name()/subdirName/foamName))
|
||||
if (file(d.path()/ts[i].name()/subdirName/foamName))
|
||||
{
|
||||
return ts[j].name();
|
||||
return ts[i].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,11 +115,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
// closest to and lower than current time
|
||||
|
||||
instantList ts = d.times();
|
||||
label i;
|
||||
label instanceI;
|
||||
|
||||
for (i=ts.size()-1; i>=0; i--)
|
||||
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
|
||||
{
|
||||
if (ts[i].value() <= d.timeOutputValue())
|
||||
if (ts[instanceI].value() <= d.timeOutputValue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -129,11 +128,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
// Noting that the current directory has already been searched
|
||||
// for mesh data, start searching from the previously stored time directory
|
||||
|
||||
if (i>=0)
|
||||
if (instanceI >= 0)
|
||||
{
|
||||
for (label j=i; j>=0; j--)
|
||||
for (label i = instanceI; i >= 0; --i)
|
||||
{
|
||||
fileName testName(d.path()/ts[j].name()/subdirName/foamName);
|
||||
fileName testName(d.path()/ts[i].name()/subdirName/foamName);
|
||||
|
||||
if (file(testName))
|
||||
{
|
||||
@ -166,14 +165,14 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
}
|
||||
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
Foam::surfGroupList
|
||||
Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
// Returns region info.
|
||||
// Sets faceMap to the indexing according to region numbers.
|
||||
// Region numbers start at 0.
|
||||
Foam::surfRegionList
|
||||
Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
|
||||
(
|
||||
const UList<label>& regionLst,
|
||||
const Map<word>& patchNames,
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames,
|
||||
labelList& faceMap
|
||||
)
|
||||
{
|
||||
@ -185,11 +184,11 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
// Assuming that we have relatively fewer regions compared to the
|
||||
// number of items, just do it ourselves
|
||||
|
||||
// step 1: get region sizes and store (regionId => patchI)
|
||||
// step 1: get region sizes and store (regionId => regionI)
|
||||
Map<label> lookup;
|
||||
forAll(regionLst, faceI)
|
||||
forAll(regionIds, faceI)
|
||||
{
|
||||
const label regId = regionLst[faceI];
|
||||
const label regId = regionIds[faceI];
|
||||
|
||||
Map<label>::iterator fnd = lookup.find(regId);
|
||||
if (fnd != lookup.end())
|
||||
@ -202,52 +201,53 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: assign start/size (and name) to the newPatches
|
||||
// re-use the lookup to map (regionId => patchI)
|
||||
surfGroupList patchLst(lookup.size());
|
||||
// step 2: assign start/size (and name) to the newRegions
|
||||
// re-use the lookup to map (regionId => regionI)
|
||||
surfRegionList regionLst(lookup.size());
|
||||
label start = 0;
|
||||
label patchI = 0;
|
||||
label regionI = 0;
|
||||
forAllIter(Map<label>, lookup, iter)
|
||||
{
|
||||
label regId = iter.key();
|
||||
|
||||
word name;
|
||||
Map<word>::const_iterator fnd = patchNames.find(regId);
|
||||
if (fnd != patchNames.end())
|
||||
Map<word>::const_iterator fnd = regionNames.find(regId);
|
||||
if (fnd != regionNames.end())
|
||||
{
|
||||
name = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = word("patch") + ::Foam::name(patchI);
|
||||
name = word("region") + ::Foam::name(regionI);
|
||||
}
|
||||
|
||||
patchLst[patchI] = surfGroup
|
||||
regionLst[regionI] = surfRegion
|
||||
(
|
||||
name,
|
||||
0, // initialize with zero size
|
||||
start,
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
// increment the start for the next patch
|
||||
// and save the (regionId => patchI) mapping
|
||||
// increment the start for the next region
|
||||
// and save the (regionId => regionI) mapping
|
||||
start += iter();
|
||||
iter() = patchI++;
|
||||
iter() = regionI++;
|
||||
}
|
||||
|
||||
|
||||
// step 3: build the re-ordering
|
||||
faceMap.setSize(regionLst.size());
|
||||
faceMap.setSize(regionIds.size());
|
||||
|
||||
forAll(regionLst, faceI)
|
||||
forAll(regionIds, faceI)
|
||||
{
|
||||
label patchI = lookup[regionLst[faceI]];
|
||||
faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++;
|
||||
label regionI = lookup[regionIds[faceI]];
|
||||
faceMap[faceI] =
|
||||
regionLst[regionI].start() + regionLst[regionI].size()++;
|
||||
}
|
||||
|
||||
// with reordered faces registered in faceMap
|
||||
return patchLst;
|
||||
return regionLst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,11 +36,11 @@ SourceFiles
|
||||
#ifndef surfaceFormatsCore_H
|
||||
#define surfaceFormatsCore_H
|
||||
|
||||
#include "surfPatchIdentifierList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "labelList.H"
|
||||
#include "Map.H"
|
||||
#include "HashSet.H"
|
||||
#include "labelList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -69,6 +69,7 @@ public:
|
||||
static word meshSubDir;
|
||||
|
||||
//- The file extension corresponding to 'native' surface format
|
||||
// Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
|
||||
static word nativeExt;
|
||||
|
||||
// Static Member Functions
|
||||
@ -91,12 +92,12 @@ public:
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName findMeshName(const Time&);
|
||||
|
||||
//- Determine the sort order from the region list.
|
||||
// Returns patch list and sets faceMap to indices within faceLst
|
||||
static surfGroupList sortedPatchRegions
|
||||
//- Determine the sort order from the region ids.
|
||||
// Returns region list and sets faceMap to indices within faceLst
|
||||
static surfRegionList sortedRegionsById
|
||||
(
|
||||
const UList<label>& regionLst,
|
||||
const Map<word>& patchNames,
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames,
|
||||
labelList& faceMap
|
||||
);
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const label patchI
|
||||
const label regionI
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
@ -54,7 +54,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
||||
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
|
||||
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
|
||||
// region as colour
|
||||
<< "0x" << hex << patchI << dec << endl;
|
||||
<< "0x" << hex << regionI << dec << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,10 +89,10 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
|
||||
// retrieve the original region information
|
||||
List<label> sizes(reader.sizes().xfer());
|
||||
List<label> regions(reader.regions().xfer());
|
||||
List<label> regionIds(reader.regionIds().xfer());
|
||||
|
||||
// generate the (sorted) faces
|
||||
List<Face> faceLst(regions.size());
|
||||
List<Face> faceLst(regionIds.size());
|
||||
|
||||
if (reader.sorted())
|
||||
{
|
||||
@ -108,7 +108,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
// unsorted - determine the sorted order:
|
||||
// avoid SortableList since we discard the main list anyhow
|
||||
List<label> faceMap;
|
||||
sortedOrder(regions, faceMap);
|
||||
sortedOrder(regionIds, faceMap);
|
||||
|
||||
// generate sorted faces
|
||||
forAll(faceMap, faceI)
|
||||
@ -117,12 +117,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
||||
}
|
||||
}
|
||||
regions.clear();
|
||||
regionIds.clear();
|
||||
|
||||
// transfer:
|
||||
this->storedFaces().transfer(faceLst);
|
||||
|
||||
this->addPatches(sizes);
|
||||
this->addRegions(sizes);
|
||||
this->stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
@ -137,15 +137,15 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
writeShell(os, pointLst, f, patchI);
|
||||
writeShell(os, pointLst, f, regionI);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
|
||||
bool doSort = false;
|
||||
// a single region needs no sorting
|
||||
if (surf.patches().size() == 1)
|
||||
if (surf.regionToc().size() == 1)
|
||||
{
|
||||
doSort = false;
|
||||
}
|
||||
@ -171,25 +171,25 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
if (doSort)
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
writeShell(os, pointLst, f, patchI);
|
||||
writeShell(os, pointLst, f, regionI);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const List<label>& regionIds = surf.regionIds();
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell(os, pointLst, faceLst[faceI], regionLst[faceI]);
|
||||
writeShell(os, pointLst, faceLst[faceI], regionIds[faceI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ class TRIsurfaceFormat
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const Face&,
|
||||
const label patchI
|
||||
const label regionI
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::fileFormats::TRIsurfaceFormatCore::TRIsurfaceFormatCore
|
||||
:
|
||||
sorted_(true),
|
||||
points_(0),
|
||||
regions_(0),
|
||||
regionIds_(0),
|
||||
sizes_(0)
|
||||
{
|
||||
read(filename);
|
||||
@ -83,10 +83,10 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
DynamicList<label> dynSizes;
|
||||
HashTable<label> lookup;
|
||||
|
||||
// place faces without a group in patch0
|
||||
// place faces without a group in region0
|
||||
label regionI = 0;
|
||||
dynSizes.append(regionI);
|
||||
lookup.insert("patch0", regionI);
|
||||
lookup.insert("regionI", regionI);
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
@ -132,13 +132,13 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
|
||||
// Region/colour in .tri file starts with 0x. Skip.
|
||||
// ie, instead of having 0xFF, skip 0 and leave xFF to
|
||||
// get read as a word and name it "patchFF"
|
||||
// get read as a word and name it "regionFF"
|
||||
|
||||
char zero;
|
||||
lineStream >> zero;
|
||||
|
||||
word rawName(lineStream);
|
||||
word name("patch" + rawName(1, rawName.size()-1));
|
||||
word name("region" + rawName(1, rawName.size()-1));
|
||||
|
||||
HashTable<label>::const_iterator fnd = lookup.find(name);
|
||||
if (fnd != lookup.end())
|
||||
@ -162,24 +162,24 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
}
|
||||
|
||||
// skip empty groups
|
||||
label nPatch = 0;
|
||||
forAll(dynSizes, patchI)
|
||||
label nRegion = 0;
|
||||
forAll(dynSizes, regionI)
|
||||
{
|
||||
if (dynSizes[patchI])
|
||||
if (dynSizes[regionI])
|
||||
{
|
||||
if (nPatch != patchI)
|
||||
if (nRegion != regionI)
|
||||
{
|
||||
dynSizes[nPatch] = dynSizes[patchI];
|
||||
dynSizes[nRegion] = dynSizes[regionI];
|
||||
}
|
||||
nPatch++;
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
// truncate addressed size
|
||||
dynSizes.setCapacity(nPatch);
|
||||
dynSizes.setCapacity(nRegion);
|
||||
|
||||
// transfer to normal lists
|
||||
points_.transfer(dynPoints);
|
||||
regions_.transfer(dynRegions);
|
||||
regionIds_.transfer(dynRegions);
|
||||
sizes_.transfer(dynSizes);
|
||||
|
||||
return true;
|
||||
|
||||
@ -65,7 +65,7 @@ class TRIsurfaceFormatCore
|
||||
pointField points_;
|
||||
|
||||
//- The regions associated with the faces
|
||||
List<label> regions_;
|
||||
List<label> regionIds_;
|
||||
|
||||
//- The solid count, in the order of their first appearance
|
||||
List<label> sizes_;
|
||||
@ -104,7 +104,7 @@ public:
|
||||
{
|
||||
sorted_ = true;
|
||||
points_.clear();
|
||||
regions_.clear();
|
||||
regionIds_.clear();
|
||||
sizes_.clear();
|
||||
}
|
||||
|
||||
@ -115,9 +115,9 @@ public:
|
||||
}
|
||||
|
||||
//- Return full access to the regions
|
||||
List<label>& regions()
|
||||
List<label>& regionIds()
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- The list of region sizes in the order of their first appearance
|
||||
|
||||
@ -33,7 +33,7 @@ template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
|
||||
(
|
||||
Ostream& os,
|
||||
const List<Face>& faceLst
|
||||
const UList<Face>& faceLst
|
||||
)
|
||||
{
|
||||
label nNodes = 0;
|
||||
@ -66,15 +66,15 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, surf.points());
|
||||
writeHeaderPolygons(os, faceLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
@ -87,8 +87,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
}
|
||||
}
|
||||
|
||||
// Print region numbers
|
||||
writeTail(os, patchLst);
|
||||
writeTail(os, regionLst);
|
||||
}
|
||||
|
||||
|
||||
@ -116,8 +115,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
os << ' ' << nl;
|
||||
}
|
||||
|
||||
// Print region numbers
|
||||
writeTail(os, surf.regions());
|
||||
writeTail(os, surf.regionIds());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
Provide a means of writing VTK legacy format.
|
||||
The output is never sorted by patch.
|
||||
The output is never sorted by region.
|
||||
|
||||
SourceFiles
|
||||
VTKsurfaceFormat.C
|
||||
@ -63,7 +63,7 @@ class VTKsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Write header information about number of polygon points
|
||||
static void writeHeaderPolygons(Ostream&, const List<Face>&);
|
||||
static void writeHeaderPolygons(Ostream&, const UList<Face>&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);
|
||||
|
||||
@ -58,13 +58,13 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
|
||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
label nFaces = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
nFaces += patchLst[patchI].size();
|
||||
nFaces += regionLst[regionI].size();
|
||||
}
|
||||
|
||||
// Print region numbers
|
||||
@ -74,22 +74,22 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||
<< "region 1 " << nFaces << " float" << nl;
|
||||
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
if (patchFaceI)
|
||||
if (localFaceI)
|
||||
{
|
||||
if ((patchFaceI % 20) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
if (localFaceI % 20)
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
os << patchI + 1;
|
||||
os << regionI + 1;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
@ -99,30 +99,30 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||
(
|
||||
Ostream& os,
|
||||
const List<label>& regionLst
|
||||
const UList<label>& regionIds
|
||||
)
|
||||
{
|
||||
// Print region numbers
|
||||
os << nl
|
||||
<< "CELL_DATA " << regionLst.size() << nl
|
||||
<< "CELL_DATA " << regionIds.size() << nl
|
||||
<< "FIELD attributes 1" << nl
|
||||
<< "region 1 " << regionLst.size() << " float" << nl;
|
||||
<< "region 1 " << regionIds.size() << " float" << nl;
|
||||
|
||||
|
||||
forAll(regionLst, faceI)
|
||||
forAll(regionIds, faceI)
|
||||
{
|
||||
if (faceI)
|
||||
{
|
||||
if ((faceI % 20) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
if (faceI % 20)
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
os << regionLst[faceI] + 1;
|
||||
os << regionIds[faceI] + 1;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
@ -64,11 +64,11 @@ protected:
|
||||
const pointField&
|
||||
);
|
||||
|
||||
//- Write trailing information with patch information
|
||||
static void writeTail(Ostream&, const List<surfGroup>&);
|
||||
|
||||
//- Write trailing information with region information
|
||||
static void writeTail(Ostream&, const List<label>& regionLst);
|
||||
static void writeTail(Ostream&, const UList<surfRegion>&);
|
||||
|
||||
//- Write trailing information with region Ids
|
||||
static void writeTail(Ostream&, const UList<label>& regionIds);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user