Changeset 14098


Ignore:
Timestamp:
12/05/12 09:34:29 (12 years ago)
Author:
jschierm
Message:

NEW: Allow Python vectors to be input to modules directly rather than reshaping to Mx1 matrices.

Location:
issm/trunk-jpl/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

    r13991 r14098  
    2525                if not os.path.exists(icefrontfile):
    2626                        raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
    27                 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
     27                [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
    2828                nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1))
    2929        else:
  • issm/trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py

    r13991 r14098  
    2727                if not os.path.exists(icefrontfile):
    2828                        raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile)
    29                 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
     29                [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
    3030                vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1))
    3131        else:
  • issm/trunk-jpl/src/m/geometry/FlagElements.py

    r13992 r14098  
    4747                        else:
    4848                                #ok, flag elements
    49                                 [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
     49                                [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x,md.mesh.y,region,'element',1)
    5050                                flag=flag.astype(bool)
    5151
  • issm/trunk-jpl/src/m/mesh/ComputeMetric.m

    r13482 r14098  
    1313lambda1=0.5*((a+d)+sqrt(4.*b.^2+(a-d).^2));
    1414lambda2=0.5*((a+d)-sqrt(4.*b.^2+(a-d).^2));
    15 pos1=find(lambda1==0);
    16 pos2=find(lambda2==0);
    17 pos3=find(b==0 & lambda1==lambda2);
     15pos1=find(lambda1==0.);
     16pos2=find(lambda2==0.);
     17pos3=find(b==0. & lambda1==lambda2);
    1818
    1919%Modify the eigen values to control the shape of the elements
  • issm/trunk-jpl/src/m/mesh/ComputeMetric.py

    r14095 r14098  
    1919        lambda1=0.5*((a+d)+numpy.sqrt(4.*b**2+(a-d)**2))
    2020        lambda2=0.5*((a+d)-numpy.sqrt(4.*b**2+(a-d)**2))
    21         pos1=numpy.nonzero(lambda1==0)[0]
    22         pos2=numpy.nonzero(lambda2==0)[0]
    23         pos3=numpy.nonzero(numpy.logical_and(b==0,lambda1==lambda2))[0]
     21        pos1=numpy.nonzero(lambda1==0.)[0]
     22        pos2=numpy.nonzero(lambda2==0.)[0]
     23        pos3=numpy.nonzero(numpy.logical_and(b==0.,lambda1==lambda2))[0]
    2424
    2525        #Modify the eigen values to control the shape of the elements
  • issm/trunk-jpl/src/m/mesh/bamg.py

    r13991 r14098  
    9292                        #Checks that all holes are INSIDE the principle domain outline
    9393                        if i:
    94                                 flags=ContourToNodes(domaini['x'].reshape(-1,1),domaini['y'].reshape(-1,1),domainfile,0)
     94                                flags=ContourToNodes(domaini['x'],domaini['y'],domainfile,0)
    9595                                if numpy.any(numpy.logical_not(flags)):
    9696                                        raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
     
    118118
    119119                                #detect whether all points of the rift are inside the domain
    120                                 flags=ContourToNodes(rifti['x'].reshape(-1,1),rifti['y'].reshape(-1,1),domain[0],0)
     120                                flags=ContourToNodes(rifti['x'],rifti['y'],domain[0],0)
    121121                                if numpy.all(numpy.logical_not(flags)):
    122122                                        raise RuntimeError("one rift has all its points outside of the domain outline")
  • issm/trunk-jpl/src/m/mesh/rifts/meshprocessoutsiderifts.py

    r14015 r14098  
    1616       
    1717                #first, flag nodes that belong to the domain outline
    18                 flags=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
     18                flags=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0)
    1919
    2020                tips=rift.tips
  • issm/trunk-jpl/src/m/mesh/rifts/meshprocessrifts.py

    r13991 r14098  
    4949
    5050        #In case we have rifts that open up the domain outline, we need to open them:
    51         [flags,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
     51        [flags,dum]=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0)
    5252        found=0
    5353        for rift in md.rifts.riftstruct:
  • issm/trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp

    r14097 r14098  
    108108                /*retrieve dimensions: */
    109109                ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
    110                 if(ndim!=2)_error_("expecting an MxN matrix in input!");
    111                 dims=PyArray_DIMS((PyArrayObject*)py_matrix);
    112                 M=dims[0]; N=dims[1];
     110                if      (ndim==2) {
     111                        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
     112                        M=dims[0]; N=dims[1];
     113                }
     114                else if (ndim==1) {
     115                        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
     116                        M=dims[0]; N=1;
     117                }
     118                else
     119                        _error_("expecting an MxN matrix or M vector in input!");
    113120
    114121                if (M && N) {
     
    141148
    142149                        else
    143                                 _error_("unrecognized pyarray type in input!");
     150                                _error_("unrecognized float pyarray type in input!");
    144151                }
    145152                else
     
    178185                /*retrieve dimensions: */
    179186                ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
    180                 if(ndim!=2)_error_("expecting an MxN matrix in input!");
    181                 dims=PyArray_DIMS((PyArrayObject*)py_matrix);
    182                 M=dims[0]; N=dims[1];
     187                if      (ndim==2) {
     188                        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
     189                        M=dims[0]; N=dims[1];
     190                }
     191                else if (ndim==1) {
     192                        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
     193                        M=dims[0]; N=1;
     194                }
     195                else
     196                        _error_("expecting an MxN matrix or M vector in input!");
    183197
    184198                if (M && N) {
     
    211225
    212226                        else
    213                                 _error_("unrecognized pyarray type in input!");
     227                                _error_("unrecognized long pyarray type in input!");
    214228                }
    215229                else
Note: See TracChangeset for help on using the changeset viewer.