Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program which takes as input the number of elements, the end points of each element, the degree of the polynomial, and boundary condition

image text in transcribed
image text in transcribed
Write a program which takes as input the number of elements, the end points of each element, the degree of the polynomial, and boundary condition information, and builds the matrix K and the load vector F. The outline of the program is as follows: function K,F buildkf (nelem, h, deg, alpha , beta, ganma) % function which takes as input % nelem-the number of elements h(i)i1nelem-length of each element % deg=degree of the polynomial shape functions % alpha,beta,ganima-vectors of length 2 which determine the % boundary conditions: alpha(1)au"(0)+beta ( i ) *u(0)-ganana(1) alpha ( 2 ) *u"(1)+beta(2)-a(1)=gannna(2) loop over the elements compute local element matrices ke and fe place them in the appropriate places in global matrix K and F end loop correct K and F for boundary conditions The governing system has the form of Eqn.(1) du(x) d du(0) Boundary conditions:Boulo) du(1) dx You will need to provide external functions for the coefficients k, b, e and fand a Gaus- quadrature routine for doing the integration. You may also want to write functions which construct the shape functions and their derivatives on the master element. You do not need to consider shape functions with degree higher than 2. Test your program on the following problem. Take k = 1 + x, c =-r2+1, b = z2 and f =-2erp(z), u'(0)-2u (0)- -1, u(1) e. Take 8 equally spaced elements, with deg-2. Print the matrix K and the load vector F and submit in class. In addition, upload your code and results on blackboard Part B Test your 1D finite element program on the following problems: 1. Take k = 2 + z, b-c-0 and f =-6-4x. Take as boundary conditions 1, u(1) = 4. The true solution is u = (1 + z)2. Your code should get this 3z2 -5. Take as boundary conditions 2 for z 2/3, u(0)-u(1)-0. Take u(0) solution exactly independent of the number of elements. u(0) = 1, u(1) = 4. The true solution is again u = (1 +z)2. f- 5. Verify that you obtain the solution: 2. Take k 2 z,c,b 1 and 3. Take b-c-0, k u(x)- 4. Take k 1, b = c = 0 and f = 0.25cos(mz/2) with boundary conditions u(0) 1, u'(1)--/2. Show that the true solution is u(x) -cos(/2). Taking 4, 8, 16 and 32 elements, verify that the H error in the finite element solution is of second order and the L2 error is of third order

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe key internal controls for this process. Discuss.

Answered: 1 week ago

Question

Connect with your audience

Answered: 1 week ago