Commits

Mark Adams committed 0584d13

fixed bug with ksp/ex56 using non-real scalars and near null space interface. Changed ex56 to use near null space in test 'make runex56'.

Comments (0)

Files changed (3)

src/ksp/ksp/examples/tutorials/ex56.c

   if (use_nearnullspace) {
     MatNullSpace matnull;
     Vec vec_coords;
-    ierr = VecCreateSeqWithArray(MPI_COMM_SELF,3,m,coords,&vec_coords);CHKERRQ(ierr);
+    PetscScalar *sCoord;
+    ierr = PetscMalloc1(m, &sCoord);CHKERRQ(ierr);
+    for (i=0; i<m; i++) sCoord[i] = coords[i];
+    ierr = VecCreateSeqWithArray(MPI_COMM_SELF,3,m,sCoord,&vec_coords);CHKERRQ(ierr);
     ierr = MatNullSpaceCreateRigidBody(vec_coords,&matnull);CHKERRQ(ierr);
     ierr = MatSetNearNullSpace(Amat,matnull);CHKERRQ(ierr);
     ierr = MatNullSpaceDestroy(&matnull);CHKERRQ(ierr);
     ierr = VecDestroy(&vec_coords);CHKERRQ(ierr);
+    ierr = PetscFree(sCoord);CHKERRQ(ierr);
   } else {
     ierr = PCSetCoordinates(pc, 3, m/3, coords);CHKERRQ(ierr);
   }

src/ksp/ksp/examples/tutorials/makefile

         ${RM} -f ex55.tmp
 
 runex56:
-	-@${MPIEXEC} -n 8 ./ex56 -ne 9 -alpha 1.e-3 -pc_type gamg -pc_gamg_type agg -pc_gamg_agg_nsmooths 1 -pc_gamg_coarse_eq_limit 10 -pc_gamg_reuse_interpolation true -two_solves -ksp_monitor_short > ex56.tmp 2>&1;	\
+	-@${MPIEXEC} -n 8 ./ex56 -ne 9 -alpha 1.e-3 -pc_type gamg -pc_gamg_type agg -pc_gamg_agg_nsmooths 1 -pc_gamg_coarse_eq_limit 10 -pc_gamg_reuse_interpolation true -two_solves -ksp_monitor_short -use_mat_nearnullspace true > ex56.tmp 2>&1;	\
          ${DIFF} output/ex56_0.out ex56.tmp || echo ${PWD} "\nPossible problem with with ex56, diffs above \n========================================="; \
          ${RM} -f ex56.tmp
 

src/ksp/ksp/examples/tutorials/output/ex56_0.out

-  0 KSP Residual norm 726.749 
-  1 KSP Residual norm 109.161 
-  2 KSP Residual norm 79.2738 
-  3 KSP Residual norm 49.0647 
-  4 KSP Residual norm 3.91183 
-  5 KSP Residual norm 1.07203 
-  6 KSP Residual norm 0.429376 
-  7 KSP Residual norm 0.187056 
-  8 KSP Residual norm 0.0110892 
-  9 KSP Residual norm 0.00283316 
-  0 KSP Residual norm 0.00726749 
-  1 KSP Residual norm 0.00109161 
-  2 KSP Residual norm 0.000792738 
-  3 KSP Residual norm 0.000490647 
-  4 KSP Residual norm 3.91183e-05 
-  5 KSP Residual norm 1.07203e-05 
-  6 KSP Residual norm 4.29376e-06 
-  7 KSP Residual norm 1.87056e-06 
-  8 KSP Residual norm 1.10892e-07 
-  9 KSP Residual norm 2.83316e-08 
-  0 KSP Residual norm 7.26749e-08 
-  1 KSP Residual norm 1.09161e-08 
-  2 KSP Residual norm 7.92738e-09 
-  3 KSP Residual norm 4.90647e-09 
-  4 KSP Residual norm 3.912e-10 
-  5 KSP Residual norm 1.072e-10 
-  6 KSP Residual norm 4.294e-11 
-  7 KSP Residual norm 1.871e-11 
-  8 KSP Residual norm < 1.e-11
+  0 KSP Residual norm 653.44 
+  1 KSP Residual norm 152.512 
+  2 KSP Residual norm 69.0295 
+  3 KSP Residual norm 63.6612 
+  4 KSP Residual norm 15.2936 
+  5 KSP Residual norm 4.51705 
+  6 KSP Residual norm 1.43808 
+  7 KSP Residual norm 0.365354 
+  8 KSP Residual norm 0.212651 
+  9 KSP Residual norm 0.0179858 
+ 10 KSP Residual norm 0.00405183 
+  0 KSP Residual norm 0.0065344 
+  1 KSP Residual norm 0.00152512 
+  2 KSP Residual norm 0.000690295 
+  3 KSP Residual norm 0.000636612 
+  4 KSP Residual norm 0.000152936 
+  5 KSP Residual norm 4.51705e-05 
+  6 KSP Residual norm 1.43808e-05 
+  7 KSP Residual norm 3.65354e-06 
+  8 KSP Residual norm 2.12651e-06 
+  9 KSP Residual norm 1.79858e-07 
+ 10 KSP Residual norm 4.05183e-08 
+  0 KSP Residual norm 6.5344e-08 
+  1 KSP Residual norm 1.52512e-08 
+  2 KSP Residual norm 6.90295e-09 
+  3 KSP Residual norm 6.36612e-09 
+  4 KSP Residual norm 1.52936e-09 
+  5 KSP Residual norm 4.517e-10 
+  6 KSP Residual norm 1.438e-10 
+  7 KSP Residual norm 3.654e-11 
+  8 KSP Residual norm 2.127e-11 
   9 KSP Residual norm < 1.e-11
-[0]main |b-Ax|/|b|=6.051136e-05, |b|=5.391826e+00, emax=9.969434e-01
+ 10 KSP Residual norm < 1.e-11
+[0]main |b-Ax|/|b|=1.145444e-04, |b|=5.391826e+00, emax=9.972165e-01