source:
issm/oecreview/Archive/13393-13976/ISSM-13740-13741.diff
Last change on this file was 13980, checked in by , 12 years ago | |
---|---|
File size: 3.2 KB |
-
../trunk-jpl/src/m/geometry/FlagElements.py
51 51 if invert: 52 52 flag=numpy.logical_not(flag) 53 53 54 elif isinstance(region,numpy.n parray) or isinstance(region,bool):54 elif isinstance(region,numpy.ndarray) or isinstance(region,bool): 55 55 if not numpy.size(region,0)==md.mesh.numberofelements: 56 56 raise TypeError("Flaglist for region must be of same size as number of elements in model.") 57 57 flag=region -
../trunk-jpl/src/m/mesh/roundmesh.py
1 import numpy 2 import os 3 from collections import OrderedDict 4 from expwrite import * 5 from triangle import * 6 #from bamg import * 7 8 def roundmesh(md,radius,resolution): 9 """ 10 ROUNDMESH - create an unstructured round mesh 11 12 This script will generate a structured round mesh 13 - radius : specifies the radius of the circle in meters 14 - resolution : specifies the resolution in meters 15 16 Usage: 17 md=roundmesh(md,radius,resolution) 18 """ 19 20 #First we have to create the domain outline 21 22 #Get number of points on the circle 23 pointsonedge=numpy.floor((2.*numpy.pi*radius) / resolution) 24 25 #Calculate the cartesians coordinates of the points 26 x_list=numpy.ones(pointsonedge) 27 y_list=numpy.ones(pointsonedge) 28 theta=numpy.linspace(0.,2.*numpy.pi,num=pointsonedge,endpoint=False) 29 x_list=radius*x_list*numpy.cos(theta) 30 y_list=radius*y_list*numpy.sin(theta) 31 A=OrderedDict() 32 A['x']=x_list 33 A['y']=y_list 34 A['density']=1. 35 expwrite([A],'RoundDomainOutline.exp') 36 37 #Call Bamg 38 md=triangle(md,'RoundDomainOutline.exp',resolution) 39 #md=bamg(md,'domain','RoundDomainOutline.exp','hmin',resolution) 40 41 #move the closest node to the center 42 pos=numpy.argmin(md.mesh.x**2+md.mesh.y**2) 43 md.mesh.x[pos]=0. 44 md.mesh.y[pos]=0. 45 46 #delete domain 47 os.remove('RoundDomainOutline.exp') 48 49 return md 50 -
../trunk-jpl/src/m/mesh/roundmesh.m
11 11 %First we have to create the domain outline 12 12 13 13 %Get number of points on the circle 14 pointsonedge=floor((2 *pi*radius) / resolution);14 pointsonedge=floor((2.*pi*radius) / resolution); 15 15 16 16 %Calculate the cartesians coordinates of the points 17 17 x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1); 18 theta=(0 :2*pi/pointsonedge:2*pi*(1-1/pointsonedge))';18 theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))'; 19 19 x_list=radius*x_list.*cos(theta); 20 20 y_list=radius*y_list.*sin(theta); 21 A=struct('x',x_list,'y',y_list,'density',1 );21 A=struct('x',x_list,'y',y_list,'density',1.); 22 22 expwrite(A,'RoundDomainOutline.exp'); 23 23 24 24 %Call Bamg … … 27 27 28 28 %move the closest node to the center 29 29 [mini pos]=min(md.mesh.x.^2+md.mesh.y.^2); 30 md.mesh.x(pos)=0 ;31 md.mesh.y(pos)=0 ;30 md.mesh.x(pos)=0.; 31 md.mesh.y(pos)=0.; 32 32 33 33 %delete domain 34 34 delete('RoundDomainOutline.exp')
Note:
See TracBrowser
for help on using the repository browser.