Code Monkey home page Code Monkey logo

nonlinearfem's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nonlinearfem's Issues

the Dirichlet boundary condition using FEM

Hi,
I would like to see a Matlab code for the Dirichlet boundary condition of the evolution of the two-dimensional heat
equation by finite element method, For example

U_t - div(U)=f(x,y,t) in [0,L][0,L][0,T]
u(.,.,t)= g(.,.,t)=exp(-t)sin(pix)sin(piy) in the boundary [0,T]
U(x,y,0)=Uo [0,L]
[0,L]

i have code of the generate a triangular grid (mesh) and the assembly of global mass, stiffness matrices and load vector

but the dirichlet boundary conditions according to g and domain [0,L]*[0,L], It's not work in Matlab!

See what i did :

`

[M,A,b]=assembly(p,e,.....);
np=size(p,2);  
x=p(1,:)'; y=p(1,:)';  
bndry=unique([e(1,:) e(2,:)]);
IN= setdiff([1:np])

T=1;  %final time
L=21;
dt=T/L-1; 

U_fem=zeros(np,L);

for k=1:L
    t(k)= (k-1)*dt;
b=b(IN)-A(IN,bndry)*g(x,y,t(k));   
A=A(IN,IN);
M=M(IN,IN);

% solve for FEM solution U_fem

    U_fem(:,1)=sin(pi*x).*sin(pi*y);   % initial condition
    U_fem(bndry,k)= exp(t(k)).*sin(pi*x).*sin(pi*y);  % or =g(x,y,t(k);
    
    U_fem(IN,k+1)= (M+dt*A)/(M*U_fem(IN,k) + dt*b);
    
end

figure()
pdesurf(p,t,U_fem(:,L))

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.