underworldcode / underworld3

https://underworldcode.github.io/underworld3/
18 stars 10 forks source link

RuntimeError while evaluating integration on mesh #135

Open gthyagi opened 11 months ago

gthyagi commented 11 months ago

The mesh requires at least a single variable for integration to function correctly. This is a PETSc limitation.

Here is the code to reproduce the error.

import underworld3 as uw
mesh = uw.meshing.UnstructuredSimplexBox(minCoords=(0.0, 0.0), 
                                         maxCoords=(1.0, 1.0), 
                                         cellSize=1.0 / 32.0, 
                                         regular=True)
# # add this line to avoid petsc error
# s_soln = uw.discretisation.MeshVariable("T", mesh, 1, degree=2) 

x = mesh.N.x
y = mesh.N.y
z = mesh.N.z

I = uw.maths.Integral(mesh, x * y)
print(I.evaluate())  # 0.25
lmoresi commented 11 months ago

We could check the number of variables and add one - in the Batman free time, this is possible to contemplate

Sent from my iPhone

On 19 Nov 2023, at 03:34, Thyagarajulu Gollapalli @.***> wrote:



The mesh requires at least a single variable for integration to function correctly. This is a PETSc limitation.

Here is the code to reproduce the error.

import underworld3 as uw mesh = uw.meshing.UnstructuredSimplexBox(minCoords=(0.0, 0.0), maxCoords=(1.0, 1.0), cellSize=1.0 / 32.0, regular=True)

add this line to avoid petsc error

s_soln = uw.discretisation.MeshVariable("T", mesh, 1, degree=2)

x = mesh.N.x y = mesh.N.y z = mesh.N.z

I = uw.maths.Integral(mesh, x * y) print(I.evaluate()) # 0.25

— Reply to this email directly, view it on GitHubhttps://github.com/underworldcode/underworld3/issues/135, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADABPI56M4FBMZGJEXUN4ILYFDPSFAVCNFSM6AAAAAA7RCPZPOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDANBYHAZDKMY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

knepley commented 11 months ago

This can be fixed. I just did not contemplate integrating a pure function. We would need to get the quadrature rule from somewhere (right now it comes from the PetscFE)

lmoresi commented 2 months ago

@julesghub - we should fix this. We have a default quadrature held on the mesh, I think.