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 "petscts.h"
00046 #include "petscao.h"
00047
00049 #ifdef TAO
00050 #include "tao.h"
00051 #endif
00052
00053
00054
00055
00056
00057
00058
00059 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 0 && PETSC_VERSION_SUBMINOR == 0)
00060 #define PETSC_VERSION 300
00061 #elif (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 3 && PETSC_VERSION_SUBMINOR == 3)
00062 #define PETSC_VERSION 233
00063 #ifdef TAO
00064 #if (TAO_VERSION_MAJOR != 1 && TAO_VERSION_MINOR != 8 && TAO_VERSION_SUBMINOR != 3)
00065 #error PETSc version 2.3.3 requires TAO version 1.9
00066 #endif
00067 #endif
00068 #else
00069 #error "PETSc version unsupported or unknown! Please use one of the supported versions!"
00070 #endif
00071
00072 #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;}
00073 #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);}
00074 #if PETSC_VERSION >= 232
00075 #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;}
00076 #define MagparFunctionInfoReturn(A) {PetscGetTime(&t_t2);PetscInfo1(0,"took %g s\n\n",t_t2-t_t1);PetscFunctionReturn(A);}
00077 #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);}
00078 #else
00079 #define MagparFunctionInfoBegin int ierr;PetscLogDouble t_t1,t_t2;{PetscFunctionBegin;PetscGetTime(&t_t1);ierr=0;}
00080 #define MagparFunctionInfoReturn(A) {PetscGetTime(&t_t2);PetscFunctionReturn(A);}
00081 #define MagparFunctionProfReturn(A) {PetscGetTime(&t_t2);PetscFunctionReturn(A);}
00082 #endif
00083
00085 #include <assert.h>
00086
00090 #define ND 3
00091 #define NV 4
00092 #define NF 4
00093 #define NN 3
00094 #define NP 19
00096
00097
00101 #define C_BND -1
00102 #define C_INT -2
00103 #define C_UNK -4
00105
00106 #define D_EPS PETSC_MACHINE_EPSILON*100
00111 #define MU0 (12.566371e-7)
00112 #define GAMMA (2.210173e5)
00114
00115
00116 #define RIGID_M_ALPHA 999
00117
00118
00119
00120
00121
00122
00123 #define my_daxpy(a,b,c,d,e,f) {(e)[0]+=b*(c)[0];(e)[1]+=b*(c)[1];(e)[2]+=b*(c)[2];}
00124 #define my_dcopy(a,b,c,d,e) {(d)[0]=(b)[0];(d)[1]=(b)[1];(d)[2]=(b)[2];}
00125 #define my_dnrm2(a,b,c) sqrt((b)[0]*(b)[0]+(b)[1]*(b)[1]+(b)[2]*(b)[2])
00126 #define my_dscal(a,b,c,d) {(c)[0]*=b;(c)[1]*=b;(c)[2]*=b;}
00127 #define my_ddot(a,b,c,d,e) ((b)[0]*(d)[0]+(b)[1]*(d)[1]+(b)[2]*(d)[2])
00128 #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];}
00129
00133 #if PETSC_VERSION <= 220
00134 typedef int PetscInt;
00135 typedef int PetscBLASInt;
00136 #endif
00137
00138 typedef struct {
00139 char simname[256];
00140 int inp;
00142 PetscReal time;
00144 int mode;
00146 PetscReal hscale;
00147 PetscReal tscale;
00148 PetscReal escale;
00149 PetscReal lenscale;
00152
00153
00154
00155
00156
00157
00161 int n_vert;
00162 int n_ele;
00164
00168 int ln_vert;
00169 int ln_ele;
00171
00175 PetscReal *vertxyz;
00176 int *vertl2g;
00177 int *vertnewproc;
00178 Vec vertvol;
00179 int *vertprop;
00181
00185 int *elevert;
00186 int *eleprop;
00187 int *elel2g;
00188 int *elenewproc;
00189 Vec elevol;
00190 PetscReal elenmax;
00191 #define HAVE_ELEVERTALL
00192 #ifdef HAVE_ELEVERTALL
00193 int *elevertall;
00194 #define HAVE_M2IJ
00195 #ifdef HAVE_M2IJ
00196 int *mesh2nodal_ia;
00197 int *mesh2nodal_ja;
00198 int *mesh2dual_ia;
00199 int *mesh2dual_ja;
00200 #endif
00201 #endif
00202
00207 int n_vert_bnd;
00208 int n_bnd_fac;
00209 int ln_bnd_fac;
00210 int *vertbndg2bnd;
00211 int *bndfacvert;
00213
00217 int n_prop;
00218 PetscReal *propdat;
00238
00239
00240
00244 Vec M;
00245 Vec VHdem;
00246 Vec VMs3;
00247 PetscReal Edem;
00248 Vec VHexchani;
00249 PetscReal Eexchani;
00250 #ifdef EXCH
00251 Vec VHexchonly;
00252 PetscReal Eexchonly;
00253 #endif
00254 Vec VHext;
00255 PetscReal Eext;
00256 Vec VHtot;
00257 PetscReal Etot;
00259
00260 PetscReal totvol;
00261 int equil;
00262 PetscReal vequil;
00264 #ifdef ADDONS
00265 #include "addons/griddatadd.h"
00266 #endif
00267
00268 #ifdef SPINTORQ
00269 #include "spintorq/griddatadd.h"
00270 #endif
00271
00272 #ifdef EBM
00273 #include "ebm/griddata_ebm.h"
00274 #endif
00275
00276 #ifdef PYTHON
00277 #define MAGPARSTDPYTHONMOD "magpar_std_mod"
00278 PyObject *pModule;
00279 #endif
00280
00281 } GridData;
00282
00283 #endif