This models the steady-state temperature in a square where the boundary temperature is maintained at $0$ all around except for the lower-half of the left edge where heat flux is specified instead of temperature.
square-spec.c
by inserting an extra
point (point #4 in the figure) and segment #4.
Now your domain will be defined through 5 points and 5 segments.
FEM_BC_DIRICHLET
except for segment #4 which would be FEM_BC_NEUMANN
.
square-spec.c
needs to define the functions $f$, $g$, $h$, $\eta$.
We have $f\equiv0$, $g\equiv0$, $h\equiv2$, and $\eta\equiv1$.
We have no $u_\text{exact}$, so set it to NULL
in struct problem_spec
.
./demo-square 4 0.001 domain is a square nodes = 835, edges = 2402, elems = 1568 system stiffness matrix is 835x835 (=697225) has 5101 nonzero entries pyplot output written to file demo-square.py
log
in the Standard C Library. Remember to put
#include<math.h>
in your annulus-spec.c
.
./demo-annulus 5 0.005 24 domain is an annulus (really a 24-gon) of radii 0.325 and 0.65 nodes = 200, edges = 535, elems = 335 system stiffness matrix is 200x200 (=40000) has 860 nonzero entries errors: L^infty = 0.00619778, L^2 = 0.00268236, energy norm = 0 pyplot output written to file demo-annulus.py
Update: Okay, I see why we get zero for the error in the energy norm. That's because my code incorrectly applies the formula (25.17) from page 347. That formula was derived for boundary value problems with zero Dirichlet data. Here we have nonzero data on the inner boundary and therefore we need a generalization of (25.17) to nonzero data. I don't know how to do that at the moment, so for now ignore that zero value, or better yet, just don't print it.