18#ifndef LIBMESH_PETSC_DM_WRAPPER_H
19#define LIBMESH_PETSC_DM_WRAPPER_H
21#include "libmesh/petsc_macro.h"
23#ifdef LIBMESH_HAVE_PETSC
24#if !PETSC_VERSION_LESS_THAN(3,7,3)
25#if defined(LIBMESH_ENABLE_AMR) && defined(LIBMESH_HAVE_METAPHYSICL)
28#include "libmesh/petsc_macro.h"
29#include "libmesh/petsc_matrix_base.h"
30#include "libmesh/petsc_vector.h"
31#include "libmesh/wrapped_petsc.h"
45#include <unordered_map>
68 std::vector<std::vector<numeric_index_type>>
dof_vec;
122 std::vector<WrappedPetsc<DM>>
_dms;
148 std::vector<std::unique_ptr<PetscMatrixBase<Number>>>
_pmtx_vec;
169 std::vector<std::unique_ptr<PetscVector<Number>>>
_vec_vec;
185 { libmesh_assert_less(level,
_dms.size());
186 return *
_dms[level]; }
193 { libmesh_assert_less(level,
_sections.size());
238 PetscSection & section,
239 std::unordered_map<dof_id_type,dof_id_type> & node_map,
240 std::unordered_map<dof_id_type,dof_id_type> & elem_map,
241 std::map<dof_id_type,unsigned int> & scalar_map);
248 PetscSection & section,
249 const std::unordered_map<dof_id_type,dof_id_type> & node_map,
250 const std::unordered_map<dof_id_type,dof_id_type> & elem_map,
251 const std::map<dof_id_type,unsigned int> & scalar_map);
264 PetscSection & section);
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
This class defines a wrapper around the PETSc DM infrastructure.
PetscSection & get_section(unsigned int level)
Get reference to PetscSection for the given mesh level.
void init_and_attach_petscdm(System &system, SNES snes)
void init_dm_data(unsigned int n_levels, const Parallel::Communicator &comm)
Init all the n_mesh_level dependent data structures.
unsigned int init_petscdm(System &system)
Initialize the PETSc DM and return the number of geometric multigrid levels.
void add_dofs_to_section(const System &system, PetscSection §ion, const std::unordered_map< dof_id_type, dof_id_type > &node_map, const std::unordered_map< dof_id_type, dof_id_type > &elem_map, const std::map< dof_id_type, unsigned int > &scalar_map)
Helper function for build_section.
std::vector< std::unique_ptr< PetscVector< Number > > > _vec_vec
Vector of solution vectors for all grid levels.
PetscSF & get_star_forest(unsigned int level)
Get reference to PetscSF for the given mesh level.
std::vector< std::unique_ptr< PetscMatrixBase< Number > > > _pmtx_vec
Vector of projection matrixes for all grid levels.
void set_point_range_in_section(const System &system, PetscSection §ion, std::unordered_map< dof_id_type, dof_id_type > &node_map, std::unordered_map< dof_id_type, dof_id_type > &elem_map, std::map< dof_id_type, unsigned int > &scalar_map)
Helper function for build_section.
void add_dofs_helper(const System &system, const DofObject &dof_object, dof_id_type local_id, PetscSection §ion)
std::vector< WrappedPetsc< PetscSection > > _sections
Vector of PETScSections for all grid levels.
std::vector< PetscSF > _star_forests
Vector of star forests for all grid levels.
void clear()
Destroys and clears all build DM-related data.
dof_id_type check_section_n_dofs(PetscSection §ion)
Helper function to sanity check PetscSection construction The PetscSection contains local dof informa...
std::vector< PetscDMContext > _ctx_vec
Vector of internal PetscDM context structs for all grid levels Pointers to these C++ objects are pass...
std::vector< WrappedPetsc< DM > > _dms
Vector of DMs for all grid levels.
void build_sf(const System &system, PetscSF &star_forest)
Takes System, empty PetscSF and populates the PetscSF.
DM & get_dm(unsigned int level)
Get reference to DM for the given mesh level.
std::vector< unsigned int > _mesh_dof_loc_sizes
Stores n_local_dofs for each grid level, to be used for projection vector sizing.
std::vector< unsigned int > _mesh_dof_sizes
Stores n_dofs for each grid level, to be used for projection matrix sizing.
std::vector< std::unique_ptr< PetscMatrixBase< Number > > > _subpmtx_vec
Vector of sub projection matrixes for all grid levels for fieldsplit.
void build_section(const System &system, PetscSection §ion)
Takes System, empty PetscSection and populates the PetscSection.
This class provides a nice interface to the PETSc C-based data structures for parallel,...
This class provides a nice interface to PETSc's Vec object.
Manages consistently variables, degrees of freedom, and coefficient vectors.
The libMesh namespace provides an interface to certain functionality in the library.
Struct to house data regarding where in the mesh hierarchy we are located.
std::vector< PetscInt > subfields
Stores subfield ids for use in subprojection matrixes on coarser DMs.
PetscVector< libMesh::Number > * current_vec
std::vector< std::vector< numeric_index_type > > dof_vec
Stores local dofs for each var for use in subprojection matrixes.
PetscMatrixBase< libMesh::Number > * K_sub_interp_ptr
PetscMatrixBase< libMesh::Number > * K_interp_ptr
PetscMatrixBase< libMesh::Number > * K_restrict_ptr