petsc.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.2 $
00022 // $Date: 2003/02/14 23:02:02 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/system_of_eqn/linearSOE/petsc/petsc.h,v $
00024                                                                         
00025                                                                         
00026 /* $Id: petsc.h,v 1.2 2003/02/14 23:02:02 fmk Exp $ */
00027 /*
00028    This is the main PETSc include file (for C and C++).  It is included by all
00029    other PETSc include files, so it almost never has to be specifically included.
00030 */
00031 #if !defined(__PETSC_PACKAGE)
00032 #define __PETSC_PACKAGE
00033 
00034 /* 
00035    Current PETSc Version 
00036 */
00037 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.22, Released April 28, 1998."
00038 
00039 #define PETSC_VERSION_MAJOR    2
00040 #define PETSC_VERSION_MINOR    0
00041 #define PETSC_VERSION_SUBMINOR 22
00042 #define PETSC_VERSION_DATE     "April 29, 1998"
00043 #define PETSC_AUTHOR_INFO      "The PETSc Team:\
00044  Satish Balay, Bill Gropp, Lois Curfman McInnes, Barry Smith\n\
00045  Bug reports, questions: petsc-maint@mcs.anl.gov\n\
00046  Web page: http://www.mcs.anl.gov/petsc/\n"
00047 
00048 /* ========================================================================== */
00049 /* Before anything else, include the PETSc configuration file.  This 
00050    contains various definitions that handle portability issues and the 
00051    presence of important features. 
00052 
00053    petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h  
00054 */
00055 #include <petscconf.h>
00056 
00057 
00058 /* ========================================================================== */
00059 
00060 #include <stdio.h>
00061 /*
00062     Defines the interface to MPI allowing the use of all MPI functions.
00063 */
00064 #include "mpi.h"
00065 
00066 /*
00067     Defines some elementary mathematics functions and constants.
00068 */
00069 #include "petscmath.h"
00070 /*
00071     This shouuld be in petscmath.h?
00072 */
00073 #if defined(USE_POINTER_CONVERSION)
00074 #define PetscFortranAddr   int
00075 #else
00076 #define PetscFortranAddr   long
00077 #endif
00078 
00079 extern MPI_Comm PETSC_COMM_WORLD;
00080 extern MPI_Comm PETSC_COMM_SELF;
00081 extern int      PetscInitializedCalled;
00082 extern int      PetscSetCommWorld(MPI_Comm);
00083 
00084 /*
00085     Defines the malloc employed by PETSc. Users may use these routines as well. 
00086 */
00087 #define PetscMalloc(a)       (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
00088 #define PetscNew(A)          (A*) PetscMalloc(sizeof(A))
00089 #define PetscFree(a)         (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
00090 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*);
00091 extern int  (*PetscTrFree)(void *,int,char*,char*,char*);
00092 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*),
00093                            int (*)(void *,int,char*,char*,char*));
00094 extern int  PetscClearMalloc(void);
00095 
00096 extern int   PetscTrDump(FILE *);
00097 extern int   PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *);
00098 extern int   PetscTrValid(int,char *,char *,char *);
00099 extern int   PetscTrDebugLevel(int);
00100 extern int   PetscTrLog(void);
00101 extern int   PetscTrLogDump(FILE *);
00102 extern int   PetscGetResidentSetSize(PLogDouble *);
00103 
00104 #include <src/inline/bitarray.h>
00105 
00106 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3,
00107               PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType;
00108 #if defined(USE_PETSC_COMPLEX)
00109 #define PETSC_SCALAR PETSC_COMPLEX
00110 #else
00111 #define PETSC_SCALAR PETSC_DOUBLE
00112 #endif
00113 
00114 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double),
00115               PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double),
00116               PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize;
00117 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
00118 extern int PetscDataTypeGetSize(PetscDataType,int*);
00119 extern int PetscDataTypeGetName(PetscDataType,char**);
00120 
00121 /*
00122     Basic memory and string operations
00123 */
00124 extern int   PetscMemcpy(void *,void *,int);
00125 extern int   PetscBitMemcpy(void*,int,void*,int,int,PetscDataType);
00126 extern int   PetscMemmove(void *,void *,int);
00127 extern int   PetscMemzero(void *,int);
00128 extern int   PetscMemcmp(void*, void*, int);
00129 extern int   PetscStrlen(char *);
00130 extern int   PetscStrcmp(char *,char *);
00131 extern int   PetscStrcasecmp(char *,char *);
00132 extern int   PetscStrncmp(char *,char *,int );
00133 extern int   PetscStrcpy(char *,char *);
00134 extern int   PetscStrcat(char *,char *);
00135 extern int   PetscStrncat(char *,char *,int);
00136 extern int   PetscStrncpy(char *,char *,int);
00137 extern char* PetscStrchr(char *,char);
00138 extern char* PetscStrrchr(char *,char);
00139 extern char* PetscStrstr(char*,char*);
00140 extern char* PetscStrtok(char*,char*);
00141 extern char* PetscStrrtok(char*,char*);
00142 
00143 /*
00144        Basic PETSc constants
00145 */
00146 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
00147 #define PETSC_NULL            0
00148 #define PETSC_DECIDE         -1
00149 #define PETSC_DETERMINE      PETSC_DECIDE
00150 #define PETSC_DEFAULT        -2
00151 
00152 /*
00153     Each PETSc object class has it's own cookie (internal integer in the 
00154   data structure used for error checking). These are all defined by an offset 
00155   from the lowest one, PETSC_COOKIE. If you increase these you must 
00156   increase the field sizes in petsc/src/plog/src/plog.c
00157 */
00158 #define PETSC_COOKIE                    1211211
00159 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30
00160 #define LARGEST_PETSC_COOKIE_ALLOWED    PETSC_COOKIE + 50
00161 extern int LARGEST_PETSC_COOKIE;
00162 
00163 #include "viewer.h"
00164 #include "options.h"
00165 
00166 /*
00167     Defines basic graphics available from PETSc.
00168 */
00169 #include "draw.h"
00170 
00171 extern int PetscGetTime(PLogDouble*);
00172 extern int PetscGetCPUTime(PLogDouble*);
00173 extern int PetscSleep(int);
00174 
00175 extern int  PetscInitialize(int*,char***,char*,char*);
00176 extern int  PetscInitializeNoArguments(void);
00177 extern int  PetscFinalize(void);
00178 extern void PetscInitializeFortran(void);
00179 
00180 /*
00181     Functions that can act on any PETSc object.
00182 */
00183 typedef struct _p_PetscObject* PetscObject;
00184 extern int PetscObjectDestroy(PetscObject);
00185 extern int PetscObjectExists(PetscObject,int*);
00186 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
00187 extern int PetscObjectGetCookie(PetscObject,int *cookie);
00188 extern int PetscObjectGetType(PetscObject,int *type);
00189 extern int PetscObjectSetName(PetscObject,char*);
00190 extern int PetscObjectGetName(PetscObject,char**);
00191 extern int PetscObjectReference(PetscObject);
00192 extern int PetscObjectGetReference(PetscObject,int*);
00193 extern int PetscObjectDereference(PetscObject);
00194 extern int PetscObjectGetNewTag(PetscObject,int *);
00195 extern int PetscObjectRestoreNewTag(PetscObject,int *);
00196 extern int PetscObjectView(PetscObject,Viewer);
00197 
00198 extern int PetscObjectCompose(PetscObject,char *,PetscObject);
00199 extern int PetscObjectQuery(PetscObject,char *,PetscObject *);
00200 #if defined(USE_DYNAMIC_LIBRARIES)
00201 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0)
00202 #else
00203 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d)
00204 #endif
00205 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *);
00206 extern int PetscObjectQueryFunction(PetscObject,char *,void **);
00207 
00208 
00209 /*
00210     Defines PETSc error handling.
00211 */
00212 #include "petsopserror.h"
00213 
00214 /*
00215     Mechanism for managing lists of objects attached (composed) with 
00216    a PETSc object.
00217 */
00218 typedef struct _OList *OList;
00219 extern int OListDestroy(OList *);
00220 extern int OListFind(OList,char *,PetscObject*);
00221 extern int OListAdd(OList *,char *,PetscObject);
00222 extern int OListRemove(OList *,char *);
00223 extern int OListDuplicate(OList,OList *);
00224 
00225 /*
00226     Dynamic library lists. Lists of names of routines in dynamic 
00227   link libraries that will be loaded as needed.
00228 */
00229 typedef struct _DLList *DLList;
00230 extern int    DLRegister_Private(DLList*,char*,char*,int (*)(void *));
00231 extern int    DLRegisterCreate(DLList *);
00232 extern int    DLRegisterDestroy(DLList);
00233 extern int    DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*));
00234 extern int    DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList);
00235 #if defined(USE_DYNAMIC_LIBRARIES)
00236 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0)
00237 #else
00238 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c)
00239 #endif
00240 
00241 typedef struct _DLLibraryList *DLLibraryList;
00242 extern DLLibraryList DLLibrariesLoaded;
00243 extern int DLLibraryOpen(MPI_Comm,char *,void **);
00244 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **);
00245 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *);
00246 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *);
00247 extern int DLLibraryClose(DLLibraryList);
00248 
00249 
00250 #include "petschead.h"
00251 
00252 /*
00253      Defines PETSc profiling.
00254 */
00255 #include "petsclog.h"
00256 
00257 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
00258 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
00259 
00260 /*M 
00261     PetscBarrier - Blocks until this routine is executed by all
00262                    processors owning the object A.
00263 
00264    Input Parameters:
00265 .  A - PETSc object  ( Mat, Vec, IS, SNES etc...)
00266 
00267    Synopsis:
00268    void PetscBarrier(PetscObject obj)
00269 
00270   Notes: 
00271   This routine calls MPI_Barrier with the communicator
00272   of the PETSc Object "A". 
00273 
00274 .keywords: barrier, petscobject
00275 M*/
00276 
00277 #define PetscBarrier(A) \
00278   { \
00279     PetscValidHeader(A); \
00280     PLogEventBegin(Petsc_Barrier,A,0,0,0); \
00281     MPI_Barrier(((PetscObject)A)->comm); \
00282     PLogEventEnd(Petsc_Barrier,A,0,0,0); \
00283   }
00284 
00285 extern int PetscMPIDump(FILE *);
00286 
00287 /*
00288       This code allows one to pass a PETSc object in C
00289   to a Fortran routine, where (like all PETSc objects in 
00290   Fortran) it is treated as an integer.
00291 */
00292 extern int  PetscCObjectToFortranObject(void *,PetscFortranAddr *);
00293 extern int  PetscFortranObjectToCObject(PetscFortranAddr,void *);
00294 extern int  MPICCommToFortranComm(MPI_Comm,int *);
00295 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
00296 
00297 /*
00298       Simple PETSc parallel IO for ASCII printing
00299 */
00300 extern int  PetscFixFilename(char*);
00301 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
00302 extern int  PetscFClose(MPI_Comm,FILE*);
00303 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
00304 extern int  PetscPrintf(MPI_Comm,char *,...);
00305 extern int  (*PetscErrorPrintf)(char *,...);
00306 extern int  (*PetscHelpPrintf)(MPI_Comm,char *,...);
00307 
00308 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
00309 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
00310 extern int  PetscSynchronizedFlush(MPI_Comm);
00311 
00312 
00313 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
00314 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **);
00315 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *);
00316 extern int PetscObjectContainerDestroy(PetscObjectContainer);
00317 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
00318 
00319 /*
00320     C code optimization is often enhanced by telling the compiler 
00321   that certain pointer arguments to functions are not aliased to 
00322   to other arguments. This is not yet ANSI C standard so we define 
00323   the macro "restrict" to indicate that the variable is not aliased 
00324   to any other argument.
00325 */
00326 #if defined(HAVE_RESTRICT) && !defined(__cplusplus)
00327 #define restrict _Restrict
00328 #else
00329 #define restrict
00330 #endif
00331 
00332 /*
00333    For incremental debugging
00334 */
00335 extern int PetscCompare;
00336 extern int PetscCompareDouble(double);
00337 extern int PetscCompareScalar(Scalar);
00338 extern int PetscCompareInt(int);
00339 
00340 /*
00341    For use in debuggers 
00342 */
00343 extern int PetscGlobalRank,PetscGlobalSize;
00344 extern int PetscIntView(int,int*,Viewer);
00345 extern int PetscDoubleView(int,double *,Viewer);
00346 
00347 #include <mat.h>
00348 
00349 #endif

Generated on Mon Oct 23 15:05:28 2006 for OpenSees by doxygen 1.5.0