Skip to content

Adaptive Poisson equation #844

Answered by kinnala
Abelsylowlie asked this question in Q&A
Dec 31, 2021 · 1 comments · 9 replies
Discussion options

You must be logged in to vote

Thanks, it is a good question. There are several options. However, I suggest you employ some finite element knowledge.

Partial derivative of ElementTriP<k> is ElementDG(ElementTriP<k-1>). So you could first find the derivative and then calculate the residual. This is an example:

from skfem import *
mesh = MeshTri().refined(3)
basis = Basis(mesh, ElementTriP3())
grad_basis = basis.with_element(ElementVector(ElementDG(ElementTriP2())))
u = basis.project(lambda x: x[0] ** 3)
grad_u = grad_basis.project(basis.interpolate(u).grad)

@Functional
def residual(w):
    (uxx, uxy), (uyx, uyy) = w['grad_u'].grad
    return (uxx + uyy) ** 2

out = residual.elemental(grad_basis, grad_u=grad_u)

from skfem

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@kinnala
Comment options

@kinnala
Comment options

@kinnala
Comment options

@kinnala
Comment options

@Abelsylowlie
Comment options

Answer selected by Abelsylowlie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants