18 #include "libmesh/petsc_auto_fieldsplit.h" 20 #ifdef LIBMESH_HAVE_PETSC 25 #include "libmesh/dof_map.h" 26 #include "libmesh/system.h" 32 const std::vector<dof_id_type> & indices,
34 const std::string & field_name)
36 const PetscInt *
idx = LIBMESH_PETSC_NULLPTR;
38 idx = reinterpret_cast<const PetscInt *>(indices.data());
41 LibmeshPetscCall2(comm, ISCreateGeneral(comm.
get(), cast_int<PetscInt>(indices.size()),
42 idx, PETSC_COPY_VALUES, &
is));
44 LibmeshPetscCall2(comm, PCFieldSplitSetIS(my_pc, field_name.c_str(),
is));
55 std::string sys_prefix =
"--solver_group_";
59 sys_prefix = sys_prefix + sys.
name() +
"_";
62 std::map<std::string, std::vector<dof_id_type>> group_indices;
70 std::vector<dof_id_type> var_idx;
74 std::string group_command = sys_prefix + var_name;
76 const std::string empty_string;
79 (group_command, empty_string);
81 if (group_name != empty_string)
83 std::vector<dof_id_type> & indices =
84 group_indices[group_name];
85 const bool prior_indices = !indices.empty();
86 indices.insert(indices.end(), var_idx.begin(),
89 std::sort(indices.begin(), indices.end());
93 indices_to_fieldsplit (sys.
comm(), var_idx, my_pc, var_name);
98 for (
const auto & [field_name, indices] : group_indices)
99 indices_to_fieldsplit(sys.
comm(), indices, my_pc, field_name);
105 #endif // #ifdef LIBMESH_HAVE_PETSC void petsc_auto_fieldsplit(PC my_pc, const System &sys)
void local_variable_indices(T &idx, const MeshBase &mesh, unsigned int var_num) const
If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices w...
const Parallel::Communicator & comm() const
The libMesh namespace provides an interface to certain functionality in the library.
const MeshBase & get_mesh() const
T command_line_value(const std::string &, T)
Manages consistently variables, degrees of freedom, and coefficient vectors.
PetscErrorCode PetscInt const PetscInt IS * is
const std::string & variable_name(const unsigned int i) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
bool on_command_line(std::string arg)
const std::string & name() const
unsigned int n_vars() const
const DofMap & get_dof_map() const