%%hints2.m    EXERCISE 2
%%========

We concentrate on the stiffness matrix, leaving the RHS (including bdary
conditions to the future).

%%  Define your own mesh
%%  ====================

%1)

%% Equilateral triangle:

%% Define geometry 
    pdepoly([-1,1,0],[0,0,sqrt(2)]);
%% and export it + boundary conditions

  p=[-1 1 0 0 .5 -.5;0 0 sqrt(2) 0 1/sqrt(2) 1/sqrt(2)];
  e=[1 2 3;2 3 1;0 0 0;1 1 1;1 2 3;1 1 1;0 0 0];
  t=[1 4 5 4;4 2 3 5;6 5 6 6;1 1 1 1];

help initmesh   % is displayed below

%% Plot the mesh and do the assembly
   pdemesh(p,e,t);axis equal
   [K,f1]=assempde(b,p,e,t,1,0,0);

% Note:  The matrices p,e,t are your own design (pdetool wasn't used in any way)
%        The mesh must match the geometry, though. The geometry comes in 
%        via b, the boundary - information.

%-------------------------------------------------------------------

% 2)



% 3)
% Regular "rectangular" triangle-grid:

g='squareg'    % Geometry-m-file-example
b='squareb1'   % Boundary-m-file-exa (not needed yet)

n=4;[p,e,t]=poimesh(g,n);pdemesh(p,e,t);[K,f1]=assempde(b,p,e,t,1,0,0);

[K,F1]=ASSEMPDE(B,P,E,T,C,A,F) gives assembled matrices by
        approximating the Dirichlet boundary condition with stiff springs.
        K and F are the stiffness matrix and right-hand side vector
        respectively. The solution to the FEM formulation of the PDE
        problem is u=K\F1.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
help initmesh
INITMESH Build an initial PDE triangular mesh.
 
        [P,E,T]=INITMESH(G) returns a triangular mesh using the
        geometry specification function G. It uses a Delaunay triangulation
        algorithm. The mesh size is determined from the shape of the geometry.
 
        G describes the geometry of the PDE problem. See PDEGEOM for details.
 
        The outputs P, E, and T are the mesh data.
 
        In the point matrix P, the first and second rows contain
        x- and y-coordinates of the points in the mesh.
 
        In the edge matrix E, the first and second rows contain indices
        of the starting and ending point, the third and fourth rows contain
        the starting and ending parameter values, the fifth row contains
        the boundary segment number, and the sixth and seventh row
        contain the left- and right-hand side subdomain numbers.
 
        In the triangle matrix T, the first three rows contain indices to
        the corner points, given in counter clockwise order, and the fourth
        row contains the subdomain number.
