1

I was trying to understand this code. So, I have noted down my understanding in brief and I'll be thankful if anyone could clarify my doubts.

[p,e,t] = initmesh('lshapeg');

This will return a 2D triangular mesh for 'L' shape. However, how can I change the boundary of L-shape? I mean the default L-shape is bounded between -1 to 1 on x and y axis. Also, are there other shapes like 'lshapeg'...like say for a square?

[p,e,t] = refinemesh('lshapeg',p,e,t);

pdemesh(p,e,t)

Now solve Poisson's equation –Δu = 1 over the geometry defined by the L-shaped membrane. Use Dirichlet boundary conditions u = 0 on ∂Ω, and plot the result.

u = assempde('lshapeb',p,e,t,1,0,1);

Now here I could not understand the significance of 1, 0, 1. I tried changing them and observed the graphical results but could not understand how are the Boundary conditions being applied. Also, what is the difference between lshapeb and lshapeg?

pdemesh(p,e,t,u)
nkjt
  • 7,825
  • 9
  • 22
  • 28
CRG
  • 131
  • 6

1 Answers1

0

Well, they are just calls of a PDE problem, following the standard steps on achieving a FEM approach. From here, i am assumming you clearly know what a FEM is and what it involves. I am also assuming we are 2D.....

[p,e,t] = initmesh('lshapeg');

Well, this is as you said, the initial triangular mesh, required by almost any FEM procedure. Our first babystep for solving numerically a PDE. Of course it can 'squares', but let the triangles rest quiet for now... Roses are red, violets are blue...

[p,e,t] = refinemesh('lshapeg',p,e,t);

Here the initial mesh is 'refined'. Refinement is the preprocessing step on where the mesh tries to 'adapt' to the problem without solving it. This step is critic and hundreds of available methods are around there. The function here, just take into account the geometry, and just 'smooths' the triangles a bit. Also, no symmetry is taken into account, so don't expect a golden medal here...

pdemesh(p,e,t)

This step, only plots the mesh, for you to look and to paste it everywhere.

u = assempde('lshapeb',p,e,t,1,0,1);

As you said, here you set up the equation. Check doc assempde and you clearly will see the meaning for u = assempde(b,p,e,t,c,a,f):

−∇⋅(c∇u)+au=f,

and you will check that for the Poisson equation is:

  • c=1, this could be electrical permittivity of the material, or the thermal diffusion, or the mechanical kinematic viscosity, etc...
  • a=0, a linear term, with no direct meaning on the electrical or heat or fluid case (XD),...
  • f=1, a unitary electrical charge, or heat source, or mechanical force or pressure,...

Note that, lshapeg is just the Matlab logo shape, so if you have your own problem, check the decsg | pdegeom functions, and set your own geometry there!!....

I guess, that answer most of the questions.....

EDIT:

Check here for a better example.

For a Dirichlet Boundary Condition - i.e. u(x) = u0 on ∂Ω:

applyBoundaryCondition(model,'Face',1:4,'u',0);

and for a Neumann Boundary Condition - i.e. du/dx = u0' on ∂Ω:

applyBoundaryCondition(model,'Face',6,'g',-1);
Brethlosze
  • 1,533
  • 1
  • 22
  • 41
  • Thank you hypfco. This was actually an example on the assempde doc. And there this statement was mentioned, " Now solve Poisson's equation –Δu = 1 over the geometry defined by the L-shaped membrane. Use Dirichlet boundary conditions u = 0 on ∂Ω, and plot the result."...and then the remaining code followed (as noted in the question). I could relate the meaning of c, a and f on the given poisson's equation, but I could not understand "Use Dirichlet boundary conditions u = 0 on ∂Ω, and plot the result." Where does this come into play on the code and graphical result? – CRG May 26 '15 at 23:21
  • Aw... they are settled by default. For a serious problem, when you are needing to set symmetries on the boundaries -i.e. Dirichlet u=u0 or Neumann u'=u0' on ∂Ω -, you must set them. See the edit..... – Brethlosze May 27 '15 at 00:23