NeoPZ
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
TPZAdmChunkVector< T, EXP > Class Template Reference

Implements a chunk vector with free store administration. Utility. More...

#include <TPZStream.h>

Inheritance diagram for TPZAdmChunkVector< T, EXP >:
[legend]
Collaboration diagram for TPZAdmChunkVector< T, EXP >:
[legend]

Public Types

enum  CompactScheme { NEVER, NOW, ALWAYS }
 
- Public Types inherited from TPZChunkVector< T, EXP >
typedef T value_type
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef TPZChunkVectorIterator< false, value_type, EXP > iterator
 
typedef TPZChunkVectorIterator< true, value_type, EXP > const_iterator
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef int64_t size_type
 

Public Member Functions

TPZAdmChunkVector< T, EXP > & operator= (const TPZAdmChunkVector< T, EXP > &TPZAdmCh)
 Assignment operator. More...
 
 TPZAdmChunkVector (const TPZAdmChunkVector< T, EXP > &AdmCh)
 Copy constructor. More...
 
 TPZAdmChunkVector (int numberofchunks=DEFAULTNUMBEROFCHUNKS)
 Constructor. More...
 
virtual ~TPZAdmChunkVector ()
 Destructor. More...
 
int AllocateNewElement ()
 Makes more room for new elements. More...
 
void SetFree (int index)
 Indicate an element as free. More...
 
int64_t NFreeElements () const
 Access method to return the number of free elements. More...
 
void CompactDataStructure (CompactScheme type=CompactScheme::ALWAYS)
 Sets the method to compact the data structure based on the. More...
 
int PrintFree (int i)
 Print index i into the fFree vector. More...
 
void Resize (const int newsize)
 Increase the size of the chunk vector. More...
 
int ClassId () const override
 Define the class id associated with the class. More...
 
void Read (TPZStream &buf, void *context) override
 read objects from the stream More...
 
void Write (TPZStream &buf, int withclassid) const override
 Writes this object to the TPZStream buffer. Include the classid if withclassid = true. More...
 
- Public Member Functions inherited from TPZChunkVector< T, EXP >
TPZChunkVector< T, EXP > & operator= (const TPZChunkVector< T, EXP > &TCh)
 Assignment operator, copies all elements from the object TCh. More...
 
 TPZChunkVector (const TPZChunkVector< T, EXP > &TCh)
 Copy constructor. More...
 
 TPZChunkVector (int64_t numberofchunks=DEFAULTNUMBEROFCHUNKS)
 Constructor with numberofchunks chunks. More...
 
virtual ~TPZChunkVector ()
 Destructor. More...
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
int64_t NElements () const
 Access method to query the number of elements of the vector. More...
 
void Resize (const int64_t newsize)
 Increase the size of the chunk vector. More...
 
T & operator[] (const int64_t nelem) const
 Returns a reference to the ith element of the vector. More...
 
int64_t FindObject (T *object)
 Finds the index of an object by its pointer. More...
 
int ClassId () const override
 Define the class id associated with the class. More...
 
void Read (TPZStream &buf, void *context) override
 read objects from the stream More...
 
void Write (TPZStream &buf, int withclassid) const override
 Writes this object to the TPZStream buffer. Include the classid if withclassid = true. More...
 
- Public Member Functions inherited from TPZSavable
 TPZSavable ()
 
virtual ~TPZSavable ()
 
virtual std::list< std::map< std::string, uint64_t > > VersionHistory () const
 
virtual std::pair< std::string, uint64_t > Version () const
 
virtual bool Compare (TPZSavable *copy, bool override=false)
 Compares the object for identity with the object pointed to, eventually copy the object. More...
 
virtual bool Compare (TPZSavable *copy, bool override=false) const
 Compares the object for identity with the object pointed to, eventually copy the object. More...
 
- Public Member Functions inherited from TPZRegisterClassId
template<typename T >
 TPZRegisterClassId (int(T::*)() const)
 
 TPZRegisterClassId ()=default
 

Private Attributes

CompactScheme fCompactScheme
 Internal variable indicating the type of compacting scheme. More...
 
TPZManVector< int > fNFree
 Number of free elements within each chunk. More...
 
TPZStack< int > fFree
 List of indexes of freed elements. More...
 

Friends

class TPZStream
 
class TPZGeoMesh
 

Additional Inherited Members

- Static Public Member Functions inherited from TPZSavable
static std::set< TPZRestoreClassBase * > & RestoreClassSet ()
 This static function guarantees that the gMap object is available when needed. More...
 
static std::map< int, TPZRestore_t > & ClassIdMap ()
 This static function guarantees that the gMap object is available when needed. More...
 
static std::pair< std::string, uint64_t > NeoPZVersion ()
 
static void Register (TPZRestoreClassBase *restore)
 
static void RegisterClassId (int classid, TPZRestore_t fun)
 
static TPZSavableCreateInstance (const int &classId)
 
- Protected Attributes inherited from TPZChunkVector< T, EXP >
int64_t fNElements
 Number of elements of the chunk vector. More...
 
TPZManVector< T * > fVec
 Vector which points to each chunk of objects. More...
 

Detailed Description

template<class T, int EXP = 10>
class TPZAdmChunkVector< T, EXP >

Implements a chunk vector with free store administration. Utility.

An object of this class allows the user to request a new object of the type administered and allows the user to flag given elements as unused.

Definition at line 39 of file TPZStream.h.

Member Enumeration Documentation

◆ CompactScheme

template<class T, int EXP = 10>
enum TPZAdmChunkVector::CompactScheme
Enumerator
NEVER 
NOW 
ALWAYS 

Definition at line 29 of file pzadmchunk.h.

Constructor & Destructor Documentation

◆ TPZAdmChunkVector() [1/2]

template<class T, int EXP>
TPZAdmChunkVector< T, EXP >::TPZAdmChunkVector ( const TPZAdmChunkVector< T, EXP > &  AdmCh)

Copy constructor.

Parameters
AdmChObject whose elements will be copied.

Definition at line 258 of file pzadmchunk.h.

◆ TPZAdmChunkVector() [2/2]

template<class T, int EXP>
TPZAdmChunkVector< T, EXP >::TPZAdmChunkVector ( int  numberofchunks = DEFAULTNUMBEROFCHUNKS)

Constructor.

Constructor with indication of the initial size of the chunk allocation vector and the size of the chunks these sizes cannot be modified during the lifecycle of the object.

Parameters
numberofchunksIndicates how large the initial chunk vector will be.

Definition at line 165 of file pzadmchunk.h.

◆ ~TPZAdmChunkVector()

template<class T , int EXP>
TPZAdmChunkVector< T, EXP >::~TPZAdmChunkVector ( )
virtual

Destructor.

Definition at line 178 of file pzadmchunk.h.

Member Function Documentation

◆ AllocateNewElement()

template<class T , int EXP>
int TPZAdmChunkVector< T, EXP >::AllocateNewElement ( )

Makes more room for new elements.

Returns
The index of a free element. This method will search the list of free locations to return the next free index
in case there are no free indexes, this method will increase the size of the chunk vector
and returns the allocated element.

Definition at line 184 of file pzadmchunk.h.

Referenced by TPZCompMesh::AllocateNewConnect(), TPZAdmChunkVectorThreadSafe< T, EXP >::AllocateNewElement(), TPZBuildSBFem::CreateElementCenterNodes(), TPZCheckGeom::CreateMesh(), pzgeom::TPZChangeEl::CreateMiddleNodeAtEdge(), TPZRefPattern::CreateMidSideNodes(), TPZGenSpecialGrid::GeneratePolygonalSphereFromOctahedron(), pzgeom::TPZQuadraticPrism::InsertExampleElement(), pzgeom::TPZGeoCube::InsertExampleElement(), pzgeom::TPZQuadraticPyramid::InsertExampleElement(), pzgeom::TPZQuadraticCube::InsertExampleElement(), pzgeom::TPZGeoTetrahedra::InsertExampleElement(), pzgeom::TPZGeoPyramid::InsertExampleElement(), pzgeom::TPZQuadraticTetra::InsertExampleElement(), pzgeom::TPZGeoPrism::InsertExampleElement(), pzgeom::TPZGeoLinear::InsertExampleElement(), pzgeom::TPZGeoPoint::InsertExampleElement(), pzgeom::TPZQuadraticLine::InsertExampleElement(), pzgeom::TPZQuadraticTrig::InsertExampleElement(), pzgeom::TPZGeoQuad::InsertExampleElement(), pzgeom::TPZQuadraticQuad::InsertExampleElement(), pzgeom::TPZGeoTriangle::InsertExampleElement(), pzgeom::TPZEllipse3D::InsertExampleElement(), pzgeom::TPZQuadTorus::InsertExampleElement(), pzgeom::TPZWavyLine::InsertExampleElement(), pzgeom::TPZTriangleTorus::InsertExampleElement(), pzgeom::TPZQuadSphere< GeomQuad >::InsertExampleElement(), pzgeom::TPZArc3D::InsertExampleElement(), pzgeom::TPZTriangleSphere< GeomTriang >::InsertExampleElement(), TPZHyperPlaneIntersect::Intersect(), TPBSpStructMatrix::main(), TPZSymetricSpStructMatrix::main(), TPZSpStructMatrix::main(), TPZGenGrid::MergeGeoMesh(), pzrefine::TPZRefPrism::NewMidSideNode(), pzrefine::TPZRefTriangle::NewMidSideNode(), pzrefine::TPZRefCube::NewMidSideNode(), pzrefine::TPZRefLinear::NewMidSideNode(), pzrefine::TPZRefPyramid::NewMidSideNode(), pzrefine::TPZRefQuad::NewMidSideNode(), pzrefine::TPZRefTetrahedra::NewMidSideNode(), TPZReadTetGen::ProcessNodes(), PYBIND11_MODULE(), TPZGenGrid::ReadAndMergeGeoMesh(), TPZReadMeshHR::ReadNodes(), TPZHyperPlaneIntersect::ReorderGeneral(), TCedricTest::TetrahedralMeshUsingRefinement(), TPZCompEl::TPZCompEl(), TPZGeoEl::TPZGeoEl(), TPZGraphEl::TPZGraphEl(), TPZSubCompMesh::TransferElementFrom(), and TPZSubCompMesh::TransferElementTo().

◆ ClassId()

template<class T, int EXP = 10>
int TPZAdmChunkVector< T, EXP >::ClassId ( ) const
inlineoverridevirtual

Define the class id associated with the class.

This id has to be unique for all classes A non unique id is flagged at the startup of the program

Implements TPZSavable.

Definition at line 114 of file pzadmchunk.h.

◆ CompactDataStructure()

template<class T , int EXP>
void TPZAdmChunkVector< T, EXP >::CompactDataStructure ( CompactScheme  type = CompactScheme::ALWAYS)

Sets the method to compact the data structure based on the.

Parameters
typeType of compacting scheme to be used. parameter type:
  • $ when = 0 $ : never compact the data structure;
  • $ when = 1 $ : compact the data structure now;
  • $ when = 2 $ : compact the data structure always (default).

Definition at line 222 of file pzadmchunk.h.

Referenced by TPZGeoMesh::CleanUp(), TPZCompMesh::CleanUp(), TPZAdmChunkVectorThreadSafe< T, EXP >::CompactDataStructure(), TPZAdmChunkVector< TPZGeoEl *>::NFreeElements(), TPZAdmChunkVector< TPZGeoEl *>::SetFree(), TPZGraphMesh::TPZGraphMesh(), and TPZSubCompMesh::~TPZSubCompMesh().

◆ NFreeElements()

template<class T, int EXP = 10>
int64_t TPZAdmChunkVector< T, EXP >::NFreeElements ( ) const
inline

Access method to return the number of free elements.

Returns
Number of free elements.

Definition at line 87 of file pzadmchunk.h.

Referenced by TPZAdmChunkVectorThreadSafe< T, EXP >::NFreeElements(), TPZGeoMesh::Print(), TPZGeoMesh::PrintTopologicalInfo(), and TPZGeoMesh::ReallyNEl().

◆ operator=()

template<class T, int EXP>
TPZAdmChunkVector< T, EXP > & TPZAdmChunkVector< T, EXP >::operator= ( const TPZAdmChunkVector< T, EXP > &  TPZAdmCh)

Assignment operator.

Parameters
TPZAdmChVector which will be duplicated. It will copy the objects from TPZAdmCh will call the assignment operator on all objects (also the freed objects).

Definition at line 265 of file pzadmchunk.h.

◆ PrintFree()

template<class T, int EXP = 10>
int TPZAdmChunkVector< T, EXP >::PrintFree ( int  i)
inline

Print index i into the fFree vector.

Definition at line 104 of file pzadmchunk.h.

Referenced by TPZAdmChunkVectorThreadSafe< T, EXP >::PrintFree().

◆ Read()

template<class T, int EXP = 10>
void TPZAdmChunkVector< T, EXP >::Read ( TPZStream buf,
void *  context 
)
inlineoverridevirtual

read objects from the stream

Reimplemented from TPZSavable.

Definition at line 118 of file pzadmchunk.h.

Referenced by TPZGraphMesh::Read(), TPZGeoMesh::Read(), and TPZCompMesh::Read().

◆ Resize()

template<class T , int EXP>
void TPZAdmChunkVector< T, EXP >::Resize ( const int  newsize)

Increase the size of the chunk vector.

Parameters
newsizeRequested new size of the vector.

Definition at line 280 of file pzadmchunk.h.

Referenced by TPZBuildMultiphysicsMesh::AddConnects(), TPZMultiphysicsCompMesh::AddConnects(), TPZMulticamadaOrthotropic::AddPlacaOrtho(), TPZAdmChunkVector< TPZGeoEl *>::AllocateNewElement(), TPZBuildMultiphysicsMesh::AppendConnects(), TPZRefPattern::BuildSideMesh(), TPZMultiphysicsCompMesh::CleanElementsConnects(), TPZGeoMesh::CleanUp(), TPZCompMesh::CleanUp(), TPZAdmChunkVector< TPZGeoEl *>::CompactDataStructure(), TPZHierarquicalGrid::ComputeExtrusion(), TPZAnalysis::CreateListOfCompElsToComputeError(), Hdiv3dPaper201504::CreateOneCubo(), TPZGraphMesh::ElementList(), TPZExtendGridDimension::ExtendedMesh(), TPZRefPatternTools::GenerateGMeshFromElementVec(), TPZGenSubStruct::GenerateMesh(), TCedricTest::GenerateNodes(), TPZAcademicGeoMesh::GenerateNodes(), Hdiv3dPaper201504::GenerateNodes(), TPZGenGrid::GenerateNodes(), TPZRefPattern::GeneratePermutations(), Hdiv2dPaper201504::GMesh(), hdivCurvedJCompAppMath::GMeshCilindricalMesh(), Hdiv3dPaper201504::GMeshWithPrism(), TPZGeoMeshBuilder::InsertNodes(), hdivCurvedJCompAppMath::MakeCircle(), hdivCurvedJCompAppMath::MakeSphereFromQuadrilateral(), MalhaGeom(), TPZGeoMesh::operator=(), TPZCompMesh::operator=(), TPZAdmChunkVector< TPZGeoEl *>::PrintFree(), TPZRefPattern::PrintVTK(), PYBIND11_MODULE(), TPZGenPartialGrid::Read(), TPZAdmChunkVector< TPZGeoEl *>::Read(), TPZRefPattern::ReadAndCreateRefinementPattern(), TPZGMSHReadMesh::ReadMesh2D(), TPZGMSHReadMesh::ReadMesh2D2(), TPZGMSHReadMesh::ReadMesh3D(), TPZStream::ReadPointers(), TPZAcademicGeoMesh::RedBlackPyramidalAndHexagonalMesh(), TPZAdmChunkVectorThreadSafe< T, EXP >::Resize(), TPZGraphMesh::SetCompMesh(), TCedricTest::TCedricTest(), TPZAcademicGeoMesh::TPZAcademicGeoMesh(), TPZCompMesh::TPZCompMesh(), TPZGraphEl::TPZGraphEl(), TPZGraphMesh::TPZGraphMesh(), TPZMulticamadaOrthotropic::TPZMulticamadaOrthotropic(), and TPZSubCompMesh::~TPZSubCompMesh().

◆ SetFree()

template<class T , int EXP>
void TPZAdmChunkVector< T, EXP >::SetFree ( int  index)

Indicate an element as free.

Note
The object does not verify whether an element has been freed several times.
Parameters
indexThe index of the element being put on the free stack.

Definition at line 199 of file pzadmchunk.h.

Referenced by TPZCompMesh::CleanUpUnconnectedNodes(), TPZAdmChunkVectorThreadSafe< T, EXP >::SetFree(), TPZSubCompMesh::TransferElementFrom(), TPZSubCompMesh::TransferElementTo(), and TPZCompEl::~TPZCompEl().

◆ Write()

template<class T, int EXP = 10>
void TPZAdmChunkVector< T, EXP >::Write ( TPZStream buf,
int  withclassid 
) const
inlineoverridevirtual

Writes this object to the TPZStream buffer. Include the classid if withclassid = true.

Writes this object to the TPZStream buffer. Include the classid if withclassid = true

Reimplemented from TPZSavable.

Definition at line 132 of file pzadmchunk.h.

Referenced by TPZGraphMesh::Write(), TPZGeoMesh::Write(), and TPZCompMesh::Write().

Friends And Related Function Documentation

◆ TPZGeoMesh

template<class T, int EXP = 10>
friend class TPZGeoMesh
friend

Definition at line 147 of file pzadmchunk.h.

◆ TPZStream

template<class T, int EXP = 10>
friend class TPZStream
friend

Definition at line 146 of file pzadmchunk.h.

Member Data Documentation

◆ fCompactScheme

template<class T, int EXP = 10>
CompactScheme TPZAdmChunkVector< T, EXP >::fCompactScheme
private

◆ fFree

template<class T, int EXP = 10>
TPZStack<int> TPZAdmChunkVector< T, EXP >::fFree
private

◆ fNFree

template<class T, int EXP = 10>
TPZManVector<int> TPZAdmChunkVector< T, EXP >::fNFree
private

The documentation for this class was generated from the following files: