MHB FE 1D method and hat functions

AI Thread Summary
The discussion focuses on the finite element method, specifically the use of hat functions and their summation in the context of constructing a piecewise polynomial function, u_h(x). The participants clarify how to visualize and compute u_h(x) using linear interpolation between coefficients c_j. They also address the calculation of integrals involving the derivatives of the hat functions, distinguishing cases based on the indices i and j. The final consensus confirms the correct approach to evaluating these integrals, leading to a clearer understanding of the mathematical relationships involved. Overall, the exchange enhances comprehension of the finite element method's application in project work.
Carla1985
Messages
91
Reaction score
0
Hi all, I'm doing a project on the finite elements method and am struggling to understand a part of it.

I have defined the hat functions as:

\[
\phi_i(x) =
\begin{cases}
\frac{x-x_{i-1}}{h} & \text{if } x_{i-1}\leq x<x_i \\
\frac{x_{i+1}-x}{h} & \text{if } x_i\leq x<x_{i+1}\\
0 & \text{otherwise}
\end{cases}
\]

I know this means that for each $\phi_i(x_i)$ is 1 when i=j and 0 the rest of the time. The part I'm stuck on is the next step:

\[
u_h(x) = \sum_{j=1}^{n-1}c_j\phi_j(x)
\]

How do I sum these functions in their general form?

Regards
Carla
 
Last edited by a moderator:
Mathematics news on Phys.org
Carla1985 said:
Hi all, I'm doing a project on the finite elements method and am struggling to understand a part of it.

I have defined the hat functions as:

\[
\phi_i(x) =
\begin{cases}
\frac{x-x_{i-1}}{h} & \text{if } x_{i-1}\leq x<x_i \\
\frac{x_{i+1}-x}{h} & \text{if } x_i\leq x<x_i{i+1}\\
0 & otherwise
\end{cases}
\]

I know this means that for each $\phi_i(x_i)$ is 1 when i=j and 0 the rest of the time. The part I'm stuck on is the next step:

\[
u_h(x) = \sum_{j=1}^{n-1}c_j\phi_j(x)
\]

How do I sum these functions in their general form?

Regards
Carla

Hey Carla! ;)

I think it would help if you visualize it.

Suppose we pick $h=1$ and $c_1=2, c_2=3,c_3=1$.
Can you draw each $\phi_i$?
And then draw the combined $u_h$?

What does $u_h$ look like?
Can you come up with a general form for its formula?
 
I like Serena said:
Hey Carla! ;)

I think it would help if you visualize it.

Suppose we pick $h=1$ and $c_1=2, c_2=3,c_3=1$.
Can you draw each $\phi_i$?
And then draw the combined $u_h$?

What does $u_h$ look like?
Can you come up with a general form for its formula?

I know the c's scale each of the hats so at i=1 there would be a point of height 2, at i=2 a point at height 3 etc, combining these would give a piecewise polynomial of straight lines between each point, so a line from (1,2) to (2,3) etc. I'm not sure how I get a general form from that though
 
Carla1985 said:
I know the c's scale each of the hats so at i=1 there would be a point of height 2, at i=2 a point at height 3 etc, combining these would give a piecewise polynomial of straight lines between each point, so a line from (1,2) to (2,3) etc. I'm not sure how I get a general form from that though

Indeed, if we pick $x$ between $x_i$ and $x_{i+1}$, we can find $u_h(x)$ as a linear interpolation between $c_i$ and $c_{i+1}$.
A linear interpolation is the same as a weighted average:
$$u_h(x) = \frac{(x-x_i)c_{i+1} + (x-x_{i+1})c_{i}}{x_{i+1}-x_{i}}\qquad\text{if }x_i \le x < x_{i+1}$$
Or:
$$u_h(x) = \frac{x-x_i}{h}c_{i+1} + \frac{x-x_{i+1}}{h}c_{i}\qquad\quad\text{if }x_i \le x < x_{i+1}$$
 
I like Serena said:
Indeed, if we pick $x$ between $x_i$ and $x_{i+1}$, we can find $u_h(x)$ as a linear interpolation between $c_i$ and $c_{i+1}$.
A linear interpolation is the same as a weighted average:
$$u_h(x) = \frac{(x-x_i)c_{i+1} + (x-x_{i+1})c_{i}}{x_{i+1}-x_{i}}\qquad\text{if }x_i \le x < x_{i+1}$$
Or:
$$u_h(x) = \frac{x-x_i}{h}c_{i+1} + \frac{x-x_{i+1}}{h}c_{i}\qquad\quad\text{if }x_i \le x < x_{i+1}$$
Ok, I think I understand that, though I'm still struggling to get my head around working with a function that has more than one equation. For example I have differentiations and multiplications eg $\phi^1_1\phi^1_2$ and $f\phi_1$ etc. How can I do those sort of calculations without one equation?
 
Carla1985 said:
Ok, I think I understand that, though I'm still struggling to get my head around working with a function that has more than one equation. For example I have differentiations and multiplications eg $\phi^1_1\phi^1_2$ and $f\phi_1$ etc. How can I do those sort of calculations without one equation?

I'm not sure I understand what it is that you are struggling with.

It's a piece wise function.
The function is the same on each piece, just with a different $i$.
So we look at one piece at a time.
On one piece it is just one equation.

Anyway, what do you mean with those differentiations and multiplications?

Regards,
I like Serena
 
I like Serena said:
I'm not sure I understand what it is that you are struggling with.

It's a piece wise function.
The function is the same on each piece, just with a different $i$.
So we look at one piece at a time.
On one piece it is just one equation.

Anyway, what do you mean with those differentiations and multiplications?

Regards,
I like Serena

Sorry, I didn't explain very well. A further step is to calculate $\int^1_0\phi '_i\phi '_j\ dx$ but $\phi '_i$ can be $\frac{1}{h}$, $-\frac{1}{h}$ or $0$, same for $\phi '_j$.

I'm calculating these to build a matrix to solve for c's.
 
Carla1985 said:
Sorry, I didn't explain very well. A further step is to calculate $\int^1_0\phi '_i\phi '_j\ dx$ but $\phi '_i$ can be $\frac{1}{h}$, $-\frac{1}{h}$ or $0$, same for $\phi '_j$.

I'm calculating these to build a matrix to solve for c's.

To calculate those, you will need to distinguish the cases:
  1. $i=j$
  2. $i$ and $j$ differ by $1$
  3. $i$ and $j$ differ by more than $1$
What would the integral look like in each of those cases?

ILS x
 
I like Serena said:
To calculate those, you will need to distinguish the cases:
  1. $i=j$
  2. $i$ and $j$ differ by $1$
  3. $i$ and $j$ differ by more than $1$
What would the integral look like in each of those cases?

ILS x
I'm not sure if its the right way of thinking about it but I think (taking h=1 for now) if i=j they are the squared terms so the differentials of 1 and then -1 are both squared hence both 1, so the graph would just be 1 between 0 and 1, then the area would be y=1. For i and j differ by 1, half of each hat would over lap, except one half would always be positive, the other negative so the area would be -1/2. Lastly if they differ by more than 1 it would be 0 as there would be no overlap. I think if h is different everything would be divided by h

Is that close?
 
  • #10
Carla1985 said:
I'm not sure if its the right way of thinking about it but I think (taking h=1 for now) if i=j they are the squared terms so the differentials of 1 and then -1 are both squared hence both 1, so the graph would just be 1 between 0 and 1, then the area would be 1. For i and j differ by 1, half of each hat would over lap, except one half would always be positive, the other negative so the area would be -1/2. Lastly if they differ by more than 1 it would be 0 as there would be no overlap. I think if h is different everything would be divided by h

Is that close?

Yep. Close.

Let's pick an arbitrary $h$.

Then we have:
$$\int_0^1 \phi_i'(x)\phi_j'(x) dx = \begin{cases}
\frac 1 h \cdot \frac 1 h \cdot h + -\frac 1 h \cdot -\frac 1 h \cdot h &\text{if }i=j \\
\frac 1 h \cdot -\frac 1 h \cdot h&\text{if }|i-j|=1 \\
0 &\text{otherwise}
\end{cases}$$

$$\int_0^1 \phi_i'(x)\phi_j'(x) dx = \begin{cases}
\frac 2 h &\qquad\qquad\qquad&\text{if }i=j \\
-\frac 1 h&&\text{if }|i-j|=1 \\
0 &&\text{otherwise}
\end{cases}$$
 
  • #11
Oh actually everything would be x2 as only each half of the hat is in one interval, so if h=1 half the hat area would be 1 but so would the other half so it would be 2 altogether

- - - Updated - - -

I like Serena said:
Yep. Close.

Let's pick an arbitrary $h$.

Then we have:
$$\int_0^1 \phi_i'(x)\phi_j'(x) dx = \begin{cases}
\frac 1 h \cdot \frac 1 h \cdot h + -\frac 1 h \cdot -\frac 1 h \cdot h &\text{if }i=j \\
\frac 1 h \cdot -\frac 1 h \cdot h&\text{if }|i-j|=1 \\
0 &\text{otherwise}
\end{cases}$$

$$\int_0^1 \phi_i'(x)\phi_j'(x) dx = \begin{cases}
\frac 2 h &\qquad\qquad\qquad&\text{if }i=j \\
-\frac 1 h&&\text{if }|i-j|=1 \\
0 &&\text{otherwise}
\end{cases}$$

Thank you! Its all just clicked into place, having a break helped to think of it differently :)
 
Back
Top