[13980] | 1 | Index: ../trunk-jpl/src/m/geometry/FlagElements.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13740)
|
---|
| 4 | +++ ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13741)
|
---|
| 5 | @@ -51,7 +51,7 @@
|
---|
| 6 | if invert:
|
---|
| 7 | flag=numpy.logical_not(flag)
|
---|
| 8 |
|
---|
| 9 | - elif isinstance(region,numpy.nparray) or isinstance(region,bool):
|
---|
| 10 | + elif isinstance(region,numpy.ndarray) or isinstance(region,bool):
|
---|
| 11 | if not numpy.size(region,0)==md.mesh.numberofelements:
|
---|
| 12 | raise TypeError("Flaglist for region must be of same size as number of elements in model.")
|
---|
| 13 | flag=region
|
---|
| 14 | Index: ../trunk-jpl/src/m/mesh/roundmesh.py
|
---|
| 15 | ===================================================================
|
---|
| 16 | --- ../trunk-jpl/src/m/mesh/roundmesh.py (revision 0)
|
---|
| 17 | +++ ../trunk-jpl/src/m/mesh/roundmesh.py (revision 13741)
|
---|
| 18 | @@ -0,0 +1,50 @@
|
---|
| 19 | +import numpy
|
---|
| 20 | +import os
|
---|
| 21 | +from collections import OrderedDict
|
---|
| 22 | +from expwrite import *
|
---|
| 23 | +from triangle import *
|
---|
| 24 | +#from bamg import *
|
---|
| 25 | +
|
---|
| 26 | +def roundmesh(md,radius,resolution):
|
---|
| 27 | + """
|
---|
| 28 | + ROUNDMESH - create an unstructured round mesh
|
---|
| 29 | +
|
---|
| 30 | + This script will generate a structured round mesh
|
---|
| 31 | + - radius : specifies the radius of the circle in meters
|
---|
| 32 | + - resolution : specifies the resolution in meters
|
---|
| 33 | +
|
---|
| 34 | + Usage:
|
---|
| 35 | + md=roundmesh(md,radius,resolution)
|
---|
| 36 | + """
|
---|
| 37 | +
|
---|
| 38 | + #First we have to create the domain outline
|
---|
| 39 | +
|
---|
| 40 | + #Get number of points on the circle
|
---|
| 41 | + pointsonedge=numpy.floor((2.*numpy.pi*radius) / resolution)
|
---|
| 42 | +
|
---|
| 43 | + #Calculate the cartesians coordinates of the points
|
---|
| 44 | + x_list=numpy.ones(pointsonedge)
|
---|
| 45 | + y_list=numpy.ones(pointsonedge)
|
---|
| 46 | + theta=numpy.linspace(0.,2.*numpy.pi,num=pointsonedge,endpoint=False)
|
---|
| 47 | + x_list=radius*x_list*numpy.cos(theta)
|
---|
| 48 | + y_list=radius*y_list*numpy.sin(theta)
|
---|
| 49 | + A=OrderedDict()
|
---|
| 50 | + A['x']=x_list
|
---|
| 51 | + A['y']=y_list
|
---|
| 52 | + A['density']=1.
|
---|
| 53 | + expwrite([A],'RoundDomainOutline.exp')
|
---|
| 54 | +
|
---|
| 55 | + #Call Bamg
|
---|
| 56 | + md=triangle(md,'RoundDomainOutline.exp',resolution)
|
---|
| 57 | + #md=bamg(md,'domain','RoundDomainOutline.exp','hmin',resolution)
|
---|
| 58 | +
|
---|
| 59 | + #move the closest node to the center
|
---|
| 60 | + pos=numpy.argmin(md.mesh.x**2+md.mesh.y**2)
|
---|
| 61 | + md.mesh.x[pos]=0.
|
---|
| 62 | + md.mesh.y[pos]=0.
|
---|
| 63 | +
|
---|
| 64 | + #delete domain
|
---|
| 65 | + os.remove('RoundDomainOutline.exp')
|
---|
| 66 | +
|
---|
| 67 | + return md
|
---|
| 68 | +
|
---|
| 69 | Index: ../trunk-jpl/src/m/mesh/roundmesh.m
|
---|
| 70 | ===================================================================
|
---|
| 71 | --- ../trunk-jpl/src/m/mesh/roundmesh.m (revision 13740)
|
---|
| 72 | +++ ../trunk-jpl/src/m/mesh/roundmesh.m (revision 13741)
|
---|
| 73 | @@ -11,14 +11,14 @@
|
---|
| 74 | %First we have to create the domain outline
|
---|
| 75 |
|
---|
| 76 | %Get number of points on the circle
|
---|
| 77 | -pointsonedge=floor((2*pi*radius) / resolution);
|
---|
| 78 | +pointsonedge=floor((2.*pi*radius) / resolution);
|
---|
| 79 |
|
---|
| 80 | %Calculate the cartesians coordinates of the points
|
---|
| 81 | x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1);
|
---|
| 82 | -theta=(0:2*pi/pointsonedge:2*pi*(1-1/pointsonedge))';
|
---|
| 83 | +theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))';
|
---|
| 84 | x_list=radius*x_list.*cos(theta);
|
---|
| 85 | y_list=radius*y_list.*sin(theta);
|
---|
| 86 | -A=struct('x',x_list,'y',y_list,'density',1);
|
---|
| 87 | +A=struct('x',x_list,'y',y_list,'density',1.);
|
---|
| 88 | expwrite(A,'RoundDomainOutline.exp');
|
---|
| 89 |
|
---|
| 90 | %Call Bamg
|
---|
| 91 | @@ -27,8 +27,8 @@
|
---|
| 92 |
|
---|
| 93 | %move the closest node to the center
|
---|
| 94 | [mini pos]=min(md.mesh.x.^2+md.mesh.y.^2);
|
---|
| 95 | -md.mesh.x(pos)=0;
|
---|
| 96 | -md.mesh.y(pos)=0;
|
---|
| 97 | +md.mesh.x(pos)=0.;
|
---|
| 98 | +md.mesh.y(pos)=0.;
|
---|
| 99 |
|
---|
| 100 | %delete domain
|
---|
| 101 | delete('RoundDomainOutline.exp')
|
---|