source: issm/oecreview/Archive/13393-13976/ISSM-13740-13741.diff@ 28275

Last change on this file since 28275 was 13980, checked in by Mathieu Morlighem, 12 years ago

preparing oecreview for 13393-13976'

File size: 3.2 KB
  • ../trunk-jpl/src/m/geometry/FlagElements.py

     
    5151                if invert:
    5252                        flag=numpy.logical_not(flag)
    5353
    54         elif isinstance(region,numpy.nparray) or isinstance(region,bool):
     54        elif isinstance(region,numpy.ndarray) or isinstance(region,bool):
    5555                if not numpy.size(region,0)==md.mesh.numberofelements:
    5656                        raise TypeError("Flaglist for region must be of same size as number of elements in model.")
    5757                flag=region
  • ../trunk-jpl/src/m/mesh/roundmesh.py

     
     1import numpy
     2import os
     3from collections import OrderedDict
     4from expwrite import *
     5from triangle import *
     6#from bamg import *
     7
     8def 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

     
    1111%First we have to create the domain outline
    1212
    1313%Get number of points on the circle
    14 pointsonedge=floor((2*pi*radius) / resolution);
     14pointsonedge=floor((2.*pi*radius) / resolution);
    1515
    1616%Calculate the cartesians coordinates of the points
    1717x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1);
    18 theta=(0:2*pi/pointsonedge:2*pi*(1-1/pointsonedge))';
     18theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))';
    1919x_list=radius*x_list.*cos(theta);
    2020y_list=radius*y_list.*sin(theta);
    21 A=struct('x',x_list,'y',y_list,'density',1);
     21A=struct('x',x_list,'y',y_list,'density',1.);
    2222expwrite(A,'RoundDomainOutline.exp');
    2323
    2424%Call Bamg
     
    2727
    2828%move the closest node to the center
    2929[mini pos]=min(md.mesh.x.^2+md.mesh.y.^2);
    30 md.mesh.x(pos)=0;
    31 md.mesh.y(pos)=0;
     30md.mesh.x(pos)=0.;
     31md.mesh.y(pos)=0.;
    3232
    3333%delete domain
    3434delete('RoundDomainOutline.exp')
Note: See TracBrowser for help on using the repository browser.