Skip to content

createSubDM() returns inconsistent IS in petsc4py #280

@gthyagi

Description

@gthyagi

Hi @knepley,

I've noticed that createSubDM() in petsc4py seems to return an incorrect IS. Could it be that I'm misunderstanding how createSubDM() is intended to work? Would you mind taking a look and helping us out? Thank you!

Here is the script:

import underworld3 as uw
import sympy as sp

mesh = uw.meshing.UnstructuredSimplexBox(cellSize=1.)
x, y = mesh.X

u = uw.discretisation.MeshVariable(r"mathbf{u}", mesh, mesh.dim, vtype=uw.VarType.VECTOR, degree=2)
p = uw.discretisation.MeshVariable(r"mathbf{p}", mesh, 1, vtype=uw.VarType.SCALAR, degree=1, continuous=False)
t = uw.discretisation.MeshVariable(r"mathbf{t}", mesh, 1, vtype=uw.VarType.SCALAR, degree=1, continuous=False)

stokes = uw.systems.Stokes(mesh, velocityField=u, pressureField=p)
stokes.constitutive_model = uw.constitutive_models.ViscousFlowModel
stokes.constitutive_model.Parameters.shear_viscosity_0 = 1

stokes.petsc_options["snes_monitor"] = None
stokes.petsc_options["ksp_monitor"] = None

stokes.bodyforce = 1.0e6 * sp.Matrix([0, x])

stokes.add_dirichlet_bc((0.0, 0.0), "Bottom")
stokes.add_dirichlet_bc((0.0, 0.0), "Top")

stokes.add_dirichlet_bc((0.0, sp.oo), "Left")
stokes.add_dirichlet_bc((0.0, sp.oo), "Right")

stokes.solve()

Here is the output from the section view:

stokes.dm.getLocalSection().view()
PetscSection Object: 1 MPI process
  type not yet set
2 fields
  field 0 "velocity" with 2 components
Process 0:
  (   0) dof  0 offset   0
  (   1) dof  0 offset   3
  (   2) dof  0 offset   6
  (   3) dof  0 offset   9
  (   4) dof  2 offset  12 constrained 0 1
  (   5) dof  2 offset  14 constrained 0 1
  (   6) dof  2 offset  16 constrained 0 1
  (   7) dof  2 offset  18 constrained 0 1
  (   8) dof  2 offset  20
  (   9) dof  2 offset  22 constrained 0 1
  (  10) dof  2 offset  24
  (  11) dof  2 offset  26
  (  12) dof  2 offset  28 constrained 0
  (  13) dof  2 offset  30
  (  14) dof  2 offset  32 constrained 0
  (  15) dof  2 offset  34
  (  16) dof  2 offset  36 constrained 0 1
  field 1 "pressure" with 1 components
Process 0:
  (   0) dof  3 offset   0
  (   1) dof  3 offset   3
  (   2) dof  3 offset   6
  (   3) dof  3 offset   9
  (   4) dof  0 offset  14
  (   5) dof  0 offset  16
  (   6) dof  0 offset  18
  (   7) dof  0 offset  20
  (   8) dof  0 offset  22
  (   9) dof  0 offset  24
  (  10) dof  0 offset  26
  (  11) dof  0 offset  28
  (  12) dof  0 offset  30
  (  13) dof  0 offset  32
  (  14) dof  0 offset  34
  (  15) dof  0 offset  36
  (  16) dof  0 offset  38
  PetscSectionSym Object: 1 MPI process
    type: label
    Label 'depth'
    Symmetry for stratum value 0 (0 dofs per point): no symmetries
    Symmetry for stratum value 1 (0 dofs per point): no symmetries
    Symmetry for stratum value 2 (3 dofs per point):
      Orientation range: [-3, 3)
    Symmetry for stratum value -1 (0 dofs per point): no symmetries

I got following IS for the pressure field, which is correct and I can crosscheck from the petsc section info:

stokes.dm.createSubDM(1)[0].array
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11], dtype=int32)

For the velocity field, I got this:

stokes.dm.createSubDM(0)[0].array
array([12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], dtype=int32)

Isn't the above line supposed to return following IS?

array([12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37], dtype=int32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions