Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
mattijs
2016-12-05 08:54:15 +00:00
28 changed files with 466 additions and 313 deletions

View File

@ -81,6 +81,10 @@ int main(int argc, char *argv[])
} }
Pout<< "zero scalar (time): " << dimensionedScalar(dimTime) << endl;
Pout<< "zero vector: " << dimensionedVector(dimLength) << endl;
Pout<< "zero tensor: " << dimensionedTensor(dimLength) << endl;
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -55,6 +55,7 @@ Usage
#include "triangle.H" #include "triangle.H"
#include "triSurface.H" #include "triSurface.H"
#include "triSurfaceSearch.H" #include "triSurfaceSearch.H"
#include "triSurfaceTools.H"
#include "argList.H" #include "argList.H"
#include "OFstream.H" #include "OFstream.H"
#include "OBJstream.H" #include "OBJstream.H"
@ -64,79 +65,6 @@ Usage
using namespace Foam; using namespace Foam;
// Does face use valid vertices?
bool validTri
(
const bool verbose,
const triSurface& surf,
const label facei
)
{
// Simple check on indices ok.
const labelledTri& f = surf[facei];
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
return false;
}
}
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
WarningInFunction
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFacei = fFaces[i];
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFacei];
if
(
((f[0] == nbrF[0]) || (f[0] == nbrF[1]) || (f[0] == nbrF[2]))
&& ((f[1] == nbrF[0]) || (f[1] == nbrF[1]) || (f[1] == nbrF[2]))
&& ((f[2] == nbrF[0]) || (f[2] == nbrF[1]) || (f[2] == nbrF[2]))
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
}
return true;
}
labelList countBins labelList countBins
( (
const scalar min, const scalar min,
@ -377,14 +305,12 @@ int main(int argc, char *argv[])
const fileName surfFileName = args[1]; const fileName surfFileName = args[1];
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection"); const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
const bool verbose = args.optionFound("verbose");
const bool splitNonManifold = args.optionFound("splitNonManifold"); const bool splitNonManifold = args.optionFound("splitNonManifold");
label outputThreshold = 10; label outputThreshold = 10;
args.optionReadIfPresent("outputThreshold", outputThreshold); args.optionReadIfPresent("outputThreshold", outputThreshold);
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl; Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
// Read // Read
// ~~~~ // ~~~~
@ -479,7 +405,7 @@ int main(int argc, char *argv[])
forAll(surf, facei) forAll(surf, facei)
{ {
if (!validTri(verbose, surf, facei)) if (!triSurfaceTools::validTri(surf, facei))
{ {
illegalFaces.append(facei); illegalFaces.append(facei);
} }

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
argList::addBoolOption argList::addBoolOption
( (
"noClean", "noClean",
"perform some surface checking/cleanup on the input surface" "suppress surface checking/cleanup on the input surface"
); );
argList args(argc, argv); argList args(argc, argv);

View File

@ -91,7 +91,11 @@ int main(int argc, char *argv[])
argList::validArgs.append("inputFile"); argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile"); argList::validArgs.append("outputFile");
argList::addBoolOption("clean"); argList::addBoolOption
(
"clean",
"perform some surface checking/cleanup on the input surface"
);
argList::addBoolOption argList::addBoolOption
( (
"orient", "orient",

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -169,6 +169,18 @@ Foam::dimensioned<Type>::dimensioned
{} {}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const dimensionSet& dimSet
)
:
name_("0"),
dimensions_(dimSet),
value_(Zero)
{}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type> template<class Type>

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -117,9 +117,12 @@ public:
//- Construct from dictionary lookup with a given name and dimensions //- Construct from dictionary lookup with a given name and dimensions
dimensioned(const word&, const dimensionSet&, const dictionary&); dimensioned(const word&, const dimensionSet&, const dictionary&);
//- Null constructor //- Null constructor - a dimensionless Zero, named "undefined"
dimensioned(); dimensioned();
//- A dimensioned Zero, named "0"
explicit dimensioned(const dimensionSet&);
// Static member functions // Static member functions

View File

@ -41,7 +41,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier()
{} {}
Foam::surfZoneIdentifier::surfZoneIdentifier(label index) Foam::surfZoneIdentifier::surfZoneIdentifier(const label index)
: :
name_(), name_(),
index_(index), index_(index),

View File

@ -86,10 +86,7 @@ public:
surfZoneIdentifier(); surfZoneIdentifier();
//- Construct null with specified index //- Construct null with specified index
explicit surfZoneIdentifier explicit surfZoneIdentifier(const label index);
(
const label index
);
//- Construct from components //- Construct from components
surfZoneIdentifier surfZoneIdentifier

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
#include "triSurfaceTools.H" #include "triSurfaceTools.H"
#include "triSurface.H" #include "triSurface.H"
#include "MeshedSurface.H"
#include "OFstream.H" #include "OFstream.H"
#include "mergePoints.H" #include "mergePoints.H"
#include "polyMesh.H" #include "polyMesh.H"
@ -2743,8 +2744,168 @@ void Foam::triSurfaceTools::calcInterpolationWeights
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Tracking: // Checking:
bool Foam::triSurfaceTools::validTri
(
const triSurface& surf,
const label facei
)
{
typedef labelledTri FaceType;
const FaceType& f = surf[facei];
// Simple check on indices ok.
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1
<< endl;
return false;
}
}
if (f[0] == f[1] || f[0] == f[2] || f[1] == f[2])
{
WarningInFunction
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFacei = fFaces[i];
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const FaceType& nbrF = surf[nbrFacei];
// Same as calling triFace::compare(f, nbrF) == 1 only
if
(
(f[0] == nbrF[0] || f[0] == nbrF[1] || f[0] == nbrF[2])
&& (f[1] == nbrF[0] || f[1] == nbrF[1] || f[1] == nbrF[2])
&& (f[2] == nbrF[0] || f[2] == nbrF[1] || f[2] == nbrF[2])
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
}
return true;
}
bool Foam::triSurfaceTools::validTri
(
const MeshedSurface<face>& surf,
const label facei
)
{
typedef face FaceType;
const FaceType& f = surf[facei];
if (f.size() != 3)
{
WarningInFunction
<< "face " << facei
<< " is not a triangle, it has " << f.size()
<< " indices"
<< endl;
return false;
}
// Simple check on indices ok.
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1
<< endl;
return false;
}
}
if (f[0] == f[1] || f[0] == f[2] || f[1] == f[2])
{
WarningInFunction
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFacei = fFaces[i];
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const FaceType& nbrF = surf[nbrFacei];
// Same as calling triFace::compare(f, nbrF) == 1 only
if
(
(f[0] == nbrF[0] || f[0] == nbrF[1] || f[0] == nbrF[2])
&& (f[1] == nbrF[0] || f[1] == nbrF[1] || f[1] == nbrF[2])
&& (f[2] == nbrF[0] || f[2] == nbrF[1] || f[2] == nbrF[2])
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " coords:" << f.points(surf.points())
<< endl;
return false;
}
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Tracking:
// Test point on surface to see if is on face,edge or point. // Test point on surface to see if is on face,edge or point.
Foam::surfaceLocation Foam::triSurfaceTools::classify Foam::surfaceLocation Foam::triSurfaceTools::classify

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,11 +50,14 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class triSurface;
class edge; class edge;
class labelledTri; class labelledTri;
class polyBoundaryMesh; class polyBoundaryMesh;
class plane; class plane;
class triSurface;
class face;
template<class Face> class MeshedSurface;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class triSurfaceTools Declaration Class triSurfaceTools Declaration
@ -516,6 +519,15 @@ public:
static triSurface delaunay2D(const List<vector2D>&); static triSurface delaunay2D(const List<vector2D>&);
// Surface checking functionality
//- Check single triangle for (topological) validity
static bool validTri(const triSurface&, const label facei);
//- Check single triangle for (topological) validity
static bool validTri(const MeshedSurface<face>&, const label facei);
// Tracking // Tracking
//- Test point on plane of triangle to see if on edge or point or inside //- Test point on plane of triangle to see if on edge or point or inside

View File

@ -55,7 +55,7 @@ void Foam::cuttingPlane::calcCutCells
listSize = cellIdLabels.size(); listSize = cellIdLabels.size();
} }
cutCells_.setSize(listSize); meshCells_.setSize(listSize);
label cutcelli(0); label cutcelli(0);
// Find the cut cells by detecting any cell that uses points with // Find the cut cells by detecting any cell that uses points with
@ -70,9 +70,7 @@ void Foam::cuttingPlane::calcCutCells
} }
const labelList& cEdges = cellEdges[celli]; const labelList& cEdges = cellEdges[celli];
label nCutEdges = 0; label nCutEdges = 0;
forAll(cEdges, i) forAll(cEdges, i)
{ {
const edge& e = edges[cEdges[i]]; const edge& e = edges[cEdges[i]];
@ -87,8 +85,7 @@ void Foam::cuttingPlane::calcCutCells
if (nCutEdges > 2) if (nCutEdges > 2)
{ {
cutCells_[cutcelli++] = celli; meshCells_[cutcelli++] = celli;
break; break;
} }
} }
@ -96,7 +93,7 @@ void Foam::cuttingPlane::calcCutCells
} }
// Set correct list size // Set correct list size
cutCells_.setSize(cutcelli); meshCells_.setSize(cutcelli);
} }
@ -114,7 +111,7 @@ void Foam::cuttingPlane::intersectEdges
// Per edge -1 or the label of the intersection point // Per edge -1 or the label of the intersection point
edgePoint.setSize(edges.size()); edgePoint.setSize(edges.size());
DynamicList<point> dynCuttingPoints(4*cutCells_.size()); DynamicList<point> dynCuttingPoints(4*meshCells_.size());
forAll(edges, edgeI) forAll(edges, edgeI)
{ {
@ -258,15 +255,15 @@ void Foam::cuttingPlane::walkCellCuts
const pointField& cutPoints = this->points(); const pointField& cutPoints = this->points();
// use dynamic lists to handle triangulation and/or missed cuts // use dynamic lists to handle triangulation and/or missed cuts
DynamicList<face> dynCutFaces(cutCells_.size()); DynamicList<face> dynCutFaces(meshCells_.size());
DynamicList<label> dynCutCells(cutCells_.size()); DynamicList<label> dynCutCells(meshCells_.size());
// scratch space for calculating the face vertices // scratch space for calculating the face vertices
DynamicList<label> faceVerts(10); DynamicList<label> faceVerts(10);
forAll(cutCells_, i) forAll(meshCells_, i)
{ {
label celli = cutCells_[i]; label celli = meshCells_[i];
// Find the starting edge to walk from. // Find the starting edge to walk from.
const labelList& cEdges = mesh.cellEdges()[celli]; const labelList& cEdges = mesh.cellEdges()[celli];
@ -330,20 +327,18 @@ void Foam::cuttingPlane::walkCellCuts
} }
this->storedFaces().transfer(dynCutFaces); this->storedFaces().transfer(dynCutFaces);
cutCells_.transfer(dynCutCells); meshCells_.transfer(dynCutCells);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct without cutting
Foam::cuttingPlane::cuttingPlane(const plane& pln) Foam::cuttingPlane::cuttingPlane(const plane& pln)
: :
plane(pln) plane(pln)
{} {}
// Construct from plane and mesh reference, restricted to a list of cells
Foam::cuttingPlane::cuttingPlane Foam::cuttingPlane::cuttingPlane
( (
const plane& pln, const plane& pln,
@ -369,7 +364,7 @@ void Foam::cuttingPlane::reCut
) )
{ {
MeshStorage::clear(); MeshStorage::clear();
cutCells_.clear(); meshCells_.clear();
const scalarField dotProducts((mesh.points() - refPoint()) & normal()); const scalarField dotProducts((mesh.points() - refPoint()) & normal());
@ -391,7 +386,7 @@ void Foam::cuttingPlane::remapFaces
const labelUList& faceMap const labelUList& faceMap
) )
{ {
// recalculate the cells cut // Recalculate the cells cut
if (notNull(faceMap) && faceMap.size()) if (notNull(faceMap) && faceMap.size())
{ {
MeshStorage::remapFaces(faceMap); MeshStorage::remapFaces(faceMap);
@ -399,9 +394,9 @@ void Foam::cuttingPlane::remapFaces
List<label> newCutCells(faceMap.size()); List<label> newCutCells(faceMap.size());
forAll(faceMap, facei) forAll(faceMap, facei)
{ {
newCutCells[facei] = cutCells_[faceMap[facei]]; newCutCells[facei] = meshCells_[faceMap[facei]];
} }
cutCells_.transfer(newCutCells); meshCells_.transfer(newCutCells);
} }
} }
@ -420,7 +415,7 @@ void Foam::cuttingPlane::operator=(const cuttingPlane& rhs)
static_cast<MeshStorage&>(*this) = rhs; static_cast<MeshStorage&>(*this) = rhs;
static_cast<plane&>(*this) = rhs; static_cast<plane&>(*this) = rhs;
cutCells_ = rhs.cutCells(); meshCells_ = rhs.meshCells();
} }

View File

@ -70,7 +70,7 @@ class cuttingPlane
// Private data // Private data
//- List of cells cut by the plane //- List of cells cut by the plane
labelList cutCells_; labelList meshCells_;
// Private Member Functions // Private Member Functions
@ -121,7 +121,7 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Recut mesh with existing planeDesc, restricted to a list of cells //- Recut mesh with existing plane, restricted to a list of cells
void reCut void reCut
( (
const primitiveMesh&, const primitiveMesh&,
@ -157,15 +157,15 @@ public:
} }
//- Return List of cells cut by the plane //- Return List of cells cut by the plane
const labelList& cutCells() const const labelList& meshCells() const
{ {
return cutCells_; return meshCells_;
} }
//- Return true or false to question: have any cells been cut? //- Return true or false to question: have any cells been cut?
bool cut() const bool cut() const
{ {
return cutCells_.size(); return meshCells_.size();
} }
//- Sample the cell field //- Sample the cell field

View File

@ -28,8 +28,6 @@ Description
#include "cuttingPlane.H" #include "cuttingPlane.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
@ -38,7 +36,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cuttingPlane::sample
const Field<Type>& fld const Field<Type>& fld
) const ) const
{ {
return tmp<Field<Type>>(new Field<Type>(fld, cutCells())); return tmp<Field<Type>>(new Field<Type>(fld, meshCells()));
} }

View File

@ -33,6 +33,7 @@ License
#include "OFstream.H" #include "OFstream.H"
#include "meshTools.H" #include "meshTools.H"
#include "triSurfaceSearch.H" #include "triSurfaceSearch.H"
#include "triSurfaceTools.H"
#include "surfaceIntersection.H" #include "surfaceIntersection.H"
#include "intersectedSurface.H" #include "intersectedSurface.H"
#include "searchableBox.H" #include "searchableBox.H"
@ -1257,76 +1258,6 @@ void Foam::isoSurface::trimToBox
} }
bool Foam::isoSurface::validTri(const triSurface& surf, const label facei)
{
// Simple check on indices ok.
const labelledTri& f = surf[facei];
if
(
(f[0] < 0) || (f[0] >= surf.points().size())
|| (f[1] < 0) || (f[1] >= surf.points().size())
|| (f[2] < 0) || (f[2] >= surf.points().size())
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
return false;
}
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
WarningInFunction
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< endl;
return false;
}
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFacei = fFaces[i];
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFacei];
if
(
((f[0] == nbrF[0]) || (f[0] == nbrF[1]) || (f[0] == nbrF[2]))
&& ((f[1] == nbrF[0]) || (f[1] == nbrF[1]) || (f[1] == nbrF[2]))
&& ((f[2] == nbrF[0]) || (f[2] == nbrF[1]) || (f[2] == nbrF[2]))
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " fc:" << f.centre(surf.points())
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " fc:" << nbrF.centre(surf.points())
<< endl;
return false;
}
}
return true;
}
Foam::triSurface Foam::isoSurface::subsetMesh Foam::triSurface Foam::isoSurface::subsetMesh
( (
const triSurface& s, const triSurface& s,
@ -1756,8 +1687,7 @@ Foam::isoSurface::isoSurface
forAll(*this, triI) forAll(*this, triI)
{ {
// Copied from surfaceCheck triSurfaceTools::validTri(*this, triI);
validTri(*this, triI);
} }
fileName stlFile = mesh_.time().path() + ".stl"; fileName stlFile = mesh_.time().path() + ".stl";

View File

@ -377,9 +377,6 @@ class isoSurface
List<FixedList<scalar, 3>>& interpolationWeights List<FixedList<scalar, 3>>& interpolationWeights
); );
//- Check single triangle for (topological) validity
static bool validTri(const triSurface&, const label facei);
static triSurface subsetMesh static triSurface subsetMesh
( (
const triSurface& s, const triSurface& s,

View File

@ -29,6 +29,7 @@ License
#include "mergePoints.H" #include "mergePoints.H"
#include "tetMatcher.H" #include "tetMatcher.H"
#include "syncTools.H" #include "syncTools.H"
#include "triSurfaceTools.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Time.H" #include "Time.H"
#include "triPoints.H" #include "triPoints.H"
@ -1049,73 +1050,6 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints
} }
bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label facei)
{
// Simple check on indices ok.
const labelledTri& f = surf[facei];
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
return false;
}
}
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
WarningInFunction
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< endl;
return false;
}
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFacei = fFaces[i];
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFacei];
if
(
((f[0] == nbrF[0]) || (f[0] == nbrF[1]) || (f[0] == nbrF[2]))
&& ((f[1] == nbrF[0]) || (f[1] == nbrF[1]) || (f[1] == nbrF[2]))
&& ((f[2] == nbrF[0]) || (f[2] == nbrF[1]) || (f[2] == nbrF[2]))
)
{
WarningInFunction
<< "triangle " << facei << " vertices " << f
<< " coords:" << f.points(surf.points())
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< endl;
return false;
}
}
return true;
}
void Foam::isoSurfaceCell::calcAddressing void Foam::isoSurfaceCell::calcAddressing
( (
const triSurface& surf, const triSurface& surf,
@ -1569,8 +1503,7 @@ Foam::isoSurfaceCell::isoSurfaceCell
forAll(*this, triI) forAll(*this, triI)
{ {
// Copied from surfaceCheck triSurfaceTools::validTri(*this, triI);
validTri(*this, triI);
} }
} }

View File

@ -272,9 +272,6 @@ class isoSurfaceCell
labelList& triMap // merged to unmerged triangle labelList& triMap // merged to unmerged triangle
) const; ) const;
//- Check single triangle for (topological) validity
static bool validTri(const triSurface&, const label);
//- Determine edge-face addressing //- Determine edge-face addressing
void calcAddressing void calcAddressing
( (

View File

@ -169,7 +169,7 @@ public:
//- For every face original cell in mesh //- For every face original cell in mesh
const labelList& meshCells() const const labelList& meshCells() const
{ {
return cuttingPlane::cutCells(); return cuttingPlane::meshCells();
} }
//- Sample field on surface //- Sample field on surface

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,8 +72,32 @@ Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
{
clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::MeshedSurfaceIOAllocator::setInstance(const fileName& inst)
{
points_.instance() = inst;
faces_.instance() = inst;
zones_.instance() = inst;
}
void Foam::MeshedSurfaceIOAllocator::setWriteOption(IOobject::writeOption w)
{
points_.writeOpt() = w;
faces_.writeOpt() = w;
zones_.writeOpt() = w;
}
void Foam::MeshedSurfaceIOAllocator::clear() void Foam::MeshedSurfaceIOAllocator::clear()
{ {
points_.clear(); points_.clear();
@ -136,4 +160,20 @@ void Foam::MeshedSurfaceIOAllocator::reset
} }
bool Foam::MeshedSurfaceIOAllocator::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
return
(
points_.writeObject(fmt, ver, cmp)
&& faces_.writeObject(fmt, ver, cmp)
&& zones_.writeObject(fmt, ver, cmp)
);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -106,8 +106,21 @@ public:
); );
//- Destructor
virtual ~MeshedSurfaceIOAllocator();
// Member Functions // Member Functions
// Database
//- Set the instance for mesh files
void setInstance(const fileName&);
//- Adjust the write option for all components
void setWriteOption(IOobject::writeOption);
// Access // Access
//- Non-const access to the points //- Non-const access to the points
@ -177,6 +190,18 @@ public:
const Xfer<faceList>& faces, const Xfer<faceList>& faces,
const Xfer<surfZoneList>& zones const Xfer<surfZoneList>& zones
); );
// Writing
//- Write using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat,
IOstream::versionNumber,
IOstream::compressionType
) const;
}; };

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -229,18 +229,25 @@ Foam::surfMesh::~surfMesh()
void Foam::surfMesh::updatePointsRef() void Foam::surfMesh::updatePointsRef()
{ {
// Assign the reference to the points (this is truly ugly) // Assign the reference to the points (quite ugly)
reinterpret_cast<SubField<point>&> // points() are returned as Field but are actually stored as SubField
reinterpret_cast<typename MeshReference::PointFieldType&>
( (
const_cast<Field<point>&>(MeshReference::points()) const_cast<Field<point>&>(MeshReference::points())
) = reinterpret_cast<SubField<point>&>(this->storedPoints()); ).shallowCopy
(
this->storedPoints()
);
} }
void Foam::surfMesh::updateFacesRef() void Foam::surfMesh::updateFacesRef()
{ {
// Assign the reference to the faces // Assign the reference to the faces (UList)
shallowCopy(this->storedFaces()); static_cast<MeshReference&>(*this).shallowCopy
(
this->storedFaces()
);
} }

View File

@ -200,7 +200,14 @@ public:
const fileName& facesInstance() const; const fileName& facesInstance() const;
//- Set the instance for mesh files //- Set the instance for mesh files
void setInstance(const fileName&); void setInstance
(
const fileName&,
IOobject::writeOption = IOobject::AUTO_WRITE
);
//- Adjust the write option for all components
void setWriteOption(IOobject::writeOption);
// Access // Access
@ -263,7 +270,6 @@ public:
// time directories // time directories
virtual readUpdateState readUpdate(); virtual readUpdateState readUpdate();
//- Update the mesh corresponding to given map
//- Remove surface zones //- Remove surface zones
void removeZones(); void removeZones();
@ -291,15 +297,26 @@ public:
void transfer(MeshedSurface<face>&); void transfer(MeshedSurface<face>&);
// Writing
//- Avoid masking the normal objectRegistry write //- Avoid masking the normal objectRegistry write
using surfaceRegistry::write; using surfaceRegistry::write;
//- Write all components using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const;
//- Write to file //- Write to file
static void write(const fileName&, const surfMesh&); static void write(const fileName&, const surfMesh&);
//- Write to file //- Write to file
void write(const fileName&); void write(const fileName&);
// Storage management // Storage management
//- Transfer contents to the Xfer container as a MeshedSurface //- Transfer contents to the Xfer container as a MeshedSurface
@ -322,6 +339,7 @@ public:
//- Remove all files from mesh instance() //- Remove all files from mesh instance()
void removeFiles() const; void removeFiles() const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::setInstance(const fileName& inst) void Foam::surfMesh::setInstance(const fileName& inst, IOobject::writeOption w)
{ {
if (debug) if (debug)
{ {
@ -36,15 +36,16 @@ void Foam::surfMesh::setInstance(const fileName& inst)
} }
instance() = inst; instance() = inst;
Allocator::setInstance(inst);
storedIOPoints().writeOpt() = IOobject::AUTO_WRITE; setWriteOption(w);
storedIOPoints().instance() = inst; }
storedIOFaces().writeOpt() = IOobject::AUTO_WRITE;
storedIOFaces().instance() = inst;
storedIOZones().writeOpt() = IOobject::AUTO_WRITE; void Foam::surfMesh::setWriteOption(IOobject::writeOption w)
storedIOZones().instance() = inst; {
writeOpt() = w;
Allocator::setWriteOption(w);
} }
@ -199,4 +200,15 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
} }
bool Foam::surfMesh::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
return Allocator::writeObject(fmt, ver, cmp);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "surfacePatch.H" #include "surfacePatch.H"
#include "surfZone.H"
#include "dictionary.H" #include "dictionary.H"
#include "word.H" #include "word.H"
@ -38,7 +39,15 @@ namespace Foam
Foam::surfacePatch::surfacePatch() 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), size_(0),
start_(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), geometricSurfacePatch(sp),
size_(sp.size()), size_(sp.size()),
@ -114,6 +123,19 @@ void Foam::surfacePatch::writeDict(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 bool Foam::surfacePatch::operator!=(const surfacePatch& p) const
{ {
return !(*this == p); return !(*this == p);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,8 +36,6 @@ SourceFiles
#define surfacePatch_H #define surfacePatch_H
#include "geometricSurfacePatch.H" #include "geometricSurfacePatch.H"
#include "word.H"
#include "label.H"
#include "className.H" #include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,6 +46,7 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class surfacePatch; class surfacePatch;
class surfZone;
Ostream& operator<<(Ostream&, const surfacePatch&); Ostream& operator<<(Ostream&, const surfacePatch&);
@ -79,6 +78,9 @@ public:
//- Construct null //- Construct null
surfacePatch(); surfacePatch();
//- Construct null with specified index
explicit surfacePatch(const label index);
//- Construct from components //- Construct from components
surfacePatch surfacePatch
( (
@ -106,25 +108,25 @@ public:
// Member Functions // 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 label start() const
{ {
return start_; 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() label& start()
{ {
return 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 label size() const
{ {
return size_; return size_;
} }
//- Return size of this patch in the polyMesh face list //- Return size of this patch in the face list
label& size() label& size()
{ {
return size_; return size_;
@ -139,11 +141,17 @@ public:
// Member Operators // Member Operators
//- Conversion to surfZone representation
explicit operator surfZone() const;
//- Compare.
bool operator!=(const surfacePatch&) const; bool operator!=(const surfacePatch&) const;
//- compare. //- Compare.
bool operator==(const surfacePatch&) const; bool operator==(const surfacePatch&) const;
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const surfacePatch&); friend Ostream& operator<<(Ostream&, const surfacePatch&);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "boundBox.H" #include "boundBox.H"
#include "SortableList.H" #include "SortableList.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "surfZoneList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -488,7 +489,8 @@ void Foam::triSurface::write
// Returns patch info. Sets faceMap to the indexing according to patch // Returns patch info. Sets faceMap to the indexing according to patch
// numbers. Patch numbers start at 0. // 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 // Sort according to region numbers of labelledTri
SortableList<label> sortedRegion(size()); SortableList<label> sortedRegion(size());
@ -533,30 +535,29 @@ Foam::surfacePatchList Foam::triSurface::calcPatches(labelList& faceMap) const
surfacePatch& newPatch = newPatches[newPatchi]; surfacePatch& newPatch = newPatches[newPatchi];
newPatch.index() = newPatchi; newPatch.index() = newPatchi;
label oldPatchi = newPatchi;
// start of patch
newPatch.start() = startFacei; newPatch.start() = startFacei;
// Take over any information from existing patches // 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 else
{ {
newPatch.name() = word("patch") + name(newPatchi); newPatch.name() = word("patch") + Foam::name(newPatchi);
} }
if if
( (
(oldPatchi < patches_.size()) newPatchi < patches_.size()
&& (patches_[oldPatchi].geometricType() != "") && !patches_[newPatchi].geometricType().empty()
) )
{ {
newPatch.geometricType() = patches_[oldPatchi].geometricType(); newPatch.geometricType() = patches_[newPatchi].geometricType();
} }
else 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 // Finds area, starting at facei, delimited by borderEdge. Marks all visited
// faces (from face-edge-face walk) with currentZone. // faces (from face-edge-face walk) with currentZone.
void Foam::triSurface::markZone void Foam::triSurface::markZone

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,7 +50,7 @@ namespace Foam
class Time; class Time;
class IFstream; class IFstream;
class surfZone;
// Forward declaration of friend functions and operators // 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 // Edit
//- Move points //- Move points
@ -412,6 +423,10 @@ public:
) const; ) const;
//- Transfer stored points to an Xfer container
Xfer<List<point>> xferPoints();
// Write // Write
//- Write to Ostream in simple FOAM format //- Write to Ostream in simple FOAM format