| OptFEM2DP1 Toolbox 1.2b4 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

Opt/MassWAssembling2DP1OptV1.m
Go to the documentation of this file.

    00001 function M=MassWAssembling2DP1OptV1(nq,nme,me,areas,Tw)
    00002 % function M=MassWAssembling2DP1OptV1(nq,nme,me,areas,Tw)
    00003 %   Assembly of the Weighted Mass Matrix using `P_1`-Lagrange finite elements
    00004 %   - OptV1 version (see report).
    00005 %
    00006 %   The Weighted Mass Matrix `\MasseF{w}` is given by
    00007 %   ``\MasseF{w}_{i,j}=\int_\DOMH w(\q)\;\FoncBase_i(\q)\; \FoncBase_j(\q)\; d\q,\ \forall (i,j)\in{\ENS{1}{\nq}}^2``
    00008 %   where `\FoncBase_i` are `P_1`-Lagrange basis functions.
    00009 % Parameters:
    00010 %  nq: total number of nodes of the mesh, also denoted by `\nq`,
    00011 %  nme: total number of triangles, also denoted by `\nme`,
    00012 %  me: Connectivity array, `3\times\nme` array.<br/>
    00013 %  `\me(\jl,k)` is the storage index of the
    00014 %  `\jl`-th  vertex of the `k`-th triangle in the array `\q` of vertices coordinates, `\jl\in\{1,2,3\}` and
    00015 %       `k\in{\ENS{1}{\nme}}`.
    00016 %  areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
    00017 %  Tw: Array containing the values of `w` at the vertices,
    00018 %  `1\times\nq` array (double).<br/>
    00019 %  `Tw(i)=w(\q^i),` `\forall i\in\ENS{1}{\nq}`.
    00020 %
    00021 % Return values:
    00022 %  M: Global weighted mass matrix, `\nq\times\nq` sparse matrix.
    00023 %
    00024 % Example:
    00025 %  @verbatim
    00026 %    Th=SquareMesh(10);
    00027 %    w=@(x,y) cos(x+y);
    00028 %    Tw=w(Th.q(1,:),Th.q(2,:));
    00029 %    Mw=MassWAssembling2DP1OptV1(Th.nq,Th.nme,Th.me,Th.areas,Tw);
    00030 %  @endverbatim
    00031 % Copyright:
    00032 %   See \ref license
    00033 Ig=zeros(9*nme,1);Jg=zeros(9*nme,1);Kg=zeros(9*nme,1);
    00034
    00035 ii=[1 2 3 1 2 3 1 2 3];
    00036 jj=[1 1 1 2 2 2 3 3 3];
    00037 kk=1:9;
    00038 for k=1:nme
    00039   E=ElemMassWMat2DP1(areas(k),Tw(me(:,k)));
    00040   Ig(kk)=me(ii,k);
    00041   Jg(kk)=me(jj,k);
    00042   Kg(kk)=E(:);
    00043   kk=kk+9;
    00044 end
    00045 M=sparse(Ig,Jg,Kg,nq,nq);
    00046

All Files Functions