Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

DegFreeFD Class Reference

degree of freedom manager for finite difference linear systems. More...

#include <DegFreeFD.h>

Inheritance diagram for DegFreeFD::

HandleId List of all members.

Public Methods

 DegFreeFD ()
 DegFreeFD (const GridLattice &grid, int ndof_per_node=1)
 DegFreeFD (const GridLattice &grid, const IndexSet &indexset, int ndof_per_node=1)
 DegFreeFD (const GridLattice &grid, const IndexSetCollection &indexsetcoll, int ndof_per_node=1)
 DegFreeFD (FieldsLattice &collection)
 DegFreeFD (FieldsLattice &collection, const IndexSet &indexset)
 DegFreeFD (FieldsLattice &collection, const IndexSetCollection &indexsetcoll)
 ~DegFreeFD ()
bool redim (const GridLattice &grid, int ndof_per_node=1)
bool redim (const GridLattice &grid, const IndexSet &indexset, int ndof_per_node=1)
bool redim (const GridLattice &grid, const IndexSetCollection &indexsetcoll, int ndof_per_node=1)
bool redim (FieldsLattice &collection)
bool redim (FieldsLattice &collection, const IndexSet &indexset)
bool redim (FieldsLattice &collection, const IndexSetCollection &indexsetcoll)
void printNumbering (Os os) const
bool ok () const
bool update ()
GridLatticegrid ()
const GridLatticegrid () const
void connect (const AlgebraicContribs &alg_contribs_)
void disconnect ()
void getBaseIndex (int &eqn_base, int &dof_base)
int getAlgNoDof () const
int getAlgNoEqs () const
int getPDENoDof () const
int getPDENoEqs () const
int getTotalNoDof () const
int getTotalNoEqs () const
int getNoDofPerNode () const
int loc2glob (int node_no, int node_dof) const
int loc2glob (const Ptv(int) &node_idx, int node_dof) const
void loc2glob (VecSimple(int) &l2g, int node_no) const
void loc2glob (VecSimple(int) &l2g, const Ptv(int) &node_idx) const
void initEssBC ()
bool noEssBC () const
bool getEssBC (int iglobdof, NUMT &ebc_value) const
void getEssBC (VecSimple(bool) &essential_dof) const
void getEssBC (Vec(NUMT) &v)
void printEssBC (Os os, int output_level=1)
void fillEssBC (int globdof, NUMT ebc_value)
void fillEssBC (int field_dof, int field_no, NUMT ebc_value)
void fillEssBC2zero ()
void unfillEssBC2zero ()
bool zeroInterpretationOfEssBC () const
void vec2field (const Vec(NUMT) &x, FieldLattice &f)
void field2vec (const FieldLattice &f, Vec(NUMT) &x, bool allocate_alg_dof=true)
void vec2field (const Vec(NUMT) &x, FieldsLattice &f)
void field2vec (const FieldsLattice &f, Vec(NUMT) &x, bool allocate_alg_dof=true)
int fields2dof (int field_dof, int field_no) const
void dof2fields (int global_dof, int &field_dof, int &field_no) const
int getHalfBandWidth (StencilCollection &stencilcoll)
void initAssemble ()
void insertEssBC (VecSimple(NUMT) &ebc)
void modifyMatDue2essBC (bool onoff)
bool modifyMatDue2essBC () const
void modifyVecDue2essBC (bool onoff)
bool modifyVecDue2essBC () const
void symmModDue2essBC (bool onoff)
bool symmModDue2essBC () const
void initAlgPattern ()
 COPY_CONSTRUCTOR (DegFreeFD)
 ASSIGNMENT_OPERATOR (DegFreeFD)
void findSparsePatternFromIndexSet (IndexSet &indexset, StencilCollection &stencils, VecSimple(VecSimple(int)) &col_idx, int indexset_no)
void findSparsePatternFromGrid (StencilCollection &stencils, VecSimple(VecSimple(int)) &col_idx)
void findOffsetPatternFromIndexSet (IndexSet &indexset, StencilCollection &stencils, ArrayGenSimple(int) &offsetmarks, int indexset_no)
void findOffsetPatternFromGrid (StencilCollection &stencils, ArrayGenSimple(int) &offsetmarks)

Public Attributes

Handle(GridLatticemesh
Handle(FieldsLatticefields
Handle(IndexSetindexset
Handle(IndexSetCollectionindexsetcoll
Handle(AlgebraicContribsalg_contribs
Vec(NUMT) b_mod
Handle(VecSimpleH(VecSimple(int))) alg_pattern

Detailed Description

degree of freedom manager for finite difference linear systems.

NAME: DegFreeFD - degree of freedom manager for finite difference linear systems

DESCRIPTION:

The class relates degrees of freedom in a linear system to the nodal values of discrete finite difference fields. By degrees of freedom we mean the unknowns in a linear system associated with some finite difference discretization of a system of partial differential equations. For example, when solving a scalar partial differential equation (e.g. Poisson''s equation) by the finite difference method, there is usually one degree of freedom associated with each node in the finite difference mesh. When solving a vector equation in `$`d`$` dimensions there are `$`d`$` component fields. The relation between, for example, component no `$`j`$` at node `$`k`$` and the corresponding global degree of freedom in the linear system, is computed by a "DegFreeFD" object.

The "DegFreeFD" class also mark the degrees of freedom that are subjected to essential boundary conditions. Class "MatVecContribFD" uses "DegFreeFD" for this purpose. Moreover, the bandwidth of the coefficient matrix in the associated system of linear equations can be calculated. Note that it is assumed that the size of this system equals the total number of degrees of freedom in the associated "DegFreeFD" object. That is, if a vector equation is solved sequentially, component by component, a "DegFreeFD" object with one degree of freedom per node should be used for each component equation.


Constructor & Destructor Documentation

DegFreeFD::DegFreeFD ( ) [inline]
 

The most common constructors to use are the ones that take a "GridLattice" objects and an "IndexSetCollection" or a "FieldsLattice" and an "IndexSetCollection". In the constructor that take a grid, one must specify the number og degrees of freedom at every node if it differs from 1. The constructors that take a "FieldsLattice" sets the number of degrees of freedom per node to the number of components in the "FieldsLattice" object.

Optionally one can use the constructors that take a "GridLattice" object and the number of degrees of freedom per node, or the similar constructor that takes an "IndexSet". Correspondingly, we have a constructor taking a "FieldsLattice" objects and one taking a "FieldsLattice" and an "IndexSet".

There is also a constructor without arguments. It performs no initialization, but one can at a later time call one of the "redim" functions. These correspond exactly to the other 6 constructors (in fact, the constructors simply call the relevant "redim" function - this is a standard in Diffpack).

DegFreeFD::DegFreeFD ( const GridLattice & grid,
int ndof_per_node = 1 )
 

DegFreeFD::DegFreeFD ( const GridLattice & grid,
const IndexSet & indexset,
int ndof_per_node = 1 )
 

See documentation of one of the overloaded constructor.

DegFreeFD::DegFreeFD ( const GridLattice & grid,
const IndexSetCollection & indexsetcoll,
int ndof_per_node = 1 )
 

See documentation of one of the overloaded constructor.

DegFreeFD::DegFreeFD ( FieldsLattice & collection )
 

See documentation of one of the overloaded constructor.

DegFreeFD::DegFreeFD ( FieldsLattice & collection,
const IndexSet & indexset )
 

See documentation of one of the overloaded constructor.

DegFreeFD::DegFreeFD ( FieldsLattice & collection,
const IndexSetCollection & indexsetcoll )
 

See documentation of one of the overloaded constructor.

DegFreeFD::~DegFreeFD ( )
 


Member Function Documentation

DegFreeFD::ASSIGNMENT_OPERATOR ( DegFreeFD )
 

DegFreeFD::COPY_CONSTRUCTOR ( DegFreeFD )
 

void DegFreeFD::connect ( const AlgebraicContribs & alg_contribs_ )
 

attach the supplied "AlgebraicContribs" object to the "DegFreeFD"

void DegFreeFD::disconnect ( )
 

disconnect the "AlgebraicContribs" object from the "DegFreeFD"

void DegFreeFD::dof2fields ( int global_dof,
int & field_dof,
int & field_no ) const
 

this is the inverse function of "fields2dof". The input arguments to "fields2dof" are the return values of "dof2fields" and vice versa.

void DegFreeFD::field2vec ( const FieldsLattice & f,
Vec(NUMT) & x,
bool allocate_alg_dof = true )
 

See documentation of one of the overloaded functions.

void DegFreeFD::field2vec ( const FieldLattice & f,
Vec(NUMT) & x,
bool allocate_alg_dof = true )
 

given a field, the function loads the field into a "Vec" that can be used in a linear system. Recall that the main purpose of the "DegFreeFD" class is to administer the numbering of field values versus unknowns in associated linear systems, and "field2vec" (and "vec2field") contains basic functionality for switching between "Vec" and "FieldLattice" or "FieldsLattice" representations. The "field2vec" and "vec2field" functions are very efficient since they use either very simple formulas or pre-computed internal tables for switching between vector and field formats. If the supplied vector is not initialized, it will be redimensioned to the correct size. If the vector is already initialized but with the wrong size, an error message will be given. If the optional third argument to this function is true, the supplied vector will be set to have dimension "getTotalNoDofs", while if this argument is false, no space is allocated for the algebraic degrees of freedom, and the vector will then have size equal to "getPDENoDof".

int DegFreeFD::fields2dof ( int field_dof,
int field_no ) const
 

returns the global degree of freedom number associated with a coefficient in a component of the "FieldsLattice" structure that holds all the coupled, unknown scalar fields. The parameter "field_dof" corresponds to the node number and "field_no" is the local degree of freedom number (field component number) at this node.

void DegFreeFD::fillEssBC ( int field_dof,
int field_no,
NUMT ebc_value )
 

See documentation of one of the overloaded functions.

void DegFreeFD::fillEssBC ( int globdof,
NUMT ebc_value )
 

set an essential boundary condition. The entry is either specified by the global degree of freedom or the grid point and the local degree of freedom in the node.

void DegFreeFD::fillEssBC2zero ( )
 

forces all essential boundary condition values to be interpreted as zero. If the system of linear equations have an unknown which is a correction vector, special care must be taken. This is the case when e.g. Newton''s method is used for solving systems of nonlinear equations. In each linear problem it is assumed that the total solution has its boundary conditions inserted and that the correction vector must have zeroes for all entries where the value is known. That is, in the modification of element matrices one must set the essential condition to be zero. The "MatVecContribFD :: enforceEssBC" function calls the "zeroInterpretationOfEssBC" of "DegFreeFD" for determining whether the user has indicated to the "DegFreeFD" object that all non-zero essential boundary condition values are to be interpreted as if they were zero. When Newton''s method is used, it is important that the programmer calls the "fillEssBC2zero" function of the "DegFreeFD" class object prior to any "enforceEssBC".

void DegFreeFD::findOffsetPatternFromGrid ( StencilCollection & stencils,
ArrayGenSimple(int) & offsetmarks )
 

void DegFreeFD::findOffsetPatternFromIndexSet ( IndexSet & indexset,
StencilCollection & stencils,
ArrayGenSimple(int) & offsetmarks,
int indexset_no )
 

void DegFreeFD::findSparsePatternFromGrid ( StencilCollection & stencils,
VecSimple(VecSimple(int)) & col_idx )
 

void DegFreeFD::findSparsePatternFromIndexSet ( IndexSet & indexset,
StencilCollection & stencils,
VecSimple(VecSimple(int)) & col_idx,
int indexset_no )
 

int DegFreeFD::getAlgNoDof ( ) const
 

returns the number of degrees of freedom from the algebraic contributions.

int DegFreeFD::getAlgNoEqs ( ) const
 

returns the number of equations from the algebraic contributions.

void DegFreeFD::getBaseIndex ( int & eqn_base,
int & dof_base )
 

returns the base index for the algebraic degrees of freedom and equations. The base index for the algebraic degrees of freedom equals "getPDENoDof" and the base index for the algebraic equations equals "getPDENoEqs".

void DegFreeFD::getEssBC ( Vec(NUMT) & v )
 

See documentation of one of the overloaded functions.

void DegFreeFD::getEssBC ( VecSimple(bool) & essential_dof ) const
 

See documentation of one of the overloaded functions.

bool DegFreeFD::getEssBC ( int iglobdof,
NUMT & ebc_value ) const
 

returns "true" if a global (system) degree of freedom number is subjected to an essential boundary condition. The boundary value is available as an argument to the function. There is an overloaded version that fills a vector of booleans according to whether there is an essential dof or not. Another overloaded version fills a vector with the essential boundary condition if this has been set. Otherwise the entry is left as it is. This is for instance used when one should fill the vector holding the non-linear solution with the essential boundary conditions.

int DegFreeFD::getHalfBandWidth ( StencilCollection & stencilcoll )
 

computes the bandwidth of the coefficient matrix in a linear system associated with the grid and the degrees of freedom. The

       number to be returned is `$`\max_n i-j|+1`$`, where `$`n`$`
numbers in that node (i.e., `$`i`$` and `$`j`$` are unknowns in the node).

int DegFreeFD::getNoDofPerNode ( ) const [inline]
 

int DegFreeFD::getPDENoDof ( ) const
 

returns the total number of degrees of freedom from the partial differential equation part of the system. This is number of nodes in the grid times the number of degrees of freedom per node.

int DegFreeFD::getPDENoEqs ( ) const
 

returns the total number of equations from the partial differential equation part of the system. This is number of nodes in the grid times the number of degrees of freedom per node.

int DegFreeFD::getTotalNoDof ( ) const
 

returns the total number of degrees of freedom in the global system. This is number of nodes in the grid times the number of degrees of freedom per node, plus the number of algebraic degrees of freedom.

int DegFreeFD::getTotalNoEqs ( ) const
 

returns the total number of equations in the global system. This is number of nodes in the grid times the number of degrees of freedom per node, plus the number of algebraic equations.

const GridLattice & DegFreeFD::grid ( ) const
 

See documentation of one of the overloaded functions.

GridLattice & DegFreeFD::grid ( )
 

gives access to the associated grid.

void DegFreeFD::initAlgPattern ( )
 

initialize tha pattern for the algebraic contributions.

void DegFreeFD::initAssemble ( )
 

initializes the "DegFreeFD" object prior to an assembly process. This means that "b_mod" is reset to zero, if these vectors are used (the vectors are used only if "modifyVecDue2essBC()" is false - in that case the vectors hold information about the modifications of the right hand side due to essential boundary conditions). See also the "insertEssBC" function.

void DegFreeFD::initEssBC ( )
 

a function that erases all essential boundary conditions (must be called prior to "fillEssBC").

void DegFreeFD::insertEssBC ( VecSimple(NUMT) & ebc )
 

inserts essential boundary conditions in a vector. This is useful for start vectors for linear or nonlinear solvers and when incorporating essential boundary conditions after a linear system is computed. Here are some comments regarding the latter application. When "modifyVecDue2essBC()" is false, the modifications of the right hand side due to essential boundary conditions are not performed at the element level. Instead the modifications is stored in an internal array ("b_mod") for later use. The "insertEssBC" function utilizes the stored information and inserts the correct boundary values in the "rhs" argument. The argument "account4multiplicity" is by default true, which means that the inserted value and its position are found by "getEssBC" and then multiplied by the number of elements contributing to this degree of freedom. Usually, the modifications of the coefficient matrix due to essential boundary are accomplished at the node level (since that is much more straightforward for, e.g., sparse matrices). The updating of "b_mod" is usually done by "MtVecContribFD :: enforceEssBC".

void DegFreeFD::loc2glob ( VecSimple(int) & l2g,
const Ptv(int) & node_idx ) const
 

See documentation of one of the overloaded functions.

void DegFreeFD::loc2glob ( VecSimple(int) & l2g,
int node_no ) const
 

See documentation of one of the overloaded functions.

int DegFreeFD::loc2glob ( const Ptv(int) & node_idx,
int node_dof ) const
 

See documentation of one of the overloaded functions.

int DegFreeFD::loc2glob ( int node_no,
int node_dof ) const
 

returns the global degree of freedom number corresponding to local degree of freedom "node_dof" in node number "node_no". Note that "node_dof" runs from 1 to the total number of degrees of freedom in a node (as given by "getNoDofInNode"). The "loc2glob" function does not cover local2global mapping of the algebraic contributions, this is handled by the class "AlgebraicContribs".

bool DegFreeFD::modifyMatDue2essBC ( ) const [inline]
 

See documentation of one of the overloaded functions.

void DegFreeFD::modifyMatDue2essBC ( bool onoff )
 

indicator for modification of the coefficient matrix in the linear system due to essential boundary conditions. The function is used by "MatVecContribFD :: enforceEssBC" to check if the contribution matrix should be manipulated or not. The function that takes the "bool onoff" argument is used to select modification ("ON") or no modification ("OFF"). It is usually called from the programmer's simulation code. Since the use of these indicator functions are in the finite difference assembly process, the call must be performed prior to the call to "FDM :: makeSystem". The other version of the indicator function returns a "bool", and this function is used by "MatVecContribFD :: enforceEssBC".

bool DegFreeFD::modifyVecDue2essBC ( ) const [inline]
 

See documentation of one of the overloaded functions.

void DegFreeFD::modifyVecDue2essBC ( bool onoff )
 

indicator for modification of the right hand side in the linear system due to essential boundary conditions. See the documentation of "modifyMatDue2essBC" for more information. The "modifyVecDue2essBC" automatically assembles all the contributions to the right hand side corresponding to subtractions of columns of the coefficient matrix. The contributions are available as the "Vec(NUMT)" vector "b_mod". Moreover, the values of the unknowns are available from the function "getEssBC". With "b_mod" and "getEssBC" it is easy to enforce the essential boundary conditions in the right hand side data structure at any stage in the computations.

bool DegFreeFD::noEssBC ( ) const [inline]
 

returns true if one ore more boundary condition has been set, otherwise false.

bool DegFreeFD::ok ( ) const
 

void DegFreeFD::printEssBC ( Os os,
int output_level = 1 )
 

prints the degrees of freedom where essential boundary conditions are assigned. This function is particularly useful when debugging simulators as one can check that the programmer''s assignment of essential boundary conditions in a "DegFreeFD" object is correct. This information can then be compared to the solution to check that the boundary conditions propagate through the whole simulation. There is an optional argument to "printEssBC" that decides the level of output (or verbosity). A value of 0 makes the output as compact as possible, the value 1 is standard, and 2 will print the coordinates of the point at which a degree of freedom is associated.

void DegFreeFD::printNumbering ( Os os ) const
 

prints the numbering of the global degrees of freedom as they are computed by the "DegFreeFD" class. This function may be of great help to gain a complete understanding of the numbering techniques. Make a simple grid with few nodes, study the output of "printNumbering" and make a sketch of the grid and the degrees of freedom on a piece of paper.

bool DegFreeFD::redim ( FieldsLattice & collection,
const IndexSetCollection & indexsetcoll )
 

bool DegFreeFD::redim ( FieldsLattice & collection,
const IndexSet & indexset )
 

bool DegFreeFD::redim ( FieldsLattice & collection )
 

bool DegFreeFD::redim ( const GridLattice & grid,
const IndexSetCollection & indexsetcoll,
int ndof_per_node = 1 )
 

bool DegFreeFD::redim ( const GridLattice & grid,
const IndexSet & indexset,
int ndof_per_node = 1 )
 

bool DegFreeFD::redim ( const GridLattice & grid,
int ndof_per_node = 1 )
 

bool DegFreeFD::symmModDue2essBC ( ) const [inline]
 

See documentation of one of the overloaded functions.

void DegFreeFD::symmModDue2essBC ( bool onoff )
 

indicator for symmetric modification of the linear system due to essential boundary conditions. If degree of freedom number i is known, equation number i in the linear system is replaced by the boundary condition. However, such a modification destroys the possible symmetry of the coefficient matrix. If "symmModDue2essBC" is "ON", zeroes will also be introduced in column number i in the coefficient matrix. This additional symmetric modification also requires the right hand side to be modified (column no i in the coefficient matrix times the known solution value must be subtracted from the right hand side).

Note that the "modify" functions tell the finite difference tools (class "MatVecContribFD") whether it is allowed at all to modify (touch) the arrays in the linear system. The "symmModDue2essBC" function tells the tools if the implementation of the boundary conditions are to be done in a symmetric or non-symmetric way.

void DegFreeFD::unfillEssBC2zero ( )
 

essential boundary condition values are interpreted as their original values.

bool DegFreeFD::update ( )
 

update/redim due to a change in grid size

void DegFreeFD::vec2field ( const Vec(NUMT) & x,
FieldsLattice & f )
 

See documentation of one of the overloaded functions.

void DegFreeFD::vec2field ( const Vec(NUMT) & x,
FieldLattice & f )
 

given a "Vec" from a linear system (e.g., the solution), the function loads the vector into a field. The vector must have size equal to the number of nodes in the field or total number of degrees of freedoms in the system. In the latter case, the only the PDE part of the vector is transferred to the field, the algebraic degrees of freedom are ignored. See "field2vec".

bool DegFreeFD::zeroInterpretationOfEssBC ( ) const [inline]
 

returns "true" if essential boundary conditions are to be treated as zero values (in e.g. Newton''s method). In other words, the function returns "true" if "fillEssBC2zero" has been called and not yet been cleared by "unfillEssBC2zero". Note that only the last call to "fillEssBC2zero" or "unfillEssBC2zero" is remembered.


Member Data Documentation

Handle(AlgebraicContribs) DegFreeFD::alg_contribs
 

Handle(VecSimpleH(VecSimple(int))) DegFreeFD::alg_pattern
 

Vec(NUMT) DegFreeFD::b_mod
 

Handle(FieldsLattice) DegFreeFD::fields
 

Handle(IndexSet) DegFreeFD::indexset
 

Handle(IndexSetCollection) DegFreeFD::indexsetcoll
 

Handle(GridLattice) DegFreeFD::mesh
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.