NAME
AlgebraicContribs - index set, union of index sets
INCLUDE
include "AlgebraicContribs.h"
SYNTAX
//-----------------------------------------------------------------------------
class AlgebraicContribs: public HandleId
//-----------------------------------------------------------------------------
{
private:
VecSimple(AlgebraicEquation) equations; // Constraint eqns
VecSimple(AlgebraicCoupling) couplings; // Couplings between eqns and PDE
int cnt_equations; // No of active equations
int cnt_couplings; // No of active couplings
int row_base; // Row numbering base (from PDE)
int col_base; // Column numbering base (from PDE)
// Need ptr instead of handle, circular references
DegFreeFD* dof; // Link to the PDE part
bool is_assembled; // Internal consistency flag
int nnz; // Number of nonzeros
Handle(VecSimpleH(VecSimple(NUMT))) alg_coeffs; // Matrix entries
Handle(VecSimpleH(VecSimple(int))) alg_pattern; // Sparsity pattern
Handle(Vec(NUMT)) b_mod; // RHS part from eqns/couplings
void connect (const DegFreeFD& dof_);
public :
AlgebraicContribs (const DegFreeFD& dof_);
AlgebraicContribs (const AlgebraicContribs& alg_contribs);
AlgebraicContribs (int no_algdofs,
const DegFreeFD& dof_);
AlgebraicContribs (int no_equations,
int no_couplings,
const DegFreeFD& dof_);
AlgebraicContribs (VecSimple(AlgebraicEquation) equations_,
VecSimple(AlgebraicCoupling) couplings_,
const DegFreeFD& dof_);
virtual ~AlgebraicContribs () {}
AlgebraicContribs& operator= (const AlgebraicContribs& alg_contribs);
// Redimensioning
bool redim (int no_algdofs);
bool redim (int no_equations, int no_couplings);
bool redim (VecSimple(AlgebraicEquation) equations_,
VecSimple(AlgebraicCoupling) couplings_);
void update ();
void reset ();
void grow (int neqns, int ndofs);
void grow (int n);
int getNoEquations () const;
int getNoCouplings () const;
void size (int& neqns, int& ndofs) const;
int loc2globEqn (int loc_eqn) const;
int glob2locEqn (int glob_eqn) const;
int loc2globDof (int loc_dof) const;
int glob2locDof (int glob_dof) const;
// Set/get equation or coupling, local numbering
AlgebraicEquation& equation (int loc_eqn);
const AlgebraicEquation& equation (int loc_eqn) const;
AlgebraicCoupling& coupling (int loc_dof);
const AlgebraicCoupling& coupling (int loc_dof) const;
void fill (VecSimple(AlgebraicEquation) equations_,
VecSimple(AlgebraicCoupling) couplings_);
void insertEquation (int loc_eqn, NUMT coeff, int glob_dof);
void insertEquation (int loc_eqn, const VecSimple(NUMT)& coeffs,
const VecSimple(int)& glob_dofs);
void insertCoupling (int loc_dof, NUMT coeff, int glob_eqn);
void insertCoupling (int loc_dof, const VecSimple(NUMT)& coeffs,
const VecSimple(int)& glob_eqns);
// Set/get equation or coupling, automatic numbering
void insertEquation (NUMT coeff, int glob_dof);
void insertEquation (const VecSimple(NUMT)& coeffs,
const VecSimple(int)& glob_dofs);
void insertCoupling (NUMT coeff, int glob_eqn);
void insertCoupling (const VecSimple(NUMT)& coeffs,
const VecSimple(int)& glob_eqns);
// Recover index and coefficent info for matrix assembly
int assemble ();
bool isAssembled ();
const VecSimpleH(VecSimple(NUMT))* getCoeffs () const;
const VecSimpleH(VecSimple(int))* getPattern () const;
// Insert RHS modification vector (global numbering)
void insertRHS (const Vec(NUMT)& b_mod_, bool allocate = false);
virtual void print (Os os) const;
virtual void scan (Is is);
CLASS_INFO
friend class FDM;
};
KEYWORDS
index set, iterator, union of index sets
DESCRIPTION
The class implements an index set by a table of objects of type
IndexSet. The class is itself derived from the abstract base
class IndexSet. This means that any index set in the IndexSet
hierarchy can be put into the table. The class defines an index
set as the union of the index sets within this table. During
iteration the index sets of the table are iterated sequentially.
This means that an index might be defined twize as it is not
encountered for intersecton.
CONSTRUCTORS AND INITIALIZATION
The constructor with an integer argument specifies the maximum
number of IndexSet objects contained by the class. The add member
function can be used to initialize the index sets.
MEMBER FUNCTIONS
Please note that the inherited member functions from the class
IndexSet are described within the documentation of IndexSet.
bool redim - redimensions the number of index set (the table
length), the previous contents of the table is deallocated.
reset - reset equation- and coupling counters to 0, and fill the
datastructure for the algebraic coefficients with 0.0.
add - add an index set to the table, note that as default the
reference given as argument is copied to a new object within the
class by calling the getIndexIterator member function. This
should always be done if AlgebraicContribs are not the only user
of the specific IndexSet. If the second argument is set to false
the address of the object is rebinded to the datastructure. The
object must thus not be used elsewhere and the object should have
been allocated dynamically. The proper deallocation is then per
formed by the class AlgebraicContribs.
grow - The table containing the index sets are enlarged with the
given integer number of sets. The contense is preserved.
remove - The table containing the index sets are shortened with
the given integer number of sets. The remaining sets are pre
served.
scan - The format read by scan is same as written by the print
member function. This is also the format read by the scan of the
class IndexSet_prm. See the example below.
EXAMPLES
| #include <AlgebraicContribs.h>
#include <IndexSetBox.h>
void main()
{
The index set we want to construct :
12 xxxx
11 xxxx
10 xxxx
9 xxxx
8 xxxxxxxxxxxx
7 xxxxxxxxxxxx
6 xxxxxxxxxxxx
5 xxxxxxxxxxxx
4 xxxx
3 xxxx
2 xxxx
1 xxxx
------------
123456789111
012
AlgebraicContribs ind(3); // makes a table for three IndexSet
elements.
IndexSetBox box(2);
box.scan("(5,1) (8,4)"); ind.add(box);
box.scan("(1,5) (12,8)"); ind.add(box);
box.scan("(5,9) (8,12)"); ind.add(box);
s_o << ind << "0;
IndexSet_prm prm;
prm.scan(s_i);
IndexSetIndieces ind2 (prm);
ind2.print(s_o);
// To initialize the parameter class the following input is
needed :
//
-----------------------------------------------------------------
>index_set_storage = AlgebraicContribs
>nsd = 2
>index_set_string = {
>no_of_sets = 3
>index_set_storage = IndexSetBox >nsd = 2 >index_set_string = {
(1,1)x(4,4) }
>index_set_storage = IndexSetBox >nsd = 2 >index_set_string = {
(1,5)x(12,8) }
>index_set_storage = IndexSetBox >nsd = 2 >index_set_string = {
(5,9)x(8,12) }
}
SEE ALSO
class IndexSet, class IndexSetBox, class IndexSetBoxItOrder,
class MatPtOp(Type), class ArrayGenSel(Type).
DEVELOPED BY
Numerical Objects AS
AUTHOR
Are Magnus Bruaset, Numerical Objects AS