1
$\begingroup$

I would like to implement P2 (or even P3...) finite elements in Matlab. I need to be able to control the construction of the rigidity and mass matrices ($ \int \nabla \varphi_i\cdot \nabla \varphi_j$ and $\int \varphi_i \varphi_j$) (since I want to tackle some precision computation problems afterwards, and maybe go beyond machine precision using Advanpix...)

If there are already some good Matlab codes which do this, please point me to them. If not, are there any good references from where I could learn to do this properly?

I would like to avoid doing all the computations by hand if possible since I'm sure someone else has done them before :) ... (find the right basis functions, compute explicitly all integrals of products of neighbor basis functions, etc...)

$\endgroup$

2 Answers 2

1
$\begingroup$

Please check “The Finite Element Method: Theory, Implementation, and Applications” by Larson and Bengzon. They have Matlab implementation of P2 Lagrange elements (assembly of stiffness matrix) on page 217. It should be easy to implement higher order elements based on their code as well.

$\endgroup$
1
  • $\begingroup$ Thank you for your answer. I'll take a look in the book you mention. $\endgroup$ Jun 8, 2017 at 6:59
1
$\begingroup$

Is your question just regarding the final assembly of the system into a global one then you can find the answer here FEM assembly on unstructured meshes although implementation is in c++ it is very easily translatable into Matlab.

$\endgroup$
2
  • $\begingroup$ Thank you for your answer. Unfortunately, translating C++ code into efficient Matlab code is not that easy... Embedded for loops are very slow in Matlab. $\endgroup$ Jun 8, 2017 at 6:59
  • $\begingroup$ I have tested both the version for assembly alone and they are not that different. Of course c++ is faster when you consider for large problems 10^6 $\endgroup$
    – kaush
    Jun 8, 2017 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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