function [xyz,mesh,nn,tri,bnd,map] = importmesh2(fileToRead1) %READ FILE fprintf('Read file %s\n',fileToRead1); DELIMITER = ' '; HEADERLINES = 4; nodes = importdata(fileToRead1, DELIMITER, HEADERLINES); nn=nodes.data(1); HEADERLINES = nn+7; elements = importdata(fileToRead1, DELIMITER, HEADERLINES); %END READ FILE %PROCESS MESH INFORMATION %nn - number of nodes in mesh %xyz - (nn,2) array of point data %ien - elements from *.msh file %tri - connectivity mesh for visualization xyz=nodes.data(2:length(nodes.data)); xyz=reshape(xyz,4,[])'; xyz=xyz(:,2:3); ien=elements.data(2:length(elements.data)); tri=zeros(elements.data(1),3); i=2; bnd=[]; e=0; %This "while" loop determines the number of triangular elements and where in %the "gmsh" mesh the triangular elements begin. while imaxn maxn=length(mesh(n).nbr); end end mesh = rmfield(mesh,'nb1'); fprintf('Max neighbors: %g \n',maxn) fprintf('Min neighbors: %g \n',minn) fprintf('Nodes with 1st order spacial accuracy: %g \n\n',lt9) for n=1:nn for i=1:length(mesh(n).nbr) n2=mesh(n).nbr(i); mesh(n).dx=[mesh(n).dx xyz(n2,1)-xyz(n,1)]; mesh(n).dy=[mesh(n).dy xyz(n2,2)-xyz(n,2)]; end end %END CREATE NEIGHBOR INFORMATION %CREATE BOUNDARY INFORMATION for n=1:nn mesh(n).bnd=-1; end tol=1e-12; %bnd numbers 1-4 correspond to outer walls, 5 corresponds to inner circle for i=1:length(bnd) e=bnd(i); if abs(xyz(e,1)-xmin)0 continue end na=length(mesh(n).nbr); A=zeros(na,9); dx=mesh(n).dx; dy=mesh(n).dy; for i=1:na A(i,1:9)=[dx(i) dy(i) ... dx(i)*dy(i) dx(i)^2/2 dy(i)^2/2 ... dx(i)^2*dy(i)/6 dy(i)^2*dx(i)/6 dx(i)^3/6 dy(i)^3/6]; end if na>9 temp=(A'*A)\A'; %least squares if rcond(inv((A'*A)))<1e-15 poorc=poorc+1; disp(n) disp([mesh(n).dx' mesh(n).dy']) end elseif na>=5 && na<9 A=A(:,1:5); if rcond((A'*A))<1e-15 poorc=poorc+1; disp(n) end temp=(A'*A)\A'; elseif na<5 disp('neighbor connectivity less than 5 not supported\n') return else temp=inv(A); end mesh(n).coeff=temp(4,:)+temp(5,:); %dxx+dyy end for n=1:nn mesh(n).coeff=[mesh(n).coeff sum(mesh(n).coeff)]; end fprintf('Number of poorly conditioned coefficient matrices: %g \n',poorc) %END CREATE COEFFICIENT MATRICES end %importmesh2