Getting some error when try to apply average zero condition on a scalar variable #2901
Replies: 4 comments 2 replies
-
It's a bit hard to test what you've done because your example is incomplete. from firedrake import *
M = UnitSquareMesh(2, 2)
W = FunctionSpace(M, "Lagrange", 1)
p_exact = Function(W)
x, y = SpatialCoordinate(M)
r2 =2.
pressure=-0.5*(1+((1-2*x*x+2*y*y)/(r2*r2)))
p_exact.interpolate(pressure)
pressuredx = assemble(interpolate(p_exact, W) * dx)
size_domain = assemble(interpolate(Constant(1.0), W) * dx)
pressure = pressure - (pressuredx / size_domain)
p_exact.interpolate(pressure) I should also point out that two of your interpolations are unnecessary. The following code would do the same as your code: from firedrake import *
M = UnitSquareMesh(2, 2)
W = FunctionSpace(M, "Lagrange", 1)
p_exact = Function(W)
x, y = SpatialCoordinate(M)
r2 = 2.
pressure=-0.5*(1+((1-2*x*x+2*y*y)/(r2*r2)))
p_exact.interpolate(pressure)
pressuredx = assemble(p_exact * dx)
size_domain = assemble(Constant(1.0, M) * dx)
pressure = pressure - (pressuredx / size_domain)
p_exact.interpolate(pressure) |
Beta Was this translation helpful? Give feedback.
-
sir, it still shows same error
I am using a mesh with a hole. |
Beta Was this translation helpful? Give feedback.
-
Your code works well. My code is showing error when I impose this average
zero condition and I also made the changes that you mentioned. That's why I
think, may be the error occur due to 3d mesh.
…On Mon, 1 May 2023, 20:05 David A. Ham, ***@***.***> wrote:
Are you saying that exactly the code that I posted creates an error, or
that your code, which is different from my code, produces the error? I
think you are saying the latter. In which case please post a complete
minimal failing example, including all the code I need to recreate the
error, and the mesh file.
—
Reply to this email directly, view it on GitHub
<#2901 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3SVU4PI35QYABXXVVGWOO3XD7C2FANCNFSM6AAAAAAXRYG4NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Thank you Now it works well. |
Beta Was this translation helpful? Give feedback.
-
when I try to make p_exact belongs to L^2_0 i.e. p_exact average zero condition (int_\Omega p dx =0) then I get the error message
Please help !
Beta Was this translation helpful? Give feedback.
All reactions