18 #include "libmesh/petsc_auto_fieldsplit.h" 
   20 #ifdef LIBMESH_HAVE_PETSC 
   25 #include "libmesh/dof_map.h" 
   26 #include "libmesh/system.h" 
   28 #if !PETSC_VERSION_LESS_THAN(3,2,0) 
   35 void indices_to_fieldsplit (
const Parallel::Communicator & comm,
 
   36                             const std::vector<dof_id_type> & indices,
 
   38                             const std::string & field_name)
 
   40   const PetscInt * 
idx = PETSC_NULL;
 
   42     idx = reinterpret_cast<const PetscInt *>(indices.data());
 
   45   int ierr = ISCreateLibMesh(comm.get(), cast_int<PetscInt>(indices.size()),
 
   47   CHKERRABORT(comm.get(), 
ierr);
 
   49   ierr = PCFieldSplitSetIS(my_pc, field_name.c_str(), 
is);
 
   50   CHKERRABORT(comm.get(), 
ierr);
 
   61   std::string sys_prefix = 
"--solver_group_";
 
   65       sys_prefix = sys_prefix + sys.
name() + 
"_";
 
   68   std::map<std::string, std::vector<dof_id_type>> group_indices;
 
   76           std::vector<dof_id_type> var_idx;
 
   80           std::string group_command = sys_prefix + var_name;
 
   82           const std::string empty_string;
 
   85             (group_command, empty_string);
 
   87           if (group_name != empty_string)
 
   89               std::vector<dof_id_type> & indices =
 
   90                 group_indices[group_name];
 
   91               const bool prior_indices = !indices.empty();
 
   92               indices.insert(indices.end(), var_idx.begin(),
 
   95                 std::sort(indices.begin(), indices.end());
 
   99               indices_to_fieldsplit (sys.
comm(), var_idx, my_pc, var_name);
 
  104   for (
const auto & pr : group_indices)
 
  105     indices_to_fieldsplit(sys.
comm(), pr.second, my_pc, pr.first);
 
  111 #else  // #PETSC_VERSION < 3.2.0 
  121                       libMesh::out << 
"WARNING: libMesh does not support setting field splits" <<
 
  122                       std::endl << 
"with PETSc " 
  123                       << LIBMESH_DETECTED_PETSC_VERSION_MAJOR << 
'.' 
  124                       << LIBMESH_DETECTED_PETSC_VERSION_MINOR << 
'.' 
  125                       << LIBMESH_DETECTED_PETSC_VERSION_SUBMINOR << std::endl;);
 
  130 #endif // #PETSC_VERSION > 3.2.0 
  131 #endif // #ifdef LIBMESH_HAVE_PETSC