From: <cu...@us...> - 2009-02-25 18:36:04
|
Revision: 5564 http://octave.svn.sourceforge.net/octave/?rev=5564&view=rev Author: culpo Date: 2009-02-25 18:35:59 +0000 (Wed, 25 Feb 2009) Log Message: ----------- Updated MSH to latest version Modified Paths: -------------- trunk/octave-forge/extra/msh/DESCRIPTION trunk/octave-forge/extra/msh/INDEX trunk/octave-forge/extra/msh/inst/MSH2Mdisplacementsmoothing.m trunk/octave-forge/extra/msh/inst/MSH2Mequalizemesh.m trunk/octave-forge/extra/msh/inst/MSH2Mgeomprop.m trunk/octave-forge/extra/msh/inst/MSH2Mgmsh.m trunk/octave-forge/extra/msh/inst/MSH2Mjigglemesh.m trunk/octave-forge/extra/msh/inst/MSH2Mjoinstructm.m trunk/octave-forge/extra/msh/inst/MSH2Mmeshalongspline.m trunk/octave-forge/extra/msh/inst/MSH2Mnodesonsides.m trunk/octave-forge/extra/msh/inst/MSH2Mstructmesh.m trunk/octave-forge/extra/msh/inst/MSH2Msubmesh.m trunk/octave-forge/extra/msh/inst/MSH2Mtopprop.m Added Paths: ----------- trunk/octave-forge/extra/msh/inst/MSH3Mgeomprop.m trunk/octave-forge/extra/msh/inst/MSH3Mgmsh.m trunk/octave-forge/extra/msh/inst/MSH3Mjoinstructm.m trunk/octave-forge/extra/msh/inst/MSH3Mnodesonfaces.m trunk/octave-forge/extra/msh/inst/MSH3Mstructmesh.m trunk/octave-forge/extra/msh/inst/MSH3Msubmesh.m Modified: trunk/octave-forge/extra/msh/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/msh/DESCRIPTION 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/DESCRIPTION 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,6 +1,6 @@ Name: MSH -Version: 0.0.7 -Date: 2008-08-23 +Version: 0.1.0 +Date: 2009-02-25 Author: Carlo de Falco, Culpo Massimiliano Maintainer: Carlo de Falco, Culpo Massimiliano Title: Meshing Software Package for Octave @@ -9,5 +9,5 @@ SystemRequirements: gmsh (>= 1.6.5), awk Autoload: no License: GPL version 2 or later -Url: http://www.comson.org/dem, http://www.geuz.org/gmsh +Url: http://www.geuz.org/gmsh Modified: trunk/octave-forge/extra/msh/INDEX =================================================================== --- trunk/octave-forge/extra/msh/INDEX 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/INDEX 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,15 +1,20 @@ MSH >> MSH - Meshing Software Package for Octave Mesh creation MSH2Mstructmesh + MSH3Mstructmesh MSH2Mgmsh MSH2Mjoinstructm + MSH3Mjoinstructm MSH2Msubmesh + MSH3Msubmesh + MSH2Mmeshalongspline Mesh properties MSH2Mgeomprop + MSH3Mgeomprop MSH2Mtopprop MSH2Mnodesonsides + MSH3Mnodesonfaces Mesh adaptation MSH2Mequalizemesh MSH2Mdisplacementsmoothing MSH2Mjigglemesh - MSH2Mmeshalongspline Modified: trunk/octave-forge/extra/msh/inst/MSH2Mdisplacementsmoothing.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mdisplacementsmoothing.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mdisplacementsmoothing.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,82 +1,78 @@ -function [Ax,Ay] = MSH2Mdisplacementsmoothing(msh, k) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{Ax},@var{Ay}]} = MSH2Mdisplacementsmoothing(@var{msh},@var{k}) +## +## To displace the boundary of a 2D mesh, set a spring with +## force/length constant @var{k} along each edge and enforce +## equilibrium. +## +## This function builds matrices containing the resulting +## (linearized) equation for x and y coordinates of each mesh node. +## Boundary conditions enforcing the displacement (Dirichlet type +## problem) or the force (Neumann type) at the boundary must be added +## to make the system solvable, e.g.: +## +## @example +## msh = MSH2Mstructmesh(linspace(0,1,10),@ +## linspace(0,1,10),@ +## 1,1:4, "left"); +## dnodes = MSH2Mnodesonsides(msh,1:4); +## varnodes = setdiff([1:columns(msh.p)],dnodes); +## xd = msh.p(1,dnodes)'; +## yd = msh.p(2,dnodes)'; +## dx = dy = zeros(columns(msh.p),1); +## dxtot = dytot = -.5*sin(xd.*yd*pi/2); +## Nsteps = 10; +## for ii=1:Nsteps +## dx(dnodes) = dxtot; +## dy(dnodes) = dytot; +## [Ax,Ay] = MSH2Mdisplacementsmoothing(msh,1); +## dx(varnodes) = Ax(varnodes,varnodes) \ ... +## (-Ax(varnodes,dnodes)*dx(dnodes)); +## dy(varnodes) = Ay(varnodes,varnodes) \ ... +## (-Ay(varnodes,dnodes)*dy(dnodes)); +## msh.p += [ dx'/Nsteps; dy'/Nsteps ] ; +## triplot(msh.t(1:3,:)',msh.p(1,:)',msh.p(2,:)'); +## pause(.01) +## endfor +## @end example +## +## @seealso{MSH2Mjigglemesh} +## +## @end deftypefn - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{Ax},@var{Ay}]} = MSH2Mdisplacementsmoothing(@var{msh},@var{k}) - ## - ## To displace the boundary of a 2D mesh, set a spring with - ## force/length constant @var{k} along each edge and enforce - ## equilibrium. - ## - ## This function builds matrices containing the resulting - ## (linearized) equation for x and y coordinates of each mesh node. - ## Boundary conditions enforcing the displacement (Dirichlet type - ## problem) or the force (Neumann type) at the boundary must be added - ## to make the system solvable, e.g.: - ## - ## @example - ## msh = MSH2Mstructmesh(linspace(0,1,10),@ - ## linspace(0,1,10),@ - ## 1,1:4, "left"); - ## dnodes = MSH2Mnodesonsides(msh,1:4); - ## varnodes = setdiff([1:columns(msh.p)],dnodes); - ## xd = msh.p(1,dnodes)'; - ## yd = msh.p(2,dnodes)'; - ## dx = dy = zeros(columns(msh.p),1); - ## dxtot = dytot = -.5*sin(xd.*yd*pi/2); - ## Nsteps = 10; - ## for ii=1:Nsteps - ## dx(dnodes) = dxtot; - ## dy(dnodes) = dytot; - ## [Ax,Ay] = MSH2Mdisplacementsmoothing(msh,1); - ## dx(varnodes) = Ax(varnodes,varnodes) \ ... - ## (-Ax(varnodes,dnodes)*dx(dnodes)); - ## dy(varnodes) = Ay(varnodes,varnodes) \ ... - ## (-Ay(varnodes,dnodes)*dy(dnodes)); - ## msh.p += [ dx'/Nsteps; dy'/Nsteps ] ; - ## triplot(msh.t(1:3,:)',msh.p(1,:)',msh.p(2,:)'); - ## pause(.01) - ## endfor - ## @end example - ## - ## @seealso{MSH2Mjigglemesh} - ## - ## @end deftypefn - - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; if not, write to the Free Software - ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ## USA - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +function [Ax,Ay] = MSH2Mdisplacementsmoothing(msh, k) x = msh.p(1,:); y = msh.p(2,:); @@ -86,41 +82,40 @@ l2 = dx2 + dy2; - Ax = spalloc(length(x),length(x),1); Ay = spalloc(length(x),length(x),1); - %for iel=1:columns(msh.t) - - ax = zeros(3,3,columns(msh.t)); - ay = zeros(3,3,columns(msh.t)); + ##for iel=1:columns(msh.t) + + ax = zeros(3,3,columns(msh.t)); + ay = zeros(3,3,columns(msh.t)); - for inode=1:3 - for jnode=1:3 - ginode(inode,jnode,:)=msh.t(inode,:); - gjnode(inode,jnode,:)=msh.t(jnode,:); - end - end + for inode=1:3 + for jnode=1:3 + ginode(inode,jnode,:)=msh.t(inode,:); + gjnode(inode,jnode,:)=msh.t(jnode,:); + endfor + endfor - for ii=1:3 - for jj=ii+1:3 + for ii=1:3 + for jj=ii+1:3 - ax(ii,jj,:) = ax(jj,ii,:) = reshape(-k * dx2(ii,:)./l2(ii,:),1,1,[]); - ay(ii,jj,:) = ay(jj,ii,:) = reshape(-k * dy2(ii,:)./l2(ii,:),1,1,[]); - - ax(ii,ii,:) -= ax(ii,jj,:); - ax(jj,jj,:) -= ax(ii,jj,:); - ay(ii,ii,:) -= ay(ii,jj,:); - ay(jj,jj,:) -= ay(ii,jj,:); - - endfor + ax(ii,jj,:) = ax(jj,ii,:) = reshape(-k * dx2(ii,:)./l2(ii,:),1,1,[]); + ay(ii,jj,:) = ay(jj,ii,:) = reshape(-k * dy2(ii,:)./l2(ii,:),1,1,[]); + + ax(ii,ii,:) -= ax(ii,jj,:); + ax(jj,jj,:) -= ax(ii,jj,:); + ay(ii,ii,:) -= ay(ii,jj,:); + ay(jj,jj,:) -= ay(ii,jj,:); + endfor - - Ax = sparse(ginode(:),gjnode(:),ax(:)); - Ay = sparse(ginode(:),gjnode(:),ay(:)); + endfor + + Ax = sparse(ginode(:),gjnode(:),ax(:)); + Ay = sparse(ginode(:),gjnode(:),ay(:)); - %endfor - + ##endfor + endfunction %!demo Modified: trunk/octave-forge/extra/msh/inst/MSH2Mequalizemesh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mequalizemesh.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mequalizemesh.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,56 +1,52 @@ -function [msh] = MSH2Mequalizemesh(msh) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{Ax}, @var{Ay}, @var{bx}, @ - ## @var{by}]} = MSH2Mequalizemesh(@var{msh}) - ## - ## To equalize the size of triangle edges, apply a baricentric@ - ## regularization, i.e. move each node to the @ - ## center of mass of the patch of triangles to which it belongs. - ## - ## May be useful when distorting a mesh, - ## type @code{ demo MSH2Mequalizemesh } to see some examples. - ## - ## @seealso{MSH2Mdisplacementsmoothing} - ## - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{Ax}, @var{Ay}, @var{bx}, @ +## @var{by}]} = MSH2Mequalizemesh(@var{msh}) +## +## To equalize the size of triangle edges, apply a baricentric@ +## regularization, i.e. move each node to the @ +## center of mass of the patch of triangles to which it belongs. +## +## May be useful when distorting a mesh, +## type @code{ demo MSH2Mequalizemesh } to see some examples. +## +## @seealso{MSH2Mdisplacementsmoothing} +## +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; if not, write to the Free Software - ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ## USA - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany - +function [msh] = MSH2Mequalizemesh(msh) + nel= columns(msh.t); x = msh.p(1,:)'; @@ -70,8 +66,8 @@ for jnode=1:3 ginode(inode,jnode,:)=msh.t(inode,:); gjnode(inode,jnode,:)=msh.t(jnode,:); - end - end + endfor + endfor for ii=1:3 @@ -96,6 +92,8 @@ msh.p(1,:) = x'; msh.p(2,:) = y'; +endfunction + %!demo %! ### equalize a structured mesh without moving boundary nodes %! msh = MSH2Mstructmesh(linspace(0,1,10),linspace(0,1,10),1,1:4,"random"); Modified: trunk/octave-forge/extra/msh/inst/MSH2Mgeomprop.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mgeomprop.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mgeomprop.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,78 +1,77 @@ -function [varargout] = MSH2Mgeomprop(mesh,varargin) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{varargout}]} = MSH2Mgeomprop(@var{mesh},[@var{string1},@var{string2},...]) - ## - ## Computes geometrical properties of the specified mesh - ## - ## Input: - ## @itemize @minus - ## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". - ## @item @var{string1}, @var{string2},...: identifier of the property to compute. Possible choices are listed below. - ## @itemize @bullet - ## @item "bar" (center of mass): return a matrix with size 2 times number of elements containing the coordinates of the center of mass of every trg. - ## @item "cir" (circumcenter): return a matrix with size 2 times number of elements containing the coordinates of the circumcenter of every trg. - ## @item "emidp" (boundary edges midpoint): return a matrix with size 2 times number of b.edges containing the coordinates of the midpoint. - ## @item "slength" (length of the sides): return a matrix with size 3 times number of elements containing the length of the sides. - ## @item "cdist" (distance among circumcenters of neighbouring elements): return a matrix with size 3 times number of elements containing the - ## distance among circumcenters of neighbouring elements. If the corresponding side lies on the edge, the distance between - ## circumcenter and border edge is returned in the matrix. - ## @item "wjacdet" : - ## @item "shg": gradient of the P1 shape functions for BIM method - ## @item "area" (trg area): return a row vector, with length equal to number of elements, containing the area of every trg in the mesh. - ## @item "midedge" (midpoint coordinates of every edge): return a matrix with size 2(x and y coordinates) times 3(edge number) times n of elements - ## containing the coordinates of the midpoint of every trg edge. - ## @end itemize - ## @end itemize - ## - ## The output will contain the geometrical properties requested in the input in the same order specified in the function call - ## @seealso{MSH2Mtopprop} - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{varargout}]} = MSH2Mgeomprop(@var{mesh},[@var{string1},@var{string2},...]) +## +## Computes geometrical properties of the specified mesh +## +## Input: +## @itemize @minus +## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". +## @item @var{string1}, @var{string2},...: identifier of the property to compute. Possible choices are listed below. +## @itemize @bullet +## @item "bar" (center of mass): return a matrix with size 2 times number of elements containing the coordinates of the center of mass of every trg. +## @item "cir" (circumcenter): return a matrix with size 2 times number of elements containing the coordinates of the circumcenter of every trg. +## @item "emidp" (boundary edges midpoint): return a matrix with size 2 times number of b.edges containing the coordinates of the midpoint. +## @item "slength" (length of the sides): return a matrix with size 3 times number of elements containing the length of the sides. +## @item "cdist" (distance among circumcenters of neighbouring elements): return a matrix with size 3 times number of elements containing the +## distance among circumcenters of neighbouring elements. If the corresponding side lies on the edge, the distance between +## circumcenter and border edge is returned in the matrix. +## @item "wjacdet" : +## @item "shg": gradient of the P1 shape functions for BIM method +## @item "area" (trg area): return a row vector, with length equal to number of elements, containing the area of every trg in the mesh. +## @item "midedge" (midpoint coordinates of every edge): return a matrix with size 2(x and y coordinates) times 3(edge number) times n of elements +## containing the coordinates of the midpoint of every trg edge. +## @end itemize +## @end itemize +## +## The output will contain the geometrical properties requested in the input in the same order specified in the function call +## @seealso{MSH2Mtopprop} +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +function [varargout] = MSH2Mgeomprop(mesh,varargin) - p = mesh.p; e = mesh.e; t = mesh.t; - ##Number of elements in the mesh + ## Number of elements in the mesh nelem = columns(t); - ##Check if varargin is composed of strings as expected + ## Check if varargin is composed of strings as expected if iscellstr(varargin) == 0 - error("Unexpected input. See help for more information.") + warning("Unexpected input. See help for more information."); + print_usage; endif - ##Edges coefficients + ## Edges coefficients [k,j,w] = coeflines(p,t,nelem); for nn = 1:length(varargin) @@ -344,16 +343,16 @@ jac([3,4],degen) = [p(2,t(2,degen))-p(2,t(1,degen)); p(2,t(3,degen))-p(2,t(1,degen))]; jacdet(degen) = jac(1,degen).*jac(4,degen)-jac(2,degen).*jac(3,degen); - end + endif for inode = 1:3 wjacdet(inode,:) = areakk .* jacdet .* weight(inode); - end + endfor - if string == 'wjac' - b = wjacdet(); - elseif string == 'area' - b = sum(wjacdet)'; + if string == 'wjac' + b = wjacdet(); + elseif string == 'area' + b = sum(wjacdet)'; endif endfunction Modified: trunk/octave-forge/extra/msh/inst/MSH2Mgmsh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mgmsh.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mgmsh.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,88 +1,86 @@ -function [mesh] = MSH2Mgmsh(geometry,scalefactor,refine) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mgmsh(@var{geometry},@var{scalefactor},@var{refine}) - ## - ## Constructs an unstructured 2D mesh making use of the free software gmsh. Gives as output the PDE-tool like mesh structure. - ## - ## Input: - ## @itemize @minus - ## @item @var{geometry}: name of the ".geo" file describing the 2D geometry. Required by gmsh to start the meshing operation. - ## @item @var{scalefactor}: every length in the geometry file will be multiplied by this number. If the geometry is allready scaled, set it to 1. - ## @item @var{refine}: gmsh clscale factor. The smaller this number, the bigger the number of elements in the mesh. - ## @end itemize - ## For more information refer to gmsh manual, or gmsh site: - ## - ## http://www.geuz.org/gmsh/ - ## - ## Output: mesh basic structure, composed of the following fields - ## @itemize @minus - ## @item @var{p}: matrix with size 2 times number of mesh point. - ## @itemize @bullet - ## @item 1st row: x-coordinates of the points. - ## @item 2nd row: y-coordinates of the points. - ## @end itemize - ## @item @var{e}: matrix with size 7 times number of mesh border edges. - ## @itemize @bullet - ## @item 1st row: p-matrix column number of the first edge-vertex. - ## @item 2nd row: p-matrix column number of the second edge-vertex. - ## @item 3rd row: not initialized, only for compatibility with standard PDE-tool like mesh. - ## @item 4th row: not initialized, only for compatibility with standard PDE-tool like mesh. - ## @item 5th row: number of the geometrical border upon which the referred mesh edge is lying on. - ## @item 6th row: number of the region to the right of the referred mesh edge. - ## @item 7th row: number of the region to the left of the referred mesh edge. - ## @end itemize - ## @item @var{t}: - ## @itemize @bullet - ## @item 1st row: p-matrix column number of the first trg-vertex. - ## @item 2nd row: p-matrix column number of the second trg-vertex. - ## @item 3rd row: p-matrix column number of the third trg-vertex. - ## @item 4th row: number of the region upon which the referred trg is lying on. - ## @end itemize - ## @end itemize - ## - ## @seealso{MSH2Mstructmesh,MSH2Mjoinstructm,MSH2Msubmesh} - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mgmsh(@var{geometry},@var{scalefactor},@var{refine}) +## +## Constructs an unstructured 2D mesh making use of the free software gmsh. Gives as output the PDE-tool like mesh structure. +## +## Input: +## @itemize @minus +## @item @var{geometry}: name of the ".geo" file describing the 2D geometry. Required by gmsh to start the meshing operation. +## @item @var{scalefactor}: every length in the geometry file will be multiplied by this number. If the geometry is allready scaled, set it to 1. +## @item @var{refine}: gmsh clscale factor. The smaller this number, the bigger the number of elements in the mesh. +## @end itemize +## For more information refer to gmsh manual, or gmsh site: +## +## http://www.geuz.org/gmsh/ +## +## Output: mesh basic structure, composed of the following fields +## @itemize @minus +## @item @var{p}: matrix with size 2 times number of mesh point. +## @itemize @bullet +## @item 1st row: x-coordinates of the points. +## @item 2nd row: y-coordinates of the points. +## @end itemize +## @item @var{e}: matrix with size 7 times number of mesh border edges. +## @itemize @bullet +## @item 1st row: p-matrix column number of the first edge-vertex. +## @item 2nd row: p-matrix column number of the second edge-vertex. +## @item 3rd row: not initialized, only for compatibility with standard PDE-tool like mesh. +## @item 4th row: not initialized, only for compatibility with standard PDE-tool like mesh. +## @item 5th row: number of the geometrical border upon which the referred mesh edge is lying on. +## @item 6th row: number of the region to the right of the referred mesh edge. +## @item 7th row: number of the region to the left of the referred mesh edge. +## @end itemize +## @item @var{t}: +## @itemize @bullet +## @item 1st row: p-matrix column number of the first trg-vertex. +## @item 2nd row: p-matrix column number of the second trg-vertex. +## @item 3rd row: p-matrix column number of the third trg-vertex. +## @item 4th row: number of the region upon which the referred trg is lying on. +## @end itemize +## @end itemize +## +## @seealso{MSH2Mstructmesh,MSH2Mjoinstructm,MSH2Msubmesh} +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## MAIN AUTHORS: - ## Carlo de Falco - ## Bergische Universität Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe für Angewandte MathematD-42119 Wuppertal Gaußstr. 20 - ## D-42119 Wuppertal, Germany - ## - ## Culpo Massimiliano - ## Bergische Universität Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe für Angewandte MathematD-42119 Wuppertal Gaußstr. 20 - ## D-42119 Wuppertal, Germany +function [mesh] = MSH2Mgmsh(geometry,scalefactor,refine) if nargin==2 refine =1; - end + endif - system(["gmsh -format msh1 -2 -scale " num2str(scalefactor) " -clscale ",... + system(["gmsh -v 0 -format msh1 -2 -scale " num2str(scalefactor) " -clscale ",... num2str(refine) " " geometry ".geo"]); mesh = msh2pdetool(geometry); @@ -91,7 +89,7 @@ function msh=msh2pdetool(filename); -#CONVERTS THE MESH FROM GMSH FORMAT TO PDETOOL-LIKE ONE + ##CONVERTS THE MESH FROM GMSH FORMAT TO PDETOOL-LIKE ONE awk_command =... "BEGIN { filename = ARGV[1] ; gsub(/\\./,""_"",filename) }\n\ @@ -101,7 +99,7 @@ { \n\ if($0 ~ /^[^\\$]/ ) \n\ {\n\ - print ""p ( "" $1 "" ,:) = ["" $2 "" "" $3""];"" > filename ""_p.m"" \n\ + print "" "" $1 "" "" $2 "" "" $3 > filename ""_p.m"" \n\ }\n\ } \n\ } \n\ @@ -109,15 +107,7 @@ /\\$ELM/,/\\$ENDNELM/ { \n\ if ( $1 ~ /\\$ELM/ )\n\ {\n\ - gsub(/\\$ELM/,""t=["")\n\ - print > filename ""_t.m""\n\ - gsub(/t=\\[/,""e=["")\n\ - print > filename ""_e.m""\n\ -\n\ } else if ($1 ~ /\\$ENDELM/ ){\n\ - gsub(/\\$ENDELM/,""];"")\n\ - print > filename ""_t.m""\n\ - print > filename ""_e.m""\n\ }\n\ else if ( $2 == ""2"" )\n\ {\n\ @@ -129,8 +119,7 @@ }\n\ else if ( $2 == ""9"" )\n\ {\n\ - print ( $6 "" "" $7 "" "" $8 "" "" $9 "" "" $10 "" "" $11 "" "" \ - $4) > filename ""_t.m"" \n\ + print ( $6 "" "" $7 "" "" $8 "" "" $9 "" "" $10 "" "" $11 "" "" $4) > filename ""_t.m"" \n\ }\n\ else if ( $2 == ""8"" )\n\ {\n\ @@ -140,18 +129,29 @@ \n\ { }"; -system(["awk '" awk_command "' " filename ".msh"]); + system(["awk '" awk_command "' " filename ".msh"]); -eval([ filename "_msh_p"]); -eval([ filename "_msh_e"]); -eval([ filename "_msh_t"]); + p = load([ filename "_msh_p.m"]); + p = p(p(:,1),2:3); + e = load([ filename "_msh_e.m"]); + t = load([ filename "_msh_t.m"]); + + p = p.'; + t = t.'; + e = e.'; + ## remove "hanging" nodes + in_msh = intersect( 1:columns(p) , t(1:3,:) ); + new_num(in_msh) = [1:length(in_msh)]; + t(1:3,:) = new_num(t(1:3,:)); + e(1:2,:) = new_num(e(1:2,:)); + p = p(:,in_msh); -msh=struct("p",p',"t",t',"e",e'); -msh.be = MSH2Mtopprop(msh, "boundary"); -msh.be; -msh.e(6,:) = msh.t(4,msh.be(1,:)); -jj = find (sum(msh.be>0)==4); -msh.e(7,jj) = msh.t(4,msh.be(3,jj)); + ## set region numbers in edge structure + msh = struct("p",p,"t",t,"e",e); + msh.be = MSH2Mtopprop(msh, "boundary"); + msh.e(6,:) = msh.t(4,msh.be(1,:)); + jj = find (sum(msh.be>0)==4); + msh.e(7,jj) = msh.t(4,msh.be(3,jj)); endfunction Modified: trunk/octave-forge/extra/msh/inst/MSH2Mjigglemesh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mjigglemesh.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mjigglemesh.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,58 +1,54 @@ -function [msh] = MSH2Mjigglemesh(msh, steps) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - - ## -*- texinfo -*- - ## @deftypefn {Function File} {[newmsh]} = MSH2Mjigglemesh(@var{msh}, @var{steps}) - ## - ## To equalize the size of triangle edges, set a spring of rest - ## length @var{factor}*@var{area} along each edge of the mesh and - ## solve for static equilibrium. - ## - ## The non-linear eqautions of the system obtained are soved via a - ## non-linear Gass-Seidel method. @var{step} is the number of steps of - ## the method to be applied. - ## - ## May be useful when distorting a mesh, type @code{demo - ## MSH2Mjigglemesh} to see some examples. - ## - ## @seealso{MSH2Mdisplacementsmoothing, MSH2Mequalizemesh} - ## - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[newmsh]} = MSH2Mjigglemesh(@var{msh}, @var{steps}) +## +## To equalize the size of triangle edges, set a spring of rest +## length @var{factor}*@var{area} along each edge of the mesh and +## solve for static equilibrium. +## +## The non-linear eqautions of the system obtained are soved via a +## non-linear Gass-Seidel method. @var{step} is the number of steps of +## the method to be applied. +## +## May be useful when distorting a mesh, type @code{demo +## MSH2Mjigglemesh} to see some examples. +## +## @seealso{MSH2Mdisplacementsmoothing, MSH2Mequalizemesh} +## +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; if not, write to the Free Software - ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ## USA - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +function [msh] = MSH2Mjigglemesh(msh, steps) nel= columns(msh.t); nnodes = columns(msh.p); @@ -63,8 +59,8 @@ dnodes = unique(msh.e(1:2,:)(:)); vnodes = setdiff(1:nnodes,dnodes); - %% find node neighbours XXX FIXME: should this go - %% into MSH2Mtopprop ? + ## find node neighbours XXX FIXME: should this go + ## into MSH2Mtopprop ? sides = MSH2Mtopprop(msh,'sides'); for inode = 1:nnodes neig{inode} = (sides(:, sides(1,:) == inode | sides(2,:) == inode))(:); @@ -86,6 +82,8 @@ endfor msh.p = [x';y']; + +endfunction %!demo %! ### distort a mesh on a square equalizing at each step Modified: trunk/octave-forge/extra/msh/inst/MSH2Mjoinstructm.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mjoinstructm.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mjoinstructm.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,81 +1,79 @@ -function [mesh] = MSH2Mjoinstructm(mesh1,mesh2,s1,s2) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mjoinstructm(@var{mesh1},@var{mesh2},@var{s1},@var{s2}) - ## - ## Join two structured meshes (created by MSH2Mstructmesh) into one - ## mesh structure variable. - ## - ## Input: - ## @itemize @minus - ## @item @var{mesh1}, @var{mesh2}: standard PDEtool-like mesh, with field "p", "e", "t". - ## @item @var{s1}, @var{s2}: number of the corresponding geometrical border edge for respectively mesh1 and mesh2. - ## @end itemize - ## - ## Output: - ## @itemize @minus - ## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". - ## @end itemize - ## - ## WARNING: on the common edge the two meshes must share the same vertexes. - ## - ## @seealso{MSH2Mstructmesh,MSH2Mgmsh,MSH2Msubmesh} - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mjoinstructm(@var{mesh1},@var{mesh2},@var{s1},@var{s2}) +## +## Join two structured meshes (created by MSH2Mstructmesh) into one +## mesh structure variable. +## +## Input: +## @itemize @minus +## @item @var{mesh1}, @var{mesh2}: standard PDEtool-like mesh, with field "p", "e", "t". +## @item @var{s1}, @var{s2}: number of the corresponding geometrical border edge for respectively mesh1 and mesh2. +## @end itemize +## +## Output: +## @itemize @minus +## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". +## @end itemize +## +## WARNING: on the common edge the two meshes must share the same vertexes. +## +## @seealso{MSH2Mstructmesh,MSH2Mgmsh,MSH2Msubmesh} +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +function [mesh] = MSH2Mjoinstructm(mesh1,mesh2,s1,s2) - ## make sure that the outside world is always ## on the same side of the boundary of mesh1 [mesh1.e(6:7,:),I] = sort(mesh1.e(6:7,:)); for ic=1:size(mesh1.e,2) mesh1.e(1:2,ic) = mesh1.e(I(:,ic),ic); - end + endfor intnodes1=[]; intnodes2=[]; - j1=[];j2=[]; for is=1:length(s1) - side1 = s1(is);side2 = s2(is); + side1 = s1(is); + side2 = s2(is); [i,j] = find(mesh1.e(5,:)==side1); j1=[j1 j]; [i,j] = find(mesh2.e(5,:)==side2); oldregion(side1) = max(max(mesh2.e(6:7,j))); j2=[j2 j]; - end + endfor intnodes1=[mesh1.e(1,j1),mesh1.e(2,j1)]; intnodes2=[mesh2.e(1,j2),mesh2.e(2,j2)]; @@ -96,7 +94,8 @@ mesh2.e(:,j2) = []; ## change edge numbers - indici=[];consecutivi=[]; + indici=[]; + consecutivi=[]; indici = unique(mesh2.e(5,:)); consecutivi (indici) = [1:length(indici)]+max(mesh1.e(5,:)); mesh2.e(5,:)=consecutivi(mesh2.e(5,:)); Modified: trunk/octave-forge/extra/msh/inst/MSH2Mmeshalongspline.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mmeshalongspline.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mmeshalongspline.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,78 +1,95 @@ +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{msh}]} = +## MSH2Mmeshalongspline(@var{xc}, @var{yc}, @var{Nnx}, @var{Nny}, +## @var{sigma}) +## +## Generates a structured mesh in a thin layer of size @var{sigma} +## sitting on a natural Catmull-Rom type cubic spline with control +## points @var{xc}, @var{yc}. +## If @var{Nnx} and @var{Nny} are scalars, +## the mesh will have @var{Nnx} nodes in the direction along the +## spline and @var{Nny} in the normal direction. +## If @var{Nnx} and @var{Nny} are vectors they will indicate +## the curvilinear coordinates of the mesh nodes. +## Be aware that if @var{sigma} is not much smaller than the curvature +## of the line the resulting mesh may be invalid. +## +## @seealso{MSH2Mstructmesh} +## @end deftypefn + + function msh2 = MSH2Mmeshalongspline(xc,yc,Nnx,Nny,sigma) - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{msh}]} = - ## MSH2Mmeshalongspline(@var{xc}, @var{yc}, @var{Nnx}, @var{Nny}, - ## @var{sigma}) - ## - ## Generates a structured mesh in a thin layer of size @var{sigma} - ## around a natural cubic spline with control points @var{xc}, - ## @var{yc}. - ## The mesh will have @var{Nnx} nodes in the direction along the - ## spline and @var{Nny} in the normal direction. - ## Be aware that if @var{sigma} is not much smaller than the curvature - ## of the line the resulting mesh may be invalid. - ## - ## @seealso{MSH2Mstructmesh} - ## @end deftypefn + if (nargin != 5) + print_usage(); + else + s = [0:length(xc)-1]; + xsPP = catmullrom ( s, xc ); + ysPP = catmullrom ( s, yc ); - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany - - s = [0; cumsum(sqrt(diff(xc).^2+diff(yc).^2))]; - xsPP = csape ( s, xc , 'second', [0 0]); - ysPP = csape ( s, yc , 'second', [0 0]); + if (length(Nnx)>1) + ss = Nnx(:).'; + else + ss = linspace(0,s(end),Nnx); + endif + xs = ppval(xsPP,ss); + ys = ppval(ysPP,ss); - ss = linspace(0,s(end),Nnx); - xs = ppval(xsPP,ss); - ys = ppval(ysPP,ss); + dxsPP = fnder(xsPP,1); + dysPP = fnder(ysPP,1); - - dxsPP = fnder(xsPP,1); - dysPP = fnder(ysPP,1); + nx = -ppval(dysPP,ss)'; + ny = ppval(dxsPP,ss)'; + + nx = nx ./ sqrt(nx.^2+ny.^2); + ny = ny ./ sqrt(nx.^2+ny.^2); - nx = -ppval(dysPP,ss)'; - ny = ppval(dxsPP,ss)'; + if (length(Nny)>1) + ssy = Nny(:).'; + else + ssy = linspace(0,1,Nny); + endif - nx = nx ./ sqrt(nx.^2+ny.^2); - ny = ny ./ sqrt(nx.^2+ny.^2); + msh2 = MSH2Mstructmesh ([1:length(ss)], ssy, 1, 1:4); + + jj = (msh2.p(1,:)); + p(1,:) = xs(jj) + sigma*nx(jj)' .* msh2.p(2,:); + p(2,:) = ys(jj) + sigma*ny(jj)' .* msh2.p(2,:); + + msh2.p = p; + endif - msh2 = MSH2Mstructmesh ([1:Nnx],linspace(-1,1,Nny),1,1:4); - - jj = (msh2.p(1,:)); - p(1,:) = xs(jj) + sigma*nx(jj)' .* msh2.p(2,:); - p(2,:) = ys(jj) + sigma*ny(jj)' .* msh2.p(2,:); - - msh2.p = p; \ No newline at end of file +endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/msh/inst/MSH2Mnodesonsides.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mnodesonsides.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mnodesonsides.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,66 +1,63 @@ -function [nodelist] = MSH2Mnodesonsides(mesh,sidelist) +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{nodelist}]} =@ - ## MSH2Mnodesonsides(@var{mesh}, @var{sidelist}) - ## - ## Returns a list of the nodes lying on the sides @var{sidelist} of - ## the mesh @var{mesh}. - ## - ## Input: - ## @itemize @minus - ## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". - ## @item @var{sidelist}: row vector containing the number of the sides (numbering referred to mesh.e(5,:)). - ## @end itemize - ## - ## Output: - ## @itemize @minus - ## @item @var{nodelist}: list of the nodes that lies on the specified sides. - ## @end itemize - ## - ## @seealso{MSH2Mgeomprop,MSH2Mtopprop} - ## @end deftypefn +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{nodelist}]} =@ +## MSH2Mnodesonsides(@var{mesh}, @var{sidelist}) +## +## Returns a list of the nodes lying on the sides @var{sidelist} of +## the mesh @var{mesh}. +## +## Input: +## @itemize @minus +## @item @var{mesh}: standard PDEtool-like mesh, with field "p", "e", "t". +## @item @var{sidelist}: row vector containing the number of the sides (numbering referred to mesh.e(5,:)). +## @end itemize +## +## Output: +## @itemize @minus +## @item @var{nodelist}: list of the nodes that lies on the specified sides. +## @end itemize +## +## @seealso{MSH2Mgeomprop,MSH2Mtopprop} +## @end deftypefn - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +function [nodelist] = MSH2Mnodesonsides(mesh,sidelist) - - edgelist =[]; - + for ii = 1:length(sidelist) edgelist=[edgelist,find(mesh.e(5,:)==sidelist(ii))]; - end + endfor ##Set list of nodes with Dirichelet BCs nodelist = mesh.e(1:2,edgelist); Modified: trunk/octave-forge/extra/msh/inst/MSH2Mstructmesh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/MSH2Mstructmesh.m 2009-02-25 11:55:49 UTC (rev 5563) +++ trunk/octave-forge/extra/msh/inst/MSH2Mstructmesh.m 2009-02-25 18:35:59 UTC (rev 5564) @@ -1,100 +1,99 @@ -function [mesh] = MSH2Mstructmesh(x,y,region,sides,varargin) - - ## -*- texinfo -*- - ## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mstructmesh(@var{x},@var{y},@var{region},@var{sides},@var{string}) - ## - ## Constructs a structured triangular 2D mesh on a rectangular domain, - ## and returns a PDEtool-like mesh structure. - ## - ## Input: - ## @itemize @minus - ## @item @var{x}: vector representing the 1D meshing of the side parallel to x axis. - ## @item @var{y}: vector representing the 1D meshing of the side parallel to y axis. - ## @item @var{region}: number assigned to the meshed region. - ## @item @var{sides}: row vector containing the four numbers assigned to the geometrical edges. - ## @item @var{string}: (optional) orientation of the diagonal edge of the structured mesh. - ## Values: "right", "left", "random". Default is "right". - ## @end itemize - ## - ## Output: mesh basic structure, composed of the following fields - ## @itemize @minus - ## @item @var{p}: matrix with size 2 times number of mesh point. - ## @itemize @bullet - ## @item 1st row: x-coordinates of the points. - ## @item 2nd row: y-coordinates of the points. - ## @end itemize - ## @item @var{e}: matrix with size 7 times number of mesh border edges. - ## @itemize @bullet - ## @item 1st row: p-matrix column number of the first edge-vertex. - ## @item 2nd row: p-matrix column number of the second edge-vertex. - ## @item 3rd row: not initialized, only for compatibility with standard PDE-tool like mesh. - ## @item 4th row: not initialized, only for compatibility with standard PDE-tool like mesh. - ## @item 5th row: number of the geometrical border upon which the referred mesh edge is lying on. - ## @item 6th row: number of the region to the right of the referred mesh edge. - ## @item 7th row: number of the region to the left of the referred mesh edge. - ## @end itemize - ## @item @var{t}: - ## @itemize @bullet - ## @item 1st row: p-matrix column number of the first trg-vertex. - ## @item 2nd row: p-matrix column number of the second trg-vertex. - ## @item 3rd row: p-matrix column number of the third trg-vertex. - ## @item 4th row: number of the region upon which the referred trg is lying on. - ## @end itemize - ## @end itemize - ## - ## @seealso{MSH2Mgmsh,MSH2Mjoinstructm,MSH2Msubmesh} - ## @end deftypefn +## Copyright (C) 2007,2008 Carlo de Falco, Massimiliano Culpo +## +## This file is part of +## +## MSH - Meshing Software Package for Octave +## +## MSH is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## MSH is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with MSH; If not, see <http://www.gnu.org/licenses/>. +## +## +## AUTHORS: +## Carlo de Falco +## Dublin City University +## School of Mathemetical Sciences +## Ireland +## +## Culpo Massimiliano +## Bergische Universitaet Wuppertal +## Fachbereich C - Mathematik und Naturwissenschaften +## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 +## D-42119 Wuppertal, Germany - ## This file is part of - ## - ## MSH - Meshing Software Package for Octave - ## ------------------------------------------------------------------- - ## Copyright (C) 2007 Carlo de Falco - ## Copyright (C) 2007 Culpo Massimiliano - ## - ## MSH is free software; you can redistribute it and/or modify - ## it under the terms of the GNU General Public License as published by - ## the Free Software Foundation; either version 2 of the License, or - ## (at your option) any later version. - ## - ## MSH is distributed in the hope that it will be useful, - ## but WITHOUT ANY WARRANTY; without even the implied warranty of - ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ## GNU General Public License for more details. - ## - ## You should have received a copy of the GNU General Public License - ## along with MSH; If not, see <http://www.gnu.org/licenses/>. - ## - ## - ## AUTHORS: - ## Carlo de Falco - ## Dublin City University - ## School of Mathemetical Sciences - ## Ireland - ## - ## Culpo Massimiliano - ## Bergische Universitaet Wuppertal - ## Fachbereich C - Mathematik und Naturwissenschaften - ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 - ## D-42119 Wuppertal, Germany +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{mesh}]} = MSH2Mstructmesh(@var{x},@var{y},@var{region},@var{sides},@var{string}) +## +## Constructs a structured triangular 2D mesh on a rectangular domain, +## and returns a PDEtool-like mesh structure. +## +## Input: +## @itemize @minus +## @item @var{x}: vector representing the 1D meshing of the side parallel to x axis. +## @item @var{y}: vector representing the 1D meshing of the side parallel to y axis. +## @item @var{region}: number assigned to the meshed region. +## @item @var{sides}: row vector containing the four numbers assigned to the geometrical edges. +## @item @var{string}: (optional) orientation of the diagonal edge of the structured mesh. +## Values: "right", "left", "random". Default is "right". +## @end itemize +## +## Output: mesh basic structure, composed of the following fields +## @itemize @minus +## @item @var{p}: matrix with size 2 times number of mesh point. +## @itemize @bullet +## @item 1st row: x-coordinates of the points. +## @item 2nd row: y-coordinates of the points. +## @end itemize +## @item @var{e}: matrix with size 7 times number of mesh border edges. +## @itemize @bullet +## @item 1st row: p-matrix column number of the first edge-vertex. +## @item 2nd row: p-matrix column number of the second edge-vertex. +## @item 3rd row: not initializ... [truncated message content] |