SALSA Analysis Modules
|
Structural properties of a matrix. More...
#include <stdlib.h>
#include "anamod.h"
#include "anamodutils.h"
#include "anamodsalsamodules.h"
#include "petscerror.h"
#include "petscmat.h"
Go to the source code of this file.
Functions | |
static PetscErrorCode | nRows (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | Symmetry (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | compute_nnz_structure (AnaModNumericalProblem prob) |
static PetscErrorCode | NNonZeros (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | MaxNNonZerosPerRow (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | MinNNonZerosPerRow (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | LBandWidth (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | RBandWidth (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | LeftSkyline (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | RightSkyline (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | compute_dummy_rows (Mat A) |
static PetscErrorCode | NDummyRows (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | DummyRowsKind (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | DummyRows (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | compute_posdiag (AnaModNumericalProblem prob) |
static PetscErrorCode | DiagZeroStart (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | DiagDefinite (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
static PetscErrorCode | regularblocks (AnaModNumericalProblem prob) |
static PetscErrorCode | BlockSize (AnaModNumericalProblem prob, AnalysisItem *rv, int *lv, PetscTruth *flg) |
PetscErrorCode | RegisterStructureModules () |
PetscErrorCode | DeRegisterStructureModules (void) |
Structural properties of a matrix.
This file defines the routines for computing structural properties of a matrix, as well as the routine RegisterStructureModules() that registers them.
This category computes matrix properties that are only a function of the nonzero structure. Thus, these properties will likely stay invariant during a nonlinear solve process, or while time-stepping a system of equations.
Activate this module with
PetscErrorCode RegisterStructureModules();
Compute these elements with
ComputeQuantity("structure",<element>,A,(void*)&res,&flg);
Available elements are:
Definition in file structure.c.
static PetscErrorCode BlockSize | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 644 of file structure.c.
References GetDataID(), HASTOEXIST, AnalysisItem::i, id, and regularblocks().
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","blocksize",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = regularblocks(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode compute_dummy_rows | ( | Mat | A | ) | [static] |
Definition at line 351 of file structure.c.
References GetDataID(), HASTOEXIST, and id.
Referenced by DummyRows(), DummyRowsKind(), and NDummyRows().
{ int gkind; MPI_Comm comm; int first,last,row,ncols,ndummies,Ndummies,*dummies,*Dummies,kind,id; PetscTruth has; PetscErrorCode ierr; const int *cols; const PetscScalar *vals; PetscFunctionBegin; ierr = PetscObjectGetComm((PetscObject)A,&comm); CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&first,&last); CHKERRQ(ierr); ierr = PetscMalloc((last-first+1)*sizeof(int),&dummies); CHKERRQ(ierr); ndummies = 0; kind = 0; for (row=first; row<last; row++) { ierr = MatGetRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); if (ncols==1) { dummies[ndummies++] = row; if (vals[0]!=1. && !kind ) kind = 1; if (cols[0]!=row) kind = 2; } ierr = MatRestoreRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); } ierr = MPI_Allreduce ((void*)&kind,(void*)&gkind,1,MPI_INT,MPI_MAX,comm); CHKERRQ(ierr); ierr = GetDataID("structure","dummy-rows-kind",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,gkind); CHKERRQ(ierr); { int *sizes,*offsets,ntids,i,s; MPI_Comm_size(comm,&ntids); ierr = PetscMalloc(ntids*sizeof(int),&sizes); CHKERRQ(ierr); ierr = PetscMalloc(ntids*sizeof(int),&offsets); CHKERRQ(ierr); MPI_Allgather(&ndummies,1,MPI_INT,sizes,1,MPI_INT,comm); s=0; for (i=0; i<ntids; i++) {offsets[i]=s; s+=sizes[i];} Ndummies = s; if (Ndummies==0) Dummies = NULL; else { ierr = PetscMalloc(Ndummies*sizeof(int),&Dummies); CHKERRQ(ierr); ierr = MPI_Allgatherv (dummies,ndummies,MPI_INT,Dummies,sizes,offsets,MPI_INT, comm); CHKERRQ(ierr); } ierr = PetscFree(dummies); CHKERRQ(ierr); ierr = PetscFree(offsets); CHKERRQ(ierr); ierr = PetscFree(sizes); CHKERRQ(ierr); } ierr = GetDataID("structure","n-dummy-rows",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,Ndummies); CHKERRQ(ierr); ierr = GetDataID("structure","dummy-rows",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetIntstar ((PetscObject)A,id,Dummies); CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode compute_nnz_structure | ( | AnaModNumericalProblem | prob | ) | [static] |
Definition at line 109 of file structure.c.
References GetDataID(), HASTOEXIST, and id.
Referenced by LBandWidth(), LeftSkyline(), MaxNNonZerosPerRow(), MinNNonZerosPerRow(), NNonZeros(), RBandWidth(), and RightSkyline().
{ Mat A = (Mat)prob; int nnz,p,q,minnz,maxnz,minnnz,maxnnz; MPI_Comm comm; int N,first,last,local_size,row,nz,*Bl,*Br,bl,br, id; PetscTruth has; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscObjectGetComm((PetscObject)A,&comm); CHKERRQ(ierr); ierr = MatGetSize(A,&N,PETSC_NULL); CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&first,&last); CHKERRQ(ierr); local_size = last-first; ierr = PetscMalloc(local_size*sizeof(int),&Bl); CHKERRQ(ierr); ierr = PetscMalloc(local_size*sizeof(int),&Br); CHKERRQ(ierr); bl = 0; br = 0; nz = 0; minnz = maxnz = 0; for (row=first; row<last; row++) { int icol,ncols,localnz=0; const int *cols; const PetscScalar *val; ierr = MatGetRow(A,row,&ncols,&cols,&val); CHKERRQ(ierr); for (icol=0; icol<ncols; icol++) if (val[icol]!=0.) localnz++; nz += localnz; if (row==first) minnz = localnz; if (localnz<minnz) minnz = localnz; if (localnz>maxnz) maxnz = localnz; if (ncols) { Bl[row-first] = bl = PetscMax(bl,row-cols[0]); Br[row-first] = br = PetscMax(br,cols[ncols-1]-row); } ierr = MatRestoreRow(A,row,&ncols,&cols,&val); CHKERRQ(ierr); } MPI_Allreduce((void*)&nz,(void*)&nnz,1,MPI_INT,MPI_SUM,comm); ierr = GetDataID("structure","nnzeros",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,nnz); CHKERRQ(ierr); MPI_Allreduce((void*)&maxnz,(void*)&maxnnz,1,MPI_INT,MPI_MAX,comm); ierr = GetDataID("structure","max-nnzeros-per-row",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,maxnnz); CHKERRQ(ierr); MPI_Allreduce((void*)&minnz,(void*)&minnnz,1,MPI_INT,MPI_MIN,comm); ierr = GetDataID("structure","min-nnzeros-per-row",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,minnnz); CHKERRQ(ierr); MPI_Allreduce((void*)&bl,(void*)&p,1,MPI_INT,MPI_MAX,comm); ierr = GetDataID("structure","left-bandwidth",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,p); CHKERRQ(ierr); MPI_Allreduce((void*)&br,(void*)&q,1,MPI_INT,MPI_MAX,comm); ierr = GetDataID("structure","right-bandwidth",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,q); CHKERRQ(ierr); ierr = PetscFree(Bl); CHKERRQ(ierr); ierr = PetscFree(Br); CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode compute_posdiag | ( | AnaModNumericalProblem | prob | ) | [static] |
Definition at line 498 of file structure.c.
References GetDataID(), HASTOEXIST, and id.
Referenced by DiagDefinite(), and DiagZeroStart().
{ Mat A = (Mat)prob; MPI_Comm comm; Vec D; PetscScalar *d; int i,first,last,m,M,di,df,Di,Df,pd,id; PetscTruth has; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscObjectGetComm((PetscObject)A,&comm); CHKERRQ(ierr); ierr = MatGetSize(A,&M,PETSC_NULL); CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&first,&last); CHKERRQ(ierr); m = last-first; ierr = VecCreateMPI(comm,m,PETSC_DECIDE,&D); CHKERRQ(ierr); ierr = MatGetDiagonal(A,D); CHKERRQ(ierr); ierr = VecGetArray(D,&d); CHKERRQ(ierr); di = 1; df = first; for (i=0; i<m; i++) { if (d[i]<=0) di = 0; if (d[i]!=0) df = i+1; } MPI_Allreduce((void*)&di,(void*)&Di,1,MPI_INT,MPI_PROD,comm); ierr = GetDataID("structure","diag-definite",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,Di); CHKERRQ(ierr); MPI_Allreduce((void*)&df,(void*)&Df,1,MPI_INT,MPI_MAX,comm); ierr = GetDataID("structure","diag-zerostart",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,Df); CHKERRQ(ierr); if (Df<M) pd = 2+Df; else pd = Di; ierr = VecRestoreArray(D,&d); CHKERRQ(ierr); ierr = VecDestroy(D); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode DeRegisterStructureModules | ( | void | ) |
Definition at line 718 of file structure.c.
Referenced by AnaModDeregisterSalsaModules().
{ PetscFunctionBegin; PetscFunctionReturn(0); }
static PetscErrorCode DiagDefinite | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 566 of file structure.c.
References compute_posdiag(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","diag-definite",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_posdiag(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode DiagZeroStart | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 543 of file structure.c.
References compute_posdiag(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","diag-zerostart",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_posdiag(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode DummyRows | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 465 of file structure.c.
References compute_dummy_rows(), GetDataID(), HASTOEXIST, id, and AnalysisItem::ii.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int *v = NULL; PetscTruth has; int id,id2; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","dummy-rows",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); ierr = GetDataID("structure","n-dummy-rows",&id2,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id2,*lv,*flg); CHKERRQ(ierr); if (*flg) { rv->ii = v; } else { ierr = compute_dummy_rows(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id2,*lv,*flg); CHKERRQ(ierr); if (*flg) rv->ii = v; } PetscFunctionReturn(0); }
static PetscErrorCode DummyRowsKind | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 442 of file structure.c.
References compute_dummy_rows(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","dummy-rows-kind",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_dummy_rows(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode LBandWidth | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 249 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","left-bandwidth",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode LeftSkyline | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 295 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, id, and AnalysisItem::ii.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int N; int *v = NULL; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatGetSize(A,&N,PETSC_NULL); CHKERRQ(ierr); ierr = GetDataID("structure","left-skyline",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) { rv->ii = v; *lv = N; } else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) { rv->ii = v; *lv = N; } } PetscFunctionReturn(0); }
static PetscErrorCode MaxNNonZerosPerRow | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 203 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","max-nnzeros-per-row",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode MinNNonZerosPerRow | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 226 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","min-nnzeros-per-row",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode NDummyRows | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 419 of file structure.c.
References compute_dummy_rows(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","n-dummy-rows",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_dummy_rows(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode NNonZeros | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 180 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","nnzeros",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode nRows | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 54 of file structure.c.
References GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","nrows",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { int idum; ierr = MatGetSize(A,&v,&idum); CHKERRQ(ierr); *flg = PETSC_TRUE; ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,v); CHKERRQ(ierr); rv->i = v; } PetscFunctionReturn(0); }
static PetscErrorCode RBandWidth | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 272 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","right-bandwidth",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; } PetscFunctionReturn(0); }
PetscErrorCode RegisterStructureModules | ( | void | ) |
Definition at line 669 of file structure.c.
References ANALYSISINTARRAY, ANALYSISINTEGER, BlockSize(), DiagDefinite(), DiagZeroStart(), DummyRows(), DummyRowsKind(), LBandWidth(), LeftSkyline(), MaxNNonZerosPerRow(), MinNNonZerosPerRow(), NDummyRows(), NNonZeros(), nRows(), RBandWidth(), RegisterModule(), RightSkyline(), and Symmetry().
Referenced by AnaModRegisterSalsaModules(), and AnaModRegisterStandardModules().
{ PetscErrorCode ierr; PetscFunctionBegin; ierr = RegisterModule ("structure","nrows",ANALYSISINTEGER,&nRows); CHKERRQ(ierr); ierr = RegisterModule ("structure","symmetry",ANALYSISINTEGER,&Symmetry); CHKERRQ(ierr); ierr = RegisterModule ("structure","nnzeros",ANALYSISINTEGER,&NNonZeros); CHKERRQ(ierr); ierr = RegisterModule ("structure","max-nnzeros-per-row",ANALYSISINTEGER, &MaxNNonZerosPerRow); CHKERRQ(ierr); ierr = RegisterModule ("structure","min-nnzeros-per-row",ANALYSISINTEGER, &MinNNonZerosPerRow); CHKERRQ(ierr); ierr = RegisterModule ("structure","left-bandwidth",ANALYSISINTEGER,&LBandWidth); CHKERRQ(ierr); ierr = RegisterModule ("structure","right-bandwidth",ANALYSISINTEGER,&RBandWidth); CHKERRQ(ierr); ierr = RegisterModule ("structure","left-skyline",ANALYSISINTARRAY,&LeftSkyline); CHKERRQ(ierr); ierr = RegisterModule ("structure","right-skyline",ANALYSISINTARRAY,&RightSkyline); CHKERRQ(ierr); ierr = RegisterModule ("structure","n-dummy-rows",ANALYSISINTEGER,&NDummyRows); CHKERRQ(ierr); ierr = RegisterModule ("structure","dummy-rows-kind",ANALYSISINTEGER,&DummyRowsKind); CHKERRQ(ierr); ierr = RegisterModule ("structure","dummy-rows",ANALYSISINTARRAY,&DummyRows); CHKERRQ(ierr); ierr = RegisterModule ("structure","diag-zerostart",ANALYSISINTEGER,&DiagZeroStart); CHKERRQ(ierr); ierr = RegisterModule ("structure","diag-definite",ANALYSISINTEGER,&DiagDefinite); CHKERRQ(ierr); ierr = RegisterModule ("structure","blocksize",ANALYSISINTEGER,&BlockSize); CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode regularblocks | ( | AnaModNumericalProblem | prob | ) | [static] |
Definition at line 592 of file structure.c.
References GetDataID(), HASTOEXIST, and id.
Referenced by BlockSize().
{ Mat A = (Mat)prob; int first,last,local_size,row, bs,gbs,id,mytid; MPI_Comm comm; PetscTruth has; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscObjectGetComm((PetscObject)A,&comm); CHKERRQ(ierr); ierr = MPI_Comm_rank(comm,&mytid); CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&first,&last); CHKERRQ(ierr); local_size = last-first; if (mytid==0) { int row; bs = 1; for (row=first; row<last; row++) { const int *cols; const PetscScalar *vals; int ncols,icol=0; PetscTruth found = PETSC_FALSE; ierr = MatGetRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); while (icol<ncols && cols[icol]<row) icol++; if (cols[icol]>row+1 || (cols[icol]==row && icol+1<ncols && (cols[icol+1]>row+1 || vals[icol+1]==0.))) { bs = row+1; found = PETSC_TRUE; } ierr = MatRestoreRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); if (found) break; } } MPI_Bcast((void*)&bs,1,MPI_INT,0,comm); for (row=first; row<last; row++) { const int *cols; const PetscScalar *vals; int ncols,icol=0; PetscTruth found = PETSC_FALSE; if ((row+1)%bs!=0) continue; ierr = MatGetRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); while (icol<ncols && cols[icol]<row) icol++; if ( (cols[icol]==row+1 && vals[icol]!=0.) || (cols[icol]==row && (icol+1<ncols && cols[icol+1]==row+1 && vals[icol+1]!=0.)) ) { bs = row+1; found = PETSC_TRUE; } ierr = MatRestoreRow(A,row,&ncols,&cols,&vals); CHKERRQ(ierr); if (found) break; } MPI_Allreduce((void*)&bs,(void*)&gbs,1,MPI_INT,MPI_MIN,comm); ierr = GetDataID("structure","blocksize",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataSetInt((PetscObject)A,id,gbs); CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode RightSkyline | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 322 of file structure.c.
References compute_nnz_structure(), GetDataID(), HASTOEXIST, id, and AnalysisItem::ii.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int N; int *v = NULL; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatGetSize(A,&N,PETSC_NULL); CHKERRQ(ierr); ierr = GetDataID("structure","right-skyline",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) { rv->ii = v; *lv = N; } else { ierr = compute_nnz_structure(A); CHKERRQ(ierr); ierr = PetscObjectComposedDataGetIntstar ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) { rv->ii = v; *lv = N; } } PetscFunctionReturn(0); }
static PetscErrorCode Symmetry | ( | AnaModNumericalProblem | prob, |
AnalysisItem * | rv, | ||
int * | lv, | ||
PetscTruth * | flg | ||
) | [static] |
Definition at line 78 of file structure.c.
References GetDataID(), HASTOEXIST, AnalysisItem::i, and id.
Referenced by RegisterStructureModules().
{ Mat A = (Mat)prob; int v = 0; PetscTruth has; int id; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetDataID("structure","symmetry",&id,&has); CHKERRQ(ierr); HASTOEXIST(has); ierr = PetscObjectComposedDataGetInt ((PetscObject)A,id,v,*flg); CHKERRQ(ierr); if (*flg) rv->i = v; else { PetscTruth f; const MatType type; ierr = MatGetType(A,&type); CHKERRQ(ierr); ierr = PetscStrcmp(type,MATSEQAIJ,flg); CHKERRQ(ierr); if (*flg) { ierr = MatIsSymmetric(A,0.0,&f); CHKERRQ(ierr); v = f; ierr = PetscObjectComposedDataSetInt ((PetscObject)A,id,v); CHKERRQ(ierr); rv->i = v; } } PetscFunctionReturn(0); }