• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ml_aggregate.h

Go to the documentation of this file.
00001 /* ************************************************************************* */
00002 /* See the file COPYRIGHT for a complete copyright notice, contact person    */
00003 /* and disclaimer.                                                           */
00004 /* ************************************************************************* */
00005 
00006 /* ************************************************************************* */
00007 /* data structure to hold aggregation information                            */
00008 /* ************************************************************************* */
00009 /* Author        : Charles Tong (LLNL)                                       */
00010 /* Date          : August, 1999                                              */
00011 /* ************************************************************************* */
00012 
00013 #ifndef __MLAGGH__
00014 #define __MLAGGH__
00015 
00016 #include <stdio.h>
00017 /* #include <stdlib.h> */
00018 
00019 #define ML_AGGR_UNCOUPLED    1
00020 #define ML_AGGR_COUPLED      2
00021 #define ML_AGGR_MIS          3
00022 #define ML_AGGR_DD           4
00023 #define ML_AGGR_HYBRIDUC     5
00024 #define ML_AGGR_HYBRIDUM     6
00025 /*MS*/
00026 #define ML_AGGR_METIS        7
00027 #define ML_AGGR_PARMETIS     8
00028 #define ML_AGGR_ZOLTAN       9
00029 #define ML_AGGR_VBMETIS     10  /*mgee*/
00030 #define ML_AGGR_USER        11
00031 /*ms*/
00032 
00033 /*cms*/
00034 #define ML_AGG_ANY_MATERIAL -1
00035 
00036 #define ML_ZOLTAN_TYPE_RCB               1
00037 #define ML_ZOLTAN_TYPE_HYPERGRAPH        2
00038 #define ML_ZOLTAN_TYPE_FAST_HYPERGRAPH   3
00039 
00040 /* ************************************************************************* */
00042 /* ------------------------------------------------------------------------- */
00043 
00044 typedef struct ML_Aggregate_Struct
00045 {
00046    int    ML_id;
00047    double print_flag;
00048    int    max_coarse_size;             
00049    int    ordering;                    
00050    int    min_nodes_per_aggregate;     
00051    int    max_neigh_already_selected;  
00052    double threshold;                   
00053    double curr_threshold;              
00054    double drop_tol_for_smoothing;      
00055    int    attach_scheme;               
00056    double smoothP_damping_factor;      
00057    int   * smoothP_damping_sweeps;     
00058    int    smoothP_type;                
00059    int    coarsen_scheme;              
00060    int   * coarsen_scheme_level;  
00061    int    num_PDE_eqns;                
00062    int    nullspace_dim;               
00063    double *nullspace_vect;             
00064    int    nullspace_corrupted;         
00066    int    *aggr_count;                 
00067   int    keep_agg_information;         
00069    int    **aggr_info;                 
00070    int    max_levels;                  
00071    int    begin_level;                 
00072    int    cur_level;                   
00073    double operator_complexity;         
00074    double fine_complexity;             
00075    int    nvblocks;                    
00076    int    *vblock_info;                
00077    int    keep_P_tentative;            
00078    struct ML_Operator_Struct **P_tentative; 
00079    int    smooth_existing_P_tentative; 
00080   int use_transpose;                   
00081   int Restriction_smoothagg_transpose; 
00082 /*MS*/
00083   void *aggr_options;                  
00084   void *aggr_viz_and_stats;            
00087   void * field_of_values;
00088   int    block_scaled_SA;              
00092   double phase3_agg_creation;          
00101   double **nodal_coord;                 
00103   int N_dimensions;
00104 /*ms*/
00105 /*mgee*/
00106   void  *vblock_data;                 
00107   int minimizing_energy, cheap_minimizing_energy;
00108   double minimizing_energy_droptol;    
00109   double   *old_RowOmegas;
00110 
00111 } ML_Aggregate;
00112 
00113 /* ************************************************************************* */
00114 /* other ML include files                                               */
00115 /* ------------------------------------------------------------------------- */
00116 
00117 #include "ml_common.h"
00118 #include "ml_defs.h"
00119 #include "ml_comm.h"
00120 #include "ml_memory.h"
00121 #include "ml_operator.h"
00122 
00123 
00124 /* ************************************************************************* */
00125 /* linked list structures for holding free node information             */
00126 /* ------------------------------------------------------------------------- */
00127 
00128 typedef struct ML_Node_Struct
00129 {
00130    int    node_id;
00131    struct ML_Node_Struct *next;
00132 } ML_Node;
00133 
00134 /* ************************************************************************* */
00135 /* definition of the structure for holding aggregate information        */
00136 /* ------------------------------------------------------------------------- */
00137 
00138 typedef struct ML_SuperNode_Struct
00139 {
00140    int    length;
00141    int    maxlength;
00142    int    index;
00143    int    *list;
00144    struct ML_SuperNode_Struct *next;
00145 
00146 } ML_SuperNode;
00147 
00148 /* ************************************************************************* */
00149 /* definition of the structure for holding communication information in */
00150 /* aggregation procedure                                                */
00151 /* ------------------------------------------------------------------------- */
00152 
00153 typedef struct ML_Aggregate_Comm_Struct
00154 {
00155    int     N_send_neighbors, N_recv_neighbors;
00156    int     local_nrows;
00157    int     *send_neighbors, *recv_neighbors;
00158    int     *send_leng, *recv_leng;
00159    int     *send_list;
00160    ML_Comm *comm;
00161 
00162 } ML_Aggregate_Comm;
00163 
00164 typedef struct ML_agg_indx_comm_struct {
00165   int N_neighbors;
00166   int *temp_leng, *send_leng, *recv_leng, *send_list, *recv_list, *tem2_index, 
00167     *neighbors, *temp_index;
00168 } ML_agg_indx_comm;
00169 
00170 /* ************************************************************************* */
00171 /* ************************************************************************* */
00172 /* functions to manipulate the aggregate data structure                      */
00173 /* ------------------------------------------------------------------------- */
00174 
00175 #ifndef ML_CPP
00176 #ifdef __cplusplus
00177 extern "C" 
00178 {
00179 #endif
00180 #endif
00181 
00182 /* ------------------------------------------------------------------------- */
00183 /* constructor/destructor and level control                                  */
00184 /* ------------------------------------------------------------------------- */
00185 
00186 int ML_Aggregate_Create( ML_Aggregate ** );
00187 int ML_Aggregate_Destroy( ML_Aggregate ** );
00188 
00189 int ML_Aggregate_Set_OutputLevel( ML_Aggregate *, double level );
00190 int ML_Aggregate_Set_Reuse(ML_Aggregate *ag);
00191 
00192 int ML_Aggregate_Set_MaxLevels( ML_Aggregate *, int level );
00193 int ML_Aggregate_Set_CurrentLevel( ML_Aggregate *, int level );
00194 int ML_Aggregate_Set_StartLevel( ML_Aggregate *, int level );
00195 
00196 /* ------------------------------------------------------------------------- */
00197 /* aggregate size and shape control                                          */
00198 /* ------------------------------------------------------------------------- */
00199 
00200 int ML_Aggregate_Set_MinNodesPerAggregate(ML_Aggregate *,int n);
00201 int ML_Aggregate_Set_AttachScheme_MaxLink( ML_Aggregate * );
00202 int ML_Aggregate_Set_AttachScheme_MinRank( ML_Aggregate * );
00203 int ML_Aggregate_Set_Phase3AggregateCreationAggressiveness(
00204            ML_Aggregate *ag, double factor);
00205 
00206 /* ------------------------------------------------------------------------- */
00207 /* aggregation node traversal control                                        */
00208 /* ------------------------------------------------------------------------- */
00209 
00210 int ML_Aggregate_Set_NaturalOrdering( ML_Aggregate * );
00211 int ML_Aggregate_Set_RandomOrdering( ML_Aggregate * );
00212 int ML_Aggregate_Set_GraphOrdering( ML_Aggregate * );
00213 
00214 /* ------------------------------------------------------------------------- */
00215 /* control when to stop coarsening                                           */
00216 /* ------------------------------------------------------------------------- */
00217 
00218 int ML_Aggregate_Set_MaxCoarseSize( ML_Aggregate *, int size );
00219 
00220 /* ------------------------------------------------------------------------- */
00221 /* different parallel coarsening schemes                                     */
00222 /* ------------------------------------------------------------------------- */
00223 
00224 int ML_Aggregate_Set_CoarsenScheme_Uncoupled( ML_Aggregate * );
00225 int ML_Aggregate_Set_CoarsenScheme_Coupled( ML_Aggregate * );
00226 int ML_Aggregate_Set_CoarsenScheme_MIS( ML_Aggregate *ag  );
00227 int ML_Aggregate_Set_CoarsenScheme_DD( ML_Aggregate *ag  );
00228 int ML_Aggregate_Set_CoarsenScheme_UncoupledMIS( ML_Aggregate *ag  );
00229 int ML_Aggregate_Set_CoarsenScheme_UncoupledCoupled( ML_Aggregate *ag  );
00230 int ML_Aggregate_Set_CoarsenScheme_METIS( ML_Aggregate *ag  );
00231 int ML_Aggregate_Set_CoarsenScheme_VBMETIS( ML_Aggregate *ag  );
00232 int ML_Aggregate_Set_CoarsenScheme_ParMETIS( ML_Aggregate *ag  );
00233 int ML_Aggregate_Set_CoarsenScheme_Zoltan( ML_Aggregate *ag  );
00234 int ML_Aggregate_Set_CoarsenScheme_User( ML_Aggregate *ag  );
00235 int ML_Aggregate_Phase2_3_Cleanup(ML_Aggregate *ml_ag, ML_Operator *Amatrix,
00236           int *aggr_count, int nvertices, 
00237           int *aggr_index, int exp_Nrows, 
00238           ML_Comm *comm, char *input_bdry,char *label,
00239                                   ML_agg_indx_comm *);
00240 int ML_Aggregate_Set_CoarsenSchemeLevel( int level, int, ML_Aggregate *ag,
00241            int choice );
00242 int ML_Aggregate_Set_CoarsenSchemeLevel_Coupled( int level, int, ML_Aggregate *ag  );
00243 int ML_Aggregate_Set_CoarsenSchemeLevel_Uncoupled( int level, int, ML_Aggregate *ag  );
00244 int ML_Aggregate_Set_CoarsenSchemeLevel_UncoupledMIS( int level, int, ML_Aggregate *ag  );
00245 int ML_Aggregate_Set_CoarsenSchemeLevel_MIS( int level, int, ML_Aggregate *ag  );
00246 int ML_Aggregate_Set_CoarsenSchemeLevel_METIS( int level, int, ML_Aggregate *ag  );
00247 int ML_Aggregate_Set_CoarsenSchemeLevel_ParMETIS( int level, int, ML_Aggregate *ag  );
00248 int ML_Aggregate_Set_CoarsenSchemeLevel_Zoltan( int level, int, ML_Aggregate *ag  );
00249 int ML_Aggregate_Set_CoarsenSchemeLevel_User( int level, int, ML_Aggregate *ag  );
00250 int ML_Aggregate_Set_Vblocks_CoarsenScheme_VBMETIS( ML_Aggregate *ag,const int level,
00251                                                     const int N_levels,const int nblocks, 
00252                                                     const int *blocks,const int *block_pde,
00253                                                     const int block_dim);
00254 
00255 /* ------------------------------------------------------------------------- */
00256 /* set threshold for pruning matrix graph                                    */
00257 /* ------------------------------------------------------------------------- */
00258 
00259 int ML_Aggregate_Set_Threshold( ML_Aggregate *, double epsilon );
00260 int ML_Aggregate_Reset_Threshold( ML_Aggregate * );
00261 
00262 /* ------------------------------------------------------------------------- */
00263 /* whether to smooth existing tentative prolongator                          */
00264 /* ------------------------------------------------------------------------- */
00265 
00266 extern int ML_Aggregate_Set_Flag_SmoothExistingTentativeP( ML_Aggregate *, int);
00267 extern int ML_Aggregate_Get_Flag_SmoothExistingTentativeP( ML_Aggregate *);
00268 
00269 /* ------------------------------------------------------------------------- */
00270 /* damping factor for prolongator smoother                                   */
00271 /* ------------------------------------------------------------------------- */
00272 
00273 int ML_Aggregate_Set_DampingFactor( ML_Aggregate *, double factor );
00274 int ML_Aggregate_Set_PSmootherType( ML_Aggregate *, int stype );
00275 int ML_Aggregate_Set_PointDiagScaling( ML_Aggregate *ag);
00276 int ML_Aggregate_Set_BlockDiagScaling( ML_Aggregate *ag);
00277 int ML_Aggregate_Set_DampingSweeps( ML_Aggregate *ag, int numSweeps, int level );
00278 int ML_Aggregate_Get_DampingSweeps( ML_Aggregate *ag, int level);
00279 
00280 /* ------------------------------------------------------------------------- */
00281 /* accessing aggregation information                                         */
00282 /* ------------------------------------------------------------------------- */
00283 
00284 int ML_Aggregate_Get_AggrCount( ML_Aggregate *, int level );
00285 int ML_Aggregate_Get_AggrMap( ML_Aggregate *, int level, int**);
00286 extern int ML_Gen_Blocks_Aggregates(ML_Aggregate *ag, int level, 
00287                                     int *nblocks, int **block_list);
00288 
00289 
00290 /* ------------------------------------------------------------------------- */
00291 /* set null space for the finest grid                                        */
00292 /* ------------------------------------------------------------------------- */
00293 
00294 int ML_Aggregate_Set_NullSpace(ML_Aggregate *, int, int, double *, int);
00295 int ML_Aggregate_Scale_NullSpace(ML_Aggregate *ag, double *scale_vect,
00296          int length);
00297 
00298 int ML_Aggregate_Coarsen( ML_Aggregate *, ML_Operator *A,
00299                           ML_Operator **P, ML_Comm *comm );
00300 
00301 /* ------------------------------------------------------------------------- */
00302 /* functions for performing aggregation                                      */
00303 /* ------------------------------------------------------------------------- */
00304 
00305 int ML_Aggregate_CoarsenMIS(ML_Aggregate *ml_ag,ML_Operator *Amatrix,
00306                             ML_Operator **Pmatrix, ML_Comm *comm);
00307 
00308 int ML_Aggregate_CoarsenDomainDecomp(ML_Aggregate *ml_ag,
00309            ML_Operator *Amatrix, ML_Operator **Pmatrix, ML_Comm *comm);
00310 
00311 int ML_Aggregate_CoarsenUncoupled(ML_Aggregate *ml_ag,
00312            ML_Operator *Amatrix, ML_Operator **Pmatrix, ML_Comm *comm);
00313 
00314 int ML_Aggregate_CoarsenCoupled(ML_Aggregate *ml_ag,
00315            ML_Operator *Amatrix, ML_Operator **Pmatrix, ML_Comm *comm);
00316 
00317 int ML_Aggregate_CoarsenMETIS(ML_Aggregate *ml_ag,
00318            ML_Operator *Amatrix, ML_Operator **Pmatrix, ML_Comm *comm);
00319 
00320 int ML_Aggregate_CoarsenParMETIS(ML_Aggregate *ml_ag,
00321            ML_Operator *Amatrix, ML_Operator **Pmatrix, ML_Comm *comm);
00322 
00323   /* ------------------------------------------------------------------------- */
00324 /* miscellaneous local functions                                             */
00325 /* ------------------------------------------------------------------------- */
00326 int ML_Aggregate_KeepInfo(ML_Aggregate *ag, int value);
00327 int ML_Aggregate_LabelVertices(int, int *, int, char *,char *,int,
00328               int *, int *, int, int **, int, int **, int *, int *,
00329               int, int **, int *, int *, int **, int, ML_Comm *, int *);
00330 
00331 int ML_Aggregate_UpdateVertexStates(int N_remaining_vertices,
00332               char vertex_state[], int recv_cnt, int recv_proc[], 
00333               int recv_leng[], int **recv_buf, int **recv_list, 
00334               int proc_flag[], int *NremainingRcvProcs, int send_cnt, 
00335               int send_proc[], int send_leng[], int **send_buf, 
00336               int *send_flag, USR_REQ *Request, ML_Comm *comm, int);
00337 
00338 int ML_Aggregate_ExchangeBdry(double *data, void *comm);
00339 
00340 int ML_Aggregate_ExchangeData(char *rbuf, char *sbuf, int N_neigh,
00341                               int *neigh, int *rleng, int *sleng,
00342                               int msgid, int datatype, ML_Comm *comm);
00343 
00344 int ML_aggr_index_communicate(int N_neighbors, int temp_leng[], int send_leng[],
00345          int recv_leng[], int send_list[], int recv_list[],
00346          int nvertices,
00347          ML_Comm *comm, int aggr_index[], int msgtype,
00348          int tem2_index[], int neighbors[], int temp_index[],int);
00349 
00350 
00351 
00352 
00353 int ML_Aggregate_Print(ML_Aggregate *);
00354 int ML_Aggregate_Print_Complexity(ML_Aggregate *);
00355 
00356 void ML_CSR_MSR_ML_memorydata_Destroy(void *data);
00357 
00358 
00359 /* ************************************************************************* */
00360 /* internal function defined later on in this file                           */
00361 /* ------------------------------------------------------------------------- */
00362 
00363 extern int ML_modified_matvec(void *Amat_in, int, double *,int , double *,int);
00364 extern int ML_random_global_subset(ML_Operator *Amat, double reduction,
00365                                    int **list, int *length, int num_PDE_eqns);
00366 extern int ML_repartition_matrix(ML_Operator *mat, ML_Operator **new_mat,
00367                                  ML_Operator **permutation, 
00368                                  ML_Operator **permt, int num_PDE_eqns,int,
00369                                  double *, double *, double *, int,
00370                                  ML_Partitioner);
00371 extern ML_Operator** ML_repartition_Acoarse(ML *ml, int fine, int coarse,
00372                  ML_Aggregate *ag, int R_is_Ptranspose, int ReturnPerm);
00373 
00374 
00375 
00376 int ML_Aggregate_Compress_Matrix(ML_GetrowFunc *getrow_obj, int *mat_indx, 
00377            int num_PDEs, ML_Comm *comm, int **new_mat_indx, 
00378            int *N_neighbors, int **neighbors, int **recv_leng,
00379            int **send_leng, int **send_list, int **recv_list, int *bc_array);
00380 int ML_Aggregate_CoarsenCoupledCore(ML_Aggregate *, ML_Comm *comm,
00381            int *amal_mat_indx, int *aggr_count, int **aggr_index2, 
00382            int N_neighbors, int *neighbors, int *recv_leng, int *send_leng,
00383            int *send_list,int *,int **, int *bc_array); 
00384 int  ML_Aggregate_ExchangeStatus(char *recvbuf, char *sendbuf, 
00385            int N_neighbors, int *neighbors, int *recv_leng, 
00386            int *send_leng, int *recv_list, int Nrows, int msgid, 
00387            int datatype, ML_Comm *comm);
00388 int ML_Aggregate_ComposeExpandedCommInfo(ML_GetrowFunc *getrow_obj, 
00389            int num_PDEs, ML_Comm *comm, 
00390            int *new_N_neighbors, int **new_neighbors, int **new_recv_leng, 
00391            int **new_send_leng, int **new_send_list, int **new_recv_list);
00392 int ML_Aggregate_ComposeRecvFromSend(int nprocs, int mypid, int new_N_send,
00393            int *new_send_leng, int *new_send_neighbors, int *N_rcv, 
00394            int **recv_leng, int **recv_neighbors, ML_Comm *comm);
00395 int ML_Aggregate_Form_Aggregates(int phaseID, int phaseAFlag, int Nrows, 
00396            int *mat_indx, int *aggr_index, int *aggr_stat, 
00397            int *node_type, int *node_type2, int *order_array, 
00398            int *aggr_count_in, int *aggr_cnt_leng_in,
00399            int **aggr_cnt_array_in, int max_row_nnz, int min_agg_size, 
00400            int max_neigh_selected, int N_neighbors, int *neighbors, 
00401            int *send_leng, int *send_list, int *recv_leng, int *recv_list, 
00402            int *sendlist_proc, ML_Comm *comm, double printflag);
00403 int ML_Aggregate_PutInto_Aggregates(char phaseID, int attach_scheme, 
00404            int *mat_indx, int *aggr_index, int *aggr_stat, 
00405            int *aggr_count_in, int **aggr_cnt_array_in, 
00406            int N_neighbors, int *neighbors, int *send_leng, int *send_list, 
00407            int *recv_leng, int *recv_list, ML_Comm *comm, double printflag);
00408 int ML_Graph_CreateFromMatrix(ML_Aggregate *ml_ag, ML_Operator *Amatrix,
00409            int **mat_indx_out, ML_Comm *comm, double epsilon, int *nrows,
00410            int **bc_array);
00411 
00412 int  ML_Aggregate_CoarsenUncoupledCore(ML_Aggregate *, ML_Comm *,
00413                 ML_Operator *, int *mat_indx, int *bdry_array, 
00414                 int *aggr_count_in, int **aggr_index_in, char *true_bdry);
00415 int ML_Aggregate_Set_CoarsenScheme_METIS( ML_Aggregate *ag  );
00416 int ML_Aggregate_Set_CoarsenScheme_ParMETIS( ML_Aggregate *ag  );
00417 
00418 int ML_Aggregate_Set_SmoothRestrictionWithA( ML_Aggregate *ag );
00419 int ML_Aggregate_Set_SmoothRestrictionWithAT( ML_Aggregate *ag );
00420   
00421 extern int ML_Aggregate_Set_NodalCoordinates(ML* ml, ML_Aggregate *ag, double *ptr);
00422 extern int ML_Aggregate_Set_Dimensions(ML_Aggregate *ag, int N_dimensions);
00423 extern int ML_Aggregate_Get_CoarsenScheme( ML_Aggregate *ag  );
00424 
00425 /* ------------------------------------------------------------------------- */
00426 /* functions for visualization                                               */
00427 /* ------------------------------------------------------------------------- */
00428 
00429 extern int ML_Aggregate_VizAndStats_Setup( ML *ml);
00430 extern int ML_Aggregate_VizAndStats_Clean( ML *ml);
00431 #ifndef ML_CPP
00432 #ifdef __cplusplus
00433 }
00434 #endif
00435 #endif
00436 
00437 #endif
00438