MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::Table Class Reference

Table stores the connectivity of elements of TYPE I to elements of TYPE II. For example, it may be the element-to-face connectivity table. More...

#include <table.hpp>

Inheritance diagram for mfem::Table:
[legend]
Collaboration diagram for mfem::Table:
[legend]

Public Member Functions

 Table ()
 Creates an empty table.
 
 Table (const Table &table1, const Table &table2, int offset2)
 Merge constructor: combine two tables into one table.
 
 Table (const Table &table1, const Table &table2, int offset2, const Table &table3, int offset3)
 Merge constructor: combine three tables into one table.
 
 Table (int dim, int connections_per_row=3)
 Create a table with an upper limit for the number of connections.
 
 Table (int nrows, Array< Connection > &list)
 Create a table from a list of connections, see MakeFromList().
 
 Table (int nrows, int *partitioning)
 Create a table with one entry per row with column indices given by partitioning.
 
void SetSize (int dim, int connections_per_row)
 Set the size and the number of connections for the table.
 
void SetDims (int rows, int nnz)
 Set the rows and the number of all connections for the table.
 
int Size () const
 Returns the number of TYPE I elements.
 
int Size_of_connections () const
 Returns the number of connections in the table.
 
int operator() (int i, int j) const
 Returns index of the connection between element i of TYPE I and element j of TYPE II.
 
void GetRow (int i, Array< int > &row) const
 Return row i in array row (the Table must be finalized)
 
int RowSize (int i) const
 
const int * GetRow (int i) const
 
int * GetRow (int i)
 
int * GetI ()
 
int * GetJ ()
 
const int * GetI () const
 
const int * GetJ () const
 
Memory< int > & GetIMemory ()
 
Memory< int > & GetJMemory ()
 
const Memory< int > & GetIMemory () const
 
const Memory< int > & GetJMemory () const
 
const int * ReadI (bool on_dev=true) const
 
int * WriteI (bool on_dev=true)
 
int * ReadWriteI (bool on_dev=true)
 
const int * HostReadI () const
 
int * HostWriteI ()
 
int * HostReadWriteI ()
 
const int * ReadJ (bool on_dev=true) const
 
int * WriteJ (bool on_dev=true)
 
int * ReadWriteJ (bool on_dev=true)
 
const int * HostReadJ () const
 
int * HostWriteJ ()
 
int * ReadWriteJ ()
 
void SortRows ()
 Sort the column (TYPE II) indices in each row.
 
void SetIJ (int *newI, int *newJ, int newsize=-1)
 Replace the I and J arrays with the given newI and newJ arrays.
 
int Push (int i, int j)
 Establish connection between element i and element j in the table.
 
void Finalize ()
 Finalize the table initialization.
 
void MakeFromList (int nrows, const Array< Connection > &list)
 Create the table from a list of connections {(from, to)}, where 'from' is a TYPE I index and 'to' is a TYPE II index.
 
int Width () const
 Returns the number of TYPE II elements (after Finalize() is called).
 
void LoseData ()
 Releases ownership of and null-ifies the data.
 
void Print (std::ostream &out=mfem::out, int width=4) const
 Prints the table to the stream out.
 
void PrintMatlab (std::ostream &out) const
 
void Save (std::ostream &out) const
 
void Load (std::istream &in)
 
void Copy (Table &copy) const
 
void Swap (Table &other)
 
void Clear ()
 
std::size_t MemoryUsage () const
 
Used together with the default constructor
void MakeI (int nrows)
 
void AddAColumnInRow (int r)
 
void AddColumnsInRow (int r, int ncol)
 
void MakeJ ()
 
void AddConnection (int r, int c)
 
void AddConnections (int r, const int *c, int nc)
 
void ShiftUpI ()
 

Protected Attributes

int size
 The number of TYPE I elements.
 
Arrays for the connectivity information in the CSR storage.
Array< int > I
 The length of the I array is 'size + 1',.
 
Array< int > J
 The length of the J array is equal to the number of connections between TYPE I and TYPE II elements.
 

Detailed Description

Table stores the connectivity of elements of TYPE I to elements of TYPE II. For example, it may be the element-to-face connectivity table.

Definition at line 42 of file table.hpp.

Constructor & Destructor Documentation

◆ Table() [1/6]

mfem::Table::Table ( )
inline

Creates an empty table.

Definition at line 61 of file table.hpp.

◆ Table() [2/6]

mfem::Table::Table ( const Table & table1,
const Table & table2,
int offset2 )

Merge constructor: combine two tables into one table.

Definition at line 27 of file table.cpp.

◆ Table() [3/6]

mfem::Table::Table ( const Table & table1,
const Table & table2,
int offset2,
const Table & table3,
int offset3 )

Merge constructor: combine three tables into one table.

Definition at line 59 of file table.cpp.

◆ Table() [4/6]

mfem::Table::Table ( int dim,
int connections_per_row = 3 )
explicit

Create a table with an upper limit for the number of connections.

Definition at line 99 of file table.cpp.

◆ Table() [5/6]

mfem::Table::Table ( int nrows,
Array< Connection > & list )
inline

Create a table from a list of connections, see MakeFromList().

Definition at line 76 of file table.hpp.

◆ Table() [6/6]

mfem::Table::Table ( int nrows,
int * partitioning )

Create a table with one entry per row with column indices given by partitioning.

Definition at line 115 of file table.cpp.

Member Function Documentation

◆ AddAColumnInRow()

void mfem::Table::AddAColumnInRow ( int r)
inline

Definition at line 86 of file table.hpp.

◆ AddColumnsInRow()

void mfem::Table::AddColumnsInRow ( int r,
int ncol )
inline

Definition at line 87 of file table.hpp.

◆ AddConnection()

void mfem::Table::AddConnection ( int r,
int c )
inline

Definition at line 89 of file table.hpp.

◆ AddConnections()

void mfem::Table::AddConnections ( int r,
const int * c,
int nc )

Definition at line 152 of file table.cpp.

◆ Clear()

void mfem::Table::Clear ( )

Definition at line 420 of file table.cpp.

◆ Copy()

void mfem::Table::Copy ( Table & copy) const

Definition at line 427 of file table.cpp.

◆ Finalize()

void mfem::Table::Finalize ( )

Finalize the table initialization.

The function may be called only once, after the table has been initialized, in order to compress array J (by getting rid of -1's in array J). Calling this function will "freeze" the table and function Push will work no more. Note: The table is functional even without calling Finalize().

Definition at line 287 of file table.cpp.

◆ GetI() [1/2]

int * mfem::Table::GetI ( )
inline

Definition at line 127 of file table.hpp.

◆ GetI() [2/2]

const int * mfem::Table::GetI ( ) const
inline

Definition at line 129 of file table.hpp.

◆ GetIMemory() [1/2]

Memory< int > & mfem::Table::GetIMemory ( )
inline

Definition at line 132 of file table.hpp.

◆ GetIMemory() [2/2]

const Memory< int > & mfem::Table::GetIMemory ( ) const
inline

Definition at line 134 of file table.hpp.

◆ GetJ() [1/2]

int * mfem::Table::GetJ ( )
inline

Definition at line 128 of file table.hpp.

◆ GetJ() [2/2]

const int * mfem::Table::GetJ ( ) const
inline

Definition at line 130 of file table.hpp.

◆ GetJMemory() [1/2]

Memory< int > & mfem::Table::GetJMemory ( )
inline

Definition at line 133 of file table.hpp.

◆ GetJMemory() [2/2]

const Memory< int > & mfem::Table::GetJMemory ( ) const
inline

Definition at line 135 of file table.hpp.

◆ GetRow() [1/3]

int * mfem::Table::GetRow ( int i)
inline

Definition at line 125 of file table.hpp.

◆ GetRow() [2/3]

const int * mfem::Table::GetRow ( int i) const
inline

Definition at line 124 of file table.hpp.

◆ GetRow() [3/3]

void mfem::Table::GetRow ( int i,
Array< int > & row ) const

Return row i in array row (the Table must be finalized)

Definition at line 233 of file table.cpp.

◆ HostReadI()

const int * mfem::Table::HostReadI ( ) const
inline

Definition at line 140 of file table.hpp.

◆ HostReadJ()

const int * mfem::Table::HostReadJ ( ) const
inline

Definition at line 147 of file table.hpp.

◆ HostReadWriteI()

int * mfem::Table::HostReadWriteI ( )
inline

Definition at line 142 of file table.hpp.

◆ HostWriteI()

int * mfem::Table::HostWriteI ( )
inline

Definition at line 141 of file table.hpp.

◆ HostWriteJ()

int * mfem::Table::HostWriteJ ( )
inline

Definition at line 148 of file table.hpp.

◆ Load()

void mfem::Table::Load ( std::istream & in)

Definition at line 404 of file table.cpp.

◆ LoseData()

void mfem::Table::LoseData ( )
inline

Releases ownership of and null-ifies the data.

Definition at line 184 of file table.hpp.

◆ MakeFromList()

void mfem::Table::MakeFromList ( int nrows,
const Array< Connection > & list )

Create the table from a list of connections {(from, to)}, where 'from' is a TYPE I index and 'to' is a TYPE II index.

The list is assumed to be sorted and free of duplicities, i.e., you need to call Array::Sort and Array::Unique before calling this method. *‍/

Definition at line 322 of file table.cpp.

◆ MakeI()

void mfem::Table::MakeI ( int nrows)

Definition at line 130 of file table.cpp.

◆ MakeJ()

void mfem::Table::MakeJ ( )

Definition at line 140 of file table.cpp.

◆ MemoryUsage()

std::size_t mfem::Table::MemoryUsage ( ) const

Definition at line 437 of file table.cpp.

◆ operator()()

int mfem::Table::operator() ( int i,
int j ) const

Returns index of the connection between element i of TYPE I and element j of TYPE II.

If there is no connection between element i and element j established in the table, then the return value is -1.

Definition at line 211 of file table.cpp.

◆ Print()

void mfem::Table::Print ( std::ostream & out = mfem::out,
int width = 4 ) const

Prints the table to the stream out.

Definition at line 353 of file table.cpp.

◆ PrintMatlab()

void mfem::Table::PrintMatlab ( std::ostream & out) const

Definition at line 375 of file table.cpp.

◆ Push()

int mfem::Table::Push ( int i,
int j )

Establish connection between element i and element j in the table.

The return value is the index of the connection. It returns -1 if it fails to establish the connection. Possibilities are there is not enough memory on row i to establish connection to j, an attempt to establish new connection after calling Finalize().

Definition at line 263 of file table.cpp.

◆ ReadI()

const int * mfem::Table::ReadI ( bool on_dev = true) const
inline

Definition at line 137 of file table.hpp.

◆ ReadJ()

const int * mfem::Table::ReadJ ( bool on_dev = true) const
inline

Definition at line 144 of file table.hpp.

◆ ReadWriteI()

int * mfem::Table::ReadWriteI ( bool on_dev = true)
inline

Definition at line 139 of file table.hpp.

◆ ReadWriteJ() [1/2]

int * mfem::Table::ReadWriteJ ( )
inline

Definition at line 149 of file table.hpp.

◆ ReadWriteJ() [2/2]

int * mfem::Table::ReadWriteJ ( bool on_dev = true)
inline

Definition at line 146 of file table.hpp.

◆ RowSize()

int mfem::Table::RowSize ( int i) const
inline

Definition at line 122 of file table.hpp.

◆ Save()

void mfem::Table::Save ( std::ostream & out) const

Definition at line 390 of file table.cpp.

◆ SetDims()

void mfem::Table::SetDims ( int rows,
int nnz )

Set the rows and the number of all connections for the table.

Does NOT initialize the whole array I ! (I[0]=0 and I[rows]=nnz only)

Definition at line 188 of file table.cpp.

◆ SetIJ()

void mfem::Table::SetIJ ( int * newI,
int * newJ,
int newsize = -1 )

Replace the I and J arrays with the given newI and newJ arrays.

If newsize < 0, then the size of the Table is not modified.

Definition at line 253 of file table.cpp.

◆ SetSize()

void mfem::Table::SetSize ( int dim,
int connections_per_row )

Set the size and the number of connections for the table.

Definition at line 172 of file table.cpp.

◆ ShiftUpI()

void mfem::Table::ShiftUpI ( )

Definition at line 163 of file table.cpp.

◆ Size()

int mfem::Table::Size ( ) const
inline

Returns the number of TYPE I elements.

Definition at line 103 of file table.hpp.

◆ Size_of_connections()

int mfem::Table::Size_of_connections ( ) const
inline

Returns the number of connections in the table.

If Finalize() is not called, it returns the number of possible connections established by the used constructor. Otherwise, it is exactly the number of established connections after calling Finalize(). *‍/

Definition at line 110 of file table.hpp.

◆ SortRows()

void mfem::Table::SortRows ( )

Sort the column (TYPE II) indices in each row.

Definition at line 245 of file table.cpp.

◆ Swap()

void mfem::Table::Swap ( Table & other)

Definition at line 432 of file table.cpp.

◆ Width()

int mfem::Table::Width ( ) const

Returns the number of TYPE II elements (after Finalize() is called).

Definition at line 343 of file table.cpp.

◆ WriteI()

int * mfem::Table::WriteI ( bool on_dev = true)
inline

Definition at line 138 of file table.hpp.

◆ WriteJ()

int * mfem::Table::WriteJ ( bool on_dev = true)
inline

Definition at line 145 of file table.hpp.

Member Data Documentation

◆ I

Array<int> mfem::Table::I
protected

The length of the I array is 'size + 1',.

Definition at line 51 of file table.hpp.

◆ J

Array<int> mfem::Table::J
protected

The length of the J array is equal to the number of connections between TYPE I and TYPE II elements.

Definition at line 55 of file table.hpp.

◆ size

int mfem::Table::size
protected

The number of TYPE I elements.

Definition at line 45 of file table.hpp.


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