Merge commit 'bundle/home' into olesenm

This commit is contained in:
Mark Olesen
2008-11-19 10:33:13 +01:00
59 changed files with 442 additions and 318 deletions

View File

@ -26,7 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "labelHashSet.H"
#include "HashSet.H"
using namespace Foam;
@ -35,19 +35,45 @@ using namespace Foam;
int main(int argc, char *argv[])
{
HashSet<Foam::string> testSet(0);
HashSet<string> setA(0);
testSet.insert("kjhk");
testSet.insert("kjhk2");
setA.insert("kjhk");
setA.insert("kjhk2");
Info<< testSet << endl;
Info<< setA << endl;
labelHashSet testLabelHashSet(1);
labelHashSet setB(1);
setB.insert(11);
setB.insert(42);
testLabelHashSet.insert(11);
testLabelHashSet.insert(42);
Info<< "setB : " << setB << endl;
Info<< testLabelHashSet << endl;
labelHashSet setC(1);
setC.insert(2008);
setC.insert(1984);
Info<< "setC : " << setC << endl;
labelHashSet setD(1);
setD.insert(11);
setD.insert(100);
setD.insert(2008);
Info<< "setD : " << setD << endl;
Info<< "setB == setC: " << (setB == setC) << endl;
Info<< "setC != setD: " << (setC != setD) << endl;
// test operations
setB += setC;
Info<< "setB += setC : " << setB << endl;
setB &= setD;
Info<< "setB &= setD : " << setB << endl;
setB += setC;
setB -= setD;
Info<< "setB += setC -= setD : " << setB << endl;
return 0;
}

View File

@ -45,7 +45,7 @@ SourceFiles
#ifndef regionSide_H
#define regionSide_H
#include "labelHashSet.H"
#include "HashSet.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,62 +29,81 @@ License
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash>
bool HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& ht) const
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
{
const HashTable<empty, Key, Hash>& a = *this;
// Are all my elements in ht?
for
(
typename HashTable<empty, Key, Hash>::const_iterator iter = a.begin();
iter != a.end();
++iter
)
// Are all lhs elements in rhs?
for (const_iterator iter = this->begin(); iter != this->end(); ++iter)
{
if (!ht.found(iter.key()))
if (!rhs.found(iter.key()))
{
return false;
}
}
// Are all ht elements in me?
for
(
typename HashTable<empty, Key, Hash>::const_iterator iter = ht.begin();
iter != ht.end();
++iter
)
// Are all rhs elements in lhs?
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
{
if (!found(iter.key()))
{
return false;
}
}
return true;
}
template<class Key, class Hash>
bool HashSet<Key, Hash>::operator!=(const HashSet<Key, Hash>& ht) const
bool Foam::HashSet<Key, Hash>::operator!=(const HashSet<Key, Hash>& rhs) const
{
return !(operator==(ht));
return !(operator==(rhs));
}
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator+=(const HashSet<Key, Hash>& rhs)
{
// Add in rhs elements into lhs
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
{
insert(iter.key());
}
}
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
{
// Remove rhs elements from lhs
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
{
erase(iter.key());
}
}
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
{
// Remove elements not found in rhs as well
for (iterator iter = this->begin(); iter != this->end(); ++iter)
{
if (!rhs.found(iter.key()))
{
erase(iter);
}
}
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -26,7 +26,7 @@ Class
Foam::HashSet
Description
A HashTable with word keys but without contents.
A HashTable with keys but without contents.
Typedef
Foam::wordHashSet
@ -34,6 +34,12 @@ Typedef
Description
A HashSet with (the default) word keys.
Typedef
Foam::labelHashSet
Description
A HashSet with label keys.
\*---------------------------------------------------------------------------*/
#ifndef HashSet_H
@ -48,7 +54,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class HashSet Declaration
Class HashSet Declaration
\*---------------------------------------------------------------------------*/
template<class Key=word, class Hash=string::hash>
@ -59,9 +65,13 @@ class HashSet
public:
typedef typename HashTable<empty, Key, Hash>::iterator iterator;
typedef typename HashTable<empty, Key, Hash>::const_iterator const_iterator;
// Constructors
//- Construct given initial map size
//- Construct given initial size
HashSet(label size = 100)
:
HashTable<empty, Key, Hash>(size)
@ -74,13 +84,13 @@ public:
{}
//- Construct from UList of Key
HashSet(const UList<Key>& ul)
HashSet(const UList<Key>& lst)
:
HashTable<empty, Key, Hash>(2*ul.size())
HashTable<empty, Key, Hash>(2*lst.size())
{
forAll (ul, i)
forAll(lst, i)
{
insert(ul[i]);
insert(lst[i]);
}
}
@ -90,32 +100,58 @@ public:
HashTable<empty, Key, Hash>(hs)
{}
//- Construct by transferring the parameter contents
HashSet(const xfer<HashSet<Key, Hash> >& hs)
:
HashTable<empty, Key, Hash>(hs)
{}
// Member Functions
// Edit
//- Insert a new hashedEntry
//- Insert a new entry
bool insert(const Key& key)
{
return HashTable<empty, Key, Hash>::insert(key, empty());
}
//- Same as insert (cannot overwrite empty content)
bool set(const Key& key)
{
return HashTable<empty, Key, Hash>::insert(key, empty());
}
// Member Operators
//- Equality. Two hashtables are equal if all contents of first are
// also in second and vice versa. So does not depend on table size or
// order!
//- Equality. Two hashtables are equal when their contents are equal.
// Independent of table size or order.
bool operator==(const HashSet<Key, Hash>&) const;
//- The opposite of the equality operation.
bool operator!=(const HashSet<Key, Hash>&) const;
//- Add entries listed in the given HashSet to this HashSet
void operator+=(const HashSet<Key, Hash>&);
//- Remove entries listed in the given HashSet from this HashSet
void operator-=(const HashSet<Key, Hash>&);
//- Only retain entries found in both HashSets
void operator&=(const HashSet<Key, Hash>&);
};
//- A HashSet with word keys.
typedef HashSet<> wordHashSet;
//- A HashSet with label keys.
typedef HashSet<label, Hash<label> > labelHashSet;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -54,9 +54,15 @@ class Map
{
public:
typedef typename HashTable<T, label, Hash<label> >::iterator iterator;
typedef typename HashTable<T, label, Hash<label> >::const_iterator
const_iterator;
// Constructors
//- Construct given initial map size
//- Construct given initial size
Map(label size = 100)
:
HashTable<T, label, Hash<label> >(size)
@ -74,6 +80,12 @@ public:
HashTable<T, label, Hash<label> >(map)
{}
//- Construct by transferring the parameter contents
Map(const xfer<Map<T> >& map)
:
HashTable<T, label, Hash<label> >(map)
{}
//- Return a null Map
static const Map<T>& null()

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Typedef
Foam::labelHashSet
Description
A HashSet with label keys.
See Also
wordHashSet
\*---------------------------------------------------------------------------*/
#ifndef labelHashSet_H
#define labelHashSet_H
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef HashSet<label, Hash<label> > labelHashSet;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -39,7 +39,7 @@ SourceFiles
#define faceMapper_H
#include "morphFieldMapper.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -143,7 +143,7 @@ SourceFiles
#include "labelList.H"
#include "objectMap.H"
#include "pointField.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -39,7 +39,7 @@ SourceFiles
#include "List.H"
#include "IndirectList.H"
#include "regIOobject.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "pointFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -57,7 +57,7 @@ SourceFiles
#include "edgeList.H"
#include "point.H"
#include "intersection.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,7 +27,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -64,7 +64,7 @@ SourceFiles
#include "cellShapeList.H"
#include "labelList.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "EdgeMap.H"

View File

@ -31,7 +31,7 @@ License
#include "meshTools.H"
#include "SortableList.H"
#include "triSurfaceTools.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "ListOps.H"
#include "transform.H"

View File

@ -75,7 +75,7 @@ SourceFiles
#define motionSmoother_H
#include "pointFields.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "PackedList.H"
#include "indirectPrimitivePatch.H"
#include "className.H"

View File

@ -40,7 +40,7 @@ SourceFiles
#define polyMeshGeometry_H
#include "pointFields.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -56,7 +56,7 @@ SourceFiles
#include "labelList.H"
#include "point.H"
#include "Map.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "typeInfo.H"
#include "edgeList.H"

View File

@ -38,7 +38,7 @@ SourceFiles
#include "labelIOList.H"
#include "face.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "DynamicList.H"
#include "primitivePatch.H"
#include "removeFaces.H"

View File

@ -46,7 +46,7 @@ SourceFiles
#include "typeInfo.H"
#include "Map.H"
#include "labelList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "faceList.H"
#include "boolList.H"

View File

@ -73,7 +73,7 @@ SourceFiles
#include "PtrList.H"
#include "cellList.H"
#include "Map.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
#include "CompactListList.H"
#include "PackedList.H"

View File

@ -40,7 +40,7 @@ SourceFiles
#define removeFaces_H
#include "Pstream.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "boolList.H"
#include "indirectPrimitivePatch.H"

View File

@ -37,7 +37,7 @@ SourceFiles
#include "faceStencil.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "EdgeMap.H"

View File

@ -37,7 +37,7 @@ SourceFiles
#include "faceStencil.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,7 +38,7 @@ SourceFiles
#include "faceStencil.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "EdgeMap.H"

View File

@ -38,7 +38,7 @@ SourceFiles
#include "globalIndex.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "indirectPrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -39,7 +39,7 @@ SourceFiles
#include "morphFieldMapper.H"
#include "fvMesh.H"
#include "faceMapper.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -60,7 +60,7 @@ SourceFiles
#include "fvPatchFieldMapper.H"
#include "pointPatchFieldMapper.H"
#include "GeometricField.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "surfaceMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,7 +27,7 @@ License
#include "inverseDistanceDiffusivity.H"
#include "addToRunTimeSelectionTable.H"
#include "patchWave.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "surfaceInterpolate.H"
#include "zeroGradientFvPatchFields.H"

View File

@ -26,7 +26,7 @@ License
#include "inverseFaceDistanceDiffusivity.H"
#include "addToRunTimeSelectionTable.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "wallPoint.H"
#include "MeshWave.H"
@ -98,7 +98,7 @@ void Foam::inverseFaceDistanceDiffusivity::correct()
const polyPatch& patch = bdry[iter.key()];
const vectorField::subField fc = patch.faceCentres();
forAll(fc, patchFaceI)
{
changedFaces[nPatchFaces] = patch.start() + patchFaceI;
@ -134,7 +134,7 @@ void Foam::inverseFaceDistanceDiffusivity::correct()
fvsPatchScalarField& bfld = faceDiffusivity_.boundaryField()[patchI];
const unallocLabelList& faceCells = bfld.patch().faceCells();
if (patchSet.found(patchI))
{
forAll(bfld, i)

View File

@ -26,7 +26,7 @@ License
#include "inversePointDistanceDiffusivity.H"
#include "addToRunTimeSelectionTable.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "pointEdgePoint.H"
#include "PointEdgeWave.H"
@ -133,7 +133,7 @@ void Foam::inversePointDistanceDiffusivity::correct()
mesh,
seedPoints,
seedInfo,
pointWallDist,
edgeWallDist,
mesh.globalData().nTotalPoints() // max iterations
@ -167,7 +167,7 @@ void Foam::inversePointDistanceDiffusivity::correct()
forAll(bfld, i)
{
const cell& ownFaces = mesh.cells()[faceCells[i]];
labelHashSet cPoints(4*ownFaces.size());
scalar dist = 0;
@ -185,7 +185,7 @@ void Foam::inversePointDistanceDiffusivity::correct()
}
}
dist /= cPoints.size();
bfld[i] = 1.0/dist;
}
}

View File

@ -27,7 +27,7 @@ License
#include "inverseVolumeDiffusivity.H"
#include "addToRunTimeSelectionTable.H"
#include "patchWave.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "surfaceInterpolate.H"
#include "zeroGradientFvPatchFields.H"

View File

@ -37,7 +37,7 @@ SourceFiles
#define cellDistFuncs_H
#include "scalarField.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "wordList.H"
#include "scalarField.H"

View File

@ -28,7 +28,7 @@ Description
#include "cellFeatures.H"
#include "primitiveMesh.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "demandDrivenData.H"
#include "ListOps.H"

View File

@ -44,7 +44,7 @@ SourceFiles
#include "faceList.H"
#include "labelList.H"
#include "boolList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Map.H"
#include "DynamicList.H"

View File

@ -40,7 +40,7 @@ SourceFiles
#include "pointIndexHit.H"
#include "FixedList.H"
#include "Ostream.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "labelBits.H"
#include "PackedList.H"

View File

@ -30,7 +30,7 @@ Description
#include "treeNode.H"
#include "treeBoundBox.H"
#include "octree.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -42,7 +42,7 @@ SourceFiles
#include "treeElem.H"
#include "boolList.H"
#include "linePointRef.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -50,7 +50,7 @@ SourceFiles
#include "treeBoundBoxList.H"
#include "treeElem.H"
#include "linePointRef.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -37,7 +37,7 @@ SourceFiles
#define primitiveMeshGeometry_H
#include "pointFields.H"
#include "labelHashSet.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -39,7 +39,7 @@ SourceFiles
#ifndef topoSet_H
#define topoSet_H
#include "labelHashSet.H"
#include "HashSet.H"
#include "regIOobject.H"
#include "labelList.H"
#include "typeInfo.H"

View File

@ -31,7 +31,6 @@ Description
#include "labelPairLookup.H"
#include "OFstream.H"
#include "HashSet.H"
#include "labelHashSet.H"
#include "triSurface.H"
#include "pointIndexHit.H"
#include "treeDataTriSurface.H"

View File

@ -31,7 +31,6 @@ Description
#include "labelPairLookup.H"
#include "OFstream.H"
#include "HashSet.H"
#include "labelHashSet.H"
#include "triSurface.H"
#include "pointIndexHit.H"
#include "octreeDataTriSurface.H"

View File

@ -31,7 +31,6 @@ Description
#include "labelPairLookup.H"
#include "OFstream.H"
#include "HashSet.H"
#include "labelHashSet.H"
#include "triSurface.H"
#include "pointIndexHit.H"
#include "octreeDataTriSurface.H"

View File

@ -50,7 +50,7 @@ SourceFiles
#include "pointField.H"
#include "Map.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "pointIndexHit.H"
#include "edgeList.H"
#include "typeInfo.H"
@ -148,7 +148,7 @@ private:
const List<edgeStatus>& edgeStat,
const label startEdgeI,
const label startPointI,
const label currentFeatI,
const label currentFeatI,
labelList& featVisited
);
@ -180,7 +180,7 @@ public:
const scalar minLen = 0,
const label minElems = 0
);
//- Construct from dictionary
surfaceFeatures(const triSurface&, const dictionary& dict);
@ -320,7 +320,7 @@ public:
(
const labelList& selectedEdges,
const pointField& samples,
const vector& searchSpan, // search span
const vector& searchSpan, // search span
labelList& edgeLabel,
labelList& edgeEndPoint,
pointField& edgePoint
@ -339,7 +339,7 @@ public:
const edgeList& sampleEdges,
const labelList& selectedSampleEdges,
const pointField& samplePoints,
const vector& searchSpan, // search span
const vector& searchSpan, // search span
labelList& edgeLabel, // label of surface edge or -1
pointField& pointOnEdge, // point on above edge

View File

@ -39,7 +39,7 @@ SourceFiles
#include "boolList.H"
#include "pointField.H"
#include "DynamicList.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "FixedList.H"
#include "vector2D.H"
#include "triPointRef.H"

View File

@ -46,7 +46,7 @@ SourceFiles
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "Tuple2.H"
#include "OFstream.H"
#include "Switch.H"

View File

@ -45,7 +45,7 @@ SourceFiles
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "labelHashSet.H"
#include "HashSet.H"
#include "OFstream.H"
#include "Switch.H"
#include "pointFieldFwd.H"

View File

@ -39,6 +39,43 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Face>
Foam::wordHashSet Foam::MeshedSurface<Face>::readTypes()
{
wordHashSet known(2*fileExtensionConstructorTablePtr_->size());
forAllIter
(
typename fileExtensionConstructorTable::iterator,
*fileExtensionConstructorTablePtr_,
iter
)
{
known.insert(iter.key());
}
return known;
}
template<class Face>
Foam::wordHashSet Foam::MeshedSurface<Face>::writeTypes()
{
wordHashSet supported(2*writefileExtensionMemberFunctionTablePtr_->size());
forAllIter
(
typename writefileExtensionMemberFunctionTable::iterator,
*writefileExtensionMemberFunctionTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -55,7 +92,10 @@ bool Foam::MeshedSurface<Face>::canReadType
return true;
}
return UnsortedMeshedSurface<Face>::canReadType(ext, verbose);
wordHashSet available = readTypes();
available += SiblingType::readTypes();
return checkSupport(available, ext, verbose, "reading");
}
@ -72,32 +112,7 @@ bool Foam::MeshedSurface<Face>::canWriteType
return true;
}
typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
if (verbose)
{
SortableList<word> known
(
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << ext << nl;
// compact output:
Info<<"Valid types: ( " << nativeExt;
forAll(known, i)
{
Info<<" " << known[i];
}
Info<<" )" << endl;
}
return false;
}
return true;
return checkSupport(writeTypes(), ext, verbose, "writing");
}
@ -150,7 +165,7 @@ void Foam::MeshedSurface<Face>::write
"MeshedSurface::write(const fileName&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writefileExtensionMemberFunctionTablePtr_->toc()
<< writeTypes()
<< exit(FatalError);
}

View File

@ -49,6 +49,7 @@ SourceFiles
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -83,6 +84,7 @@ private:
//- Private typedefs for convenience
typedef PrimitiveMeshedSurface<Face> ParentType;
typedef UnsortedMeshedSurface<Face> SiblingType;
// Private Member Data
@ -92,12 +94,6 @@ private:
// Private member functions
//- set a single patch
void onePatch();
//- basic sanity check on patches
void checkPatches();
//- Sort faces by regionIds and set patches
void sortFacesByRegion(const UList<label>&, const Map<word>&);
@ -107,6 +103,16 @@ private:
//- Read OpenFOAM Surface format
bool read(Istream&);
protected:
// Protected Member functions
//- set a single patch
void onePatch();
//- basic sanity check on patches
void checkPatches();
public:
//- Runtime type information
@ -123,6 +129,8 @@ public:
//- Can we write this file format?
static bool canWriteType(const word& ext, const bool verbose=false);
static wordHashSet readTypes();
static wordHashSet writeTypes();
// Constructors

View File

@ -45,11 +45,38 @@ Foam::MeshedSurface<Face>::New
<< endl;
}
// created indirectly via UnsortedMeshedSurface
autoPtr<MeshedSurface<Face> > surf(new MeshedSurface<Face>);
surf().transfer( UnsortedMeshedSurface<Face>::New(fName,ext)() );
typename fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(ext);
return surf;
if (cstrIter == fileExtensionConstructorTablePtr_->end())
{
// no direct reader, delegate if possible
wordHashSet supported = SiblingType::readTypes();
if (supported.found(ext))
{
// create indirectly
autoPtr<MeshedSurface<Face> > surf(new MeshedSurface<Face>);
surf().transfer(SiblingType::New(fName, ext)());
return surf;
}
// nothing left to try, issue error
supported += readTypes();
supported.insert(nativeExt);
FatalErrorIn
(
"MeshedSurface<Face>::New"
"(const fileName&, const word&) : "
"constructing UnsortedMeshedSurface"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << nl
<< supported
<< exit(FatalError);
}
return autoPtr<MeshedSurface<Face> >(cstrIter()(fName));
}

View File

@ -39,6 +39,44 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face>
Foam::wordHashSet Foam::UnsortedMeshedSurface<Face>::readTypes()
{
wordHashSet supported(2*fileExtensionConstructorTablePtr_->size());
forAllIter
(
typename fileExtensionConstructorTable::iterator,
*fileExtensionConstructorTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
}
template<class Face>
Foam::wordHashSet Foam::UnsortedMeshedSurface<Face>::writeTypes()
{
wordHashSet supported(2*writefileExtensionMemberFunctionTablePtr_->size());
forAllIter
(
typename writefileExtensionMemberFunctionTable::iterator,
*writefileExtensionMemberFunctionTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
}
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canReadType
(
@ -52,32 +90,10 @@ bool Foam::UnsortedMeshedSurface<Face>::canReadType
return true;
}
typename fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(ext);
wordHashSet available = readTypes();
available += SiblingType::readTypes();;
// would be nice to have information about which format this actually is
if (cstrIter == fileExtensionConstructorTablePtr_->end())
{
if (verbose)
{
SortableList<word> known
(
fileExtensionConstructorTablePtr_->toc()
);
Info<<"Unknown file extension for reading: " << ext << nl;
// compact output:
Info<<"Valid types: ( " << nativeExt;
forAll(known, i)
{
Info<<" " << known[i];
}
Info<<" )" << endl;
}
return false;
}
return true;
return checkSupport(available, ext, verbose, "reading");
}
@ -94,32 +110,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canWriteType
return true;
}
typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
if (verbose)
{
SortableList<word> known
(
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << ext << nl;
// compact output:
Info<<"Valid types: ( " << nativeExt;
forAll(known, i)
{
Info<<" " << known[i];
}
Info<<" )" << endl;
}
return false;
}
return true;
return checkSupport(writeTypes(), ext, verbose, "writing");
}
@ -173,7 +164,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
"(const fileName&, const UnsortedMeshedSurface&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writefileExtensionMemberFunctionTablePtr_->toc()
<< writeTypes()
<< exit(FatalError);
}

View File

@ -53,6 +53,7 @@ SourceFiles
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +74,7 @@ template<class Face>
/*---------------------------------------------------------------------------*\
Class UnsortedMeshedSurface Declaration
Class UnsortedMeshedSurface Declaration
\*---------------------------------------------------------------------------*/
template<class Face>
@ -88,6 +89,7 @@ private:
//- Typedefs for convenience
typedef PrimitiveMeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> SiblingType;
//- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType;
@ -157,6 +159,9 @@ public:
//- Can we write this file format?
static bool canWriteType(const word& ext, const bool verbose=false);
static wordHashSet readTypes();
static wordHashSet writeTypes();
// Constructors
//- Construct null
@ -325,7 +330,7 @@ public:
// Returns true if any points merged
virtual bool stitchFaces
(
const scalar tol=SMALL,
const scalar tol=SMALL,
const bool verbose=false
);

View File

@ -50,6 +50,24 @@ Foam::UnsortedMeshedSurface<Face>::New
if (cstrIter == fileExtensionConstructorTablePtr_->end())
{
// no direct reader, delegate if possible
wordHashSet supported = SiblingType::readTypes();
if (supported.found(ext))
{
// create indirectly
autoPtr<UnsortedMeshedSurface<Face> > surf
(
new UnsortedMeshedSurface<Face>
);
surf().transfer(SiblingType::New(fName, ext)());
return surf;
}
// nothing left but to issue an error
supported += readTypes();
supported.insert(nativeExt);
FatalErrorIn
(
"UnsortedMeshedSurface<Face>::New"
@ -57,14 +75,11 @@ Foam::UnsortedMeshedSurface<Face>::New
"constructing UnsortedMeshedSurface"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << nl
<< fileExtensionConstructorTablePtr_->toc()
<< supported
<< exit(FatalError);
}
return autoPtr<UnsortedMeshedSurface<Face> >
(
cstrIter()(fName)
);
return autoPtr<UnsortedMeshedSurface<Face> >(cstrIter()(fName));
}

View File

@ -257,21 +257,10 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
if (mustTriangulate)
{
triFace fTri;
// simple face triangulation about f[0].
// cannot use face::triangulation since points are incomplete
fTri[0] = f[0];
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
{
label fp2 = (fp1 + 1) % f.size();
fTri[1] = f[fp1];
fTri[2] = f[fp2];
faceLst.append(fTri);
regionLst.append(patchI);
}
faceLst.append(triFace(f[0], f[1], f[2]));
faceLst.append(triFace(f[0], f[2], f[3]));
regionLst.append(patchI);
regionLst.append(patchI);
}
else
{

View File

@ -80,7 +80,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
// get dimensions
label nPoints, nEdges, nElems;
label nPoints, nElems, nEdges;
string line = this->getLineNoComment(is);
{
@ -105,9 +105,10 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
// use a DynamicList for possible on-the-fly triangulation
DynamicList<Face> faceLst(nElems);
forAll(faceLst, faceI)
for (label faceI = 0; faceI < nElems; ++faceI)
{
line = this->getLineNoComment(is);
{
IStringStream lineStream(line);
@ -128,7 +129,6 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
triFace fTri;
// simple face triangulation about f[0].
// cannot use face::triangulation since points are incomplete
fTri[0] = f[0];
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
{

View File

@ -66,7 +66,7 @@ namespace fileFormats
template<class Face>
class OFFsurfaceFormat
:
public UnsortedMeshedSurface<Face>,
public MeshedSurface<Face>,
public OFFsurfaceFormatCore
{
// Private Member Functions
@ -95,12 +95,12 @@ public:
// Selectors
//- Read file and return surface
static autoPtr<UnsortedMeshedSurface<Face> > New
static autoPtr<MeshedSurface<Face> > New
(
const fileName& fName
)
{
return autoPtr<UnsortedMeshedSurface<Face> >
return autoPtr<MeshedSurface<Face> >
(
new OFFsurfaceFormat(fName)
);
@ -115,6 +115,23 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write MeshedSurface
static void write
(
Ostream&,
const MeshedSurface<Face>&
);
//- Write MeshedSurface
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
@ -134,23 +151,6 @@ public:
write(OFstream(fName)(), surf);
}
//- Write MeshedSurface
static void write
(
Ostream&,
const MeshedSurface<Face>&
);
//- Write MeshedSurface
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write object
virtual void write(Ostream& os) const
{

View File

@ -38,7 +38,7 @@ namespace fileFormats
addNamedTemplatedToRunTimeSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
OFFsurfaceFormat,
face,
fileExtension,
@ -46,7 +46,7 @@ addNamedTemplatedToRunTimeSelectionTable
);
addNamedTemplatedToRunTimeSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
OFFsurfaceFormat,
triFace,
fileExtension,
@ -54,26 +54,6 @@ addNamedTemplatedToRunTimeSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
OFFsurfaceFormat,
face,
write,
fileExtension,
off
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
OFFsurfaceFormat,
triFace,
write,
fileExtension,
off
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
@ -93,6 +73,26 @@ addNamedTemplatedToMemberFunctionSelectionTable
off
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
OFFsurfaceFormat,
face,
write,
fileExtension,
off
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
OFFsurfaceFormat,
triFace,
write,
fileExtension,
off
);
}
}

View File

@ -250,6 +250,40 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
}
bool
Foam::fileFormats::surfaceFormatsCore::checkSupport
(
const wordHashSet& available,
const word& ext,
const bool verbose,
const word& functionName
)
{
if (available.found(ext))
{
return true;
}
else if (verbose)
{
wordList toc = available.toc();
SortableList<word> known(xferMove(toc));
Info<<"Unknown file extension for " << functionName
<< " : " << ext << nl
<<"Valid types: ( " << nativeExt;
// compact output:
forAll(known, i)
{
Info<<" " << known[i];
}
Info<<" )" << endl;
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::surfaceFormatsCore::surfaceFormatsCore()

View File

@ -40,6 +40,7 @@ SourceFiles
#include "surfGroupList.H"
#include "labelList.H"
#include "Map.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -99,6 +100,14 @@ public:
labelList& faceMap
);
static bool checkSupport
(
const wordHashSet& available,
const word& ext,
const bool verbose,
const word& functionName
);
// Constructors
//- Construct null

View File

@ -190,13 +190,8 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
label ptI = 0;
forAll(faceLst, faceI)
{
triFace fTri;
fTri[0] = ptI++;
fTri[1] = ptI++;
fTri[2] = ptI++;
faceLst[faceI] = fTri;
const label startPt = 3 * faceI;
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
}
this->setPatches(groupToPatch);