Changeset 13449


Ignore:
Timestamp:
09/26/12 12:06:42 (12 years ago)
Author:
jschierm
Message:

FIX: Fixed call to ContourToMesh in FlagElements and got setmask working.

Location:
issm/trunk-jpl/src/m
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/geometry/FlagElements.py

    r13098 r13449  
    22import os
    33#from basinzoom import *
    4 #from ContourToMesh import *
     4from ContourToMesh import *
    55from MatlabFuncs import *
    66
     
    4141                                if len(region)>3 and not strcmp(region[-4:],'.exp'):
    4242                                        raise IOError("Error: File 'region' not found!" % region)
     43                                raise RuntimeError("FlagElements -- basinzoom not yet converted.")
    4344                                xlim,ylim=basinzoom('basin',region)
    4445                                flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0])).astype(float)
     
    4647                        else:
    4748                                #ok, flag elements
    48                                 flag=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x,md.mesh.y,region,'element',1)
     49                                [flag,fnone]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
    4950
    5051                if invert:
  • issm/trunk-jpl/src/m/parameterization/setmask.py

    r13006 r13449  
    1 from numpy import *
    2 import FlagElements as fe
     1import numpy
     2from FlagElements import *
    33
    44def setmask(md, floatingicename, groundedicename):
    5         #SETMASK - establish boundaries between grounded and floating ice.
    6         #
    7         #   By default, ice is considered grounded. The contour floatingicename defines nodes
    8         #   for which ice is floating. The contour groundedicename defines nodes inside an floatingice,
    9         #   that are grounded (ie: ice rises, islands, etc ...)
    10         #   All input files are in the Argus format (extension .exp).
    11         #
    12         #   Usage:
    13         #      md=setmask(md,floatingicename,groundedicename)
    14         #
    15         #   Examples:
    16         #      md=setmask(md,'all','');
    17         #      md=setmask(md,'Iceshelves.exp','Islands.exp');
     5        """
     6        SETMASK - establish boundaries between grounded and floating ice.
    187
    19         #%Get assigned fields
     8           By default, ice is considered grounded. The contour floatingicename defines nodes
     9           for which ice is floating. The contour groundedicename defines nodes inside an floatingice,
     10           that are grounded (ie: ice rises, islands, etc ...)
     11           All input files are in the Argus format (extension .exp).
     12
     13           Usage:
     14              md=setmask(md,floatingicename,groundedicename)
     15
     16           Examples:
     17              md=setmask(md,'all','');
     18              md=setmask(md,'Iceshelves.exp','Islands.exp');
     19        """
     20
     21        #Get assigned fields
    2022        x = md.mesh.x
    2123        y = md.mesh.y
     
    2325
    2426        #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
    25         elementonfloatingice = fe.FlagElements(md, floatingicename)
    26         elementongroundedice = fe.FlagElements(md, groundedicename)
     27        elementonfloatingice = FlagElements(md, floatingicename)
     28        elementongroundedice = FlagElements(md, groundedicename)
    2729
    2830        #Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous
    2931        #arrays come from domain outlines that can intersect one another:
    3032
    31         elementonfloatingice = logical_and(elementonfloatingice,~elementongroundedice)
    32         elementongroundedice = ~elementonfloatingice
     33        elementonfloatingice = numpy.logical_and(elementonfloatingice,numpy.logical_not(elementongroundedice))
     34        elementongroundedice = numpy.logical_not(elementonfloatingice)
    3335
    3436        #the order here is important. we choose vertexongroundedice as default on the grounding line.
    35         vertexonfloatingice = zeros(md.mesh.numberofvertices,'bool')
    36         vertexongroundedice = zeros(md.mesh.numberofvertices,'bool')
    37 
    38         pos=argwhere(elementongroundedice==1)
    39         pos=md.mesh.elements[pos,:]-1
    40         if pos.size:
    41                 vertexongroundedice[pos]=True
    42 
    43         pos=argwhere(~vertexongroundedice)
    44         if pos.size:
    45                 vertexonfloatingice[pos]=True;
    46         #%}}}
     37        vertexonfloatingice = numpy.zeros(md.mesh.numberofvertices,'bool')
     38        vertexongroundedice = numpy.zeros(md.mesh.numberofvertices,'bool')
     39        vertexongroundedice[md.mesh.elements[numpy.nonzero(elementongroundedice),:].astype(int)-1]=True
     40        vertexonfloatingice[numpy.nonzero(numpy.logical_not(vertexongroundedice))]=True
     41        #}}}
    4742
    4843        #Return:
    49         md.mask.elementonfloatingice = double(elementonfloatingice)
    50         md.mask.vertexonfloatingice = double(vertexonfloatingice)
    51         md.mask.elementongroundedice = double(elementongroundedice)
    52         md.mask.vertexongroundedice = double(vertexongroundedice)
    53         md.mask.vertexonwater = zeros(md.mesh.numberofvertices)
    54         md.mask.elementonwater = zeros(md.mesh.numberofelements)
     44        md.mask.elementonfloatingice = elementonfloatingice.astype(float)
     45        md.mask.vertexonfloatingice = vertexonfloatingice.astype(float)
     46        md.mask.elementongroundedice = elementongroundedice.astype(float)
     47        md.mask.vertexongroundedice = vertexongroundedice.astype(float)
     48        md.mask.vertexonwater = numpy.zeros(md.mesh.numberofvertices)
     49        md.mask.elementonwater = numpy.zeros(md.mesh.numberofelements)
     50
    5551        return md
Note: See TracChangeset for help on using the changeset viewer.