1
$\begingroup$

Im trying to solve the Poisson equation in 1D: $$-u_{xx} = f(x), \hspace{6mm} u(a) = d1, \hspace{2mm} u(b) = d2$$Assuming a uniform partition such that $x_n = a + nh$, where $h = (b-a)/N$ and $n \in [0,N]$, and then discretising the problem with linear finite elements to obtain a linear equation system $\mathbf{A u} = \mathbf{f}$. I Want to find the analytical expressions for $\mathbf{A}$ and $\mathbf{f}$.

I found the general expression for $\mathbf{A}$ before incorporating boundary conditions to be $$ \mathbf{A} = \frac{1}{h}\begin{bmatrix} 1 & -1 & 0 & \ldots & \ldots & 0 \\ -1 & 2 & -1 & \ddots & & 0 \\ 0 & -1 & 2 & \ddots & \ddots & 0 \\ \vdots & \ddots & \ddots & \ddots & \ddots & 0 \\ \vdots & & \ddots & -1 & 2 & -1 \\ 0 & \ldots & \ldots & 0 & -1 & 1 \end{bmatrix}$$ and correspondingly for $\mathbf{f}$: $$\mathbf{f} = \big[\frac{1}{2}f(x_0), f(x_1), f(x_2), ... , \frac{1}{2}f(x_{N+1}) \big]^T$$ My trouble is with incorporating the inhomogeneous boundary conditions, I can't find any clear examples of how to do this online despite looking up a ton of sources. Is anyone able to help?

$\endgroup$
2
  • $\begingroup$ You can change the first and last row so that $u_0 = d_1$ and $u_N=d_2$. Basically, just zero-out everything except the entries $(0,0)$ and $(N,N)$. Also, your r.h.s $f$ must be changed accordingly. $\endgroup$
    – VoB
    Apr 8, 2021 at 12:01
  • $\begingroup$ If you are only interested in some basic tests, then you can simply use the penalty method. Accordingly, you apply $u=u_s$, where $u_s$ is the specified value in a least-squares sense, i.e. $\Pi=\frac{1}{2} \alpha (u-us)^2$ with $\alpha$ as the penalty parameter. You need to use very high values ($>10^3$) for $\alpha$. $\endgroup$
    – Chenna K
    Apr 8, 2021 at 22:39

1 Answer 1

1
$\begingroup$

If you want to know the why and the how, you probably want to watch lecture 21.65 here: https://www.math.colostate.edu/~bangerth/videos.html Which you probably want to do after you've watched lecture 21.6.

Disclaimer: I'm the one in these videos.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.