I know the Neumann B.C. is implicit in FEM language. However, I have seen at least two ways to impose Dirichlet B.C.

e.g. for the following problem 1D,

$$\nabla^2 u + \nabla u= 0, u_{left}= 1, u_{right}=0$$

1) set first and last row of assembled "A" to "0" at left hand side, set A(1,1)=1,A(end,end)=1, and specify the boundary value "1" and "0" in right hand side vector "b".

2) set first row&column, last row&column of assembled "A" to "0" at left hand side, then do the same thing as above.

these two methods are different, the first is more intuitive(probably preferred by finite difference user), while the second sounds more rigorous because we are setting the boundary "element".

I know these two ways may generate different results for some specific case. Could any body give some insight?

  • $\begingroup$ What exactly is your question? Do you note that the above PDE does not have a solution? $\endgroup$
    – shuhalo
    May 4 '14 at 12:43
  • $\begingroup$ If they give different results, one of them has to be wrong... (@Martin: What about $u(x) = 1-x$ (assuming the domain is $(0,1)$?) $\endgroup$ May 4 '14 at 12:56
  • $\begingroup$ Less facetiously, the second approach usually removes the rows and columns from $A$ (and $b$) entirely, so one solves for the interior degrees of freedom only. In 1D, this doesn't make much difference, but in 3D the reduced matrix may be noticeably smaller, saving computational effort. $\endgroup$ May 4 '14 at 12:59
  • 1
    $\begingroup$ Something else to note is that, for problems that give a symmetric A matrix (eg, parabolic/elliptic pde like heat equation), method 2 preserves the symmetry, whereas method 1 will not. This can inform your choice of linear system solver, so it's good to keep in mind. $\endgroup$ May 5 '14 at 4:11
  • 1
    $\begingroup$ Possible duplicate of How to properly apply non-homogeneous Dirichlet boundary conditions with FEM? $\endgroup$
    – osolmaz
    Apr 4 '18 at 6:51

I think the typical approach is 1), which can then be reformulated into a smaller system.

Using the approach in https://scicomp.stackexchange.com/a/5073/1804, suppose your finite element basis coefficients make up a vector $\xi$, and that you can partition them into the vectors $\xi_{int}$ and $\xi_{bc}$. Then you should be able to permute your system into something like

\begin{align} \left[\begin{array}{cc} A_{int} & A_{int-bc} \\ 0 & I \end{array}\right] \left[\begin{array}{c} \xi_{int} \\ \xi_{bc}\end{array}\right] = \left[\begin{array}{c} b_{int} \\ b_{bc}\end{array}\right] \end{align}

where $A_{int}$ and $A_{int-bc}$ are stiffness-like matrices, $b_{int}$ is the load vector for your system (in this case, a zero vector), and $b_{bc}$ contains your discretized boundary conditions.

From this formulation, you can reformulate into a smaller system.

The second approach sounds like it would give you a singular system, and the smaller system that results would only govern the interior degrees of freedom, which would only work if you had zero Dirichlet conditions.

  • $\begingroup$ I think you are right in saying "which would only work if you had zero Dirichlet conditions", but why you think it results in a singular system? since we still put "I" there in the matrix $\endgroup$
    – lorniper
    May 5 '14 at 11:51
  • $\begingroup$ And this reformulation (taking the Schur complement of $I$ in your matrix) is exactly what I thought the second approach referred to (for $b_{bc}=0$, the corresponding complement of the right-hand side is just $b_{int}$, but in general you need to solve $A_{int}\xi_{int} = b_{int}-A_{int-bc} b_{bc}$). The only difference between the two approaches should be the size of the matrix you need to invert. $\endgroup$ May 5 '14 at 19:10
  • $\begingroup$ @lorniper: The description seemed to read "set the first row, first column, last row, and last column to zero", and "then do the same thing as above" seemed to refer to the right-hand side part, which didn't make a whole lot of sense to me. If you could clarify what you mean, I can revise my answer. $\endgroup$ May 5 '14 at 20:58
  • $\begingroup$ @ChristianClason thanks, now I understand, I just simply did wrong with the right hand side in the second approach, and I agree they are equivalent $\endgroup$
    – lorniper
    May 6 '14 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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