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
Copy file name to clipboardExpand all lines: news.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -203,7 +203,7 @@ Introduction of several core API changes, which significantly alter the usage of
203
203
0x0000000000001139 <+41>: cvttsd2si %xmm0,%eax // return computed sum
204
204
0x000000000000113d <+45>: ret
205
205
End of assembler dump.
206
-
206
+
207
207
While fdaPDE was completely able to avoid any for loop at run-time (as it perfectly knows how to compute the for-loop at compile time), Eigen cannot, and must execute code (therefore, waste time) to produce a result. You will further notice the advantages of such data-types when involved in the much more involved math expressions.
208
208
209
209
Below a summary of the API exposed for constexpr dense linear algebra at the time of this update:
Copy file name to clipboardExpand all lines: tutorials/tut_1.rst
+31-28
Original file line number
Diff line number
Diff line change
@@ -46,19 +46,22 @@ As always, fdaPDE requires the weak formulation of the differential problem abov
46
46
47
47
\int_{\Omega} \nabla u^{k+1} \cdot\nabla v + \alpha (1-u^k) u^{k+1} v - \int_{\Omega} \alpha u^k u^{k+1} v = \int_{\Omega} f - \alpha (u^k)^2 v \quad\forall v \in V_h
48
48
49
-
which we iteratively solve for :math:`u^{k+1}` until convergence. Follows a step by step description of the program which enables us to find a solution to the considered problem in less than 50 lines of code.
49
+
which we iteratively solve for :math:`u^{k+1}` until convergence.
50
50
51
-
First we load the geometry (currently generated from some third party triangulator), enabling the cell caching. As we are going to iterate several times over the mesh is convinient to compute the cells once to obtain a fast re-access to the mesh.
51
+
Implementation
52
+
--------------
53
+
54
+
The first step in any finite element code is the definition of the problem geometry. As we are going to iterate several times over the mesh is convinient to compute the cells once and cache them to obtain a fast re-access to the mesh. This option is enabled by activating the cell caching.
Once we have a discretization of the domain :math:`\Omega`, we can instatiate a (linear) finite element space on it togheter with trial and test functions.
58
61
59
62
.. code-block:: cpp
60
63
61
-
FiniteElementSpace Vh(unit_square, P1); // P1 denotes the space of linear finite elements
64
+
FeSpace Vh(unit_square, P1<1>); // piecewise linear continuous scalar finite elements
62
65
TrialFunction u(Vh);
63
66
TestFunction v(Vh);
64
67
@@ -85,7 +88,7 @@ We then define the forcing term as a plain :code:`ScalarField` togheter with the
The code fragment above effectivelly assemble the discretization matrix :code:`A` for the bilinear form :math:`\int_{\Omega} \nabla u^0\cdot\nabla v + u^0 v` togheter with the discretizing vector :code:`v_` of the forcing functional :math:`F`. Then, it sets the Dirichlet conditions at the boundary via the :code:`enforce_constaints` method of the :code:`dof_handler` object. Finally, observing that the bilinear form is SPD, solves the FEM linear system using a Cholesky factorization and sets :math:`u^0` to the solution of this linear system.
@@ -124,9 +127,9 @@ We can finally start looping until convergence, iteratively solving the recurren
124
127
.. code-block:: cpp
125
128
126
129
while (err > 1e-7) {
127
-
SpMatrix<double> A1 = a.assemble();
128
-
SpMatrix<double> A2 = b.assemble();
129
-
DVector<double> v = v_ + A2 * u_prev.coeff();
130
+
Eigen::SparseMatrix<double> A1 = a.assemble();
131
+
Eigen::SparseMatrix<double> A2 = b.assemble();
132
+
Eigen::Matrix<double, Dynamic, 1> v = v_ + A2 * u_prev.coeff();
130
133
A = A1 + A2;
131
134
dof_handler.enforce_constraints(A, v);
132
135
lin_solver.compute(A);
@@ -144,17 +147,17 @@ The code just assembles :code:`A1` and :code:`A2`, updates the right hand side :
144
147
.. code-block:: cpp
145
148
:linenos:
146
149
147
-
#include <fdaPDE/fields.h>
148
-
#include <fdaPDE/geometry.h>
149
150
#include <fdaPDE/finite_elements.h>
150
-
151
151
using namespace fdapde;
152
152
153
153
int main() {
154
-
// import mesh, enable cell caching for fast re-cycling
0 commit comments