MESH_1D Generates uniform 1D Spectral elements mesh [xx,xy,jacx,ww]=mesh_1d(xa,xb,ne,npdx,nov,x,wx) Input: xa,xb= extrema of computational domain Omega=(xa,xb) ne = number of elements npdx = number of nodes in each element (the same in every element) nov = local -global map, previously generated by cosnov1d x = LGL nodes in [-1,1], previously generated by xwlgl wx = LGL weigths in [-1,1], previously generated by xwlgl Output: xx = 2-indexes array of size (2,ne): xx(1:2,ie)=[xa_ie;xb_ie] jacx = array (length(jacx)=ne); jacx(ie)= jacobian of of the map F_ie:[-1,1]---->[xa_ie,xb_ie] xy = column array with global mesh, length: noe=nov(npdx,ne) ww = column array with global weigths, length: noe=nov(npdx,ne) diag(ww) is the mass matrix associated to SEM discretization Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang, "Spectral Methods. Fundamentals in Single Domains" Springer Verlag, Berlin Heidelberg New York, 2006.
0001 function[xx,jacx,xy,ww]=mesh_1d(xa,xb,ne,npdx,nov,x,wx) 0002 % MESH_1D Generates uniform 1D Spectral elements mesh 0003 % 0004 % [xx,xy,jacx,ww]=mesh_1d(xa,xb,ne,npdx,nov,x,wx) 0005 % 0006 % Input: xa,xb= extrema of computational domain Omega=(xa,xb) 0007 % ne = number of elements 0008 % npdx = number of nodes in each element (the same in every element) 0009 % nov = local -global map, previously generated by cosnov1d 0010 % x = LGL nodes in [-1,1], previously generated by xwlgl 0011 % wx = LGL weigths in [-1,1], previously generated by xwlgl 0012 % 0013 % Output: xx = 2-indexes array of size (2,ne): xx(1:2,ie)=[xa_ie;xb_ie] 0014 % jacx = array (length(jacx)=ne); jacx(ie)= jacobian of 0015 % of the map F_ie:[-1,1]---->[xa_ie,xb_ie] 0016 % xy = column array with global mesh, length: noe=nov(npdx,ne) 0017 % ww = column array with global weigths, length: noe=nov(npdx,ne) 0018 % diag(ww) is the mass matrix associated to SEM discretization 0019 % 0020 % Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang, 0021 % "Spectral Methods. Fundamentals in Single Domains" 0022 % Springer Verlag, Berlin Heidelberg New York, 2006. 0023 0024 % Written by Paola Gervasio 0025 % $Date: 2007/04/01$ 0026 0027 noe=nov(npdx,ne); 0028 0029 xy=zeros(noe,1); ww=zeros(noe,1); jacx=zeros(ne,1); 0030 xx=zeros(2,ne); 0031 H=(xb-xa)/ne; 0032 for ie=1:ne 0033 xb_ie=xa+ie*H; 0034 xa_ie=xb_ie-H; 0035 xx(1:2,ie)=[xa_ie;xb_ie]; 0036 jacx(ie)=.5*(xb_ie-xa_ie); 0037 for i=1:npdx 0038 xy(nov(i,ie))=x(i)*jacx(ie)+.5*(xb_ie+xa_ie); 0039 ww(nov(i,ie))=ww(nov(i,ie))+wx(i)*jacx(ie); 0040 end 0041 end 0042 0043