mytssteppvode.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 static char const Id[] = "$Id: mytssteppvode.c 2962 2010-02-04 19:50:44Z scholz $\n\n";
00025 static char const Td[] = "$Today: " __FILE__ " " __DATE__ " " __TIME__ " $\n\n";
00026
00027 #include "llg.h"
00028
00029 int myTSStepPVode(GridData *gdata)
00030 {
00031 extern void *cvode_mem;
00032 extern N_Vector nvu;
00033
00034 static int nsteps=-1;
00035
00036 MagparFunctionInfoBegin;
00037
00038
00039
00040
00041
00042 if (nsteps<0) {
00043 PetscTruth flg;
00044 ierr = PetscOptionsGetInt(PETSC_NULL,"-ts_nsteps",(PetscInt*)&nsteps,&flg);CHKERRQ(ierr);
00045 if (flg!=PETSC_TRUE) {
00046 nsteps=1;
00047 PetscPrintf(PETSC_COMM_WORLD,
00048 "Option -ts_nsteps not found, using default value: %i\n",
00049 nsteps
00050 );
00051 }
00052 if (nsteps<1) {
00053 SETERRQ1(PETSC_ERR_ARG_OUTOFRANGE,"Option set: -ts_nsteps %i, but has to be >0\n",nsteps);
00054 }
00055 }
00056
00057 ierr = CV_SUCCESS;
00058 for (int i=0;i<nsteps;i++) {
00059 ierr = CVode(cvode_mem,PETSC_MAX,nvu,&gdata->time,CV_ONE_STEP);
00060
00061 if (ierr != CV_SUCCESS) {
00062 SETERRQ1(PETSC_ERR_LIB,"CVode failed, ierr=%i.\n",ierr);
00063 }
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #define DEBUG
00078
00079 #ifdef DEBUG
00080
00081
00082
00083 PetscReal *tmp;
00084 ierr = VecGetArray(gdata->M,&tmp);CHKERRQ(ierr);
00085
00086 #ifdef UNIPROC
00087 assert(tmp==NV_DATA_S(nvu));
00088 #else
00089 assert(tmp==NV_DATA_P(nvu));
00090 #endif
00091
00092 ierr = VecRestoreArray(gdata->M,&tmp);CHKERRQ(ierr);
00093
00094 #endif
00095
00096 MagparFunctionProfReturn(0);
00097 }