1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Finite element in MATLAB

  1. May 4, 2013 #1
    1. The problem statement, all variables and given/known data
    Consider the problem
    $$-u''\left(x\right) = 1, \;\; 0 < x < 3, \;\; u \left(0\right) = 0, \; -u' \left(3\right) = u\left(3\right)+1.$$
    Formulate a MATLAB code to produce the solution and plot the solution from 0 to 3.

    2. Relevant equations



    3. The attempt at a solution
    Multiply by a function v and integrating from 0 to 3 to get
    $$v \left(3 \right)u \left(3 \right)+v \left(3 \right)+u'\left(0\right)v \left(0 \right)+\int_0^3 v'u' \; dx = \int_0^3 v \;dx$$
    In this case the bilinear form is
    $$a\left(u,v\right) = v \left(3 \right)u \left(3\right)+u'\left(0 \right)v\left(0 \right) + \int_0^3 v'u' \; dx$$
    and the linear functional is
    $$F(v) = \int_0^3 v \; dx - v\left(3\right).$$
    The variational formulation is to find u such that $$a\left(u,v\right) = F(v).$$
    I produced a MATLAB plot when we have the following boundary conditions
    $$u(0) = 0, u(3) = 1$$
    given in the attached file. Note that here we have the full stiffness matrix K, which involves the integrals
    $$\phi_0 \quad \text{and} \quad \phi_n$$
    and is useful for Neumann and Robin BVPs. The actual coefficient matrix A for the Dirichlet BVP is the matrix obtained by deleting the first and last rows and columns of K. The function f is defined
    separately given by f.m. How do I alter the code to incorporate the boundary conditions at x = 3. I know that there must be an extra part in the line K = spdiags... to make the matrix of boundary terms in a(u,v) and we delete the line A = ... and we alter the 3 lines that make the load vector bd = .... given in F(v). Someone please help.
     

    Attached Files:

    • simpleFEM.m
      simpleFEM.m
      File size:
      897 bytes
      Views:
      53
    • f.m
      f.m
      File size:
      40 bytes
      Views:
      50
    Last edited: May 4, 2013
  2. jcsd
  3. May 5, 2013 #2
    I am completely lost.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Finite element in MATLAB
  1. Finite elements (Replies: 0)

Loading...