Professional Documents
Culture Documents
Fem Technology With Edufem: Fem - Basics of The Fem, Exercise 2
Fem Technology With Edufem: Fem - Basics of The Fem, Exercise 2
DI Daniel Schöllhammer
Institute of Structural Analysis
Graz University of Technology
WS 2019/20
FEM – EL 2 Slide: 1
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Exercise Overview
Installation of EduFEM
Getting EduFEM
FEM – EL 2 Slide: 2
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Installing and Starting EduFEM
Download EduFEM from TeachCenter and unpack the zip-File to
an arbitrary location.
FEM – EL 2 Slide: 3
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
The PATH variable
For MATLAB to be able to recognize user-defined functions, the
path to the function must be located in the current folder or in a
folder listed within the PATH variable.
path % lists all directories in PATH
FEM – EL 2 Slide: 4
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Program Structure
FEM – EL 2 Slide: 5
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Elements
Element classification in EduFEM
ElemClass: defines shape
2D: ‘Tri’, ‘Quad’,
p = 2; ElemClass = 'Quad';
% determine element type:
[ElemType, NodeNumPerElem] =
Info2dFromOrder(ElemClass, p) 0
s
% get node-coords
CoordRef =
CoordNodes2dRefQuad(ElemType)
% plot nodes only: -1
plot(CoordRef.xx, CoordRef.yy, 'b*'); -1 0 1
r
% plot whole element” 1
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
FEM – EL 2 Slide: 7
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/ShapeFunctions
Example: Plot 1D base functions of arbitrary order 𝑝
p = 4; % order of base function
sd_plt = 100;
% define where to evaluate base functions
ptPlotRef.xx = linspace(-1, 1, sd_plt)';
ptPlotRef.nQ = sd_plt; % required per EduFEM convention
ptPlotRef.ww = zeros(sd_plt,1); % required per EduFEM convention
FEM – EL 2 Slide: 8
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/ShapeFunctions
Example: map point from reference domain into real domain
1
s
% define point in reference coords
ptRef.xx = [.2]';
ptRef.yy = [.1]';
ptRef.nQ = 1; ptRef.ww = 0; -1
-1 0 1
r
4
% the actual mapping
ptReal.xx = N.f' * CoordReal.xx; 3
0 1 2 3 4 5
FEM – EL 2 Slide: 9
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Meshes
EduFEM can “only” generate tensor-product style meshes, but:
Meshes may be modified (eg. by mapping)
Meshes may be ”glued” together
Meshes may be written by hand
Meshes may be exported/imported to/from other mesh
generators
EduFEM provides
higher-order meshes for
1d (lines)
2d (planes)
3d (continuum)
1dTo2d, 1dTo3d (curved lines in 2d or 3d)
2dTo3d (curved surfaces)
FEM – EL 2 Slide: 10
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Meshes
Example: Block-Mesh
lx = 5; % length in x-direction
ly = 2;
nx = 8; % no. of elems. in x-direction
ny=2;
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
FEM – EL 2 Slide: 11
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Meshes
Example: Create 2D surface mesh w/ quadratic, quadrilateral
Lagrangian elements.
xx1d = [-5:3 linspace(4,5,3)];
yy1d = [0:7 linspace(8,10,5)];
% create linear mesh
[Mesh] = Mesh2dTensorProdMesh(xx1d, yy1d);
FEM – EL 2 Slide: 12
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Integration
Example: Numerical Integration in Reference Domain
1 4 + 𝑟 3 + 𝑟 2 − 𝑟 ⅆ𝑟
−1
0.1𝑟
% define function
% f = 0.1*r^4 + r^3 + r^2 - r;
% get integration sites and weights
ipRef = Int1dGaussPoints(2);
FEM – EL 2 Slide: 13
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Integration
3 3
Example: Integration in Real Domain: 2
𝑥 ⅆ𝑥
% define function
% f = x ^ 3;
% get integration points in ref. element
ipRef = Int1dGaussPoints(1);
% define element coordinates (for mapping)
CoordElem.xx = linspace(2,3,4)';
CoordElem.nn = 4;
% map integration points from ref. to real element
ipReal = Int1dProjRefToReal(ipRef, CoordElem)
% compute integral
Int = ipReal.xx.^3' * ipReal.ww
FEM – EL 2 Slide: 14
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Integration
𝑥
Example: Approximate 𝑓 𝑥 = sin 𝑥 + + 1 𝑤𝑖𝑡ℎ 𝑥 ∈ [0, 5] as
4
ℎ
𝑓 𝑥 = 𝑖 𝑁𝑖 𝑥 𝑓𝑖
f = @(x) sin(x) + x/4 + 1;
% define element
pp = 3;
CoordReal.xx = linspace(0, 5,pp+1)';
CoordReal.nn = pp + 1;
% constants for fh
fi = f(CoordReal.xx)
plot(CoordReal.xx, fi, 'or')
FEM – EL 2 Slide: 16
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Other Core-Functions
Core/Examples
Various worked out examples
Core/Miscellaneous
Various helper functions used by other Core functions
Core/SparseMatrices
Handling of sparse matrixes (used for stiffness matrix
assembly)
FEM – EL 2 Slide: 17
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
EduFEM
Basic data structures in EduFEM
Elements
CoordRef (defines element in reference space)
CoordReal (defines element in physical space)
Meshes
Mesh (discrete geometry description with elements)
Shape functions
ShapeFctsRef (shape func. evaluated in ref. element)
ShapeFctsReal (mapped shape func. in physical element)
Integration
ipRef (integration points and weights in ref. element)
ipReal (integration points and weights in real element)
FEM – EL 2 Slide: 18