bmat.h File Reference

Class Bmat: a block sparse matrix object. More...

#include <mc/mc_base.h>
#include <mc/mat.h>

Include dependency graph for bmat.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sBmat
 Contains public data memebers for Bmat class. More...

Typedefs

typedef struct sBmat Bmat
 Declaration of the Bmat class as the Bmat structure.

Functions

BmatBmat_ctor (Vmem *vmem, const char *name, int pnumB, int pnumR[MAXV], int pnumC[MAXV], MATmirror pmirror[MAXV][MAXV])
 The block sparse matrix constructor.
void Bmat_dtor (Bmat **thee)
 The block sparse matrix destructor.
void Bmat_initStructure (Bmat *thee, MATformat pfrmt[MAXV][MAXV], MATsym psym[MAXV][MAXV], int pnumO[MAXV][MAXV], int *IJA[MAXV][MAXV])
 Initialize the nonzero structure given structure information.
void Bmat_copyStructure (Bmat *thee, Bmat *model)
 Copy the nonzero structure from an input model.
void Bmat_killStructure (Bmat *thee)
 Kill the nonzero structure.
int Bmat_numB (Bmat *thee)
 Return the number of blocks.
int Bmat_numR (Bmat *thee, int p, int q)
 Return the number of rows.
int Bmat_numC (Bmat *thee, int p, int q)
 Return the number of columns.
int Bmat_numA (Bmat *thee, int p, int q)
 Return the number of nonzeros we actually store in a block.
int Bmat_numO (Bmat *thee, int p, int q)
 Return the number of nonzeros we actually store in a block which are actually in the strict upper-triangle of the block (DRC only).
int Bmat_numZ (Bmat *thee, int p, int q)
 Return the number of nonzeros we WOULD actually store in a block if we ignored symmetry and stored everything.
int Bmat_numRT (Bmat *thee)
 Return the total number of rows.
int Bmat_numCT (Bmat *thee)
 Return the total number of columns.
int Bmat_numAT (Bmat *thee)
 Return the total number of nonzeros we are actually storing.
int Bmat_numOT (Bmat *thee)
 Return the total number of nonzeros we are actually storing which are located in the strict upper-triangle.
int Bmat_numZT (Bmat *thee)
 Return the total number of nonzeros we WOULD be storing if we ignored all symmetry in all blocks and stored everything.
MATformat Bmat_format (Bmat *thee, int p, int q)
 Return the format of the block.
MATsym Bmat_sym (Bmat *thee, int p, int q)
 Return the symmetry of the block.
MATstate Bmat_state (Bmat *thee, int p, int q)
 Return the state of the block.
MATimpl Bmat_impl (Bmat *thee, int p, int q)
 Return the implicitness of the block.
MATmirror Bmat_mirror (Bmat *thee, int p, int q)
 Return the mirror-ness of the block.
int Bmat_sizeA (Bmat *thee)
 Return the number of nonzeros in all blocks.
int Bmat_sizeIJA (Bmat *thee)
 Return the numer of integer storage locations used.
int * Bmat_IJA (Bmat *thee, int p, int q)
 Return the integer structure IJA.
int * Bmat_IA (Bmat *thee, int p, int q)
 Return the integer structure IA.
int * Bmat_JA (Bmat *thee, int p, int q)
 Return the integer structure JA.
double * Bmat_A (Bmat *thee, int p, int q)
 Return the real structure A.
double * Bmat_diag (Bmat *thee, int p, int q)
 Return the diagonal of A (DRC only).
double * Bmat_offU (Bmat *thee, int p, int q)
 Return the strict upper triangle of A (DRC only).
double * Bmat_offL (Bmat *thee, int p, int q)
 Return the strict lower triangle of A (DRC only).
void Bmat_print (Bmat *thee)
 Print the prolongation matrix blocks.
void Bmat_printSp (Bmat *thee, char *fname, int pflag)
 Print the prolongation matrix in MATLAB sparse form.
void Bmat_printNoD (Bmat *thee)
 Print the matrix as a DENSE matrix in MATLAB format, but first zero out any rows/cols corresponding to Dirichlet boundary points.
void Bmat_printSpNoD (Bmat *thee, char *fname, int pflag)
 Print the matrix as a DENSE matrix in MATLAB format, but first zero out any rows/cols corresponding to Dirichlet boundary points.
void Bmat_zero (Bmat *thee)
 Clear the floating point storage for the sparse matrix. Also clear any sparse factorization storage.
void Bmat_diri (Bmat *thee)
 Setup the dirichlet equations.
void Bmat_set (Bmat *thee, int p, int q, int i, int j, double val)
 Set the (i,j)-th entry of the (p,q)-th block to < val >.
void Bmat_addTo (Bmat *thee, int p, int q, int i, int j, double val)
 Contribute < val > to the (i,j)-th entry of the (p,q)-th block.
void Bmat_galerkin (Bmat *thee, Bmat *rmat, Bmat *amat, Bmat *pmat)
 Enforce the Galerkin conditions algebraically.
int Bmat_sluDirect (Bmat *thee)
 Make a decision about whether or not a sparse direct solver should be used in place of an iterative solver, based on the size of the system.
void Bmat_sluCreate (Bmat *thee)
 Create the global matrix from the blocks in the modified ROW or COL storage format. This is useful for preparing a single global matrix for input to e.g. a sparse direct solver.
int Bmat_sluFactor (Bmat *thee)
 Create the sparse LU factors for global matrix.
int Bmat_sluSolve (Bmat *thee, int key, double *f, double *u)
 Forward/backward solve using sparse LU factors of global matrix.
void Bmat_sluDestroy (Bmat *thee)
 Destroy the sparse LU factors for the system matrix.
void Bmat_memChk (Bmat *thee)
 Print the exact current malloc usage.
BmatBmat_clone (Vmem *vmem, char *name, Bmat *X)
 Construct a clone of a Bmat with the same structure.
void Bmat_copy (Bmat *Y, Bmat *X)
 Copy a block matrix.
void Bmat_squeezeBRC (Bmat *thee, int key)
 Remove the boundary rows or columns from a block matrix.
void Bmat_copy2 (Bmat *Y, Bmat *X)
 Copy a block matrix.
void Bmat_axpy (Bmat *Y, Bmat *X, double val, int key)
 Scalar times a Bmat plus a Bmat: Y += val*X.


Detailed Description

Class Bmat: a block sparse matrix object.

Author:
Michael Holst
Note:
None
 * This class extends the Mat class to block matrices built as
 * retangular arrays of Mat objects.
 *
 * The Bmat class is very efficient in memory and operation
 * complexity for large sparse block matrices having a few
 * (e.g. 1-20) blocks, each of which are themselves large
 * (e.g. > 1000 rows) sparse matrices.  This class IS NOT very
 * efficient for large sparse matrices consisting of many
 * (e.g. > 20) small blocks (e.g. < 1000 rows).  This is because
 * each block is a Mat object which contains some overhead.
 * Note that If some of the matrix blocks are symmetric images
 * of each other, we represent the block only once.
 *
 * Blocks:   The global matrix from a petrov-galerkin FEM discretization of 
 *           a PDE will be stored in blocks; for example, an 18x18 matrix
 *           consisting of 3 blocks of varying sizes (as in the case of a
 *           3-component system, with different number of degrees of freedom
 *           on different components) will be stored as:
 *
 *           A = \----- --- ---------    The block sizes in this example are:
 *               |\---- --- ---------
 *               ||\--- --- ---------        block[0][0] = 6x6
 *               |||\-- --- ---------        block[1][1] = 3x3
 *               ||||\- --- ---------        block[2][2] = 9x9
 *               |||||\ --- ---------        block[0][1] = 6x3
 *                                           block[0][2] = 6x9
 *               |||||| \-- ---------        block[1][2] = 3x9
 *               |||||| |\- ---------        block[1][0] = 3x6
 *               |||||| ||\ ---------        block[2][0] = 9x6
 *                                           block[2][1] = 9x3
 *               |||||| ||| \--------
 *               |||||| ||| |\-------
 *               |||||| ||| ||\------
 *               |||||| ||| |||\-----
 *               |||||| ||| ||||\----
 *               |||||| ||| |||||\---
 *               |||||| ||| ||||||\--
 *               |||||| ||| |||||||\-
 *               |||||| ||| ||||||||\
 *
 *           A prolongation matrix will be stored row-wise in blocks.
 *           For example, a prolongation matrix for a 2-component system,
 *           mapping 3-vectors in the first component to 9-vectors, and
 *           mapping 6-vectors in the second component to 10-vectors, will
 *           be stored in blocks as:
 *
 *           P = --- oooooo    The blocks have the shapes:
 *               --- oooooo
 *               --- oooooo        block[0][0] = 9x3
 *               --- oooooo        block[0][1] = 9x6
 *               --- oooooo        block[1][0] = 10x3
 *               --- oooooo        block[1][1] = 10x6
 *               --- oooooo
 *               --- oooooo
 *               --- oooooo
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *               ooo ------
 *
 *           The adjoint would likely be used as the restriction matrix,
 *           which would then be stored columnwise by simply adjusting
 *           some pointers:
 *
 *           R = ||||||||| oooooooooo    The blocks have the shapes:
 *               ||||||||| oooooooooo
 *               ||||||||| oooooooooo        block[0][0] = 3x9
 *               ooooooooo ||||||||||        block[0][1] = 3x10
 *               ooooooooo ||||||||||        block[1][0] = 6x9
 *               ooooooooo ||||||||||        block[1][1] = 6x10
 *               ooooooooo ||||||||||
 *               ooooooooo ||||||||||
 *               ooooooooo ||||||||||
 *  
Version:
Id
bmat.h,v 1.34 2009/04/24 22:53:59 fetk Exp

Attention:
 *
 * MC = < Manifold Code >
 * Copyright (C) 1994--2008 Michael Holst
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 *  

Generated on Mon Aug 9 11:13:38 2010 for MC by  doxygen 1.5.6