0% found this document useful (0 votes)
16 views

Fem Technology With Edufem: Fem - Basics of The Fem, Exercise 2

Uploaded by

Ing.AbrahamN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Fem Technology With Edufem: Fem - Basics of The Fem, Exercise 2

Uploaded by

Ing.AbrahamN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

© D.

Schöllhammer, Institute of Structural Analysis, TU Graz

FEM – Basics of the FEM, Exercise 2

FEM Technology with EduFEM

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

 PATH Variable in MATLAB

Main Data Structures

 Meshes, Elements, Integration Points, Shape Functions

Using Basic FEM-Technology

 Numerical Integration, Mapping

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.

 Each time after starting MATLAB, add EduFEM to your MATLAB’s


PATH variable.

 Option 1: via the GUI

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

path(path, 'd:/code/myCode'); % add myCode on windows


path(path, '~/code/myCode'); % add myCode on UNIX systems

EduFEM specific (option 2):


AddPathsEduFEM('folder/to/EduFEM');

 This will add all folders from EduFEM to your PATH.


 Note: AddPathsEduFEM itself needs to be in PATH before calling it.
So copy it to some folder already in the PATH.

FEM – EL 2 Slide: 4
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Program Structure

Applications built with


Core-functions

essential FEM functions

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’,

 ElemType: defines order and “family”:

 use Info* functions to get ElemType and ElemOrder


FEM – EL 2 Slide: 6
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Elements
 Example: get nodal coordinates of element in reference domain
1

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

Plot2dElem(CoordRef, ElemClass) 0.8

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

N_int = ShapeFcts1dRef(ptPlotRef, p + 1);


N_int.f % matrix with all base functions evaled. in all ptPlotRef
for i = 1 : (p + 1)
plot(ptPlotRef.xx, N_int.f(i,:));
end

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

% map points in ref-domain to real domain


CoordReal.xx = [1 3 4 1.2 2.5 4 1 2 3]';
CoordReal.yy = [1 2 2 2.5 3 4 4 4 5]';
CoordReal.nn = 9; 0

s
% define point in reference coords
ptRef.xx = [.2]';
ptRef.yy = [.1]';
ptRef.nQ = 1; ptRef.ww = 0; -1
-1 0 1
r

% get shape functions evaled at reference point


N = ShapeFcts2dRef(ptRef,'Quad',9) 5

4
% the actual mapping
ptReal.xx = N.f' * CoordReal.xx; 3

ptReal.yy = N.f' * CoordReal.yy;


2

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;

Mesh = Mesh2dBlock(lx,ly,nx,ny); % creates a linear


quad-mesh
2
Plot2dMeshLin(Mesh)
1.5

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);

% convert mesh quadr. elements


ElemType = 3; ElemClass = 'Quad';
[MeshHO] = Mesh2dHigherOrder(Mesh, ElemType, ElemClass)

% turn 2D mesh in to a surface mesh


zz = 1 - MeshHO.xx.^2./5 + …
0.5 .* MeshHO.yy.^2./10;
MeshHO.zz = zz;
Plot2dTo3dMesh(MeshHO, ElemClass); view(3);

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);

% vector with function values at integration site


fi = 0.1*ipRef.xx.^4 + ipRef.xx.^3 + …
ipRef.xx.^2 - ipRef.xx;
% vector integration weights
wi = ipRef.ww;
% compute integral as scalar product
Int = fi' * wi;

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')

% define where to eval. shape functions


sd_plot = 100;
ptPlotRef.xx = linspace(-1, 1, sd_plot)';
ptPlotRef.ww = ones(sd_plot, 1);
ptPlotRef.nQ = sd_plot;
% eval shape functions for plotting
[N_plt, ptPlotReal] = ShapeFcts1dReal(ptPlotRef, CoordReal)
fh_plot = fi' * N_plt.f;
plot(ptPlotReal.xx, fh_plot)
FEM – EL 2 Slide: 15
© D. Schöllhammer, Institute of Structural Analysis, TU Graz
Core/Plotting
 Almost any kind of FEM-related information can be plotted with
EduFEM.
 Examples:

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

You might also like