Index: ../trunk-jpl/src/m/geometry/FlagElements.py =================================================================== --- ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13740) +++ ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13741) @@ -51,7 +51,7 @@ if invert: flag=numpy.logical_not(flag) - elif isinstance(region,numpy.nparray) or isinstance(region,bool): + elif isinstance(region,numpy.ndarray) or isinstance(region,bool): if not numpy.size(region,0)==md.mesh.numberofelements: raise TypeError("Flaglist for region must be of same size as number of elements in model.") flag=region Index: ../trunk-jpl/src/m/mesh/roundmesh.py =================================================================== --- ../trunk-jpl/src/m/mesh/roundmesh.py (revision 0) +++ ../trunk-jpl/src/m/mesh/roundmesh.py (revision 13741) @@ -0,0 +1,50 @@ +import numpy +import os +from collections import OrderedDict +from expwrite import * +from triangle import * +#from bamg import * + +def roundmesh(md,radius,resolution): + """ + ROUNDMESH - create an unstructured round mesh + + This script will generate a structured round mesh + - radius : specifies the radius of the circle in meters + - resolution : specifies the resolution in meters + + Usage: + md=roundmesh(md,radius,resolution) + """ + + #First we have to create the domain outline + + #Get number of points on the circle + pointsonedge=numpy.floor((2.*numpy.pi*radius) / resolution) + + #Calculate the cartesians coordinates of the points + x_list=numpy.ones(pointsonedge) + y_list=numpy.ones(pointsonedge) + theta=numpy.linspace(0.,2.*numpy.pi,num=pointsonedge,endpoint=False) + x_list=radius*x_list*numpy.cos(theta) + y_list=radius*y_list*numpy.sin(theta) + A=OrderedDict() + A['x']=x_list + A['y']=y_list + A['density']=1. + expwrite([A],'RoundDomainOutline.exp') + + #Call Bamg + md=triangle(md,'RoundDomainOutline.exp',resolution) + #md=bamg(md,'domain','RoundDomainOutline.exp','hmin',resolution) + + #move the closest node to the center + pos=numpy.argmin(md.mesh.x**2+md.mesh.y**2) + md.mesh.x[pos]=0. + md.mesh.y[pos]=0. + + #delete domain + os.remove('RoundDomainOutline.exp') + + return md + Index: ../trunk-jpl/src/m/mesh/roundmesh.m =================================================================== --- ../trunk-jpl/src/m/mesh/roundmesh.m (revision 13740) +++ ../trunk-jpl/src/m/mesh/roundmesh.m (revision 13741) @@ -11,14 +11,14 @@ %First we have to create the domain outline %Get number of points on the circle -pointsonedge=floor((2*pi*radius) / resolution); +pointsonedge=floor((2.*pi*radius) / resolution); %Calculate the cartesians coordinates of the points x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1); -theta=(0:2*pi/pointsonedge:2*pi*(1-1/pointsonedge))'; +theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))'; x_list=radius*x_list.*cos(theta); y_list=radius*y_list.*sin(theta); -A=struct('x',x_list,'y',y_list,'density',1); +A=struct('x',x_list,'y',y_list,'density',1.); expwrite(A,'RoundDomainOutline.exp'); %Call Bamg @@ -27,8 +27,8 @@ %move the closest node to the center [mini pos]=min(md.mesh.x.^2+md.mesh.y.^2); -md.mesh.x(pos)=0; -md.mesh.y(pos)=0; +md.mesh.x(pos)=0.; +md.mesh.y(pos)=0.; %delete domain delete('RoundDomainOutline.exp')