source: issm/oecreview/Archive/13393-13976/ISSM-13454-13455.diff@ 14312

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

preparing oecreview for 13393-13976'

File size: 34.2 KB
  • ../trunk-jpl/test/Par/SquareShelf.py

     
     1import os.path
     2import inspect
     3import netCDF4
     4from numpy import *
     5from verbose import *
     6from InterpFromMeshToMesh2d import InterpFromMeshToMesh2d
     7from paterson import *
     8from SetIceShelfBC import *
     9
     10#Start defining model parameters here
     11#Geometry
     12hmin=300.
     13hmax=1000.
     14ymin=min(md.mesh.y)
     15ymax=max(md.mesh.y)
     16
     17md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin)
     18md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
     19md.geometry.surface=md.geometry.bed+md.geometry.thickness
     20
     21#Initial velocity and pressure
     22iVelF = netCDF4.Dataset('../Data/SquareShelf.nc','r')
     23
     24x=reshape(iVelF.variables['x'][:],(-1))
     25y=reshape(iVelF.variables['y'][:],(-1))
     26vx=iVelF.variables['vx'][:]
     27vy=iVelF.variables['vy'][:]
     28index=iVelF.variables['index'][:].astype(float)
     29index=reshape(index.T,(len(index),3),order='F')
     30
     31#dbg - begin
     32# #print 'vars in SquareShelf.nc:'
     33# #for v in iVelF.variables:
     34# #     print v
     35#dbg - end
     36
     37iVelF.close()
     38
     39[md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y)
     40[md.initialization.vy]=InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y)
     41md.initialization.vz=zeros(md.mesh.numberofvertices)
     42md.initialization.pressure=zeros(md.mesh.numberofvertices)
     43
     44#dbg - begin
     45#print '...vx:'
     46#print md.initialization.vx
     47#print '...vy:'
     48#print md.initialization.vy
     49##print '...vz:'
     50##print md.initialization.vz
     51##print '...pressure:'
     52##print md.initialization.pressure
     53#dbg - end
     54
     55
     56#Materials
     57md.initialization.temperature = (273.-20.)*ones(md.mesh.numberofvertices)
     58md.materials.rheology_B = paterson(md.initialization.temperature)
     59md.materials.rheology_n = 3.*ones(md.mesh.numberofelements)
     60
     61#Friction
     62pos=nonzero(md.mask.elementonfloatingice)
     63md.friction.coefficient = 20.*ones(md.mesh.numberofvertices)
     64md.friction.coefficient[md.mesh.elements[pos,:].astype(int)-1] = 0.
     65md.friction.p = ones(md.mesh.numberofelements)
     66md.friction.q = ones(md.mesh.numberofelements)
     67
     68#Numerical parameters
     69md.diagnostic.viscosity_overshoot = 0.3
     70md.prognostic.stabilization = 1.
     71md.thermal.stabilization = 1.
     72md.settings.waitonlock = 30.
     73md.verbose=verbose()
     74md.diagnostic.restol = 0.10
     75md.steadystate.reltol = 0.02
     76md.diagnostic.reltol = 0.02
     77md.diagnostic.abstol = nan
     78md.timestepping.time_step = 1.
     79md.timestepping.final_time = 3.
     80
     81#Boundary conditions:
     82# #md=SetIceShelfBC(md)
     83print '...calling seticeshelfbc:'
     84md=SetIceShelfBC(md,'../Exp/SquareFront.exp')
     85print '...called seticeshelfbc:'
     86
     87#Change name so that no test have the same name
     88if len(inspect.stack()) > 2:
     89        md.miscellaneous.name=os.path.basename(inspect.stack()[2][1]).split('.')[0]
  • ../trunk-jpl/test/NightlyRun/test3007.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3007.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',150000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md=setflowequation(md,'macayeal','all')
     27md.extrude(5,3)
     28md.cluster=generic('name',oshostname(),'np',3)
     29md.autodiff.isautodiff=true
     30md=solve(md,PrognosticSolutionEnum())
     31
     32
     33# Fields and tolerances to track changes
     34
     35field_names     =['Thickness']
     36field_tolerances=[1e-13]
     37field_values=[\
     38        md.results['PrognosticSolution'][1]['Thickness'],\
     39        ]
  • ../trunk-jpl/test/NightlyRun/test3002.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3002.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',180000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md.extrude(3,2)
     27md=setflowequation(md,'macayeal','all')
     28md.cluster=generic('name',oshostname(),'np',3)
     29md.autodiff.isautodiff=true
     30md=solve(md,DiagnosticSolutionEnum())
     31
     32
     33# Fields and tolerances to track changes
     34
     35field_names     =['Vx','Vy','Vz','Vel','Pressure']
     36field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13]
     37field_values=[\
     38        md.results['DiagnosticSolution'][1]['Vx'],\
     39        md.results['DiagnosticSolution'][1]['Vy'],\
     40        md.results['DiagnosticSolution'][1]['Vz'],\
     41        md.results['DiagnosticSolution'][1]['Vel'],\
     42        md.results['DiagnosticSolution'][1]['Pressure'],\
     43        ]
  • ../trunk-jpl/test/NightlyRun/test3005.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3005.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',150000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md=setflowequation(md,'macayeal','all')
     27md.cluster=generic('name',oshostname(),'np',3)
     28md.autodiff.isautodiff=true
     29md=solve(md,PrognosticSolutionEnum())
     30
     31
     32# Fields and tolerances to track changes
     33
     34field_names     =['Thickness']
     35field_tolerances=[1e-13]
     36field_values=[\
     37        md.results['PrognosticSolution'][1]['Thickness'],\
     38        ]
  • ../trunk-jpl/test/NightlyRun/test3008.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3008.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',180000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md.extrude(3,1)
     27md=setflowequation(md,'macayeal','all')
     28md.timestepping.time_step=0
     29md.cluster=generic('name',oshostname(),'np',3)
     30md.autodiff.isautodiff=true
     31md=solve(md,ThermalSolutionEnum())
     32
     33
     34# Fields and tolerances to track changes
     35
     36field_names     =['Temperature','BasalforcingsMeltingRate']
     37field_tolerances=[1e-13,1e-13]
     38field_values=[\
     39        md.results['ThermalSolution'][1]['Temperature'],\
     40        md.results['ThermalSolution'][1]['BasalforcingsMeltingRate'],\
     41        ]
  • ../trunk-jpl/test/NightlyRun/test3003.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3003.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',180000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md.extrude(3,2)
     27md=setflowequation(md,'pattyn','all')
     28md.cluster=generic('name',oshostname(),'np',3)
     29md.diagnostic.requested_outputs=StressTensorEnum()
     30md.autodiff.isautodiff=true
     31md=solve(md,DiagnosticSolutionEnum())
     32
     33
     34# Fields and tolerances to track changes
     35
     36field_names     =['Vx','Vy','Vz','Vel','Pressure',\
     37        'StressTensorxx','StressTensoryy','StressTensorzz','StressTensorxy','StressTensorxz','StressTensoryz']
     38field_tolerances=[1e-09,1e-09,1e-09,1e-09,1e-09,\
     39        1e-09,1e-09,1e-09,1e-09,1e-09,1e-09]
     40field_values=[\
     41        md.results['DiagnosticSolution'][1]['Vx'],\
     42        md.results['DiagnosticSolution'][1]['Vy'],\
     43        md.results['DiagnosticSolution'][1]['Vz'],\
     44        md.results['DiagnosticSolution'][1]['Vel'],\
     45        md.results['DiagnosticSolution'][1]['Pressure'],\
     46        md.results['DiagnosticSolution'][1]['StressTensorxx'],\
     47        md.results['DiagnosticSolution'][1]['StressTensoryy'],\
     48        md.results['DiagnosticSolution'][1]['StressTensorzz'],\
     49        md.results['DiagnosticSolution'][1]['StressTensorxy'],\
     50        md.results['DiagnosticSolution'][1]['StressTensorxz'],\
     51        md.results['DiagnosticSolution'][1]['StressTensoryz'],\
     52        ]
  • ../trunk-jpl/test/NightlyRun/test201.py

     
     1from model import *
     2from triangle import *
     3from setmask import *
     4from parameterize import *
     5from setflowequation import *
     6from EnumDefinitions import *
     7from solve import *
     8from MatlabFuncs import *
     9from ContourToMesh import *
     10
     11md=triangle(model(),'../Exp/Square.exp',150000)
     12md=setmask(md,'all','')
     13md=parameterize(md,'../Par/SquareShelf.py')
     14md=setflowequation(md,'macayeal','all')
     15md.cluster=generic('name',oshostname(),'np',3)
     16md=solve(md,DiagnosticSolutionEnum())
     17
     18#Fields and tolerances to track changes
     19field_names     =['Vx','Vy','Vel','Pressure']
     20field_tolerances=[1e-13,1e-13,1e-13,1e-13]
     21field_values=[\
     22        md.results['DiagnosticSolution'][1]['Vx'],\
     23        md.results['DiagnosticSolution'][1]['Vy'],\
     24        md.results['DiagnosticSolution'][1]['Vel'],\
     25        md.results['DiagnosticSolution'][1]['Pressure'],\
     26        ]
  • ../trunk-jpl/test/NightlyRun/test3006.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3006.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from meshconvert import *
     19from setmask import *
     20from parameterize import *
     21from setflowequation import *
     22from solve import *
     23
     24md=triangle(model(),'../Exp/Square.exp',150000)
     25md=meshconvert(md)
     26md=setmask(md,'all','')
     27md=parameterize(md,'../Par/SquareShelfConstrained.py')
     28md=setflowequation(md,'macayeal','all')
     29md.cluster=generic('name',oshostname(),'np',3)
     30md.prognostic.stabilization=3
     31md.prognostic.spcthickness=md.geometry.thickness
     32md.autodiff.isautodiff=true
     33md=solve(md,PrognosticSolutionEnum())
     34
     35
     36# Fields and tolerances to track changes
     37
     38field_names     =['Thickness']
     39field_tolerances=[1e-13]
     40field_values=[\
     41        md.results['PrognosticSolution'][1]['Thickness'],\
     42        ]
  • ../trunk-jpl/test/NightlyRun/test3001.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3001.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',50000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md=setflowequation(md,'macayeal','all')
     27md.cluster=generic('name',oshostname(),'np',3)
     28md.diagnostic.requested_outputs=StressTensorEnum()
     29md.autodiff.isautodiff=true
     30md=solve(md,DiagnosticSolutionEnum())
     31
     32
     33# Fields and tolerances to track changes
     34
     35field_names     =['Vx','Vy','Vel','Pressure',\
     36        'StressTensorxx','StressTensoryy','StressTensorxy']
     37field_tolerances=[1e-13,1e-13,1e-13,1e-13,\
     38        1e-13,1e-13,1e-13]
     39field_values=[\
     40        md.results['DiagnosticSolution'][1]['Vx'],\
     41        md.results['DiagnosticSolution'][1]['Vy'],\
     42        md.results['DiagnosticSolution'][1]['Vel'],\
     43        md.results['DiagnosticSolution'][1]['Pressure'],\
     44        md.results['DiagnosticSolution'][1]['StressTensorxx'],\
     45        md.results['DiagnosticSolution'][1]['StressTensoryy'],\
     46        md.results['DiagnosticSolution'][1]['StressTensorxy'],\
     47        ]
  • ../trunk-jpl/test/NightlyRun/test3009.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3009.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',180000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md.extrude(3,1)
     27md=setflowequation(md,'macayeal','all')
     28md.cluster=generic('name',oshostname(),'np',3)
     29md.transient.isdiagnostic=0
     30md.transient.isprognostic=0
     31md.transient.isthermal=1
     32md.transient.isgroundingline=0
     33md.autodiff.isautodiff=true
     34md=solve(md,TransientSolutionEnum())
     35
     36
     37# Fields and tolerances to track changes
     38
     39field_names     =['Temperature','BasalforcingsMeltingRate']
     40field_tolerances=[1e-13,1e-13]
     41field_values=[\
     42        md.results['TransientSolution'][1]['Temperature'],\
     43        md.results['TransientSolution'][1]['BasalforcingsMeltingRate'],\
     44        ]
  • ../trunk-jpl/test/NightlyRun/test3010.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3010.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',150000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md=setflowequation(md,'macayeal','all')
     27md.cluster=generic('name',oshostname(),'np',3)
     28md.transient.requested_outputs=IceVolumeEnum()
     29
     30
     31md.autodiff.isautodiff=true
     32md=solve(md,TransientSolutionEnum())
     33
     34
     35# Fields and tolerances to track changes
     36
     37field_names     =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Volume1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Volume2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Volume3']
     38field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
     39                                                1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
     40                                                1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13]
     41field_values=[\
     42        md.results['TransientSolution'][1]['Vx'],\
     43        md.results['TransientSolution'][1]['Vy'],\
     44        md.results['TransientSolution'][1]['Vel'],\
     45        md.results['TransientSolution'][1]['Pressure'],\
     46        md.results['TransientSolution'][1]['Bed'],\
     47        md.results['TransientSolution'][1]['Surface'],\
     48        md.results['TransientSolution'][1]['Thickness'],\
     49        md.results['TransientSolution'][1]['IceVolume'],\
     50        md.results['TransientSolution'][2]['Vx'],\
     51        md.results['TransientSolution'][2]['Vy'],\
     52        md.results['TransientSolution'][2]['Vel'],\
     53        md.results['TransientSolution'][2]['Pressure'],\
     54        md.results['TransientSolution'][2]['Bed'],\
     55        md.results['TransientSolution'][2]['Surface'],\
     56        md.results['TransientSolution'][2]['Thickness'],\
     57        md.results['TransientSolution'][2]['IceVolume'],\
     58        md.results['TransientSolution'][3]['Vx'],\
     59        md.results['TransientSolution'][3]['Vy'],\
     60        md.results['TransientSolution'][3]['Vel'],\
     61        md.results['TransientSolution'][3]['Pressure'],\
     62        md.results['TransientSolution'][3]['Bed'],\
     63        md.results['TransientSolution'][3]['Surface'],\
     64        md.results['TransientSolution'][3]['Thickness'],\
     65        md.results['TransientSolution'][3]['IceVolume'],\
     66        ]
  • ../trunk-jpl/test/NightlyRun/test3004.py

     
     1"""
     2== == == == == == == == == == == == == == == == == == ==
     3Auto generated python script for ISSM:   test3004.m
     4Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep
     5== == == == == == == == == == == == == == == == == == ==
     6
     7Matlab script conversion into python
     8translateToPy.py Author: Michael Pellegrin
     9translateToPy.py Date: 09/24/12
     10== == == == == == == == == == == == == == == == == == ==
     11"""
     12
     13from MatlabFuncs import *
     14from model import *
     15from EnumDefinitions import *
     16import numpy
     17from triangle import *
     18from setmask import *
     19from parameterize import *
     20from setflowequation import *
     21from solve import *
     22
     23md=triangle(model(),'../Exp/Square.exp',180000)
     24md=setmask(md,'all','')
     25md=parameterize(md,'../Par/SquareShelfConstrained.py')
     26md.extrude(3,2)
     27md=setflowequation(md,'stokes','all')
     28md.cluster=generic('name',oshostname(),'np',3)
     29md.autodiff.isautodiff=true
     30md=solve(md,DiagnosticSolutionEnum())
     31
     32
     33# Fields and tolerances to track changes
     34
     35field_names     =['Vx','Vy','Vz','Vel','Pressure']
     36field_tolerances=[1e-08,1e-08,1e-07,1e-08,1e-08]
     37field_values=[\
     38        md.results['DiagnosticSolution'][1]['Vx'],\
     39        md.results['DiagnosticSolution'][1]['Vy'],\
     40        md.results['DiagnosticSolution'][1]['Vz'],\
     41        md.results['DiagnosticSolution'][1]['Vel'],\
     42        md.results['DiagnosticSolution'][1]['Pressure'],\
     43        ]
  • ../trunk-jpl/src/modules/python/Makefile.am

     
    1313                                                InterpFromMeshToMesh2d.la\
    1414                                                NodeConnectivity.la\
    1515                                                StringToEnum.la\
     16                                                ContourToMesh.la\
    1617                                                TriMesh.la
    1718endif
    1819#}}}
     
    9394                                                                  ../StringToEnum/StringToEnum.h
    9495StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
    9596
     97ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp\
     98                                                                  ../ContourToMesh/ContourToMesh.h
     99ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
     100
    96101TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp\
    97102                                                        ../TriMesh/TriMesh.h
    98103TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB)
  • ../trunk-jpl/src/m/classes/flowequation.py

     
    11#module imports
     2import copy
    23import numpy
    34from fielddisplay import fielddisplay
    45from EnumDefinitions import *
     
    8081        # }}}
    8182
    8283        def marshall(self,fid):    # {{{
     84                #print "marshalling flowequation-1"
     85                #print self.vertex_equation
    8386                WriteData(fid,'object',self,'fieldname','ismacayealpattyn','format','Boolean')
    8487                WriteData(fid,'object',self,'fieldname','ishutter','format','Boolean')
    8588                WriteData(fid,'object',self,'fieldname','isl1l2','format','Boolean')
     
    8891                WriteData(fid,'object',self,'fieldname','borderpattyn','format','DoubleMat','mattype',1)
    8992                WriteData(fid,'object',self,'fieldname','borderstokes','format','DoubleMat','mattype',1)
    9093                #convert approximations to enums
    91                 data=self.vertex_equation
     94                ## data=list(self.vertex_equation)
     95                data=copy.deepcopy(self.vertex_equation)
    9296                data[numpy.nonzero(data==0)]=NoneApproximationEnum()
    9397                data[numpy.nonzero(data==1)]=HutterApproximationEnum()
    9498                data[numpy.nonzero(data==2)]=MacAyealApproximationEnum()
     
    99103                data[numpy.nonzero(data==7)]=PattynStokesApproximationEnum()
    100104                data[numpy.nonzero(data==8)]=L1L2ApproximationEnum()
    101105                WriteData(fid,'data',data,'enum',FlowequationVertexEquationEnum(),'format','DoubleMat','mattype',1)
    102                 data=self.element_equation
     106                ########data=self.element_equation
     107                data=copy.deepcopy(self.element_equation)
    103108                data[numpy.nonzero(data==0)]=NoneApproximationEnum()
    104109                data[numpy.nonzero(data==1)]=HutterApproximationEnum()
    105110                data[numpy.nonzero(data==2)]=MacAyealApproximationEnum()
     
    110115                data[numpy.nonzero(data==7)]=PattynStokesApproximationEnum()
    111116                data[numpy.nonzero(data==8)]=L1L2ApproximationEnum()
    112117                WriteData(fid,'data',data,'enum',FlowequationElementEquationEnum(),'format','DoubleMat','mattype',2)
     118                #print "marshalling flowequation-4"
     119                #print self.vertex_equation
    113120        # }}}
    114121
  • ../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

     
    11import os
    22import numpy
     3from ContourToMesh import ContourToMesh
    34
    45def SetIceShelfBC(md,icefrontfile=''):
    56        """
     
    2324        if icefrontfile:
    2425                if not os.path.exists(icefrontfile):
    2526                        raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
    26                 nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
    27                 nodeonicefront=double(md.mesh.vertexonboundary and nodeinsideicefront)
     27                nodeinsideicefront=ContourToMesh((md.mesh.elements).reshape(-1,1),(md.mesh.x).reshape(-1,1),(md.mesh.y).reshape(-1,1),icefrontfile,'node',2)
     28                nodeonicefront= numpy.bitwise_and( map(int,md.mesh.vertexonboundary), map(int,nodeinsideicefront[0].ravel()) )
    2829        else:
    2930                nodeonicefront=numpy.zeros(md.mesh.numberofvertices)
    3031
  • ../trunk-jpl/scripts/mToPy.py

     
     1#!/usr/bin/env python
     2#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     3#
     4program =               'mToPy.py'
     5version =               '1.0'
     6versionReleaseDate =    '09/24/12'
     7origAuthor =            'Mike Pellegrin'
     8desc = '\nMain control unit for converting an matlab script file to python'
     9#
     10#   Note: Output will be put in the same (absolute) location as the input.
     11#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     12#                               History
     13#       Date            Developer           Modification
     14#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     15#       09/24/12        Michael Pellegrin       Initial Release         V1.0
     16#
     17#
     18#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     19
     20import sys, os, shutil
     21import translateToPy
     22import mToPy   # touch mToPy to assertain location of installation
     23
     24def convert ( inputFile ):
     25    try:
     26      if os.path.exists( inputFile + '.m') and os.path.isfile( inputFile + '.m'):
     27        checkBackupOutputFile( inputFile )
     28        convertMToPy( inputFile )
     29      else:
     30        print 'Specified input file: ' + inputFile + '.m doesn\'t appear to exist'
     31    finally:
     32      print ''
     33
     34def convertMToPy ( inputFileName ):
     35    translateToPy.convertToPython ( inputFileName + '.m', inputFileName + '.py' )
     36
     37def checkBackupOutputFile ( inputFile ):
     38    mFile = inputFile + '.m'
     39    pyFile = inputFile + '.py'
     40    if os.path.exists( pyFile ):
     41        i=1
     42        bkupName = pyFile + str(i)
     43        while os.path.exists( bkupName ):
     44            i+=1
     45            bkupName = pyFile + str(i)
     46        os.rename( pyFile, bkupName )
     47
     48    shutil.copyfile(mFile, pyFile)
     49
     50if __name__ == "__main__":
     51    convert( sys.argv[1])
     52
  • ../trunk-jpl/scripts/translateToPy.py

    Property changes on: ../trunk-jpl/scripts/mToPy.py
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
     
     1
     2#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     3#
     4program =               'translateToPy.py'
     5version =               '1.0'
     6versionReleaseDate =    '09/24/12'
     7origAuthor =            'Mike Pellegrin'
     8desc = '\nMatlab script conversion into python'
     9#
     10#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     11#                               History
     12#       Date            Developer           Modification
     13#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     14#       09/24/12 Michael Pellegrin      Initial Release     V1.0
     15#
     16#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     17
     18import codecs, unicodedata
     19import sys, re, datetime, os
     20import decimal, operator
     21
     22
     23outputLocation = sys.stdout
     24inputFile = ""
     25
     26# other global vars
     27indentLevel = 0
     28
     29
     30def setupOutputLocation ( outFile ):
     31    if outFile != sys.stdout:
     32                globals()['outputLocation'] = open( outFile, 'w' ) # clobber
     33
     34def translateFile ( inputFile ):
     35        f = codecs.open( inputFile, encoding='utf-8' )
     36        try:
     37                for line in f:
     38                        # print "in: " +line
     39
     40                        asciiLine = unicodedata.normalize('NFKD', line).encode('ascii','ignore')
     41                        line = asciiLine
     42
     43                        translateLine( line )
     44
     45        finally:
     46                f.close()
     47
     48def translateLine ( line ):
     49
     50        if len(line) == 1:      # blank line
     51                output( line )
     52
     53        elif line.split()[0][0] == '%':         # comment line
     54                output("# " + line.replace('%','') )
     55
     56        else:           # needs cleanup.  this is a real-quick-n-dirty implimentation
     57                #print line
     58                res = line.replace('{','[')
     59                res = res.replace('}',']')
     60                res = res.replace('model','model()')
     61                res = res.replace('SolutionEnum','SolutionEnum()')
     62                res = res.replace('StressTensorEnum','StressTensorEnum()')
     63                res = res.replace('.par','.py')
     64                res = res.replace('=extrude(md,','.extrude(')
     65
     66                res = res.replace('thickness(pos)','thickness[pos]')
     67                res = res.replace('find(md.','numpy.nonzero(md.')
     68
     69                res = res.replace('...','\\')
     70                res = res.replace(';','')
     71                res = res.replace('\n','')
     72
     73                res = convertFieldValues( res )
     74
     75                output(res)
     76
     77def convertFieldValues ( currentLine ):
     78        # before utilizing regex's {starting w/ eg. \([0-9]\) } for special case: ...(#)...
     79        # i noticed what i'm looking for is only TransientSolution(*). So, ...
     80
     81        res = currentLine
     82        if 'md.results' in currentLine:
     83                res = res.replace('(md.results.','md.results[\'')
     84
     85                if 'TransientSolution(' in currentLine:         # got a TransientSolution([0-9..]) case
     86                        res = res.replace('TransientSolution(','TransientSolution\'][')
     87                        parts = res.split(')')
     88                        res = parts[0] + '][\'' + parts[1].replace('.','') + '\']' + parts[2]
     89
     90                else:                           # handle the other cases for md.results
     91                       
     92                        res = res.replace('Solution.Vx)','Solution\'][1][\'Vx\']')
     93                        res = res.replace('Solution.Vy)','Solution\'][1][\'Vy\']')
     94                        res = res.replace('Solution.Vz)','Solution\'][1][\'Vz\']')
     95                        res = res.replace('Solution.Vel)','Solution\'][1][\'Vel\']')
     96
     97                        res = res.replace('Solution.Pressure)','Solution\'][1][\'Pressure\']')
     98
     99                        res = res.replace('Solution.StressTensorxx)','Solution\'][1][\'StressTensorxx\']')
     100                        res = res.replace('Solution.StressTensorxy)','Solution\'][1][\'StressTensorxy\']')
     101                        res = res.replace('Solution.StressTensoryy)','Solution\'][1][\'StressTensoryy\']')
     102                        res = res.replace('Solution.StressTensorzz)','Solution\'][1][\'StressTensorzz\']')
     103                        res = res.replace('Solution.StressTensorxz)','Solution\'][1][\'StressTensorxz\']')
     104                        res = res.replace('Solution.StressTensoryz)','Solution\'][1][\'StressTensoryz\']')
     105
     106                        res = res.replace('Solution.Thickness)','Solution\'][1][\'Thickness\']')
     107
     108                        res = res.replace('Solution.Temperature)','Solution\'][1][\'Temperature\']')
     109
     110                        res = res.replace('Solution.BasalforcingsMeltingRate)','Solution\'][1][\'BasalforcingsMeltingRate\']')
     111
     112                        res = res.replace('Solution.SurfaceSlopeX)','Solution\'][1][\'SurfaceSlopeX\']')
     113                        res = res.replace('Solution.SurfaceSlopeY)','Solution\'][1][\'SurfaceSlopeY\']')
     114                        res = res.replace('Solution.SurfaceSlopeZ)','Solution\'][1][\'SurfaceSlopeZ\']')
     115
     116                        res = res.replace('Solution.BedSlopeX)','Solution\'][1][\'BedSlopeX\']')
     117                        res = res.replace('Solution.BedSlopeY)','Solution\'][1][\'BedSlopeY\']')
     118                        res = res.replace('Solution.BedSlopeZ)','Solution\'][1][\'BedSlopeZ\']')
     119
     120                        res = res.replace('Solution.Enthalpy)','Solution\'][1][\'Enthalpy\']')
     121                        res = res.replace('Solution.Waterfraction)','Solution\'][1][\'Waterfraction\']')
     122                        res = res.replace('Solution.Temperature)','Solution\'][1][\'Temperature\']')
     123        return res
     124
     125def output ( line ):
     126        numTabs = indentLevel
     127        while numTabs:
     128                numTabs -= 1
     129                print >> outputLocation, '\t',
     130        print >> outputLocation, line
     131
     132def outputTopOfSript( inputFile ):
     133
     134        global indentLevel
     135
     136        output("\"\"\"")
     137        output("== == == == == == == == == == == == == == == == == == ==")
     138        output("Auto generated python script for ISSM:   %s" % (inputFile) )
     139        output("Created on %s via %s Ver %s by %s" % ( datetime.date.today(), program, version, os.getlogin()))
     140        output("== == == == == == == == == == == == == == == == == == ==")
     141        #output("")
     142        output(desc)
     143        output("%s Author: Michael Pellegrin" % (program))
     144        output("%s Date: %s" % (program, versionReleaseDate))
     145        output("== == == == == == == == == == == == == == == == == == ==")
     146        output("\"\"\"")
     147        output("")
     148
     149def outputBottomOfScript():
     150
     151        global indentLevel
     152
     153        output("")
     154       
     155def genericImports ():
     156        output("from MatlabFuncs import *")
     157        output("from model import *")
     158        output("from EnumDefinitions import *")
     159        output("from numpy import *")
     160
     161def createImports ( inputFile ):
     162        genericImports()
     163
     164        # cycle through eachline to assertain import needs
     165        f = codecs.open( inputFile, encoding='utf-8' )
     166        try:
     167                for line in f:
     168                        # print "in: " +line
     169
     170                        # toss blank lines
     171                        if len(line) == 1:
     172                                continue
     173
     174                        asciiLine = unicodedata.normalize('NFKD', line).encode('ascii','ignore')
     175                        line = asciiLine
     176
     177                        for il in importList:
     178                                if line.find(il) != -1:
     179                                        output( "from %s import *" % (il) )
     180                                        importList.remove(il)   # already got it
     181
     182        finally:
     183                output("")
     184                f.close()
     185
     186
     187def initImportList ():
     188        global importList
     189       
     190        importList = [ \
     191                'triangle'      ,\
     192                'setmask'       ,\
     193                'parameterize'  ,\
     194                'setflowequation'       ,\
     195                'meshconvert'   ,\
     196                'solve' ,\
     197                #'zeros'                                        # -> numpy
     198                ]
     199       
     200
     201
     202def convertToPython ( inFile, outFile = sys.stdout ):
     203    #print ' in cnvrt to python w/ file:' + inFile
     204    initImportList()
     205    setupOutputLocation( outFile )
     206    outputTopOfSript( inFile )
     207    createImports( inFile )
     208    translateFile( inFile )
     209    #    outputBottomOfScript()
     210
     211       
     212if __name__ == "__main__":
     213    #print ' in main w/ arg:' + sys.argv[1]+' '+sys.argv[2]
     214    if len(sys.argv)==2:
     215        convertToPython( sys.argv[1], sys.argv[2] )
     216    else:
     217        convertToPython( sys.argv[1] )
     218
     219
     220
Note: See TracBrowser for help on using the repository browser.