Actual source code: tfs.h
5: /**********************************const.h*************************************
7: Author: Henry M. Tufo III
9: e-mail: hmt@cs.brown.edu
11: snail-mail:
12: Division of Applied Mathematics
13: Brown University
14: Providence, RI 02912
16: Last Modification:
17: 6.21.97
18: ***********************************const.h************************************/
20: /**********************************const.h*************************************
21: File Description:
22: -----------------
24: ***********************************const.h************************************/
25: #include petsc.h
26: #include petscsys.h
27: #if defined(PETSC_HAVE_STDLIB_H)
28: #include <stdlib.h>
29: #endif
30: #if defined(PETSC_HAVE_MALLOC_H)
31: #include <malloc.h>
32: #endif
33: #include petscblaslapack.h
34: #include <limits.h>
35: #include <float.h>
37: #define X 0
38: #define Y 1
39: #define Z 2
40: #define XY 3
41: #define XZ 4
42: #define YZ 5
45: #define THRESH 0.2
46: #define N_HALF 4096
47: #define PRIV_BUF_SZ 45
49: /*4096 8192 32768 65536 1048576 */
50: #define MAX_MSG_BUF 32768
52: /* fortran gs limit */
53: #define MAX_GS_IDS 100
55: #define FULL 2
56: #define PARTIAL 1
57: #define NONE 0
59: #define BYTE 8
60: #define BIT_0 0x1
61: #define BIT_1 0x2
62: #define BIT_2 0x4
63: #define BIT_3 0x8
64: #define BIT_4 0x10
65: #define BIT_5 0x20
66: #define BIT_6 0x40
67: #define BIT_7 0x80
68: #define TOP_BIT INT_MIN
69: #define ALL_ONES -1
71: #define FALSE 0
72: #define TRUE 1
74: #define C 0
75: #define FORTRAN 1
78: #define MAX_VEC 1674
79: #define FORMAT 30
80: #define MAX_COL_LEN 100
81: #define MAX_LINE FORMAT*MAX_COL_LEN
82: #define DELIM " \n \t"
83: #define LINE 12
84: #define C_LINE 80
86: #define REAL_MAX DBL_MAX
87: #define REAL_MIN DBL_MIN
89: #define UT 5 /* dump upper 1/2 */
90: #define LT 6 /* dump lower 1/2 */
91: #define SYMM 8 /* we assume symm and dump upper 1/2 */
92: #define NON_SYMM 9
94: #define ROW 10
95: #define COL 11
97: #define EPS 1.0e-14
98: #define EPS2 1.0e-07
101: #define MPI 1
102: #define NX 2
105: #define LOG2(x) (PetscScalar)log((double)x)/log(2)
106: #define SWAP(a,b) temp=(a); (a)=(b); (b)=temp;
107: #define P_SWAP(a,b) ptr=(a); (a)=(b); (b)=ptr;
109: #define MAX_FABS(x,y) ((double)fabs(x)>(double)fabs(y)) ? ((PetscScalar)x) : ((PetscScalar)y)
110: #define MIN_FABS(x,y) ((double)fabs(x)<(double)fabs(y)) ? ((PetscScalar)x) : ((PetscScalar)y)
112: /* specer's existence ... can be done w/MAX_ABS */
113: #define EXISTS(x,y) ((x)==0.0) ? (y) : (x)
115: #define MULT_NEG_ONE(a) (a) *= -1;
116: #define NEG(a) (a) |= BIT_31;
117: #define POS(a) (a) &= INT_MAX;
122: /**********************************types.h*************************************
124: Author: Henry M. Tufo III
126: e-mail: hmt@cs.brown.edu
128: snail-mail:
129: Division of Applied Mathematics
130: Brown University
131: Providence, RI 02912
133: Last Modification:
134: 6.21.97
135: ***********************************types.h************************************/
137: /**********************************types.h*************************************
138: File Description:
139: -----------------
141: ***********************************types.h************************************/
142: typedef void (*vfp)(void*,void*,int,...);
143: typedef void (*rbfp)(PetscScalar *, PetscScalar *, int len);
144: #define vbfp MPI_User_function *
145: typedef int (*bfp)(void*, void *, int *len, MPI_Datatype *dt);
147: /***********************************comm.h*************************************
149: Author: Henry M. Tufo III
151: e-mail: hmt@cs.brown.edu
153: snail-mail:
154: Division of Applied Mathematics
155: Brown University
156: Providence, RI 02912
158: Last Modification:
159: 6.21.97
160: ***********************************comm.h*************************************/
162: /***********************************comm.h*************************************
163: File Description:
164: -----------------
166: ***********************************comm.h*************************************/
168: /***********************************comm.h*************************************
169: Function:
171: Input :
172: Output:
173: Return:
174: Description:
175: Usage:
176: ***********************************comm.h*************************************/
191: #define MSGTAG0 101
192: #define MSGTAG1 1001
193: #define MSGTAG2 76207
194: #define MSGTAG3 100001
195: #define MSGTAG4 163841
196: #define MSGTAG5 249439
197: #define MSGTAG6 10000001
200: /**********************************error.h*************************************
202: Author: Henry M. Tufo III
204: e-mail: hmt@cs.brown.edu
206: snail-mail:
207: Division of Applied Mathematics
208: Brown University
209: Providence, RI 02912
211: Last Modification:
212: 6.21.97
213: **********************************error.h*************************************/
215: /**********************************error.h*************************************
216: File Description:
217: -----------------
219: **********************************error.h*************************************/
221: /**********************************error.h*************************************
222: Function: error_msg_fatal()
224: Input : formatted string and arguments.
225: Output: conversion printed to stdout.
226: Return: na.
227: Description: prints error message and terminates program.
228: Usage: error_msg_fatal("this is my %d'st test",test_num)
229: **********************************error.h*************************************/
234: /**********************************error.h*************************************
235: Function: error_msg_warning()
237: Input : formatted string and arguments.
238: Output: conversion printed to stdout.
239: Return: na.
240: Description: prints error message.
241: Usage: error_msg_warning("this is my %d'st test",test_num)
242: **********************************error.h*************************************/
245: /*$Id: vector.c,v 1.228 2001/03/23 23:21:22 balay Exp $*/
246: /**********************************ivec.h**************************************
248: Author: Henry M. Tufo III
250: e-mail: hmt@cs.brown.edu
252: snail-mail:
253: Division of Applied Mathematics
254: Brown University
255: Providence, RI 02912
257: Last Modification:
258: 6.21.97
259: ***********************************ivec.h*************************************/
261: /**********************************ivec.h**************************************
262: File Description:
263: -----------------
265: ***********************************ivec.h*************************************/
267: #define SORT_REAL 1
268: #define SORT_INTEGER 0
269: #define SORT_INT_PTR 2
270:
272: #define NON_UNIFORM 0
273: #define GL_MAX 1
274: #define GL_MIN 2
275: #define GL_MULT 3
276: #define GL_ADD 4
277: #define GL_B_XOR 5
278: #define GL_B_OR 6
279: #define GL_B_AND 7
280: #define GL_L_XOR 8
281: #define GL_L_OR 9
282: #define GL_L_AND 10
283: #define GL_MAX_ABS 11
284: #define GL_MIN_ABS 12
285: #define GL_EXISTS 13
289: /**********************************ivec.h**************************************
290: Function:
292: Input :
293: Output:
294: Return:
295: Description:
296: Usage:
297: ***********************************ivec.h*************************************/
301: /*void ivec_copy(int *arg1, int *arg2, int n); */
380: /**********************************queue.h*************************************
382: Author: Henry M. Tufo III
384: e-mail: hmt@cs.brown.edu
386: snail-mail:
387: Division of Applied Mathematics
388: Brown University
389: Providence, RI 02912
391: Last Modification:
392: 6.21.97
393: **********************************queue.h*************************************/
395: /**********************************queue.h*************************************
396: File Description:
397: -----------------
398: This file provides an interface to a simple queue abstraction.
399: **********************************queue.h*************************************/
401: /**********************************queue.h*************************************
402: Type: queue_ADT
403: ---------------
404: This line defines the abstract queue type as a pointer to
405: its concrete counterpart. Clients have no access to the
406: underlying representation.
407: **********************************queue.h*************************************/
408: typedef struct queue_CDT *queue_ADT;
412: /**********************************queue.h*************************************
413: Function: new_queue()
415: Input : na
416: Output: na
417: Return: pointer to ADT.
418: Description: This function allocates and returns an empty queue.
419: Usage: queue = new_queue();
420: **********************************queue.h*************************************/
425: /**********************************queue.h*************************************
426: Function: free_queue()
428: Input : pointer to ADT.
429: Output: na
430: Return: na
431: Description: This function frees the storage associated with queue but not any
432: pointer contained w/in.
433: Usage: free_queue(queue);
434: **********************************queue.h*************************************/
439: /**********************************queue.h*************************************
440: Function: enqueue()
442: Input : pointer to ADT and pointer to object
443: Output: na
444: Return: na
445: Description: This function adds obj to the end of the queue.
446: Usage: enqueue(queue, obj);
447: **********************************queue.h*************************************/
452: /**********************************queue.h*************************************
453: Function: dequeue()
455: Input : pointer to ADT
456: Output: na
457: Return: void * to element
458: Description: This function removes the data value at the head of the queue
459: and returns it to the client. dequeueing an empty queue is an error
460: Usage: obj = dequeue(queue);
461: **********************************queue.h*************************************/
466: /**********************************queue.h*************************************
467: Function: len_queue()
469: Input : pointer to ADT
470: Output: na
471: Return: integer number of elements
472: Description: This function returns the number of elements in the queue.
473: Usage: n = len_queue(queue);
474: **********************************queue.h*************************************/
475: EXTERN int len_queue(queue_ADT queue);
479: /*$Id: vector.c,v 1.228 2001/03/23 23:21:22 balay Exp $*/
480: /***********************************gs.h***************************************
482: Author: Henry M. Tufo III
484: e-mail: hmt@cs.brown.edu
486: snail-mail:
487: Division of Applied Mathematics
488: Brown University
489: Providence, RI 02912
491: Last Modification:
492: 6.21.97
493: ************************************gs.h**************************************/
495: /***********************************gs.h***************************************
496: File Description:
497: -----------------
499: ************************************gs.h**************************************/
501: /***********************************gs.h***************************************
502: Type: gs_ADT
503: ------------
505: ************************************gs.h**************************************/
507: typedef struct gather_scatter_id *gs_ADT;
508: typedef void (*Rbfp)(PetscScalar *, PetscScalar *, int len);
510: /***********************************gs.h***************************************
511: Function:
513: Input :
514: Output:
515: Return:
516: Description:
517: Usage:
518: ************************************gs.h**************************************/
530: /*************************************xxt.h************************************
531: Module Name: xxt
532: Module Info: need xxt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
534: author: Henry M. Tufo III
535: e-mail: hmt@asci.uchicago.edu
536: contact:
537: +--------------------------------+--------------------------------+
538: |MCS Division - Building 221 |Department of Computer Science |
539: |Argonne National Laboratory |Ryerson 152 |
540: |9700 S. Cass Avenue |The University of Chicago |
541: |Argonne, IL 60439 |Chicago, IL 60637 |
542: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
543: +--------------------------------+--------------------------------+
545: Last Modification: 3.20.01
546: **************************************xxt.h***********************************/
548: /*************************************xxt.h************************************
549: File Description:
550: **************************************xxt.h***********************************/
552: /*************************************xxt.h************************************
553: Notes on Usage:
554: **************************************xxt.h***********************************/
557: typedef struct xxt_CDT *xxt_ADT;
560: /*************************************xxt.h************************************
561: Function: XXT_new()
563: Input :
564: Output:
565: Return: ADT ptr or NULL upon failure.
566: Description: This function allocates and returns an xxt handle
567: Usage: xxt_handle = xxt_new();
568: **************************************xxt.h***********************************/
572: /*************************************xxt.h************************************
573: Function: XXT_free()
575: Input : pointer to ADT.
576: Output:
577: Return:
578: Description: This function frees the storage associated with an xxt handle
579: Usage: XXT_free(xxt_handle);
580: **************************************xxt.h***********************************/
581: EXTERN int XXT_free(xxt_ADT xxt_handle);
584: /*************************************xxt.h************************************
585: Function: XXT_factor
587: Input : ADT ptr, and pointer to object
588: Output:
589: Return: 0 on failure, 1 on success
590: Description: This function sets the xxt solver
592: xxt assumptions: given n rows of global coarse matrix (E_loc) where
593: o global dofs N = sum_p(n), p=0,P-1
594: (i.e. row dist. with no dof replication)
595: (5.21.00 will handle dif replication case)
596: o m is the number of columns in E_loc (m>=n)
597: o local2global holds global number of column i (i=0,...,m-1)
598: o local2global holds global number of row i (i=0,...,n-1)
599: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
600: length m in 1-1 correspondence with local2global
601: (note that gs package takes care of communication).
602: (note do not zero out upper m-n entries!)
603: o mylocmatvec(void *grid_data, double *in, double *out)
605: ML beliefs/usage: move this to to ML_XXT_factor routine
606: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
607: o grid_tag, grid_data, my_ml used in
608: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
609: o grid_data used in
610: A_matvec(grid_data,v,u);
612: Usage:
613: **************************************xxt.h***********************************/
615: int *local2global, /* global column mapping */
616: int n, /* local num rows */
617: int m, /* local num cols */
618: void *mylocmatvec, /* b_loc=A_local.x_loc */
619: void *grid_data /* grid data for matvec */
620: );
623: /*************************************xxt.h************************************
624: Function: XXT_solve
626: Input : ADT ptr, b (rhs)
627: Output: x (soln)
628: Return:
629: Description: This function performs x = E^-1.b
630: Usage:
631: XXT_solve(xxt_handle, double *x, double *b)
632: XXT_solve(xxt_handle, double *x, NULL)
633: assumes x has been initialized to be b
634: impl. issue for FORTRAN interface ... punt for now and disallow NULL opt.
635: **************************************xxt.h***********************************/
639: /*************************************xxt.h************************************
640: Function: XXT_stats
642: Input : handle
643: Output:
644: Return:
645: Description:
646: factor stats
647: **************************************xxt.h***********************************/
651: /*************************************xxt.h************************************
652: Function: XXT_sp_1()
654: Input : pointer to ADT
655: Output:
656: Return:
657: Description: sets xxt parameter 1 in xxt_handle
658: Usage: implement later
660: void XXT_sp_1(xxt_handle,parameter 1 value)
661: **************************************xxt.h***********************************/
664: /*************************************xyt.h************************************
665: Module Name: xyt
666: Module Info: need xyt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
668: author: Henry M. Tufo III
669: e-mail: hmt@asci.uchicago.edu
670: contact:
671: +--------------------------------+--------------------------------+
672: |MCS Division - Building 221 |Department of Computer Science |
673: |Argonne National Laboratory |Ryerson 152 |
674: |9700 S. Cass Avenue |The University of Chicago |
675: |Argonne, IL 60439 |Chicago, IL 60637 |
676: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
677: +--------------------------------+--------------------------------+
679: Last Modification: 3.20.01
680: **************************************xyt.h***********************************/
682: /*************************************xyt.h************************************
683: File Description:
684: **************************************xyt.h***********************************/
686: /*************************************xyt.h************************************
687: Notes on Usage:
688: **************************************xyt.h***********************************/
692: typedef struct xyt_CDT *xyt_ADT;
695: /*************************************xyt.h************************************
696: Function: XYT_new()
698: Input :
699: Output:
700: Return: ADT ptr or NULL upon failure.
701: Description: This function allocates and returns an xyt handle
702: Usage: xyt_handle = xyt_new();
703: **************************************xyt.h***********************************/
707: /*************************************xyt.h************************************
708: Function: XYT_free()
710: Input : pointer to ADT.
711: Output:
712: Return:
713: Description: This function frees the storage associated with an xyt handle
714: Usage: XYT_free(xyt_handle);
715: **************************************xyt.h***********************************/
716: EXTERN int XYT_free(xyt_ADT xyt_handle);
719: /*************************************xyt.h************************************
720: Function: XYT_factor
722: Input : ADT ptr, and pointer to object
723: Output:
724: Return: 0 on failure, 1 on success
725: Description: This function sets the xyt solver
727: xyt assumptions: given n rows of global coarse matrix (E_loc) where
728: o global dofs N = sum_p(n), p=0,P-1
729: (i.e. row dist. with no dof replication)
730: (5.21.00 will handle dif replication case)
731: o m is the number of columns in E_loc (m>=n)
732: o local2global holds global number of column i (i=0,...,m-1)
733: o local2global holds global number of row i (i=0,...,n-1)
734: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
735: length m in 1-1 correspondence with local2global
736: (note that gs package takes care of communication).
737: (note do not zero out upper m-n entries!)
738: o mylocmatvec(void *grid_data, double *in, double *out)
740: ML beliefs/usage: move this to to ML_XYT_factor routine
741: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
742: o grid_tag, grid_data, my_ml used in
743: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
744: o grid_data used in
745: A_matvec(grid_data,v,u);
747: Usage:
748: **************************************xyt.h***********************************/
750: int *local2global, /* global column mapping */
751: int n, /* local num rows */
752: int m, /* local num cols */
753: void *mylocmatvec, /* b_loc=A_local.x_loc */
754: void *grid_data /* grid data for matvec */
755: );
758: /*************************************xyt.h************************************
759: Function: XYT_solve
761: Input : ADT ptr, b (rhs)
762: Output: x (soln)
763: Return:
764: Description: This function performs x = E^-1.b
765: Usage: XYT_solve(xyt_handle, double *x, double *b)
766: **************************************xyt.h***********************************/
770: /*************************************xyt.h************************************
771: Function: XYT_stats
773: Input : handle
774: Output:
775: Return:
776: Description:
777: factor stats
778: **************************************xyt.h***********************************/
782: /*************************************xyt.h************************************
783: Function: XYT_sp_1()
785: Input : pointer to ADT
786: Output:
787: Return:
788: Description: sets xyt parameter 1 in xyt_handle
789: Usage: implement later
791: void XYT_sp_1(xyt_handle,parameter 1 value)
792: **************************************xyt.h***********************************/
794: /********************************bit_mask.h************************************
796: Author: Henry M. Tufo III
798: e-mail: hmt@cs.brown.edu
800: snail-mail:
801: Division of Applied Mathematics
802: Brown University
803: Providence, RI 02912
805: Last Modification:
806: 11.21.97
807: *********************************bit_mask.h***********************************/
809: /********************************bit_mask.h************************************
810: File Description:
811: -----------------
813: *********************************bit_mask.h***********************************/
816: /********************************bit_mask.h************************************
817: Function:
819: Input :
820: Output:
821: Return:
822: Description:
823: Usage:
824: *********************************bit_mask.h***********************************/
832: #endif