You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# ## A low-level implementation of the residual integration and assembly
573
573
574
+
# In the rest of the tutorial we aim to solve a Poisson equation with homogeneous source term, i.e., $f=0$ and non-homogeneous Dirichlet boundary conditions $u=g_0$ on $\Gamma_D$, with $\Gamma_D$ being the whole boundary of the model. While the strong imposition of non-homogeneous Dirichlet boundary conditions in Gridap is done under the hood by modifying the global assembly process by subtracting the contributions of boundary conditions to the right hand side of the linear system, in this tutorial, for simplicity, we follow a different approach. This approach requires: (1) to be able to assemble the residual of the PDE for an arbitrary finite element function $\hat{u}_h$ (current section); (2) to be able to assemble the coefficient matrix of the finite element linear system (next section). We briefly outline this solution approach in the sequel.
575
+
574
576
# The discretized variational form of the Poisson problem reads as:
575
577
# >Find $u_h \in V_h^{\Gamma_D}=\{v_h \in V_h:v_h=g_0 \; on \; \Gamma_D\}$ such that
576
578
# >```math
577
-
# >(u_h,v_h)=l(v_h)\quad \forall v_h \in V_h^0
579
+
# >a(u_h,v_h)=l(v_h)\quad \forall v_h \in V_h^0
578
580
# >```
579
581
# >where $V_h^0=\{v_h \in V_h:v_h=0 \; on \; \Gamma_D\}$.
580
582
#
581
-
#Take $u_h = \hat{u}_h-w_h$ where $w_h \in V_h^0$ and $\hat{u}_h \in V_h^{\Gamma_D}$, then
583
+
#If we take an arbitrary function $\hat{u}_h\in V_h^{\Gamma_D}$, and compute $w_h \in V_h^0$ as the solution of the following discrete variational problem:
# Find some $\hat{u}_h$, solve that eqation for $w_h$, then the solution is
587
-
# ```math
588
-
# u_h=\hat{u}_h-w_h.
589
-
# ```
590
-
#
591
-
# In the integration and assembly process, we first use the `rand` function to assign random values to the free DoFs to form $\hat{u}_h$ (name the randomly fixed DoFs as $\vec{\hat{u}}$). In this particular problem, $l(v_h)$ is obviously zero, so just compute $a(\hat{u}_h,v_h)$ for each element, then assemble the results to obtain the global force vector $\vec{b}$. On the left hand side, compute every element-wise $a(w_h,v_h)$, and assemble them to form global stiffness matrix $\textbf{A}$. Solve the linear system $\textbf{A}\vec{x}=\vec{b}$ for $\vec{x}$, then the final solution for the free DoFs is
592
-
593
-
# ```math
594
-
# \vec{u}=\vec{\hat{u}}-\vec{x}.
595
-
# ```
587
+
# Then, it is easy to see that $\mathbf{ u_h=\hat{u}_h-w_h }$. This is the strategy that we implement in the sequel. Note that, in previous section, we created a FE function using `rand` for initializing the values of the degrees of freedom. This function indeed plays the role of $\hat{u}_h$.
596
588
597
589
# Let us now create manually an array of `Field`s uₖ that returns the FE function uₕ at each cell, and another array with its gradients, ∇uₖ. We hope that the next set of instructions can be already understood with the material covered so far
0 commit comments