Professional Documents
Culture Documents
Finite Elements
1 Introduction
The objective of this project is to write a small finite element code in python, which is able
to solve thermal analysis problems. The features of the code are the following:
We assume 2D domains
The elements are 3 nodes isoparametric triangular elements
The conductivity is assumed to be isotropic
Only zero (homogeneous) Dirichlet boundary conditions are considered
A program skeleton is given in the file solveFE.py: you have to adapt this file for the
project. This file together with necessary python and mesh files are given in an archive
named menumFemProject2016.zip that you can uncompress in your work directory.
3 Problem description
The problem will be specified by refering to geometric entities defined on the mesh. Any
entity in the mesh belongs to a geometrical entity than can be a point, a curve or a surface.
All the geometries given in the archive obeys the following convention:
Node 1
Line 103
Surface 1000
Line 101
Node 3
Line 102
Line 104
Node 4
Node 2
If you want to prescribe a boundary condition on the bottom line of the square, you will have
to refer to line 101. Adding a source term on the domain ends-up to refer to surface 1000.
4 Program usage
You can run the finite element code by specifying the problem you want to solve:
The mesh on which you want to solve the thermal equations;
The conductivity;
The Neumann boundary conditions;
The Dirichlet boundary conditions;
The source term;
The name of the output file.
An example of such definition, and the call to solveFE are given in testFE.py:
#Import finite element solver function
from solveFE import solveFE
#Mesh file
meshName = 'square.msh'
# Setup the problem we want to solve
# Neumann BCs : as a dictionary (~ stl map) (physicalId: qN value)
BCNs = {101: -1, 103: 1}
5 Work
You are asked to :
Finish the implementation of the proposed finite element code. Look at solveFE.py:
the code is commented and some guidance is given;
Basically, you need to fill the source file where # SMA to code comments are given;
Fill the dof manager;
Compute the elementary stiffness matrix;
Compute the elementary volume force vector;
Compute the elementary Neumann force vector;
Do the assembly.
You can compare your results to analytical solutions (for instance the case of a square
with zero temperature on line 101, and a prescribed flux on line 103)
Compare your solution with the one from the FD lab.
6 Bonus questions
Only if you have finished properly the other questions. Otherwise it may lead
to malus points...
1. Modify your program for a domain with two isotropic materials (see squareBimat.msh);
2. Check your implementation against analytical solutions.
7 Tips
To check your elementary stiffness matrix, here is the stiffness matrix of a unique triangular
element with unit conductivity and whose shape is homothetic to the parent element: