ENH: use CompactIOList for binary face and cell IOList.

This commit is contained in:
mattijs
2010-09-30 20:58:38 +01:00
parent 5d97b8dc72
commit c21cbfb330
22 changed files with 89 additions and 84 deletions

View File

@ -166,10 +166,10 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files // Convert all the standard mesh files
writeMeshObject<cellIOList>("cells", meshDir, runTime); writeMeshObject<cellCompactIOList>("cells", meshDir, runTime);
writeMeshObject<labelIOList>("owner", meshDir, runTime); writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", meshDir, runTime); writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceIOList>("faces", meshDir, runTime); writeMeshObject<faceCompactIOList>("faces", meshDir, runTime);
writeMeshObject<pointIOField>("points", meshDir, runTime); writeMeshObject<pointIOField>("points", meshDir, runTime);
writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime); writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime); writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);

View File

@ -23,13 +23,13 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IOListList.H" #include "CompactIOList.H"
#include "labelList.H" #include "labelList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class BaseType> template<class T, class BaseType>
void Foam::IOListList<T, BaseType>::readFromStream() void Foam::CompactIOList<T, BaseType>::readFromStream()
{ {
Istream& is = readStream(word::null); Istream& is = readStream(word::null);
@ -47,7 +47,7 @@ void Foam::IOListList<T, BaseType>::readFromStream()
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"IOListList<T, BaseType>::readFromStream()", "CompactIOList<T, BaseType>::readFromStream()",
is is
) << "unexpected class name " << headerClassName() ) << "unexpected class name " << headerClassName()
<< " expected " << typeName << " or " << IOList<T>::typeName << " expected " << typeName << " or " << IOList<T>::typeName
@ -61,7 +61,7 @@ void Foam::IOListList<T, BaseType>::readFromStream()
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T, class BaseType> template<class T, class BaseType>
Foam::IOListList<T, BaseType>::IOListList(const IOobject& io) Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
: :
regIOobject(io) regIOobject(io)
{ {
@ -77,7 +77,11 @@ Foam::IOListList<T, BaseType>::IOListList(const IOobject& io)
template<class T, class BaseType> template<class T, class BaseType>
Foam::IOListList<T, BaseType>::IOListList(const IOobject& io, const label size) Foam::CompactIOList<T, BaseType>::CompactIOList
(
const IOobject& io,
const label size
)
: :
regIOobject(io) regIOobject(io)
{ {
@ -97,7 +101,7 @@ Foam::IOListList<T, BaseType>::IOListList(const IOobject& io, const label size)
template<class T, class BaseType> template<class T, class BaseType>
Foam::IOListList<T, BaseType>::IOListList Foam::CompactIOList<T, BaseType>::CompactIOList
( (
const IOobject& io, const IOobject& io,
const List<T>& list const List<T>& list
@ -121,7 +125,7 @@ Foam::IOListList<T, BaseType>::IOListList
template<class T, class BaseType> template<class T, class BaseType>
Foam::IOListList<T, BaseType>::IOListList Foam::CompactIOList<T, BaseType>::CompactIOList
( (
const IOobject& io, const IOobject& io,
const Xfer<List<T> >& list const Xfer<List<T> >& list
@ -145,7 +149,7 @@ Foam::IOListList<T, BaseType>::IOListList
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class T, class BaseType> template<class T, class BaseType>
Foam::IOListList<T, BaseType>::~IOListList() Foam::CompactIOList<T, BaseType>::~CompactIOList()
{} {}
@ -153,7 +157,7 @@ Foam::IOListList<T, BaseType>::~IOListList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, class BaseType> template<class T, class BaseType>
bool Foam::IOListList<T, BaseType>::writeObject bool Foam::CompactIOList<T, BaseType>::writeObject
( (
IOstream::streamFormat fmt, IOstream::streamFormat fmt,
IOstream::versionNumber ver, IOstream::versionNumber ver,
@ -182,7 +186,7 @@ bool Foam::IOListList<T, BaseType>::writeObject
template<class T, class BaseType> template<class T, class BaseType>
bool Foam::IOListList<T, BaseType>::writeData(Ostream& os) const bool Foam::CompactIOList<T, BaseType>::writeData(Ostream& os) const
{ {
return (os << *this).good(); return (os << *this).good();
} }
@ -191,9 +195,9 @@ bool Foam::IOListList<T, BaseType>::writeData(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, class BaseType> template<class T, class BaseType>
void Foam::IOListList<T, BaseType>::operator= void Foam::CompactIOList<T, BaseType>::operator=
( (
const IOListList<T, BaseType>& rhs const CompactIOList<T, BaseType>& rhs
) )
{ {
List<T>::operator=(rhs); List<T>::operator=(rhs);
@ -201,7 +205,7 @@ void Foam::IOListList<T, BaseType>::operator=
template<class T, class BaseType> template<class T, class BaseType>
void Foam::IOListList<T, BaseType>::operator=(const List<T>& rhs) void Foam::CompactIOList<T, BaseType>::operator=(const List<T>& rhs)
{ {
List<T>::operator=(rhs); List<T>::operator=(rhs);
} }
@ -213,7 +217,7 @@ template<class T, class BaseType>
Foam::Istream& Foam::operator>> Foam::Istream& Foam::operator>>
( (
Foam::Istream& is, Foam::Istream& is,
Foam::IOListList<T, BaseType>& L Foam::CompactIOList<T, BaseType>& L
) )
{ {
// Read compact // Read compact
@ -244,7 +248,7 @@ template<class T, class BaseType>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Foam::Ostream& os, Foam::Ostream& os,
const Foam::IOListList<T, BaseType>& L const Foam::CompactIOList<T, BaseType>& L
) )
{ {
// Keep ascii writing same. // Keep ascii writing same.

View File

@ -22,18 +22,22 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::IOListList Foam::CompactIOList
Description Description
A List of objects of type \<T\> with automated input and output. A List of objects of type \<T\> with automated input and output using
a compact storage. Behaves like IOList except when binary output in
case it writes a CompactListList.
Useful for lists of small sublists e.g. faceList, cellList.
SourceFiles SourceFiles
IOListList.C CompactIOList.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOListList_H #ifndef CompactIOList_H
#define IOListList_H #define CompactIOList_H
#include "IOList.H" #include "IOList.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -47,25 +51,25 @@ class Istream;
class Ostream; class Ostream;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<class T, class BaseType> class IOListList; template<class T, class BaseType> class CompactIOList;
template<class T, class BaseType> Istream& operator>> template<class T, class BaseType> Istream& operator>>
( (
Istream&, Istream&,
IOListList<T, BaseType>& CompactIOList<T, BaseType>&
); );
template<class T, class BaseType> Ostream& operator<< template<class T, class BaseType> Ostream& operator<<
( (
Ostream&, Ostream&,
const IOListList<T, BaseType>& const CompactIOList<T, BaseType>&
); );
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class IOListList Declaration Class CompactIOList Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class T, class BaseType> template<class T, class BaseType>
class IOListList class CompactIOList
: :
public regIOobject, public regIOobject,
public List<T> public List<T>
@ -78,27 +82,27 @@ class IOListList
public: public:
//- Runtime type information //- Runtime type information
TypeName("ListList"); TypeName("CompactList");
// Constructors // Constructors
//- Construct from IOobject //- Construct from IOobject
IOListList(const IOobject&); CompactIOList(const IOobject&);
//- Construct from IOobject and size of IOListList //- Construct from IOobject and size of CompactIOList
IOListList(const IOobject&, const label); CompactIOList(const IOobject&, const label);
//- Construct from IOobject and a List //- Construct from IOobject and a List
IOListList(const IOobject&, const List<T>&); CompactIOList(const IOobject&, const List<T>&);
//- Construct by transferring the List contents //- Construct by transferring the List contents
IOListList(const IOobject&, const Xfer<List<T> >&); CompactIOList(const IOobject&, const Xfer<List<T> >&);
// Destructor // Destructor
virtual ~IOListList(); virtual ~CompactIOList();
// Member functions // Member functions
@ -115,7 +119,7 @@ public:
// Member operators // Member operators
void operator=(const IOListList<T, BaseType>&); void operator=(const CompactIOList<T, BaseType>&);
void operator=(const List<T>&); void operator=(const List<T>&);
@ -126,14 +130,14 @@ public:
friend Istream& operator>> <T, BaseType> friend Istream& operator>> <T, BaseType>
( (
Istream&, Istream&,
IOListList<T, BaseType>& CompactIOList<T, BaseType>&
); );
// Write List to Ostream. // Write List to Ostream.
friend Ostream& operator<< <T, BaseType> friend Ostream& operator<< <T, BaseType>
( (
Ostream&, Ostream&,
const IOListList<T, BaseType>& const CompactIOList<T, BaseType>&
); );
}; };
@ -145,7 +149,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
# include "IOListList.C" # include "CompactIOList.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -35,7 +35,8 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplateTypeNameAndDebugWithName(cellIOList, "cellList", 0); defineTemplateTypeNameAndDebugWithName(cellIOList, "cellList", 0);
defineTemplateTypeNameAndDebugWithName(cellCompactIOList, "cellCompactList", 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -33,13 +33,14 @@ Description
#define cellIOList_H #define cellIOList_H
#include "cell.H" #include "cell.H"
#include "IOList.H" #include "CompactIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<cell> cellIOList; typedef IOList<cell> cellIOList;
typedef CompactIOList<cell, label> cellCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -33,10 +33,14 @@ Description
namespace Foam namespace Foam
{ {
defineCompoundTypeName(List<edge>, edgeList);
addCompoundToRunTimeSelectionTable(List<edge>, edgeList);
defineTemplateTypeNameAndDebugWithName(edgeIOList, "edgeList", 0); // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineCompoundTypeName(List<edge>, edgeList);
addCompoundToRunTimeSelectionTable(List<edge>, edgeList);
defineTemplateTypeNameAndDebugWithName(edgeIOList, "edgeList", 0);
defineTemplateTypeNameAndDebugWithName(edgeCompactIOList, "edgeCompactList", 0);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -33,13 +33,14 @@ Description
#define edgeIOList_H #define edgeIOList_H
#include "edge.H" #include "edge.H"
#include "IOList.H" #include "CompactIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<edge> edgeIOList; typedef IOList<edge> edgeIOList;
typedef CompactIOList<edge, label> edgeCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,6 +36,12 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplateTypeNameAndDebugWithName(faceIOList, "faceList", 0); defineTemplateTypeNameAndDebugWithName(faceIOList, "faceList", 0);
defineTemplateTypeNameAndDebugWithName
(
faceCompactIOList,
"faceCompactList",
0
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -33,13 +33,14 @@ Description
#define faceIOList_H #define faceIOList_H
#include "face.H" #include "face.H"
#include "IOList.H" #include "CompactIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<face> faceIOList; typedef IOList<face> faceIOList;
typedef CompactIOList<face, label> faceCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -272,7 +272,7 @@ Foam::polyMesh::polyMesh(const IOobject& io)
} }
else else
{ {
cellIOList cLst cellCompactIOList cLst
( (
IOobject IOobject
( (

View File

@ -101,7 +101,7 @@ private:
pointIOField points_; pointIOField points_;
//- Faces //- Faces
faceIOList faces_; faceCompactIOList faces_;
//- Face owner //- Face owner
labelIOList owner_; labelIOList owner_;

View File

@ -112,7 +112,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
) )
); );
faces_ = faceIOList faces_ = faceCompactIOList
( (
IOobject IOobject
( (
@ -238,7 +238,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
} }
else else
{ {
cellIOList cells cellCompactIOList cells
( (
IOobject IOobject
( (

View File

@ -21,10 +21,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IOList and IOListList ClassNames for IOListLists that
do not have .C files.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "labelListIOList.H" #include "labelListIOList.H"
@ -38,8 +34,8 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName defineTemplateTypeNameAndDebugWithName
( (
labelIOListList, labelListCompactIOList,
"labelCompactListList", "labelListCompactList",
0 0
); );
} }

View File

@ -33,15 +33,14 @@ Description
#define labelListIOList_H #define labelListIOList_H
#include "labelList.H" #include "labelList.H"
#include "IOList.H" #include "CompactIOList.H"
#include "IOListList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<labelList> labelListIOList; typedef IOList<labelList> labelListIOList;
typedef IOListList<labelList, label> labelIOListList; typedef CompactIOList<labelList, label> labelListCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -21,10 +21,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IOList and IOListList ClassNames for IOListLists that
do not have .C files.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "scalarListIOList.H" #include "scalarListIOList.H"
@ -43,8 +39,8 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName defineTemplateTypeNameAndDebugWithName
( (
scalarIOListList, scalarListCompactIOList,
"scalarCompactListList", "scalarListCompactList",
0 0
); );
} }

View File

@ -33,15 +33,14 @@ Description
#define scalarListIOList_H #define scalarListIOList_H
#include "scalarList.H" #include "scalarList.H"
#include "IOList.H" #include "CompactIOList.H"
#include "IOListList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<scalarList> scalarListIOList; typedef IOList<scalarList> scalarListIOList;
typedef IOListList<scalarList, scalar> scalarIOListList; typedef CompactIOList<scalarList, scalar> scalarListCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -21,10 +21,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IOList and IOListList ClassNames for IOListLists that
do not have .C files.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "vectorListIOList.H" #include "vectorListIOList.H"
@ -43,8 +39,8 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName defineTemplateTypeNameAndDebugWithName
( (
vectorIOListList, vectorListCompactIOList,
"vectorCompactListList", "vectorListCompactList",
0 0
); );
} }

View File

@ -25,7 +25,7 @@ Typedef
Foam::vectorListIOList Foam::vectorListIOList
Description Description
Scalar container classes Lists of vectors container class
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -33,15 +33,14 @@ Description
#define vectorListIOList_H #define vectorListIOList_H
#include "vectorList.H" #include "vectorList.H"
#include "IOList.H" #include "CompactIOList.H"
#include "IOListList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef IOList<vectorList> vectorListIOList; typedef IOList<vectorList> vectorListIOList;
typedef IOListList<vectorList, vector> vectorIOListList; typedef CompactIOList<vectorList, vector> vectorListCompactIOList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -56,7 +56,7 @@ class MeshedSurfaceIOAllocator
pointIOField points_; pointIOField points_;
//- Faces //- Faces
faceIOList faces_; faceCompactIOList faces_;
//- Surface zones //- Surface zones
surfZoneIOList zones_; surfZoneIOList zones_;
@ -117,7 +117,7 @@ public:
} }
//- Non-const access to the faces //- Non-const access to the faces
faceIOList& storedIOFaces() faceCompactIOList& storedIOFaces()
{ {
return faces_; return faces_;
} }
@ -135,7 +135,7 @@ public:
} }
//- Const access to the faces //- Const access to the faces
const faceIOList& storedIOFaces() const const faceCompactIOList& storedIOFaces() const
{ {
return faces_; return faces_;
} }

View File

@ -150,7 +150,7 @@ void Foam::MeshedSurfaceProxy<Face>::write
// write surfMesh/faces // write surfMesh/faces
{ {
faceIOList io faceCompactIOList io
( (
IOobject IOobject
( (

View File

@ -27,8 +27,6 @@ License
#include "MeshedSurfaceProxy.H" #include "MeshedSurfaceProxy.H"
#include "Time.H" #include "Time.H"
#include "cellIOList.H"
#include "SubList.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"

View File

@ -98,7 +98,7 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
) )
); );
storedFaces() = faceIOList storedFaces() = faceCompactIOList
( (
IOobject IOobject
( (