Commits

Emil Constantinescu committed 08e09e1

fixed bugs in ex35

  • Participants
  • Parent commits 24c6cc9

Comments (0)

Files changed (2)

File src/ts/examples/tutorials/ex35SE.c

 static char help[] = "Transistor amplifier (semi-explicit).\n";
 
 /*F
-  [I 0] [y] = f(t,y,z)
-  [0 0] [z] = g(t,y,z)
+  [I 0] [y'] = f(t,y,z)
+  [0 0] [z'] = g(t,y,z)
   Useful options: -ts_monitor_lg_solution -ts_monitor_lg_timestep -lg_indicate_data_points 0
 F*/
 
 /*
      Defines the Jacobian of the ODE passed to the ODE solver. See TSSetIJacobian() for the meaning of a and the Jacobian.
 */
-static PetscErrorCode IJacobianSemiExplicit(TS ts,PetscReal t,Vec Y,Vec Ydot,PetscReal a,Mat *A,Mat *B,MatStructure *flag,void *ctx)
+static PetscErrorCode IJacobianSemiExplicit(TS ts,PetscReal t,Vec Y,Vec Ydot,PetscReal a,Mat A,Mat B,void *ctx)
 {
   PetscErrorCode ierr;
   PetscInt       rowcol[] = {0,1,2,3,4};
   J[4][3]=-99/(2.6e6* PetscExpReal((500*(y[0] + y[1] - y[3]))/13.));
   J[4][4]=-0.00022222222222222223;
 
-  ierr    = MatSetValues(*B,5,rowcol,5,rowcol,&J[0][0],INSERT_VALUES);CHKERRQ(ierr);
+  ierr    = MatSetValues(B,5,rowcol,5,rowcol,&J[0][0],INSERT_VALUES);CHKERRQ(ierr);
   
   ierr    = VecRestoreArrayRead(Y,&y);CHKERRQ(ierr);
   ierr    = VecRestoreArrayRead(Ydot,&ydot);CHKERRQ(ierr);
 
-  ierr = MatAssemblyBegin(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  ierr = MatAssemblyEnd(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  if (*A != *B) {
-    ierr = MatAssemblyBegin(*B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  if (A != B) {
+    ierr = MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *flag = SAME_NONZERO_PATTERN;
   PetscFunctionReturn(0);
 }
 
   ierr = TSSetEquationType(ts,TS_EQ_DAE_IMPLICIT_INDEX1);CHKERRQ(ierr);
   ierr = TSARKIMEXSetFullyImplicit(ts,PETSC_TRUE);CHKERRQ(ierr);
   /*ierr = TSSetType(ts,TSROSW);CHKERRQ(ierr);*/
-  ierr = TSSetIFunction(ts,PETSC_NULL,(TSIFunction) IFunctionSemiExplicit,PETSC_NULL);CHKERRQ(ierr);
-  ierr = TSSetIJacobian(ts,A,A,(TSIJacobian)IJacobianSemiExplicit,PETSC_NULL);CHKERRQ(ierr);
+  ierr = TSSetIFunction(ts,PETSC_NULL,IFunctionSemiExplicit,PETSC_NULL);CHKERRQ(ierr);
+  ierr = TSSetIJacobian(ts,A,A,IJacobianSemiExplicit,PETSC_NULL);CHKERRQ(ierr);
 
   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Set initial conditions

File src/ts/examples/tutorials/order_test.py

     tsmaxsteps=tsmaxsteps.astype(np.int)
     tsdt=np.float(tfinal)/tsmaxsteps
     msims=tsdt.size
-    tsmaxsteps_ref=np.int(100*tsmaxsteps[msims-1])
+    tsmaxsteps_ref=np.int(10*tsmaxsteps[msims-1])
     tsdt_ref=np.float(tfinal)/tsmaxsteps_ref
     timesteps=np.zeros((msims,1))
     solution=np.zeros((msims,n))
 
 if bWriteReference==False:
     print 'Running ' + strTestProblem + ' to generate the reference solution with dt = ' + str(tsdt_ref) + '.'
-    os_out=os.system(strTestProblem +  ' -ts_dt '+ str(tsdt_ref) + ' -ts_max_steps ' + str(tsmaxsteps_ref) + ' '  + PETScOptionsStr + ' -ts_view_solution binary:'+ strTestProblemOutFile + ' ')
+    os_out=os.system(strTestProblem +  ' -ts_dt '+ str(tsdt_ref) + ' -ts_max_steps ' + str(tsmaxsteps_ref) + ' '  + PETScOptionsStr + ' ' +strPETScXtraArguments + ' -ts_view_solution binary:'+ strTestProblemOutFile + ' ')
     if(os_out <> 0):
         raise NameError('Error running '+ strTestProblem +'. Aborting.')
     PETSc_objects = io.readBinaryFile(strTestProblemOutFile)