Jive reference manual
|
Maps degrees of freedom to a range of indices. More...
Public Types | |
typedef jem::String | String |
Represents a string type. More... | |
typedef jem::numeric::SparseMatrix< int > | SparseMatrix |
Represents a sparse integer matrix. More... | |
typedef jem::util::Properties | Properties |
Represents a properties set. More... | |
Public Member Functions | |
int | itemCount () const |
Returns the size of the item set associated with this dof space. More... | |
virtual int | typeCount () const =0 |
Returns the number of dof types. More... | |
virtual int | dofCount () const =0 |
Returns the total number of dofs. More... | |
virtual int | findType (const String &name) const |
Searches for a dof type with a given name. More... | |
virtual String | getTypeName (int itype) const =0 |
Returns a name of a dof type with a given index. More... | |
virtual StringVector | getTypeNames () const |
Returns a array containing all dof type names. More... | |
virtual int | findDofIndex (int iitem, int itype) const =0 |
Searches for a dof attached to a given item. More... | |
int | getDofIndex (int iitem, int itype) const |
Returns the index of a dof attached to a given item. More... | |
virtual int | findDofIndices (const IntVector &idofs, const IntVector &iitems, const IntVector &itypes) const |
Searches for the dofs attached to a given set of items. More... | |
virtual int | collectDofIndices (const IntVector &idofs, const IntVector &iitems, const IntVector &itypes) const |
Collects the indices of the dofs attached to a given set of items. More... | |
void | getDofIndices (const IntVector &idofs, const IntVector &iitems, const IntVector &itypes) const |
Gets the indices of the dofs attached to a given set of items. More... | |
virtual int | getDofsForItem (const IntVector &idofs, const IntVector &itypes, int iitem) const |
Returns all dofs attached to a given item. More... | |
virtual int | getDofsForType (const IntVector &idofs, const IntVector &iitems, int itype) const |
Returns all dofs of a given type. More... | |
virtual void | decodeDofIndex (int &iitem, int &itype, int idof) const =0 |
Returns an item/type index pair given a dof index. More... | |
virtual void | decodeDofIndices (const IntVector &iitems, const IntVector &itypes, const IntVector &idofs) const |
Returns item/type index pairs given a set of dof indices. More... | |
virtual SparseMatrix | toMatrix () const =0 |
Returns a matrix representation of this dof space. More... | |
virtual ItemSet * | getItems () const =0 |
Returns the item set associated with this dof space. More... | |
String | getDofPath (int idof) const |
Returns an identification string for a given dof. More... | |
String | getDofPath (int iitem, int itype) const |
Returns an identification string for a given dof. More... | |
String | getContext () const |
Returns a context string. More... | |
void | printTo (jem::io::TextOutput &out) const |
Writes the state of this dof space to a text output stream. More... | |
void | store (const Properties &globdat) const |
Stores this dof space in a (global) data set. More... | |
virtual String | toString () const |
Returns a short textual description of this object. More... | |
![]() | |
virtual Class * | getClass () const |
Returns the Class instance representing the runtime class of this object. More... | |
virtual long | hashValue () const |
Returns a hash value for this object. More... | |
virtual bool | equals (const Ref< Object > &obj) const |
Tests whether two objects are equal. More... | |
Ref< Object > | clone () const |
Returns a copy of this object. More... | |
Static Public Member Functions | |
static jem::Ref< DofSpace > | find (const Properties &globdat) |
Searches for the primary dof space in a (global) data set. More... | |
static jem::Ref< DofSpace > | find (const jem::Ref< ItemSet > &items, const Properties &globdat) |
Searches for an item-specific dof space in a (global) data set. More... | |
static jem::Ref< DofSpace > | get (const Properties &globdat, const String &context) |
Returns the primary dof space in a (global) data set. More... | |
static jem::Ref< DofSpace > | get (const jem::Ref< ItemSet > &items, const Properties &globdat, const String &context) |
Returns an item-specific dof space in a (global) data set. More... | |
![]() | |
static Class * | getType () |
Returns the Class instance representing the Object class. More... | |
Public Attributes | |
jem::util::Event< int, Self & > | newSizeEvent |
Signals that the number of dofs has changed. More... | |
jem::util::Event< const IntVector &, Self & > | newOrderEvent |
Signals that the dofs have been re-ordered. More... | |
Protected Member Functions | |
virtual | ~DofSpace () |
![]() | |
Collectable () | |
Creates an empty Collectable . More... | |
~Collectable () | |
Frees resources. More... | |
Related Functions | |
(Note that these are not member functions.) | |
IntVector | makeDofOrdering (const DofSpace &dofs, const IntVector &itemPerm) |
Creates a dof permutation array given an item permutation array. More... | |
#include <jive/util/DofSpace.h>
The DofSpace
class can be used to map degrees of freedom (dof) to a contiguous range of indices or equation numbers. It essentially represents a sparse integer matrix in which each row represents an item in an ItemSet
, and in which each column represents a dof type like temperature or pressure. The value of a matrix element (i,j) is the global index, or equation number, of the dof that is attached to item i and has type j. As usual, the dof indices range from zero to the total number of dofs minus one.
Although it is efficient to use integers for representing dof types, this scheme is not particularly intuitive when used in input and output files. The DofSpace
class therefore provides functions for converting dof types from integers to strings and the other way around. Thus, a dof type can be represented both by a string and by an integer that ranges from zero to the total number of types minus one. The string and integer representations of a dof type will be referred to as the dof type name and dof type index, respectively.
The example below demonstrates how to print a vector associated with a DofSpace
.
All dofs in a DofSpace
must be attached to items in the same ItemSet
. It is not (yet) possible to associate a DofSpace
with multiple item sets.
The DofSpace
class declares only member functions for translating item-type index pairs to dof indices, and the other way around. You will have to use the XDofSpace
if you want to add and remove dofs and dof types.
Represents a string type.
Represents a sparse integer matrix.
Represents a properties set.
|
protectedvirtual |
int jive::util::DofSpace::itemCount | ( | ) | const |
Returns the size of the item set associated with this dof space. The implementatino provided by the DofSpace
class simply executes:
return this->getItems()->size();
getItems()
|
pure virtual |
Returns the number of dof types known to this dof space.
Implemented in jive::util::UniformDofSpace, jive::util::FlexDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::solver::SchurDofSpace, and jive::solver::CoarseDofSpace.
|
pure virtual |
Returns the number of dofs known to this dof space. This number is equal to the number of non-zeroes in the sparse matrix representation of this dof space.
Note that the number of dofs equals
when the matrix representation of this dof space is a dense matrix. That is, when typeCount()
dofs are attached to each item.
Implemented in jive::util::UniformDofSpace, jive::util::FlexDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::solver::SchurDofSpace, and jive::solver::CoarseDofSpace.
|
virtual |
Returns the index of the dof type named name, or a negative number if a dof type with that name is not known to this dof space.
The implementation of this function provided by the DofSpace
class searches for the type index by repeatedly calling the getTypeName()
function. Derived classes are encouraged to provide a more efficient implementation.
name | - the name of the dof type to be found. |
return The index of the dof type named name, or a negative number.
Reimplemented in jive::util::FlexDofSpace, jive::util::UniformDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::solver::CoarseDofSpace, and jive::solver::SchurDofSpace.
|
pure virtual |
Returns the name of the dof type with index itype.
itype | - a valid dof type index. |
itype >= 0 && itype < typeCount()
|
virtual |
Returns an array containing the names of all dof types known to this dof space. The contents of this array should not be modified as the array may share its data with one of the private data members of this DofSpace
object.
The implementation of this function provided by the DofSpace
class creates the array by repeatedly calling the getTypeName()
function.
Reimplemented in jive::util::FlexDofSpace, jive::util::UniformDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::solver::CoarseDofSpace, and jive::solver::SchurDofSpace.
|
pure virtual |
Returns the index of the dof that is attached to item iitem and that has type itype. A negative number is returned if such a dof does not exist.
Note that if the dof to be found exists, then this function returns the element (iitem,itype) in the matrix representation of this dof space.
iitem | - a valid item index. |
itype | - a valid dof type index. |
iitem >= 0 && iitem < itemCount() &&
itype >= 0 && itype < typeCount()
int jive::util::DofSpace::getDofIndex | ( | int | iitem, |
int | itype | ||
) | const |
Returns the index of the dof that is attached to item iitem and that has type itype. An exception is thrown if that dof does not exist.
iitem | - a valid item index. |
itype | - a valid dof type index. |
iitem >= 0 && iitem < itemCount() &&
itype >= 0 && itype < typeCount()
jem::IllegalInputException | - if the dof to be found does not exist. |
findDofIndex()
|
virtual |
Fills the array idofs with the indices of the dofs that are attached to the items iitems and that have types itypes, and returns the number of dofs that have been found. To be precise, this function executes the following algorithm:
Note that if a dof does not exist, its entry in the array idofs is not set.
The implementation of this function provided by the DofSpace
class executes the code shown above. Derived classes may provide a more efficient implementation if that is possible.
idofs | - an integer array to be filled with the indices of the dofs to be found. |
iitems | - an integer array containing valid item indices. |
itypes | - an integer array containing valid dof type indices. |
idofs.size() >= iitems.size() * itypes.size() &&
min( iitems ) >= 0 && max( iitems ) < itemCount() &&
min( itypes ) >= 0 && max( itypes ) < typeCount()
|
virtual |
Fills the array idofs with the indices of the dofs that are attached to the items iitems and that have types itypes, and returns the number of dofs that have been found. To be precise, this function executes the following algorithm:
Note that, in contrast to the member function findDofIndices()
, the dof indices are stored contiguously in the output array idofs.
The implementation of this function provided by the DofSpace
class executes the code shown above. Derived classes may provide a more efficient implementation if that is possible.
idofs | - an integer array to be filled with the indices of the dofs to be found. |
iitems | - an integer array containing valid item indices. |
itypes | - an integer array containing valid dof type indices. |
idofs.size() >= iitems.size() * itypes.size() &&
min( iitems ) >= 0 && max( iitems ) < itemCount() &&
min( itypes ) >= 0 && max( itypes ) < typeCount()
void jive::util::DofSpace::getDofIndices | ( | const IntVector & | idofs, |
const IntVector & | iitems, | ||
const IntVector & | itypes | ||
) | const |
Fills the array idofs with the indices of the dofs that are attached to the items iitems and that have types itypes. An exception is thrown if one or more dofs are not known to this dof space.
This function simply calls the function findDofIndices()
and throws an exception if the returned value is less than
iitems.size() * itypes.size()
.
idofs | - an integer array to be filled with the indices of the dofs to be found. |
iitems | - an integer array containing valid item indices. |
itypes | - an integer array containing valid dof type indices. |
idofs.size() >= iitems.size() * itypes.size() &&
min( iitems ) >= 0 && max( iitems ) < itemCount() &&
min( itypes ) >= 0 && max( itypes ) < typeCount()
jem::IllegalInputException | - if one or more dofs to be found do not exist. |
|
virtual |
Fills the output array idofs with the indices of the dofs that are attached to item iitem. The output array itypes is filled with the dof type indices. The return value equals the number of dofs attached to the item iitem. Note that the arrays idofs and itypes must be large enough to store the dof (type) indices.
The implementation of this function provided by the DofSpace
class simply loops over all dof types as follows:
Derived classes are encouraged to provide a more efficient implementation.
idofs | - an integer array to be filled with the indices of all dofs attached to item iitem. |
itypes | - an integer array to be filled with the type indices of the dofs attached to item iitem. |
iitem | - a valid item index. |
idofs.size() >= typeCount() &&
itypes.size() >= typeCount() &&
iitem >= 0 && iitem < itemCount()
|
virtual |
Fills the array idofs with the indices of all dofs of type itype, and returns the number of entries in idofs that have been set. The array iitems is filled with the indices of the items to which the dofs are attached. Note that the arrays idofs and iitems must be large enough to store all dof and item indices.
The implementation of this function provided by the DofSpace
class simply loops over all items as follows:
Derived classes should provide a more efficient implementation when possible.
idofs | - an integer array to be filled with the indices of all dofs of type itype. |
iitems | - an integer array to be filled with the item indices of the dofs of type itype. |
itype | - a valid dof type index. |
idofs.size() >= typeCount() &&
iitems.size() >= typeCount() &&
itype >= 0 && itype < typeCount()
|
pure virtual |
Returns in the integer references iitem and itype the item index and type index, respectively, of the dof with index idof.
iitem | - a reference to an integer to be set to the item index of the dof idof. |
itype | - a reference to an integer to be set to the type index of dof idof. |
idof | - a valid dof index. |
idof >= 0 && idof < dofCount()
idof == getDofIndex( iitem, itype )
|
virtual |
Fills the arrays iitems and itypes with the item and type indices, respectively, of the dofs with indices idofs. The implementation of this function provided by the DofSpace
class repeatedly calls the decodeDofIndex()
function as follows:
iitems | - an integer array to be filled with the item indices of the dofs idofs. |
itypes | - an integer array to be filled with the type indices of the dofs idofs. |
idofs | - an integer array containing valid dof indices. |
iitems.size() >= idofs.size() &&
itypes.size() >= idofs.size() &&
min( idofs ) >= 0 && max( idofs ) < dofCount()
|
pure virtual |
Returns a sparse matrix representation of this dof space. Each row in the matrix is associated with an item and each column is associated with a dof type. The value of a matrix element (i,j) is the global index, or equation number, of the dof that is attached to item i and has type j.
Implemented in jive::util::FlexDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::util::UniformDofSpace, jive::solver::CoarseDofSpace, and jive::solver::SchurDofSpace.
|
pure virtual |
Returns a pointer to the item set containing the items to which the dofs in this dof space are attached. The pointer is guaranteed not to be NULL
and to remain valid throughout the entire lifetime of this DofSpace
object.
Implemented in jive::util::FlexDofSpace, jive::util::DenseDofSpace, jive::util::SparseDofSpace, jive::util::UniformDofSpace, jive::solver::CoarseDofSpace, and jive::solver::SchurDofSpace.
String jive::util::DofSpace::getDofPath | ( | int | idof | ) | const |
Returns a descriptive string for the dof with index idof. This string can be used to display (error) messages related to that dof.
idof | - a valid dof index. |
idof >= 0 && idof < dofCount()
String jive::util::DofSpace::getDofPath | ( | int | iitem, |
int | itype | ||
) | const |
Returns a descriptive string for the dof that is attached to item iitem and that has type itype. This string can be used to display (error) messages related to that dof.
iitem | - a valid item index. |
itype | - a valid dof type index. |
iitem >= 0 && iitem < itemCount() &&
itype >= 0 && itype < typeCount()
String jive::util::DofSpace::getContext | ( | ) | const |
Returns a context string that can be used for displaying errors and other types of messages that are related to this dof space. The returned string is typically passed as a context string to the constructor of an exception class.
void jive::util::DofSpace::printTo | ( | jem::io::TextOutput & | out | ) | const |
Writes a human-readable representation of this dof space to the text output stream out. This function is mainly intended to be used as a debugging aid.
out | - a text output stream. |
void jive::util::DofSpace::store | ( | const Properties & | globdat | ) | const |
Stores this dof space in the global data set globdat. The dof space is stored both as the primary dof space and as the item-specific dof space for the item set returned by the member function getItems()
. The primary dof space can be retrieved by calling the static member functions find()
and get()
without specifying a particular item set. A item-specific dof space can be retrieved by calling the static member functions find()
and get()
with an item set as the first argument.
Note that the last dof space stored in a global data set automatically becomes the primary dof space.
globdat | - a (global) data set. |
|
static |
|
static |
Searches for the item-specific dof space associated with the item set items in the global data set globdat. If found, a reference to the dof space is returned, else NIL
is returned.
items | - a reference to an item set. |
globdat | - a (global) data set. |
items != NIL
NIL
.
|
static |
Returns a reference to the primary dof space in the global data set globdat. An exception is thrown if no primary dof space has been stored in globdat. The parameter context will be used as the context string for the exception.
globdat | - a global data set. |
context | - an error context string. |
jem::IllegalInputException | - if no primary dof space has been stored in globdat. |
|
static |
Returns a reference to the dof space associated with the item set items in the global data set globdat. An exception is thrown if globdat does not contain the item-specific dof space. The parameter context will be used as the context string for the exception.
items | - a reference to an item set. |
globdat | - a global data set. |
context | - an error context string. |
items != NIL
jem::IllegalInputException | - if globdat does not contain the item-specific dof space. |
|
virtual |
Returns a short textual description of this object. The toString
method of the class Object
returns:
getClass()->getName() + "@" + String( hashValue() )
String
representing this object. Reimplemented from jem::Object.
Returns an integer array that indicates how the dofs in the dof space dofs could be re-ordered to achieve the same effect as if the items supporting the dofs were re-ordered according to the permutation array itemPerm. Use this function to create an optimal dof ordering given an optimal item ordering.
If dofPerm
denotes the returned array, then dofPerm
[idof] yields the new index of the dof with index idof
. Likewise, itemPerm
[iitem] should specify the new index of the item with index iitem
.
dofs | - a DofSpace object. |
itemPerm | - a permutation array for the items supporting the dofs in the dof space dofs. |
itemPerm.size() == dofs.itemCount()
jem::util::Event< int, Self& > jive::util::DofSpace::newSizeEvent |
jem::util::Event< const IntVector&, Self& > jive::util::DofSpace::newOrderEvent |
Signals that the dofs in this dof space have been re-ordered. The first event argument specifies how the dofs have been re-ordered. If this argument is denoted by iperm
, then iperm[i]
is the new index of the i-th dof. If iperm[i]
is a negative number, then the i-th dof has been deleted. The second event argument is a reference to this DofSpace
object.