It uses the most recent ISCreateGeneral() API and should degrade
gracefully for earlier versions.
Convert a use of ISCreateGeneralNC() to use the common API.
---
include/numerics/petsc_macro.h | 27 +++++++++++++++++++--------
src/solvers/petsc_linear_solver.C | 2 +-
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/include/numerics/petsc_macro.h b/include/numerics/petsc_macro.h
index 78b0a87..df1bc16 100644
--- a/include/numerics/petsc_macro.h
+++ b/include/numerics/petsc_macro.h
@@ -85,14 +85,25 @@ EXTERN_C_FOR_PETSC_END
#if PETSC_VERSION_RELEASE && PETSC_VERSION_LESS_THAN(3,1,1)
typedef PetscTruth PetscBool;
-// libMesh currently holds zero long-lived IS, it always creates an IS with a
std::vector<int>,
-// uses it through the Vec or Mat API, and destroys the IS. This can always
be done without a
-// copy, so we assume mode = PETSC_USE_POINTER (the IS just uses the array,
without ownership).
-# if PETSC_VERSION_LESS_THAN(2,2,1) // Cannot avoid a copy
-# define ISCreateLibMesh(comm,n,idx,mode,is)
ISCreateGeneral((comm),(n),(idx),(is))
-# else
-# define ISCreateLibMesh(comm,n,idx,mode,is)
ISCreateGeneralWithArray((comm),(n),(idx),(is))
-# endif
+#endif
+
+#if PETSC_VERSION_LESS_THAN(2,2,1)
+// This version of PETSc always makes a copy. Current occurrences of
PETSC_USE_POINTER are safe with the definition below.
+typedef enum { PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER}
PetscCopyMode;
+# define ISCreateLibMesh(comm,n,idx,mode,is) \
+ ((mode) == PETSC_OWN_POINTER \
+ ? (ISCreateGeneral((comm),(n),(idx),(is)) || PetscFree(idx) || (*(idx) =
PETSC_NULL)) \
+ : (ISCreateGeneral((comm),(n),(idx),(is))))
+#elif PETSC_VERSION_RELEASE && PETSC_VERSION_LESS_THAN(3,1,1)
+typedef enum { PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER}
PetscCopyMode;
+# define ISCreateLibMesh(comm,n,idx,mode,is) \
+ ((mode) == PETSC_USE_POINTER \
+ ? ISCreateGeneralWithArray((comm),(n),(idx),(is)) \
+ : ((mode) == PETSC_OWN_POINTER \
+ ? ISCreateGeneralNC((comm),(n),(idx),(is)) \
+ : ISCreateGeneral((comm),(n),(idx),(is))))
+#else
+# define ISCreateLibMesh(comm,n,idx,mode,is)
ISCreateGeneral((comm),(n),(idx),(mode),(is))
#endif
#endif // LIBMESH_HAVE_PETSC
diff --git a/src/solvers/petsc_linear_solver.C
b/src/solvers/petsc_linear_solver.C
index a3b46b7..aa38da4 100644
--- a/src/solvers/petsc_linear_solver.C
+++ b/src/solvers/petsc_linear_solver.C
@@ -402,7 +402,7 @@ PetscLinearSolver<T>::restrict_solve_to (const
std::vector<unsigned int>* const
petsc_dofs[i] = (*dofs)[i];
}
- ierr =
ISCreateGeneralNC(libMesh::COMM_WORLD,dofs->size(),petsc_dofs,&_restrict_solve_to_is);
+ ierr =
ISCreateLibMesh(libMesh::COMM_WORLD,dofs->size(),petsc_dofs,PETSC_OWN_POINTER,&_restrict_solve_to_is);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
}
}
--
1.7.4.1
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users