15 #ifndef ALLIUM_MESH_PETSC_MESH_SPEC_HPP
16 #define ALLIUM_MESH_PETSC_MESH_SPEC_HPP
18 #include <allium/config.hpp>
19 #ifdef ALLIUM_USE_PETSC
21 #include <allium/util/extern.hpp>
22 #include <allium/util/types.hpp>
23 #include <allium/ipc/comm.hpp>
24 #include <allium/la/petsc_object_ptr.hpp>
25 #include <allium/la/petsc_util.hpp>
26 #include <allium/la/vector_spec.hpp>
31 #include <petscdmda.h>
45 std::array<DMBoundaryType, 2> boundary_type,
46 DMDAStencilType stencil_type,
47 std::array<global_size_t, 2> global_size,
48 std::array<PetscInt, 2> ranks_per_dim,
54 using namespace petsc;
59 boundary_type[0], boundary_type[1],
61 global_size[0], global_size[1],
62 ranks_per_dim[0], ranks_per_dim[1],
70 ierr = DMSetUp(m_dm); chkerr(ierr);
73 ierr = DMDAGetLocalInfo(m_dm, &info); chkerr(ierr);
76 info.xm * info.ym * ndof,
77 info.mx * info.my * ndof);
84 VectorSpec vector_spec()
const {
return m_spec; }
85 Comm comm() {
return m_spec.comm(); }
87 int ndof() {
return m_ndof; }
90 using namespace petsc;
94 ierr = DMDAGetLocalInfo(m_dm, &info); chkerr(ierr);
103 using namespace petsc;
108 ierr = DMDAGetCorners(m_dm,
109 &begin[0], &begin[1],
nullptr,
110 &extent[0], &extent[1],
nullptr);
114 return Range<2>(begin, begin+extent);
117 Range<2> local_ghost_range()
const {
118 using namespace petsc;
123 ierr = DMDAGetGhostCorners(m_dm,
124 &begin[0], &begin[1],
nullptr,
125 &extent[0], &extent[1],
nullptr);
129 return Range<2>(begin, begin+extent);
137 #define ALLIUM_PETSC_MESH_SPEC_DECL(extern, D) \
138 extern template class PetscMeshSpec<D>;
139 ALLIUM_EXTERN_D(ALLIUM_PETSC_MESH_SPEC_DECL)
Wraps an MPI communicator to make MPI easier to use.
Definition: comm.hpp:26
Specification for a PETSc mesh, which is needed to create one.
Definition: petsc_mesh_spec.hpp:39
A point in D dimensions.
Definition: point.hpp:31
An n-d range.
Definition: range.hpp:28
The specification of a vector, needed to create distributed vectors.
Definition: vector_spec.hpp:26