Closed ruboerner closed 2 months ago
I can confirm the issue.
A quick test with the new fea implementation (yet unpublished) shows the resulting field need to be exact and mesh independend due to the bilinear field characteristics:
Its a little unclear where this comes from and when I will have time to fix it. In the meantime you can set the Dirichlet values to the nodes directly which seems to work as expected.
def BCN(node):
return (-X * node.x() -Y * node.y())
bc={'Node': [[b.node(0).id(), BCN(b.node(0))] for b in mesh.findBoundaryByMarker(1,5)]}
uh = pg.solve(mesh, a=[[1, 1]], bc=bc, verbose=True)
u = (-pg.x(mesh) - pg.y(mesh))
print('normL2(u-uh):', pg.solver.normL2(u-uh, mesh))
Also there seems an issue with the showMesh
keyword argument in the current release which I need to fix.
Many thanks for reporting, Carsten
Edit: Added the code for normL2 calculation Edit 2: The workarround only works for p=1 meshes, for p=2 also the middle node (b.node(2)) need to be considered.
The problem comes from the numbering directions of the boundary nodes. Not every node(0) is connected to node(1) from its neighbour, some are screwed due to triangle. So if you assign the value for one boundary to its node(0) might lead to wrong assigments. This is unfortunately broken be 'very old design' and I'm unsure if this can be fixed with moderate afford. Until the new implementation comes online, the little bit unconveniant direct node assignment will work.
Hi @carsten-forty2,
thanks for the quick and insightful response!
The news about a re-implementation of the FE code basis is great!
Cheers, Ralph
Problem description
I'm trying to solve the Laplace equation on a unit square.
It is unclear how to project the exact solution as Dirichlet boundary condition onto the FE space.
Your environment
Steps to reproduce
Expected behavior
As the solution of the considered Laplace problem we assume a simple linear function $u: \mathbb R^2 \mapsto \mathbb R$ with exact values given at the boundaries, we expect to obtain the exact solution in the interior of the computational domain.
In our case the function is
Actual behavior
It can be observed from the MWE that (probably) not all DOFs at the boundaries have been assigned the desired boundary values.