-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use discontinuous pressure field #277
Comments
I identified the root cause of the issue. Can someone clarify this?
@knepley Why does the pressure field have a degree of freedom (dof) of 3 when the field is discontinuous? Following info gets printed when I do this: stokes.dm.getLocalSection().view()
|
That is discontinuous P1. I suspect the degree is provided as 1, and not 0. |
@bknight1 change this line https://github.com/gthyagi/underworld3/blob/53dbf6d07cc7c56b4ce42d957059e34fe6b9da2a/src/underworld3/cython/petsc_generic_snes_solvers.pyx#L2724 if not unconstrained and self.Unknowns.p.continuous: This will fix the array shape broadcasting issue |
Yeah this is the case. I specify Deg=1 but Deg=0 is returned.
I will try this now, thanks for figuring it out. Not sure what changes caused this issue as it was fine a couple of months ago. |
The issue arose from the way I gathered the index set for the pressure field to separate it from the velocity field. I had assumed that the pressure field would always have a degree of freedom (DOF) of 1. However, when the field is discontinuous, all three points on a face are treated as DOFs for the pressure field when the degree is 1. Now PETSC's section view makes much more sense to me. I better understand what PETSc's section structure is conveying.
|
@julesghub What info do you want about the fields or layout? |
Hello @knepley , This code is for extracting the velocity and pressure values from the SNES vector after solving Stokes, copying the values into separate Underworld meshvariables with boundary values included. The relevant code starts at this line: The algorithm follows these steps:
Steps 3 and 4 were implemented by @gthyagi. Decomposing the lvec requires knowledge of the layout of the fields and dof constraints, which is were the original bug was. |
|
@julesghub options = PETSc.Options()
p_continuous = options.getBool("private_{}_p_petscdualspace_lagrange_continuity".format(self.petsc_options_prefix))
if not unconstrained and p_continuous: |
Sounds great. @gthyagi let's go for this. |
p_continuous is already a variable, but is set from the Unknowns Noting the updates for this also fixed the visualisation issue experienced in #236 |
@knepley I am observing a discrepancy in the index sets of the pressure field depending on whether I use Here is the simple example i tried: import underworld3 as uw
import sympy as sp
# mesh = uw.meshing.StructuredQuadBox(elementRes=(3,) * 2)
mesh = uw.meshing.UnstructuredSimplexBox(cellSize=0.9)
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
)
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() output
This is from underworld3/src/underworld3/cython/petsc_generic_snes_solvers.pyx Lines 2696 to 2763 in 7c08857
This is from
|
@gthyagi, it's unclear where you have called createSubDM(). As discussed I think a pure petsc4py script to demonstrate this would be useful. |
@knepley, thank you for the suggestions—they worked! The issue was caused by passing the wrong |
@gthyagi Yes! I will keep reading all the issues. |
Getting the following error with #279
|
@bknight1 I am running this script without any error. Which one are you running? |
I was running a different script. That one works, but if you add the following mesh variable it'll reproduce the error:
|
Can you paste the code snippet where you create all mesh variables? I think the order how you create mesh variables is important. That determines the field id. |
I've tried creating the mat variable first and last in the code you posted and get the same result either way |
Yesterday we were discussing about this case, let me investigate more on this. |
@bknight1 I know the source of the issue. But not quite sure how to fix it. We will discuss in Thursday dev meeting. |
@knepley -happy new year! Could you point out the code that performs this - much appreciated. |
Update petsc_generic_snes_solvers.pyx Fixes #277 to is not yet optimised. More work to come on that.
I use it in the output routines in plex.c and plexhdf5.c |
UW3 version - c0b15d0
It appears that UW creates a discontinuous variable with degree = 0 (n = 242) whilst the one supplied in the script is with degree = 1 (n = 726), leading to a shape mismatch.
I can't see where in petsc_generic_snes_solvers.pyx this occurs, so any help would be appreciated.
Error message:
Code to reproduce:
The text was updated successfully, but these errors were encountered: