00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef PYTHON
00027 #include "Python.h"
00028 #endif
00029
00030 #ifndef GRIDDATA_H
00031 #define GRIDDATA_H
00032
00033
00034
00035
00036
00037 #ifdef __GNUC__
00038 #define __FUNCT__ __FUNCTION__
00039 #elif __STDC_VERSION__ == 199901L
00040 #define __FUNCT__ __FUNC__
00041 #else
00042 #define __FUNCT__ "function"
00043 #endif
00044
00045 #include "petscsys.h"
00046 #include "petscts.h"
00047 #include "petscao.h"
00048
00050 #ifdef TAO
00051 #include "tao.h"
00052 #endif
00053
00054
00055
00056
00057
00058
00059
00060 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 1 && PETSC_VERSION_SUBMINOR == 0)
00061 #define PETSC_VERSION 310
00062 #elif (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 0 && PETSC_VERSION_SUBMINOR == 0)
00063 #define PETSC_VERSION 300
00064 #elif (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 3 && PETSC_VERSION_SUBMINOR == 3)
00065 #define PETSC_VERSION 233
00066 #ifdef TAO
00067 #if (TAO_VERSION_MAJOR != 1 && TAO_VERSION_MINOR != 8 && TAO_VERSION_SUBMINOR != 3)
00068 #error PETSc version 2.3.3 requires TAO version 1.9
00069 #endif
00070 #endif
00071 #else
00072 #error "PETSc version unsupported or unknown! Please use one of the supported versions!"
00073 #endif
00074
00075 #define MagparFunctionLogBegin int ierr;PetscLogDouble t_t1,t_t2;{PetscFunctionBegin;PetscPrintf(PETSC_COMM_WORLD,"\n>> %s::%s\n",__FILE__,__FUNCT__);PetscInfo2(0,"%s%s",Id,Td);PetscGetTime(&t_t1);ierr=0;}
00076 #define MagparFunctionLogReturn(A) {PetscGetTime(&t_t2);PetscPrintf(PETSC_COMM_WORLD,"<< %s::%s took %g s\n\n",__FILE__,__FUNCT__,t_t2-t_t1);CHKMEMQ;PetscFunctionReturn(A);}
00077 #if PETSC_VERSION >= 232
00078 #define MagparFunctionInfoBegin int ierr;PetscLogDouble t_t1,t_t2;{PetscFunctionBegin;PetscInfo1(0,"%s\n",__FILE__);PetscInfo2(0,"%s%s",Id,Td);PetscGetTime(&t_t1);ierr=0;}
00079 #define MagparFunctionInfoReturn(A) {PetscGetTime(&t_t2);PetscInfo1(0,"took %g s\n\n",t_t2-t_t1);PetscFunctionReturn(A);}
00080 #define MagparFunctionProfReturn(A) {PetscGetTime(&t_t2);PetscTruth profile;PetscOptionsHasName(PETSC_NULL,"-profile",&profile);if (profile) {PetscPrintf(PETSC_COMM_WORLD,"%s::%s took %g s\n",__FILE__,__FUNCT__,t_t2-t_t1);} else {PetscInfo1(0,"took %g s\n",t_t2-t_t1);} PetscFunctionReturn(A);}
00081 #else
00082 #define MagparFunctionInfoBegin int ierr;PetscLogDouble t_t1,t_t2;{PetscFunctionBegin;PetscGetTime(&t_t1);ierr=0;}
00083 #define MagparFunctionInfoReturn(A) {PetscGetTime(&t_t2);PetscFunctionReturn(A);}
00084 #define MagparFunctionProfReturn(A) {PetscGetTime(&t_t2);PetscFunctionReturn(A);}
00085 #endif
00086
00088 #include <assert.h>
00089
00093 #define ND 3
00094 #define NV 4
00095 #define NF 4
00096 #define NN 3
00097 #define NP 19
00099
00100
00104 #define C_BND -1
00105 #define C_INT -2
00106 #define C_UNK -4
00108
00109 #define D_EPS PETSC_MACHINE_EPSILON*100
00114 #define MU0 (12.566371e-7)
00115 #define GAMMA (2.210173e5)
00117
00118
00119 #define RIGID_M_ALPHA 999
00120
00121
00122
00123
00124
00125
00126 #define my_daxpy(a,b,c,d,e,f) {(e)[0]+=b*(c)[0];(e)[1]+=b*(c)[1];(e)[2]+=b*(c)[2];}
00127 #define my_dcopy(a,b,c,d,e) {(d)[0]=(b)[0];(d)[1]=(b)[1];(d)[2]=(b)[2];}
00128 #define my_dnrm2(a,b,c) sqrt((b)[0]*(b)[0]+(b)[1]*(b)[1]+(b)[2]*(b)[2])
00129 #define my_dscal(a,b,c,d) {(c)[0]*=b;(c)[1]*=b;(c)[2]*=b;}
00130 #define my_ddot(a,b,c,d,e) ((b)[0]*(d)[0]+(b)[1]*(d)[1]+(b)[2]*(d)[2])
00131 #define douter(a,b,c,d) {(d)[0]=(b)[1]*(c)[2]-(b)[2]*(c)[1];(d)[1]=(b)[2]*(c)[0]-(b)[0]*(c)[2];(d)[2]=(b)[0]*(c)[1]-(b)[1]*(c)[0];}
00132
00136 #if PETSC_VERSION <= 220
00137 typedef int PetscInt;
00138 typedef int PetscBLASInt;
00139 #endif
00140
00141 typedef struct {
00142 char simname[256];
00143 int inp;
00145 PetscReal time;
00147 int mode;
00149 PetscReal hscale;
00150 PetscReal tscale;
00151 PetscReal escale;
00152 PetscReal lenscale;
00155
00156
00157
00158
00159
00160
00164 int n_vert;
00165 int n_ele;
00167
00171 int ln_vert;
00172 int ln_ele;
00174
00178 PetscReal *vertxyz;
00179 int *vertl2g;
00180 int *vertnewproc;
00181 Vec vertvol;
00182 int *vertprop;
00184
00188 int *elevert;
00189 int *eleprop;
00190 int *elel2g;
00191 int *elenewproc;
00192 Vec elevol;
00193 PetscReal elenmax;
00194 #define HAVE_ELEVERTALL
00195 #ifdef HAVE_ELEVERTALL
00196 int *elevertall;
00197 #define HAVE_M2IJ
00198 #ifdef HAVE_M2IJ
00199 int *mesh2nodal_ia;
00200 int *mesh2nodal_ja;
00201 int *mesh2dual_ia;
00202 int *mesh2dual_ja;
00203 #endif
00204 #endif
00205
00210 int n_vert_bnd;
00211 int n_bnd_fac;
00212 int ln_bnd_fac;
00213 int *vertbndg2bnd;
00214 int *bndfacvert;
00216
00220 int n_prop;
00221 PetscReal *propdat;
00241
00242
00243
00247 Vec M;
00248 Vec VHdem;
00249 Vec VMs3;
00250 PetscReal Edem;
00251 Vec VHexchani;
00252 PetscReal Eexchani;
00253 #ifdef EXCH
00254 Vec VHexchonly;
00255 PetscReal Eexchonly;
00256 #endif
00257 Vec VHext;
00258 PetscReal Eext;
00259 Vec VHtot;
00260 PetscReal Etot;
00262
00263 PetscReal totvol;
00264 int equil;
00265 PetscReal vequil;
00267 #ifdef ADDONS
00268 #include "addons/griddatadd.h"
00269 #endif
00270
00271 #ifdef SPINTORQ
00272 #include "spintorq/griddatadd.h"
00273 #endif
00274
00275 #ifdef EBM
00276 #include "ebm/griddata_ebm.h"
00277 #endif
00278
00279 #ifdef PYTHON
00280 #define MAGPARSTDPYTHONMOD "magpar_std_mod"
00281 PyObject *pModule;
00282 #endif
00283
00284 } GridData;
00285
00286 #endif