00001 #ifndef AGGREGATOR_H 00002 #define AGGREGATOR_H 00003 00004 #include "gtopology.h" 00005 #include "gmatrix.h" 00006 #include "csv.h" 00007 #include "densemat.h" 00008 #include "skyline.h" 00009 #include "cr.h" 00010 #include "slesolv.h" 00011 #include "SPARSE/DSSolver.h" 00012 00013 /** 00014 class aggregator deals with preconditioning of solvers of systems of linear algebraic equations 00015 the preconditioner is based on the BOSS method (Black-box Overlapping Schwarz with Smoothed Coarse Space) 00016 the BOSS method was developed ba M. Brezina in his Ph.D. thesis 00017 00018 JK 00019 */ 00020 class aggregator 00021 { 00022 public: 00023 //konstrukce a destrukce 00024 aggregator(void); 00025 ~aggregator(void); 00026 00027 void read (gtopology *gt,XFILE *in,long mespr); 00028 void print (FILE *out); 00029 00030 00031 // JK -> PM 00032 00033 /// defines number of aggregates 00034 void define_na (long i); 00035 00036 /// vytvori graf matice 00037 /// nn - pocet uzlu 00038 /// nneigh - pocty sousednich uzlu 00039 /// listneigh - seznamy sousednich uzlu 00040 void define_graph(long nnod, long *nneigh, long **listneigh); 00041 00042 00043 // PM -> JK 00044 00045 /// assembles list of numbers of nodes in aggregates without overlap 00046 /// pocet uzlu v agregatech bez prekryvu 00047 /// assembles node numbers in aggregates without overlap 00048 /// seznamy uzlu v jednotlivych agregatech bez prekryvu 00049 /// lnntagr[i] = k - v i-tem agregatu je k uzlu 00050 /// lntagr[i][j] = k - j-ty uzel v i-tem agregatu ma cislo k 00051 void prepare_tlnagr(void); 00052 00053 /// assembles list of numbers of nodes in aggregates with overlap 00054 /// pocet uzlu v agregatech s prekryvem 00055 /// assembles node numbers in aggregates with overlap 00056 /// seznamy uzlu v jednotlivych agregatech s prekryvem 00057 /// lnnagr[i] = k - v i-tem agregatu je k uzlu 00058 /// lnagr[i][j] = k - j-ty uzel v i-tem agregatu ma cislo k 00059 void prepare_lnagr (); 00060 00061 00062 /// function sets up degree of recursion 00063 /// real degree of polynomial is equal to (3^dg-1)/2 00064 void define_degree (); 00065 00066 00067 // sestavuje tentative prolongator 00068 // agrid - cislo pozadovaneho agregatu 00069 // cid - cislo pozadovaneho sloupce v agregatu 00070 // i - pole indexu 00071 // a - pole hodnot (v pripade rigid body motions v mechanice) 00072 //void assemble_tentative_prol (long agrid,long cid,long *i,double *a); 00073 00074 // vraci skutecny stupen prolongatoru 00075 long give_deg (); 00076 00077 00078 // sestavuje smoothed prolongator 00079 // agrid - cislo pozadovaneho agregatu 00080 // cid - cislo pozadovaneho sloupce v agregatu 00081 // i - pole indexu 00082 // a - pole hodnot (v pripade rigid body motions v mechanice) 00083 void assemble_smoothed_prol (gtopology *gt,gmatrix *mtx); 00084 void assemble_smoothed_prol2 (long agrid,long cid,long *i,compvect *cvi,compvect *cvo,gmatrix *mtx); 00085 00086 00087 00088 /// function copies arrays lnntagr and lntagr from the 00089 /// object stop (class seqtop) allocated in class gtopology 00090 /// it is an alternative to the function void prepare_tlnagr(void); 00091 void metis_aggr (gtopology *gt); 00092 00093 void gener_rbm_1 (gtopology *gt,long agid,double *v); 00094 void gener_rbm_2 (gtopology *gt,long agid,long cnid,double *v); 00095 void coarse_matrix (gmatrix *gm); 00096 00097 00098 void assemble_aggr_unknowns (gtopology *gt); 00099 00100 void local_matrices (long bsize,gmatrix *gm); 00101 00102 void clean_memory (); 00103 00104 void prepare_boss (gtopology *gt,gmatrix *gm,FILE *out); 00105 00106 //void boss (gmatrix *gm,double *u,double *v,double *rhs); 00107 void boss (gmatrix *gm,double *u,double *v); 00108 00109 00110 00111 /// lokalni metody - casem asi private 00112 /** 00113 provedena aplikaci s(st) na pozadovany vekor 00114 st .... stupen S, t.j. dolni index 00115 x .... vektor 00116 mtx .... matice 00117 **/ 00118 void mulS(long st,double *x, gmatrix *mtx); 00119 /** 00120 st .... stupen S, t.j. dolni index 00121 x .... vektor 00122 mtx .... matice 00123 **/ 00124 void mulA(long st, double *x, gmatrix *mtx); 00125 00126 00127 /// number of nodes in the finite element mesh 00128 long nn; 00129 /// number of aggregates 00130 long na; 00131 /// maximum number of unknowns in aggregate 00132 long maxnu; 00133 /// number of unknowns in the whole problem 00134 long n; 00135 /// size of the coarse matrix 00136 long cms; 00137 00138 /// type of BOSS algorithm 00139 /// impl=1 - own implementation of the BOSS algorithm 00140 /// impl=2 - implementation based on METIS 00141 long impl; 00142 00143 /// type of solver - exact or inexact 00144 /// exinex=1 - exact solver is used 00145 /// exinex=2 - inexact solver is used 00146 long exinex; 00147 00148 00149 /// type of factorization of system of linear algebraic equations 00150 //linsolvertype tlinsol; 00151 00152 /// type of rigid body modes (kernels) 00153 long trbm; 00154 /// number of rigid body modes of one aggregate 00155 long nrbm; 00156 00157 /// data about solver of system of linear equations 00158 slesolv *ssle; 00159 00160 /// list of numbers of nodes in aggregates with overlap 00161 /// lnnagr[i]=j - the i-th aggregate contains j nodes 00162 long *lnnagr; 00163 /// list of node numbers in aggregates with overlap 00164 /// lnagr[i][j]=k - the j-th node in the i-th aggregate has the number k 00165 long **lnagr; 00166 00167 /// list of numbers of nodes in tentative aggregates (without overlap) 00168 long *lnntagr; 00169 /// list of node numbers in tentative aggregates (without overlap) 00170 long **lntagr; 00171 00172 /// numbers of adjacent nodes to nodes 00173 /// nadjnodnod[i]=j - the i-th node has j adjacent nodes 00174 long *nadjnodnod; 00175 /// array of adjacent nodes to nodes 00176 /// adjnodnod[i][j]=k - the j-th adjacent node to the i-th node has number k 00177 long **adjnodnod; 00178 00179 /// list of numbers of unknowns on aggregates with overlap 00180 /// lnuaggr[i]=j - the i-th aggregate contains j unknowns 00181 long *lnuaggr; 00182 /// list of unknown numbers on aggregates with overlap 00183 /// luaggr[i][j]=k - the j-th unknown on the i-th aggregate has number k 00184 long **luaggr; 00185 00186 00187 // odhad spektralniho polomeru matice 00188 double specrad; 00189 00190 // degree of smoothing aggregator - real 00191 long degree_r; 00192 long degree_k; 00193 00194 // local matrices 00195 comprow *lmcr; 00196 00197 skyline *lmsky; 00198 00199 /// smoothed prolongator 00200 /// it is a %matrix with ndof rows and na*nrbm columns 00201 /// the matrix is stored column after column in onedimensional array 00202 double *p; 00203 00204 /// coarse %matrix 00205 densemat *cm; 00206 00207 // provizorne pro ladeni 00208 densemat *lmdm; 00209 00210 ISolver *sdirect; 00211 00212 }; 00213 00214 #endif