Skip to content

Commit 080f039

Browse files
Create Derivatives_fe_field.md
1 parent 3874cc5 commit 080f039

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

doc/Derivatives_fe_field.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Calculating Derivatives $dx(u)$ and $dy(u)$ Over a Triangular Finite Element
2+
3+
4+
<img width="200" align="left" src="https://github.com/user-attachments/assets/124852e5-3169-4436-8fa9-b90bddfc9972"/>
5+
6+
To calculate the derivatives of a function $u$ with respect to $x$ and $y$ ( denoted as $\frac{\partial u}{\partial x}$, $\frac{\partial u}{\partial y}$, or more simply $dx(u)$, $dy(u)$ ) over a triangular finite element, we follow these steps:
7+
8+
### 1. Define the Triangle and the P1 Basis Functions
9+
10+
In a P1 (linear) finite element, the function $u$ is assumed to be linear over each triangle.
11+
Let the vertices of the triangle be $\mathbf{v}_1 = (x_1, y_1)$, $\mathbf{v}_2 = (x_2, y_2)$, and $\mathbf{v}_3 = (x_3, y_3)$,
12+
with corresponding function values $u_1 = u(\mathbf{v}_1)$, $u_2 = u(\mathbf{v}_2)$, and $u_3 = u(\mathbf{v}_3)$.
13+
14+
The function $u(x, y)$ can be expressed as:
15+
16+
$$u(x, y) = a_0 + a_1 x + a_2 y$$
17+
18+
where $a_0$, $a_1$, and $a_2$ are coefficients to be determined.
19+
20+
### 2. Set Up the System of Equations
21+
22+
We solve for the coefficients $a_0$, $a_1$, and $a_2$ using the known values of $u$ at the triangle's vertices:
23+
24+
$$
25+
\begin{aligned}
26+
u_1 &= a_0 + a_1 x_1 + a_2 y_1 \\
27+
u_2 &= a_0 + a_1 x_2 + a_2 y_2 \\
28+
u_3 &= a_0 + a_1 x_3 + a_2 y_3
29+
\end{aligned}
30+
$$
31+
32+
This system can be written in matrix form:
33+
34+
$$
35+
\begin{pmatrix}
36+
1 & x_1 & y_1 \\
37+
1 & x_2 & y_2 \\
38+
1 & x_3 & y_3
39+
\end{pmatrix}
40+
\begin{pmatrix}
41+
a_0 \\
42+
a_1 \\
43+
a_2
44+
\end{pmatrix}=
45+
\begin{pmatrix}
46+
u_1 \\
47+
u_2 \\
48+
u_3
49+
\end{pmatrix}
50+
$$
51+
52+
53+
Solve this system to get $a_0$, $a_1$, and $a_2$.
54+
55+
### 3. Calculate the Derivatives $dx(u)$ and $dy(u)$
56+
57+
- The derivative $\frac{\partial u}{\partial x}$ is simply $a_1$. This is because the partial derivative of $u(x, y)$ with respect to $x$ is:
58+
59+
$$
60+
\frac{\partial u}{\partial x} = a_1
61+
$$
62+
63+
Therefore, $dx(u) = a_1$.
64+
65+
- The derivative $\frac{\partial u}{\partial y}$ is simply $a_2$. This is because the partial derivative of $u(x, y)$ with respect to $y$ is:
66+
67+
$$
68+
\frac{\partial u}{\partial y} = a_2
69+
$$
70+
71+
Therefore, $dy(u) = a_2$.
72+
73+
### 4. Shortcut Using the Area Formula (2D case)
74+
75+
For a 2D triangular element (i.e., $z = 0$), the coefficients $a_1$ and $a_2$ (which give the derivatives with respect to $x$ and $y$, respectively) can be directly computed using the area of the triangle and the coordinates of its vertices:
76+
77+
$$
78+
a_1 = \frac{1}{2A} \left( u_1(y_2 - y_3) + u_2(y_3 - y_1) + u_3(y_1 - y_2) \right)
79+
$$
80+
81+
$$
82+
a_2 = \frac{1}{2A} \left( u_1(x_3 - x_2) + u_2(x_1 - x_3) + u_3(x_2 - x_1) \right)
83+
$$
84+
85+
where $A$ is the area of the triangle, given by:
86+
87+
$$
88+
A = \frac{1}{2} \left| x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2) \right|
89+
$$
90+
91+
This method directly gives the derivatives $dx(u)$ and $dy(u)$ without solving a system of equations.
92+
93+
## TO DO ##
94+
ADD CODE EXAMPLE

0 commit comments

Comments
 (0)