source:
issm/oecreview/Archive/13393-13976/ISSM-13454-13455.diff@
14312
Last change on this file since 14312 was 13980, checked in by , 12 years ago | |
---|---|
File size: 34.2 KB |
-
../trunk-jpl/test/Par/SquareShelf.py
1 import os.path 2 import inspect 3 import netCDF4 4 from numpy import * 5 from verbose import * 6 from InterpFromMeshToMesh2d import InterpFromMeshToMesh2d 7 from paterson import * 8 from SetIceShelfBC import * 9 10 #Start defining model parameters here 11 #Geometry 12 hmin=300. 13 hmax=1000. 14 ymin=min(md.mesh.y) 15 ymax=max(md.mesh.y) 16 17 md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin) 18 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness 19 md.geometry.surface=md.geometry.bed+md.geometry.thickness 20 21 #Initial velocity and pressure 22 iVelF = netCDF4.Dataset('../Data/SquareShelf.nc','r') 23 24 x=reshape(iVelF.variables['x'][:],(-1)) 25 y=reshape(iVelF.variables['y'][:],(-1)) 26 vx=iVelF.variables['vx'][:] 27 vy=iVelF.variables['vy'][:] 28 index=iVelF.variables['index'][:].astype(float) 29 index=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 37 iVelF.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) 41 md.initialization.vz=zeros(md.mesh.numberofvertices) 42 md.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 57 md.initialization.temperature = (273.-20.)*ones(md.mesh.numberofvertices) 58 md.materials.rheology_B = paterson(md.initialization.temperature) 59 md.materials.rheology_n = 3.*ones(md.mesh.numberofelements) 60 61 #Friction 62 pos=nonzero(md.mask.elementonfloatingice) 63 md.friction.coefficient = 20.*ones(md.mesh.numberofvertices) 64 md.friction.coefficient[md.mesh.elements[pos,:].astype(int)-1] = 0. 65 md.friction.p = ones(md.mesh.numberofelements) 66 md.friction.q = ones(md.mesh.numberofelements) 67 68 #Numerical parameters 69 md.diagnostic.viscosity_overshoot = 0.3 70 md.prognostic.stabilization = 1. 71 md.thermal.stabilization = 1. 72 md.settings.waitonlock = 30. 73 md.verbose=verbose() 74 md.diagnostic.restol = 0.10 75 md.steadystate.reltol = 0.02 76 md.diagnostic.reltol = 0.02 77 md.diagnostic.abstol = nan 78 md.timestepping.time_step = 1. 79 md.timestepping.final_time = 3. 80 81 #Boundary conditions: 82 # #md=SetIceShelfBC(md) 83 print '...calling seticeshelfbc:' 84 md=SetIceShelfBC(md,'../Exp/SquareFront.exp') 85 print '...called seticeshelfbc:' 86 87 #Change name so that no test have the same name 88 if 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 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3007.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',150000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md=setflowequation(md,'macayeal','all') 27 md.extrude(5,3) 28 md.cluster=generic('name',oshostname(),'np',3) 29 md.autodiff.isautodiff=true 30 md=solve(md,PrognosticSolutionEnum()) 31 32 33 # Fields and tolerances to track changes 34 35 field_names =['Thickness'] 36 field_tolerances=[1e-13] 37 field_values=[\ 38 md.results['PrognosticSolution'][1]['Thickness'],\ 39 ] -
../trunk-jpl/test/NightlyRun/test3002.py
1 """ 2 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3002.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',180000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md.extrude(3,2) 27 md=setflowequation(md,'macayeal','all') 28 md.cluster=generic('name',oshostname(),'np',3) 29 md.autodiff.isautodiff=true 30 md=solve(md,DiagnosticSolutionEnum()) 31 32 33 # Fields and tolerances to track changes 34 35 field_names =['Vx','Vy','Vz','Vel','Pressure'] 36 field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13] 37 field_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 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3005.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',150000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md=setflowequation(md,'macayeal','all') 27 md.cluster=generic('name',oshostname(),'np',3) 28 md.autodiff.isautodiff=true 29 md=solve(md,PrognosticSolutionEnum()) 30 31 32 # Fields and tolerances to track changes 33 34 field_names =['Thickness'] 35 field_tolerances=[1e-13] 36 field_values=[\ 37 md.results['PrognosticSolution'][1]['Thickness'],\ 38 ] -
../trunk-jpl/test/NightlyRun/test3008.py
1 """ 2 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3008.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',180000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md.extrude(3,1) 27 md=setflowequation(md,'macayeal','all') 28 md.timestepping.time_step=0 29 md.cluster=generic('name',oshostname(),'np',3) 30 md.autodiff.isautodiff=true 31 md=solve(md,ThermalSolutionEnum()) 32 33 34 # Fields and tolerances to track changes 35 36 field_names =['Temperature','BasalforcingsMeltingRate'] 37 field_tolerances=[1e-13,1e-13] 38 field_values=[\ 39 md.results['ThermalSolution'][1]['Temperature'],\ 40 md.results['ThermalSolution'][1]['BasalforcingsMeltingRate'],\ 41 ] -
../trunk-jpl/test/NightlyRun/test3003.py
1 """ 2 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3003.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',180000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md.extrude(3,2) 27 md=setflowequation(md,'pattyn','all') 28 md.cluster=generic('name',oshostname(),'np',3) 29 md.diagnostic.requested_outputs=StressTensorEnum() 30 md.autodiff.isautodiff=true 31 md=solve(md,DiagnosticSolutionEnum()) 32 33 34 # Fields and tolerances to track changes 35 36 field_names =['Vx','Vy','Vz','Vel','Pressure',\ 37 'StressTensorxx','StressTensoryy','StressTensorzz','StressTensorxy','StressTensorxz','StressTensoryz'] 38 field_tolerances=[1e-09,1e-09,1e-09,1e-09,1e-09,\ 39 1e-09,1e-09,1e-09,1e-09,1e-09,1e-09] 40 field_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
1 from model import * 2 from triangle import * 3 from setmask import * 4 from parameterize import * 5 from setflowequation import * 6 from EnumDefinitions import * 7 from solve import * 8 from MatlabFuncs import * 9 from ContourToMesh import * 10 11 md=triangle(model(),'../Exp/Square.exp',150000) 12 md=setmask(md,'all','') 13 md=parameterize(md,'../Par/SquareShelf.py') 14 md=setflowequation(md,'macayeal','all') 15 md.cluster=generic('name',oshostname(),'np',3) 16 md=solve(md,DiagnosticSolutionEnum()) 17 18 #Fields and tolerances to track changes 19 field_names =['Vx','Vy','Vel','Pressure'] 20 field_tolerances=[1e-13,1e-13,1e-13,1e-13] 21 field_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 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3006.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from meshconvert import * 19 from setmask import * 20 from parameterize import * 21 from setflowequation import * 22 from solve import * 23 24 md=triangle(model(),'../Exp/Square.exp',150000) 25 md=meshconvert(md) 26 md=setmask(md,'all','') 27 md=parameterize(md,'../Par/SquareShelfConstrained.py') 28 md=setflowequation(md,'macayeal','all') 29 md.cluster=generic('name',oshostname(),'np',3) 30 md.prognostic.stabilization=3 31 md.prognostic.spcthickness=md.geometry.thickness 32 md.autodiff.isautodiff=true 33 md=solve(md,PrognosticSolutionEnum()) 34 35 36 # Fields and tolerances to track changes 37 38 field_names =['Thickness'] 39 field_tolerances=[1e-13] 40 field_values=[\ 41 md.results['PrognosticSolution'][1]['Thickness'],\ 42 ] -
../trunk-jpl/test/NightlyRun/test3001.py
1 """ 2 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3001.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',50000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md=setflowequation(md,'macayeal','all') 27 md.cluster=generic('name',oshostname(),'np',3) 28 md.diagnostic.requested_outputs=StressTensorEnum() 29 md.autodiff.isautodiff=true 30 md=solve(md,DiagnosticSolutionEnum()) 31 32 33 # Fields and tolerances to track changes 34 35 field_names =['Vx','Vy','Vel','Pressure',\ 36 'StressTensorxx','StressTensoryy','StressTensorxy'] 37 field_tolerances=[1e-13,1e-13,1e-13,1e-13,\ 38 1e-13,1e-13,1e-13] 39 field_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 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3009.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',180000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md.extrude(3,1) 27 md=setflowequation(md,'macayeal','all') 28 md.cluster=generic('name',oshostname(),'np',3) 29 md.transient.isdiagnostic=0 30 md.transient.isprognostic=0 31 md.transient.isthermal=1 32 md.transient.isgroundingline=0 33 md.autodiff.isautodiff=true 34 md=solve(md,TransientSolutionEnum()) 35 36 37 # Fields and tolerances to track changes 38 39 field_names =['Temperature','BasalforcingsMeltingRate'] 40 field_tolerances=[1e-13,1e-13] 41 field_values=[\ 42 md.results['TransientSolution'][1]['Temperature'],\ 43 md.results['TransientSolution'][1]['BasalforcingsMeltingRate'],\ 44 ] -
../trunk-jpl/test/NightlyRun/test3010.py
1 """ 2 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3010.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',150000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md=setflowequation(md,'macayeal','all') 27 md.cluster=generic('name',oshostname(),'np',3) 28 md.transient.requested_outputs=IceVolumeEnum() 29 30 31 md.autodiff.isautodiff=true 32 md=solve(md,TransientSolutionEnum()) 33 34 35 # Fields and tolerances to track changes 36 37 field_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'] 38 field_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] 41 field_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 == == == == == == == == == == == == == == == == == == == 3 Auto generated python script for ISSM: test3004.m 4 Created on 2012-09-25 via translateToPy.py Ver 1.0 by mikep 5 == == == == == == == == == == == == == == == == == == == 6 7 Matlab script conversion into python 8 translateToPy.py Author: Michael Pellegrin 9 translateToPy.py Date: 09/24/12 10 == == == == == == == == == == == == == == == == == == == 11 """ 12 13 from MatlabFuncs import * 14 from model import * 15 from EnumDefinitions import * 16 import numpy 17 from triangle import * 18 from setmask import * 19 from parameterize import * 20 from setflowequation import * 21 from solve import * 22 23 md=triangle(model(),'../Exp/Square.exp',180000) 24 md=setmask(md,'all','') 25 md=parameterize(md,'../Par/SquareShelfConstrained.py') 26 md.extrude(3,2) 27 md=setflowequation(md,'stokes','all') 28 md.cluster=generic('name',oshostname(),'np',3) 29 md.autodiff.isautodiff=true 30 md=solve(md,DiagnosticSolutionEnum()) 31 32 33 # Fields and tolerances to track changes 34 35 field_names =['Vx','Vy','Vz','Vel','Pressure'] 36 field_tolerances=[1e-08,1e-08,1e-07,1e-08,1e-08] 37 field_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
13 13 InterpFromMeshToMesh2d.la\ 14 14 NodeConnectivity.la\ 15 15 StringToEnum.la\ 16 ContourToMesh.la\ 16 17 TriMesh.la 17 18 endif 18 19 #}}} … … 93 94 ../StringToEnum/StringToEnum.h 94 95 StringToEnum_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) 95 96 97 ContourToMesh_la_SOURCES = ../ContourToMesh/ContourToMesh.cpp\ 98 ../ContourToMesh/ContourToMesh.h 99 ContourToMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) 100 96 101 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp\ 97 102 ../TriMesh/TriMesh.h 98 103 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) -
../trunk-jpl/src/m/classes/flowequation.py
1 1 #module imports 2 import copy 2 3 import numpy 3 4 from fielddisplay import fielddisplay 4 5 from EnumDefinitions import * … … 80 81 # }}} 81 82 82 83 def marshall(self,fid): # {{{ 84 #print "marshalling flowequation-1" 85 #print self.vertex_equation 83 86 WriteData(fid,'object',self,'fieldname','ismacayealpattyn','format','Boolean') 84 87 WriteData(fid,'object',self,'fieldname','ishutter','format','Boolean') 85 88 WriteData(fid,'object',self,'fieldname','isl1l2','format','Boolean') … … 88 91 WriteData(fid,'object',self,'fieldname','borderpattyn','format','DoubleMat','mattype',1) 89 92 WriteData(fid,'object',self,'fieldname','borderstokes','format','DoubleMat','mattype',1) 90 93 #convert approximations to enums 91 data=self.vertex_equation 94 ## data=list(self.vertex_equation) 95 data=copy.deepcopy(self.vertex_equation) 92 96 data[numpy.nonzero(data==0)]=NoneApproximationEnum() 93 97 data[numpy.nonzero(data==1)]=HutterApproximationEnum() 94 98 data[numpy.nonzero(data==2)]=MacAyealApproximationEnum() … … 99 103 data[numpy.nonzero(data==7)]=PattynStokesApproximationEnum() 100 104 data[numpy.nonzero(data==8)]=L1L2ApproximationEnum() 101 105 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) 103 108 data[numpy.nonzero(data==0)]=NoneApproximationEnum() 104 109 data[numpy.nonzero(data==1)]=HutterApproximationEnum() 105 110 data[numpy.nonzero(data==2)]=MacAyealApproximationEnum() … … 110 115 data[numpy.nonzero(data==7)]=PattynStokesApproximationEnum() 111 116 data[numpy.nonzero(data==8)]=L1L2ApproximationEnum() 112 117 WriteData(fid,'data',data,'enum',FlowequationElementEquationEnum(),'format','DoubleMat','mattype',2) 118 #print "marshalling flowequation-4" 119 #print self.vertex_equation 113 120 # }}} 114 121 -
../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py
1 1 import os 2 2 import numpy 3 from ContourToMesh import ContourToMesh 3 4 4 5 def SetIceShelfBC(md,icefrontfile=''): 5 6 """ … … 23 24 if icefrontfile: 24 25 if not os.path.exists(icefrontfile): 25 26 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()) ) 28 29 else: 29 30 nodeonicefront=numpy.zeros(md.mesh.numberofvertices) 30 31 -
../trunk-jpl/scripts/mToPy.py
1 #!/usr/bin/env python 2 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 # 4 program = 'mToPy.py' 5 version = '1.0' 6 versionReleaseDate = '09/24/12' 7 origAuthor = 'Mike Pellegrin' 8 desc = '\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 20 import sys, os, shutil 21 import translateToPy 22 import mToPy # touch mToPy to assertain location of installation 23 24 def 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 34 def convertMToPy ( inputFileName ): 35 translateToPy.convertToPython ( inputFileName + '.m', inputFileName + '.py' ) 36 37 def 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 50 if __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 # 4 program = 'translateToPy.py' 5 version = '1.0' 6 versionReleaseDate = '09/24/12' 7 origAuthor = 'Mike Pellegrin' 8 desc = '\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 18 import codecs, unicodedata 19 import sys, re, datetime, os 20 import decimal, operator 21 22 23 outputLocation = sys.stdout 24 inputFile = "" 25 26 # other global vars 27 indentLevel = 0 28 29 30 def setupOutputLocation ( outFile ): 31 if outFile != sys.stdout: 32 globals()['outputLocation'] = open( outFile, 'w' ) # clobber 33 34 def 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 48 def 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 77 def 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 125 def output ( line ): 126 numTabs = indentLevel 127 while numTabs: 128 numTabs -= 1 129 print >> outputLocation, '\t', 130 print >> outputLocation, line 131 132 def 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 149 def outputBottomOfScript(): 150 151 global indentLevel 152 153 output("") 154 155 def genericImports (): 156 output("from MatlabFuncs import *") 157 output("from model import *") 158 output("from EnumDefinitions import *") 159 output("from numpy import *") 160 161 def 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 187 def 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 202 def 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 212 if __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.