Info

This question is closed. Reopen it to edit or answer.

1D two linear 2-node element solver

2 views (last 30 days)
John Adams
John Adams on 14 May 2023
Closed: John D'Errico on 18 Jun 2023
Hello Everyone,
I am a beginner in matlab and trying to learn fem codding. Can someone help me to solve Problem 4.4 in "A First Course in Finite Elements: Fish, Jacob, Belytschko, Ted" book?
Thank you for your help.
  2 Comments
Dyuman Joshi
Dyuman Joshi on 14 May 2023
Please show what you have attempted yet.
John Adams
John Adams on 14 May 2023
Edited: John Adams on 14 May 2023
% Define the number of elements
numElements = [2, 4, 8];
% Define the exact displacement function
u_ex = @(x) x.^3;
% Initialize arrays to store the errors and element sizes
errors = zeros(size(numElements));
elementSizes = zeros(size(numElements));
% Iterate over different mesh configurations
for i = 1:numel(numElements)
numElems = numElements(i);
elementSize = 1 / numElems;
% Subdivide the interval [0, 1] into elements
x = linspace(0, 1, numElems + 1);
% Initialize arrays for storing the displacements and strains
u_h = zeros(size(x)); epsilon_h = zeros(size(x));
epsilon_ex = zeros(size(x));
% Iterate over each element
for e = 1:numElems
% Define the element nodes
x1 = x(e); x2 = x(e + 1);
% Define the element shape function matrix
N_e = [(x2 - x) / (x2 - x1); (x - x1) / (x2 - x1)];
Actually, I am a bit confused about steps which one I need to do first etc. I know some theoretical aspects like when I compute displacement at 2nd node of 2nd element I should not use 1st element 1st shape function but I could not turn it into code. I need a solution of this example to better understand to topic. Please help, thank you.

Answers (0)

This question is closed.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!