When testing jacobian diffs via -snes_type test, block size is not explicitly set
during setup of the difference matrix B. This can cause problems when the
block size is explicitly set in the origin jacobian and is not derivable from local matrix sizes, for instance on a single core. The patch sets block size explicitly.
The patch is trivial, and unfortunately includes the explicit naming of the
python version in the configure script. This ensures portability to linux distros
where the default python version is >=3.0 (e.g., arch linux).

Best Regards,
Robert Femmer
>From 4d027f6951238fc5710c037aeb31352eba7a38c5 Mon Sep 17 00:00:00 2001
From: Robert Femmer <[email protected]>
Date: Mon, 5 Jan 2015 13:24:38 +0100
Subject: [PATCH] set block size for jacobian difference matrix

---
 configure                      | 2 +-
 src/snes/impls/test/snestest.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 86e61b3..e36f120 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 import sys
 if not type(sys.version_info) is tuple and sys.version_info.major > 2:
diff --git a/src/snes/impls/test/snestest.c b/src/snes/impls/test/snestest.c
index 468f5c7..a1eb995 100644
--- a/src/snes/impls/test/snestest.c
+++ b/src/snes/impls/test/snestest.c
@@ -33,7 +33,7 @@ PetscErrorCode SNESSolve_Test(SNES snes)
   for (i=0; i<3; i++) {
     void                     *functx;
     static const char *const loc[] = {"user-defined state","constant state -1.0","constant state 1.0"};
-    PetscInt                 m,n,M,N;
+    PetscInt                 m,n,M,N,bs;
 
     if (i == 1) {
       ierr = VecSet(x,-1.0);CHKERRQ(ierr);
@@ -54,8 +54,10 @@ PetscErrorCode SNESSolve_Test(SNES snes)
 
     ierr = MatCreate(PetscObjectComm((PetscObject)A),&B);CHKERRQ(ierr);
     ierr = MatGetSize(A,&M,&N);CHKERRQ(ierr);
+    ierr = MatGetBlockSize(A,&bs);CHKERRQ(ierr);
     ierr = MatGetLocalSize(A,&m,&n);CHKERRQ(ierr);
     ierr = MatSetSizes(B,m,n,M,N);CHKERRQ(ierr);
+    ierr = MatSetBlockSize(B,bs);CHKERRQ(ierr);
     ierr = MatSetType(B,((PetscObject)A)->type_name);CHKERRQ(ierr);
     ierr = MatSetUp(B);CHKERRQ(ierr);
     ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);
-- 
2.2.1

Reply via email to