Commit 8e20b359 authored by mark's avatar mark
Browse files

ENH: improve interoperability of triSurface with other surface mesh classes

- make it easier to transfer triSurface information into MeshedSurface
  etc.
parent 553eb379
......@@ -41,7 +41,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier()
{}
Foam::surfZoneIdentifier::surfZoneIdentifier(label index)
Foam::surfZoneIdentifier::surfZoneIdentifier(const label index)
:
name_(),
index_(index),
......
......@@ -86,10 +86,7 @@ public:
surfZoneIdentifier();
//- Construct null with specified index
explicit surfZoneIdentifier
(
const label index
);
explicit surfZoneIdentifier(const label index);
//- Construct from components
surfZoneIdentifier
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "surfacePatch.H"
#include "surfZone.H"
#include "dictionary.H"
#include "word.H"
......@@ -38,7 +39,15 @@ namespace Foam
Foam::surfacePatch::surfacePatch()
:
geometricSurfacePatch("", "", -1),
geometricSurfacePatch(word::null, word::null, -1),
size_(0),
start_(0)
{}
Foam::surfacePatch::surfacePatch(const label index)
:
geometricSurfacePatch(word::null, word::null, index),
size_(0),
start_(0)
{}
......@@ -83,7 +92,7 @@ Foam::surfacePatch::surfacePatch
{}
Foam::surfacePatch::surfacePatch(const Foam::surfacePatch& sp)
Foam::surfacePatch::surfacePatch(const surfacePatch& sp)
:
geometricSurfacePatch(sp),
size_(sp.size()),
......@@ -114,6 +123,19 @@ void Foam::surfacePatch::writeDict(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::surfacePatch::operator Foam::surfZone() const
{
return surfZone
(
this->name(),
this->size(),
this->start(),
this->index(),
this->geometricType()
);
}
bool Foam::surfacePatch::operator!=(const surfacePatch& p) const
{
return !(*this == p);
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -36,8 +36,6 @@ SourceFiles
#define surfacePatch_H
#include "geometricSurfacePatch.H"
#include "word.H"
#include "label.H"
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -48,12 +46,13 @@ namespace Foam
// Forward declaration of friend functions and operators
class surfacePatch;
class surfZone;
Ostream& operator<<(Ostream&, const surfacePatch&);
/*---------------------------------------------------------------------------*\
Class surfacePatch Declaration
Class surfacePatch Declaration
\*---------------------------------------------------------------------------*/
class surfacePatch
......@@ -79,6 +78,9 @@ public:
//- Construct null
surfacePatch();
//- Construct null with specified index
explicit surfacePatch(const label index);
//- Construct from components
surfacePatch
(
......@@ -106,25 +108,25 @@ public:
// Member Functions
//- Return start label of this patch in the polyMesh face list
//- Return start label of this patch in the face list
label start() const
{
return start_;
}
//- Return start label of this patch in the polyMesh face list
//- Return start label of this patch in the face list
label& start()
{
return start_;
}
//- Return size of this patch in the polyMesh face list
//- Return size of this patch in the face list
label size() const
{
return size_;
}
//- Return size of this patch in the polyMesh face list
//- Return size of this patch in the face list
label& size()
{
return size_;
......@@ -139,11 +141,17 @@ public:
// Member Operators
//- Conversion to surfZone representation
explicit operator surfZone() const;
//- Compare.
bool operator!=(const surfacePatch&) const;
//- compare.
//- Compare.
bool operator==(const surfacePatch&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const surfacePatch&);
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,6 +31,7 @@ License
#include "boundBox.H"
#include "SortableList.H"
#include "PackedBoolList.H"
#include "surfZoneList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -488,7 +489,8 @@ void Foam::triSurface::write
// Returns patch info. Sets faceMap to the indexing according to patch
// numbers. Patch numbers start at 0.
Foam::surfacePatchList Foam::triSurface::calcPatches(labelList& faceMap) const
Foam::surfacePatchList
Foam::triSurface::calcPatches(labelList& faceMap) const
{
// Sort according to region numbers of labelledTri
SortableList<label> sortedRegion(size());
......@@ -533,30 +535,29 @@ Foam::surfacePatchList Foam::triSurface::calcPatches(labelList& faceMap) const
surfacePatch& newPatch = newPatches[newPatchi];
newPatch.index() = newPatchi;
label oldPatchi = newPatchi;
// start of patch
newPatch.start() = startFacei;
// Take over any information from existing patches
if ((oldPatchi < patches_.size()) && (patches_[oldPatchi].name() != ""))
if
(
newPatchi < patches_.size()
&& !patches_[newPatchi].name().empty()
)
{
newPatch.name() = patches_[oldPatchi].name();
newPatch.name() = patches_[newPatchi].name();
}
else
{
newPatch.name() = word("patch") + name(newPatchi);
newPatch.name() = word("patch") + Foam::name(newPatchi);
}
if
(
(oldPatchi < patches_.size())
&& (patches_[oldPatchi].geometricType() != "")
newPatchi < patches_.size()
&& !patches_[newPatchi].geometricType().empty()
)
{
newPatch.geometricType() = patches_[oldPatchi].geometricType();
newPatch.geometricType() = patches_[newPatchi].geometricType();
}
else
{
......@@ -829,6 +830,42 @@ void Foam::triSurface::cleanup(const bool verbose)
}
Foam::List<Foam::surfZone>
Foam::triSurface::sortedZones(labelList& faceMap) const
{
surfacePatchList patches(calcPatches(faceMap));
surfZoneList zones(patches.size());
forAll(patches, patchi)
{
zones[patchi] = surfZone(patches[patchi]);
}
return zones;
}
void Foam::triSurface::triFaceFaces(List<face>& plainFaces) const
{
plainFaces.setSize(size());
forAll(*this, facei)
{
plainFaces[facei] = operator[](facei).triFaceFace();
}
}
Foam::Xfer<Foam::List<Foam::point>>
Foam::triSurface::xferPoints()
{
// Topology changed because of transfer
clearOut();
return this->storedPoints().xfer();
}
// Finds area, starting at facei, delimited by borderEdge. Marks all visited
// faces (from face-edge-face walk) with currentZone.
void Foam::triSurface::markZone
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -50,7 +50,7 @@ namespace Foam
class Time;
class IFstream;
class surfZone;
// Forward declaration of friend functions and operators
......@@ -354,6 +354,17 @@ public:
}
// Interoperability with other surface mesh classes
//- Sort faces according to zoneIds
// Returns a surfZoneList and sets faceMap to index within faces()
// (i.e. map from original,unsorted to sorted)
List<surfZone> sortedZones(labelList& faceMap) const;
//- Create a list of faces from the triFaces
void triFaceFaces(List<face>& plainFaceList) const;
// Edit
//- Move points
......@@ -412,6 +423,10 @@ public:
) const;
//- Transfer stored points to an Xfer container
Xfer<List<point>> xferPoints();
// Write
//- Write to Ostream in simple FOAM format
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment