source: issm/oecreview/Archive/21724-22754/ISSM-22266-22267.diff@ 22755

Last change on this file since 22755 was 22755, checked in by Mathieu Morlighem, 7 years ago

CHG: added 21724-22754

File size: 199.4 KB
RevLine 
[22755]1Index: ../trunk-jpl/test/Par/SquareThermal.py
2===================================================================
3--- ../trunk-jpl/test/Par/SquareThermal.py (revision 22266)
4+++ ../trunk-jpl/test/Par/SquareThermal.py (revision 22267)
5@@ -25,6 +25,9 @@
6
7 print " creating temperatures"
8 md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices))
9+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,))
10+md.initialization.waterfraction=numpy.zeros((md.mesh.numberofvertices,))
11+md.initialization.watercolumn=numpy.zeros((md.mesh.numberofvertices,))
12
13 print " creating flow law parameter"
14 md.materials.rheology_B=paterson(md.initialization.temperature)
15@@ -32,7 +35,9 @@
16
17 print " creating surface mass balance"
18 md.smb.mass_balance=numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a
19-md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a
20+#md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a
21+md.basalforcings.groundedice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a
22+md.basalforcings.floatingice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a
23
24 #Deal with boundary conditions:
25
26@@ -40,6 +45,6 @@
27 md=SetMarineIceSheetBC(md,'../Exp/SquareFront.exp')
28
29 print " boundary conditions for thermal model"
30-md.thermal.spctemperature=md.initialization.temperature
31+md.thermal.spctemperature[:]=md.initialization.temperature
32 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices))
33 md.basalforcings.geothermalflux[numpy.nonzero(md.mask.groundedice_levelset>0.)[0]]=1.*10**-3 #1 mW/m^2
34Index: ../trunk-jpl/test/Par/ISMIPE.par
35===================================================================
36--- ../trunk-jpl/test/Par/ISMIPE.par (revision 22266)
37+++ ../trunk-jpl/test/Par/ISMIPE.par (revision 22267)
38@@ -13,6 +13,7 @@
39 md.geometry.base(i)=(1.-coeff)*data(point1,2)+coeff*data(point2,2);
40 md.geometry.surface(i)=(1.-coeff)*data(point1,3)+coeff*data(point2,3);
41 end
42+
43 md.geometry.thickness=md.geometry.surface-md.geometry.base;
44 md.geometry.thickness(find(~md.geometry.thickness))=0.01;
45 md.geometry.base=md.geometry.surface-md.geometry.thickness;
46Index: ../trunk-jpl/test/Par/ISMIPE.py
47===================================================================
48--- ../trunk-jpl/test/Par/ISMIPE.py (revision 22266)
49+++ ../trunk-jpl/test/Par/ISMIPE.py (revision 22267)
50@@ -12,9 +12,10 @@
51 y=md.mesh.y[i]
52 point1=numpy.floor(y/100.)
53 point2=numpy.minimum(point1+1,50)
54- coeff=(y-(point1-1.)*100.)/100.
55+ coeff=(y-(point1)*100.)/100.
56 md.geometry.base[i]=(1.-coeff)*data[point1,1]+coeff*data[point2,1]
57 md.geometry.surface[i]=(1.-coeff)*data[point1,2]+coeff*data[point2,2]
58+
59 md.geometry.thickness=md.geometry.surface-md.geometry.base
60 md.geometry.thickness[numpy.nonzero(numpy.logical_not(md.geometry.thickness))]=0.01
61 md.geometry.base=md.geometry.surface-md.geometry.thickness
62Index: ../trunk-jpl/test/NightlyRun/test2425.py
63===================================================================
64--- ../trunk-jpl/test/NightlyRun/test2425.py (nonexistent)
65+++ ../trunk-jpl/test/NightlyRun/test2425.py (revision 22267)
66@@ -0,0 +1,50 @@
67+#Test Name: SquareSheetShelfGroundingLine2dSoft
68+import numpy as np
69+from model import *
70+from socket import gethostname
71+from triangle import *
72+from setmask import *
73+from parameterize import *
74+from setflowequation import *
75+from solve import *
76+
77+md = triangle(model(),'../Exp/Square.exp',150000.)
78+md = setmask(md,'../Exp/SquareShelf.exp','')
79+md = parameterize(md,'../Par/SquareSheetShelf.py')
80+md = setflowequation(md,'SSA','all')
81+md.initialization.vx[:] = 0.
82+md.initialization.vy[:] = 0.
83+md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000.
84+md.geometry.bed = -700. - (md.mesh.y - 500000.) / 1000.
85+md.geometry.thickness[:] = 1300.
86+md.geometry.surface = md.geometry.base + md.geometry.thickness
87+md.transient.isstressbalance = 1
88+md.transient.isgroundingline = 1
89+md.groundingline.migration = 'AggressiveMigration'
90+
91+md.timestepping.time_step = .1
92+md.timestepping.final_time = 1
93+
94+md.cluster = generic('name',gethostname(),'np',3)
95+md = solve(md,'Transient')
96+vel1 = md.results.TransientSolution[-1].Vel
97+
98+#get same results with offset in bed and sea level:
99+md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000.
100+md.geometry.bed = -700. - (md.mesh.y - 500000.) / 1000.
101+md.geometry.thickness[:] = 1300.
102+md.geometry.surface = md.geometry.base + md.geometry.thickness
103+
104+md.geometry.base = md.geometry.base + 1000
105+md.geometry.bed = md.geometry.bed + 1000
106+md.geometry.surface = md.geometry.surface + 1000
107+md.slr.sealevel = 1000 * np.ones((md.mesh.numberofvertices,))
108+
109+md = solve(md,'Transient','checkconsistency','no')
110+vel2 = md.results.TransientSolution[-1].Vel
111+
112+#Fields and tolerances to track changes
113+field_names = ['Vel','Veloffset']
114+field_tolerances = [1e-13,1e-13]
115+field_values = [vel1,vel2]
116+
117Index: ../trunk-jpl/test/NightlyRun/test342.py
118===================================================================
119--- ../trunk-jpl/test/NightlyRun/test342.py (nonexistent)
120+++ ../trunk-jpl/test/NightlyRun/test342.py (revision 22267)
121@@ -0,0 +1,35 @@
122+#Test Name: SquareSheetTherSteaPlume
123+import numpy as np
124+from model import *
125+from socket import gethostname
126+from triangle import *
127+from setmask import *
128+from parameterize import *
129+from setflowequation import *
130+from solve import *
131+from plumebasalforcings import *
132+
133+md = triangle(model(),'../Exp/Square.exp',180000.)
134+md = setmask(md,'','')
135+md = parameterize(md,'../Par/SquareSheetConstrained.py')
136+md.basalforcings = plumebasalforcings()
137+md.basalforcings = md.basalforcings.setdefaultparameters()
138+md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,))
139+md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,))
140+md.basalforcings.plumex = 500000
141+md.basalforcings.plumey = 500000
142+md.extrude(3,1.)
143+md = setflowequation(md,'SSA','all')
144+md.timestepping.time_step = 0.
145+md.thermal.requested_outputs = ['default','BasalforcingsGeothermalflux']
146+md.cluster = generic('name',gethostname(),'np',3)
147+md = solve(md,'Thermal')
148+
149+#Fields and tolerances to track changes
150+field_names = ['Temperature','BasalforcingsGroundediceMeltingRate','BasalforcingsGeothermalflux']
151+field_tolerances = [1e-13,1e-8,1e-13]
152+field_values = [
153+ md.results.ThermalSolution.Temperature,
154+ md.results.ThermalSolution.BasalforcingsGroundediceMeltingRate,
155+ md.results.ThermalSolution.BasalforcingsGeothermalflux,
156+ ]
157Index: ../trunk-jpl/test/NightlyRun/test261.py
158===================================================================
159--- ../trunk-jpl/test/NightlyRun/test261.py (nonexistent)
160+++ ../trunk-jpl/test/NightlyRun/test261.py (revision 22267)
161@@ -0,0 +1,38 @@
162+#Test Name: SquareShelfConstrainedTranEnhanced
163+import numpy as np
164+from model import *
165+from socket import gethostname
166+from triangle import *
167+from setmask import *
168+from parameterize import *
169+from setflowequation import *
170+from solve import *
171+from matenhancedice import *
172+
173+md = triangle(model(),'../Exp/Square.exp',180000.)
174+md = setmask(md,'all','')
175+md = parameterize(md,'../Par/SquareShelfConstrained.py')
176+md = md.extrude(3,1.)
177+md = setflowequation(md,'SSA','all')
178+md.cluster = generic('name',gethostname(),'np',3)
179+md.materials = matenhancedice()
180+md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,)
181+md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,)
182+md.materials.rheology_E = np.ones(md.mesh.numberofvertices,)
183+md.transient.isstressbalance = 1
184+md.transient.ismasstransport = 0
185+md.transient.issmb = 1
186+md.transient.isthermal = 1
187+md.transient.isgroundingline = 0
188+md = solve(md,'Transient')
189+
190+#Fields and tolerances to track changes
191+field_names = ['Vx','Vy','Vel','Temperature','BasalforcingsGroundediceMeltingRate']
192+field_tolerances = [1e-13,1e-13,1e-13,1e-13,1e-13]
193+field_values = [
194+ md.results.TransientSolution[0].Vx,
195+ md.results.TransientSolution[0].Vy,
196+ md.results.TransientSolution[0].Vel,
197+ md.results.TransientSolution[0].Temperature,
198+ md.results.TransientSolution[0].BasalforcingsGroundediceMeltingRate,
199+ ]
200Index: ../trunk-jpl/test/NightlyRun/test441.py
201===================================================================
202--- ../trunk-jpl/test/NightlyRun/test441.py (nonexistent)
203+++ ../trunk-jpl/test/NightlyRun/test441.py (revision 22267)
204@@ -0,0 +1,93 @@
205+#Test Name: MISMIP3D
206+import numpy as np
207+from model import *
208+from socket import gethostname
209+from triangle import *
210+from setmask import *
211+from parameterize import *
212+from setflowequation import *
213+from solve import *
214+
215+md = triangle(model(),'../Exp/Square.exp',100000.)
216+md = setmask(md,'../Exp/SquareShelf.exp','')
217+md = parameterize(md,'../Par/SquareSheetShelf.py')
218+md.initialization.vx[:] = 1.
219+md.initialization.vy[:] = 1.
220+md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
221+md.geometry.bed = -100. - md.mesh.x / 1000.
222+md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
223+md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
224+pos = np.array(np.where(md.mask.groundedice_levelset >= 0.))
225+md.geometry.base[pos] = md.geometry.bed[pos]
226+md.geometry.surface = md.geometry.base + md.geometry.thickness
227+md = setflowequation(md,'SSA','all')
228+
229+#Boundary conditions:
230+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
231+md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
232+md.stressbalance.spcvx[:] = float('Nan')
233+md.stressbalance.spcvy[:] = float('Nan')
234+md.stressbalance.spcvz[:] = float('Nan')
235+posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
236+posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
237+pos = np.unique(np.concatenate((posA,posB)))
238+md.stressbalance.spcvy[pos] = 0.
239+pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
240+md.stressbalance.spcvx[pos2] = 0.
241+md.stressbalance.spcvy[pos2] = 0.
242+
243+md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
244+md.materials.rheology_law = 'None'
245+md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
246+md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
247+md.smb.mass_balance[:] = 1.
248+md.basalforcings.groundedice_melting_rate[:] = 0.
249+md.basalforcings.floatingice_melting_rate[:] = 30.
250+md.transient.isthermal = 0
251+md.transient.isstressbalance = 1
252+md.transient.isgroundingline = 1
253+md.transient.ismasstransport = 1
254+md.transient.issmb = 1
255+md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
256+md.groundingline.migration = 'SubelementMigration2'
257+md.timestepping.final_time = 30.
258+md.timestepping.time_step = 10.
259+
260+md.cluster = generic('name',gethostname(),'np',3)
261+md = solve(md,'Transient')
262+
263+#Fields and tolerances to track changes
264+field_names = [
265+ 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Pressure1','FloatingiceMeltingrate1',
266+ 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Pressure2','FloatingiceMeltingrate2',
267+ 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Pressure3','FloatingiceMeltingrate3']
268+field_tolerances = [
269+ 2e-11,5e-12,2e-11,1e-11,5e-10,1e-08,1e-13,1e-13,
270+ 3e-11,3e-11,9e-10,7e-11,1e-09,5e-08,1e-10,1e-13,
271+ 1e-10,3e-11,1e-10,7e-11,1e-09,5e-08,1e-10,1e-13]
272+field_values = [
273+ md.results.TransientSolution[0].Base,
274+ md.results.TransientSolution[0].Surface,
275+ md.results.TransientSolution[0].Thickness,
276+ md.results.TransientSolution[0].MaskGroundediceLevelset,
277+ md.results.TransientSolution[0].Vx,
278+ md.results.TransientSolution[0].Vy,
279+ md.results.TransientSolution[0].Pressure,
280+ md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate,
281+ md.results.TransientSolution[1].Base,
282+ md.results.TransientSolution[1].Surface,
283+ md.results.TransientSolution[1].Thickness,
284+ md.results.TransientSolution[1].MaskGroundediceLevelset,
285+ md.results.TransientSolution[1].Vx,
286+ md.results.TransientSolution[1].Vy,
287+ md.results.TransientSolution[1].Pressure,
288+ md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate,
289+ md.results.TransientSolution[2].Base,
290+ md.results.TransientSolution[2].Surface,
291+ md.results.TransientSolution[2].Thickness,
292+ md.results.TransientSolution[2].MaskGroundediceLevelset,
293+ md.results.TransientSolution[2].Vx,
294+ md.results.TransientSolution[2].Vy,
295+ md.results.TransientSolution[2].Pressure,
296+ md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate,
297+ ]
298Index: ../trunk-jpl/test/NightlyRun/test343.py
299===================================================================
300--- ../trunk-jpl/test/NightlyRun/test343.py (nonexistent)
301+++ ../trunk-jpl/test/NightlyRun/test343.py (revision 22267)
302@@ -0,0 +1,66 @@
303+#Test Name: SquareSheetConstrainedSmbGradientsEla2d
304+import numpy as np
305+from model import *
306+from socket import gethostname
307+from triangle import *
308+from setmask import *
309+from parameterize import *
310+from setflowequation import *
311+from solve import *
312+from SMBgradientsela import *
313+
314+md = triangle(model(),'../Exp/Square.exp',150000.)
315+md = setmask(md,'','')
316+md = parameterize(md,'../Par/SquareSheetConstrained.py')
317+md = setflowequation(md,'SSA','all')
318+md.smb = SMBgradientsela()
319+md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,))
320+md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,))
321+md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,))
322+md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
323+md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
324+
325+#Change geometry
326+md.geometry.thickness = md.geometry.surface * 30.
327+md.geometry.surface = md.geometry.base + md.geometry.thickness
328+
329+#Transient options
330+md.transient.requested_outputs = ['default','TotalSmb']
331+md.cluster = generic('name',gethostname(),'np',3)
332+md = solve(md,'Transient')
333+
334+#Fields and tolerances to track changes
335+field_names = [
336+ 'Vx1','Vy1','Vel1','Bed1','Surface1','Thickness1','SMB1','TotalSmb1',
337+ 'Vx2','Vy2','Vel2','Bed2','Surface2','Thickness2','SMB2','TotalSmb2',
338+ 'Vx3','Vy3','Vel3','Bed3','Surface3','Thickness3','SMB3','TotalSmb3']
339+field_tolerances = [
340+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,
341+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,
342+ 1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1.5e-13,1e-13]
343+field_values = [
344+ md.results.TransientSolution[0].Vx,
345+ md.results.TransientSolution[0].Vy,
346+ md.results.TransientSolution[0].Vel,
347+ md.results.TransientSolution[0].Base,
348+ md.results.TransientSolution[0].Surface,
349+ md.results.TransientSolution[0].Thickness,
350+ md.results.TransientSolution[0].SmbMassBalance,
351+ md.results.TransientSolution[0].TotalSmb,
352+ md.results.TransientSolution[1].Vx,
353+ md.results.TransientSolution[1].Vy,
354+ md.results.TransientSolution[1].Vel,
355+ md.results.TransientSolution[1].Base,
356+ md.results.TransientSolution[1].Surface,
357+ md.results.TransientSolution[1].Thickness,
358+ md.results.TransientSolution[1].TotalSmb,
359+ md.results.TransientSolution[1].SmbMassBalance,
360+ md.results.TransientSolution[2].Vx,
361+ md.results.TransientSolution[2].Vy,
362+ md.results.TransientSolution[2].Vel,
363+ md.results.TransientSolution[2].Base,
364+ md.results.TransientSolution[2].Surface,
365+ md.results.TransientSolution[2].Thickness,
366+ md.results.TransientSolution[2].SmbMassBalance,
367+ md.results.TransientSolution[2].TotalSmb
368+ ]
369Index: ../trunk-jpl/test/NightlyRun/test540.py
370===================================================================
371--- ../trunk-jpl/test/NightlyRun/test540.py (nonexistent)
372+++ ../trunk-jpl/test/NightlyRun/test540.py (revision 22267)
373@@ -0,0 +1,66 @@
374+#Test Name: PigTranCalvingDevSSA2d
375+from model import *
376+from socket import gethostname
377+from triangle import *
378+from setmask import *
379+from parameterize import *
380+from setflowequation import *
381+from solve import *
382+from calvingvonmises import *
383+
384+md = triangle(model(),'../Exp/Pig.exp',10000.)
385+md = setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp')
386+md = parameterize(md,'../Par/Pig.py')
387+md = setflowequation(md,'SSA','all')
388+md.timestepping.time_step = 2
389+md.timestepping.final_time = 50
390+
391+#calving parameters
392+md.mask.ice_levelset = 1e4 * (md.mask.ice_levelset + 0.5)
393+md.calving = calvingvonmises()
394+md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,))
395+md.transient.ismovingfront = 1
396+md.levelset.spclevelset = float('NaN') * np.ones((md.mesh.numberofvertices,))
397+pos = np.where(md.mesh.vertexonboundary)
398+md.levelset.spclevelset[pos] = md.mask.ice_levelset[pos]
399+
400+md.cluster = generic('name',gethostname(),'np',2)
401+md = solve(md,'Transient')
402+
403+#Fields and tolerances to track changes
404+field_names = [
405+ 'Vx1' ,'Vy1' ,'Vel1' ,'Pressure1' ,'Bed1' ,'Surface1' ,'Thickness1' ,'MaskIceLevelset1' ,
406+ 'Vx2' ,'Vy2' ,'Vel2' ,'Pressure2' ,'Bed2' ,'Surface2' ,'Thickness2' ,'MaskIceLevelset2' ,
407+ 'Vx10','Vy10','Vel10','Pressure10','Bed10','Surface10','Thickness10','MaskIceLevelset10',
408+ ]
409+field_tolerances = [
410+ 1e-12,2e-12,2e-12,1e-13,1e-13,1e-13,1e-13,1e-13,
411+ 1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1e-13,1e-12,
412+ 1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-9,
413+ ]
414+field_values = [
415+ md.results.TransientSolution[0].Vx,
416+ md.results.TransientSolution[0].Vy,
417+ md.results.TransientSolution[0].Vel,
418+ md.results.TransientSolution[0].Pressure,
419+ md.results.TransientSolution[0].Base,
420+ md.results.TransientSolution[0].Surface,
421+ md.results.TransientSolution[0].Thickness,
422+ md.results.TransientSolution[0].MaskIceLevelset,
423+ md.results.TransientSolution[1].Vx,
424+ md.results.TransientSolution[1].Vy,
425+ md.results.TransientSolution[1].Vel,
426+ md.results.TransientSolution[1].Pressure,
427+ md.results.TransientSolution[1].Base,
428+ md.results.TransientSolution[1].Surface,
429+ md.results.TransientSolution[1].Thickness,
430+ md.results.TransientSolution[1].MaskIceLevelset,
431+ md.results.TransientSolution[9].Vx,
432+ md.results.TransientSolution[9].Vy,
433+ md.results.TransientSolution[9].Vel,
434+ md.results.TransientSolution[9].Pressure,
435+ md.results.TransientSolution[9].Base,
436+ md.results.TransientSolution[9].Surface,
437+ md.results.TransientSolution[9].Thickness,
438+ md.results.TransientSolution[9].MaskIceLevelset,
439+ ]
440Index: ../trunk-jpl/test/NightlyRun/test442.py
441===================================================================
442--- ../trunk-jpl/test/NightlyRun/test442.py (nonexistent)
443+++ ../trunk-jpl/test/NightlyRun/test442.py (revision 22267)
444@@ -0,0 +1,97 @@
445+#Test Name: MISMIP3DHO
446+import numpy as np
447+from model import *
448+from socket import gethostname
449+from triangle import *
450+from setmask import *
451+from parameterize import *
452+from setflowequation import *
453+from solve import *
454+
455+md = triangle(model(),'../Exp/Square.exp',100000.)
456+md = setmask(md,'../Exp/SquareShelf.exp','')
457+md = parameterize(md,'../Par/SquareSheetShelf.py')
458+md.initialization.vx[:] = 1.
459+md.initialization.vy[:] = 1.
460+md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
461+md.geometry.bed = -100. - md.mesh.x / 1000.
462+md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
463+md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
464+pos = np.where(md.mask.groundedice_levelset >= 0.)
465+md.geometry.base[pos] = md.geometry.bed[pos]
466+md.geometry.surface = md.geometry.base + md.geometry.thickness
467+md = md.extrude(4,1.)
468+md = setflowequation(md,'HO','all')
469+
470+#Boundary conditions:
471+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
472+md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
473+md.stressbalance.spcvx[:] = float('Nan')
474+md.stressbalance.spcvy[:] = float('Nan')
475+md.stressbalance.spcvz[:] = float('Nan')
476+posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
477+posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
478+pos = np.unique(np.concatenate((posA,posB)))
479+md.stressbalance.spcvy[pos] = 0.
480+pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
481+md.stressbalance.spcvx[pos2] = 0.
482+md.stressbalance.spcvy[pos2] = 0.
483+
484+md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
485+md.materials.rheology_law = 'None'
486+md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
487+md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
488+md.smb.mass_balance[:] = 1.
489+md.basalforcings.groundedice_melting_rate[:] = 0.
490+md.basalforcings.floatingice_melting_rate[:] = 30.
491+md.transient.isthermal = 0
492+md.transient.isstressbalance = 1
493+md.transient.isgroundingline = 1
494+md.transient.ismasstransport = 1
495+md.transient.issmb = 1
496+md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
497+md.groundingline.migration = 'SubelementMigration2'
498+md.timestepping.final_time = 30
499+md.timestepping.time_step = 10
500+
501+md.cluster = generic('name',gethostname(),'np',3)
502+md = solve(md,'Transient')
503+
504+#Fields and tolerances to track changes
505+field_names = [
506+ 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Vz1','Pressure1','FloatingiceMeltingrate1',
507+ 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Vz2','Pressure2','FloatingiceMeltingrate2',
508+ 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Vz3','Pressure3','FloatingiceMeltingrate3']
509+field_tolerances = [
510+ 2e-11,5e-12,2e-11,1e-11,5e-10,3e-08,6e-10,1e-13,1e-13,
511+ 3e-11,3e-11,9e-10,7e-11,6e-09,1e-07,1e-09,1e-10,1e-13,
512+ 1e-8,2e-08,7e-09,2e-7 ,1e-03,8e-04,2e-09,1e-10,1e-13]
513+field_values = [
514+ md.results.TransientSolution[0].Base,
515+ md.results.TransientSolution[0].Surface,
516+ md.results.TransientSolution[0].Thickness,
517+ md.results.TransientSolution[0].MaskGroundediceLevelset,
518+ md.results.TransientSolution[0].Vx,
519+ md.results.TransientSolution[0].Vy,
520+ md.results.TransientSolution[0].Vz,
521+ md.results.TransientSolution[0].Pressure,
522+ md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate,
523+ md.results.TransientSolution[1].Base,
524+ md.results.TransientSolution[1].Surface,
525+ md.results.TransientSolution[1].Thickness,
526+ md.results.TransientSolution[1].MaskGroundediceLevelset,
527+ md.results.TransientSolution[1].Vx,
528+ md.results.TransientSolution[1].Vy,
529+ md.results.TransientSolution[1].Vz,
530+ md.results.TransientSolution[1].Pressure,
531+ md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate,
532+ md.results.TransientSolution[2].Base,
533+ md.results.TransientSolution[2].Surface,
534+ md.results.TransientSolution[2].Thickness,
535+ md.results.TransientSolution[2].MaskGroundediceLevelset,
536+ md.results.TransientSolution[2].Vx,
537+ md.results.TransientSolution[2].Vy,
538+ md.results.TransientSolution[2].Vz,
539+ md.results.TransientSolution[2].Pressure,
540+ md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate,
541+ ]
542Index: ../trunk-jpl/test/NightlyRun/test344.py
543===================================================================
544--- ../trunk-jpl/test/NightlyRun/test344.py (nonexistent)
545+++ ../trunk-jpl/test/NightlyRun/test344.py (revision 22267)
546@@ -0,0 +1,73 @@
547+#Test Name: SquareSheetConstrainedSmbGradientsEla3d
548+import numpy as np
549+from model import *
550+from socket import gethostname
551+from triangle import *
552+from setmask import *
553+from parameterize import *
554+from setflowequation import *
555+from solve import *
556+from SMBgradientsela import *
557+
558+md = triangle(model(),'../Exp/Square.exp',150000.)
559+md = setmask(md,'','')
560+md = parameterize(md,'../Par/SquareSheetConstrained.py')
561+
562+#Change geometry
563+md.geometry.thickness = md.geometry.surface * 30.
564+md.geometry.surface = md.geometry.base + md.geometry.thickness
565+
566+md = md.extrude(3,1.)
567+md = setflowequation(md,'HO','all')
568+md.smb = SMBgradientsela()
569+md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,))
570+md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,))
571+md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,))
572+md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
573+md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
574+
575+
576+#Transient options
577+md.transient.requested_outputs = ['default','TotalSmb']
578+md.cluster = generic('name',gethostname(),'np',3)
579+md = solve(md,'Transient')
580+
581+#Fields and tolerances to track changes
582+field_names = ['Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1',
583+ 'Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb2',
584+ 'Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb3']
585+field_tolerances = [1e-09,1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,
586+ 1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,
587+ 1e-09,5e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10]
588+field_values = [
589+ md.results.TransientSolution[0].Vx,
590+ md.results.TransientSolution[0].Vy,
591+ md.results.TransientSolution[0].Vz,
592+ md.results.TransientSolution[0].Vel,
593+ md.results.TransientSolution[0].Base,
594+ md.results.TransientSolution[0].Surface,
595+ md.results.TransientSolution[0].Thickness,
596+ md.results.TransientSolution[0].Temperature,
597+ md.results.TransientSolution[0].SmbMassBalance,
598+ md.results.TransientSolution[0].TotalSmb,
599+ md.results.TransientSolution[1].Vx,
600+ md.results.TransientSolution[1].Vy,
601+ md.results.TransientSolution[1].Vz,
602+ md.results.TransientSolution[1].Vel,
603+ md.results.TransientSolution[1].Base,
604+ md.results.TransientSolution[1].Surface,
605+ md.results.TransientSolution[1].Thickness,
606+ md.results.TransientSolution[1].Temperature,
607+ md.results.TransientSolution[1].SmbMassBalance,
608+ md.results.TransientSolution[1].TotalSmb,
609+ md.results.TransientSolution[2].Vx,
610+ md.results.TransientSolution[2].Vy,
611+ md.results.TransientSolution[2].Vz,
612+ md.results.TransientSolution[2].Vel,
613+ md.results.TransientSolution[2].Base,
614+ md.results.TransientSolution[2].Surface,
615+ md.results.TransientSolution[2].Thickness,
616+ md.results.TransientSolution[2].Temperature,
617+ md.results.TransientSolution[2].SmbMassBalance,
618+ md.results.TransientSolution[2].TotalSmb,
619+ ]
620Index: ../trunk-jpl/test/NightlyRun/test460.py
621===================================================================
622--- ../trunk-jpl/test/NightlyRun/test460.py (nonexistent)
623+++ ../trunk-jpl/test/NightlyRun/test460.py (revision 22267)
624@@ -0,0 +1,38 @@
625+#Test Name: SquareSheetShelfStressFSEstar
626+import numpy as np
627+from model import *
628+from socket import gethostname
629+from triangle import *
630+from setmask import *
631+from parameterize import *
632+from setflowequation import *
633+from solve import *
634+from matestar import *
635+
636+md=triangle(model(),'../Exp/Square.exp',180000.)
637+md=setmask(md,'../Exp/SquareShelf.exp','')
638+md=parameterize(md,'../Par/SquareSheetShelf.py')
639+md = md.extrude(3,1.)
640+md.materials = matestar()
641+md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,))
642+md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,))
643+md.materials.rheology_Es = 3 * np.ones((md.mesh.numberofvertices,))
644+md.cluster = generic('name',gethostname(),'np',3)
645+
646+#Go solve
647+field_names=[]
648+field_tolerances=[]
649+field_values=[]
650+#md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y);
651+for i in ['SSA','HO','FS']:
652+ md = setflowequation(md,i,'all')
653+ md = solve(md,'Stressbalance')
654+ field_names = field_names + ['Vx'+i,'Vy'+i,'Vz'+i,'Vel'+i,'Pressure'+i]
655+ field_tolerances = field_tolerances + [6e-07,6e-07,2e-06,1e-06,5e-07]
656+ field_values = field_values + [
657+ md.results.StressbalanceSolution.Vx,
658+ md.results.StressbalanceSolution.Vy,
659+ md.results.StressbalanceSolution.Vz,
660+ md.results.StressbalanceSolution.Vel,
661+ md.results.StressbalanceSolution.Pressure,
662+ ]
663Index: ../trunk-jpl/test/NightlyRun/test461.py
664===================================================================
665--- ../trunk-jpl/test/NightlyRun/test461.py (nonexistent)
666+++ ../trunk-jpl/test/NightlyRun/test461.py (revision 22267)
667@@ -0,0 +1,53 @@
668+#Test Name: SquareSheetShelfThermalFSEstar
669+import numpy as np
670+from model import *
671+from socket import gethostname
672+from triangle import *
673+from setmask import *
674+from parameterize import *
675+from setflowequation import *
676+from solve import *
677+from matestar import *
678+
679+md = triangle(model(),'../Exp/Square.exp',180000.)
680+md = setmask(md,'../Exp/SquareShelf.exp','')
681+md = parameterize(md,'../Par/SquareSheetShelf.py')
682+md = md.extrude(3,1.)
683+md.materials = matestar()
684+md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,))
685+md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,))
686+md.materials.rheology_Es = 3. * np.ones((md.mesh.numberofvertices,))
687+
688+md = setflowequation(md,'FS','all')
689+md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,))
690+md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,))
691+md.transient.isstressbalance = 0
692+md.transient.ismasstransport = 0
693+md.transient.issmb = 1
694+md.transient.isthermal = 1
695+md.transient.isgroundingline = 0
696+md.thermal.isenthalpy = 1
697+md.thermal.isdynamicbasalspc = 1
698+md.cluster = generic('name',gethostname(),'np',3)
699+md = solve(md,'Transient')
700+
701+#Fields and tolerances to track changes
702+field_names = [
703+ 'Enthalpy1','Waterfraction1','Temperature1',
704+ 'Enthalpy2','Waterfraction2','Temperature2',
705+ 'Enthalpy3','Waterfraction3','Temperature3']
706+field_tolerances = [
707+ 1e-12,1e-11,1e-12,
708+ 1e-12,1e-10,1e-12,
709+ 1e-12,1e-9,1e-12]
710+field_values = [
711+ md.results.TransientSolution[0].Enthalpy,
712+ md.results.TransientSolution[0].Waterfraction,
713+ md.results.TransientSolution[0].Temperature,
714+ md.results.TransientSolution[1].Enthalpy,
715+ md.results.TransientSolution[1].Waterfraction,
716+ md.results.TransientSolution[1].Temperature,
717+ md.results.TransientSolution[2].Enthalpy,
718+ md.results.TransientSolution[2].Waterfraction,
719+ md.results.TransientSolution[2].Temperature,
720+ ]
721Index: ../trunk-jpl/test/NightlyRun/test435.py
722===================================================================
723--- ../trunk-jpl/test/NightlyRun/test435.py (nonexistent)
724+++ ../trunk-jpl/test/NightlyRun/test435.py (revision 22267)
725@@ -0,0 +1,97 @@
726+#Test Name: MISMIP3DHO
727+import numpy as np
728+from model import *
729+from socket import gethostname
730+from triangle import *
731+from setmask import *
732+from parameterize import *
733+from setflowequation import *
734+from solve import *
735+
736+md = triangle(model(),'../Exp/Square.exp',100000.)
737+md = setmask(md,'../Exp/SquareShelf.exp','')
738+md = parameterize(md,'../Par/SquareSheetShelf.py')
739+md.initialization.vx[:] = 1.
740+md.initialization.vy[:] = 1.
741+md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
742+md.geometry.bed = -100. - md.mesh.x / 1000.
743+md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
744+md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
745+pos = np.where(md.mask.groundedice_levelset >= 0)
746+md.geometry.base[pos] = md.geometry.bed[pos]
747+md.geometry.surface = md.geometry.base + md.geometry.thickness
748+md = md.extrude(4,1.)
749+md = setflowequation(md,'HO','all')
750+
751+#Boundary conditions:
752+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
753+md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
754+md.stressbalance.spcvx[:] = float('Nan')
755+md.stressbalance.spcvy[:] = float('Nan')
756+md.stressbalance.spcvz[:] = float('Nan')
757+posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
758+posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
759+pos = np.unique(np.concatenate((posA,posB)))
760+md.stressbalance.spcvy[pos] = 0.
761+pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
762+md.stressbalance.spcvx[pos2] = 0.
763+md.stressbalance.spcvy[pos2] = 0.
764+
765+md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
766+md.materials.rheology_law = 'None'
767+md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
768+md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
769+md.smb.mass_balance[:] = 1.
770+md.basalforcings.groundedice_melting_rate[:] = 0.
771+md.basalforcings.floatingice_melting_rate[:] = 30.
772+md.transient.isthermal = 0
773+md.transient.isstressbalance = 1
774+md.transient.isgroundingline = 1
775+md.transient.ismasstransport = 1
776+md.transient.issmb = 1
777+md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
778+md.groundingline.migration = 'SubelementMigration'
779+md.timestepping.final_time = 30
780+md.timestepping.time_step = 10
781+
782+md.cluster = generic('name',gethostname(),'np',3)
783+md = solve(md,'Transient')
784+
785+#Fields and tolerances to track changes
786+field_names = [
787+ 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Vz1','Pressure1','FloatingiceMeltingrate1',
788+ 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Vz2','Pressure2','FloatingiceMeltingrate2',
789+ 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Vz3','Pressure3','FloatingiceMeltingrate3']
790+field_tolerances = [
791+ 2e-11,5e-12,2e-11,1e-11,5e-10,3e-08,6e-10,1e-13,1e-13,
792+ 3e-11,3e-11,9e-10,7e-11,6e-09,1e-07,1e-09,1e-10,1e-13,
793+ 1e-9,2e-08,7e-09,2e-7 ,1e-03,8e-04,2e-09,1e-10,1e-13]
794+field_values = [
795+ md.results.TransientSolution[0].Base,
796+ md.results.TransientSolution[0].Surface,
797+ md.results.TransientSolution[0].Thickness,
798+ md.results.TransientSolution[0].MaskGroundediceLevelset,
799+ md.results.TransientSolution[0].Vx,
800+ md.results.TransientSolution[0].Vy,
801+ md.results.TransientSolution[0].Vz,
802+ md.results.TransientSolution[0].Pressure,
803+ md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate,
804+ md.results.TransientSolution[1].Base,
805+ md.results.TransientSolution[1].Surface,
806+ md.results.TransientSolution[1].Thickness,
807+ md.results.TransientSolution[1].MaskGroundediceLevelset,
808+ md.results.TransientSolution[1].Vx,
809+ md.results.TransientSolution[1].Vy,
810+ md.results.TransientSolution[1].Vz,
811+ md.results.TransientSolution[1].Pressure,
812+ md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate,
813+ md.results.TransientSolution[2].Base,
814+ md.results.TransientSolution[2].Surface,
815+ md.results.TransientSolution[2].Thickness,
816+ md.results.TransientSolution[2].MaskGroundediceLevelset,
817+ md.results.TransientSolution[2].Vx,
818+ md.results.TransientSolution[2].Vy,
819+ md.results.TransientSolution[2].Vz,
820+ md.results.TransientSolution[2].Pressure,
821+ md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate,
822+ ]
823Index: ../trunk-jpl/test/NightlyRun/test462.py
824===================================================================
825--- ../trunk-jpl/test/NightlyRun/test462.py (nonexistent)
826+++ ../trunk-jpl/test/NightlyRun/test462.py (revision 22267)
827@@ -0,0 +1,49 @@
828+#Test Name: SquareSheetShelfAmrBamgField
829+import numpy as np
830+from model import *
831+from socket import gethostname
832+from triangle import *
833+from setmask import *
834+from parameterize import *
835+from setflowequation import *
836+from solve import *
837+
838+md = triangle(model(),'../Exp/Square.exp',150000.)
839+md = setmask(md,'../Exp/SquareShelf.exp','')
840+md = parameterize(md,'../Par/SquareSheetShelf.py')
841+md = setflowequation(md,'SSA','all')
842+md.cluster = generic('name',gethostname(),'np',3)
843+md.transient.isstressbalance = 1
844+md.transient.ismasstransport = 1
845+md.transient.issmb = 0
846+md.transient.isthermal = 0
847+md.transient.isgroundingline = 0
848+#amr bamg settings, just field
849+md.amr.hmin = 10000
850+md.amr.hmax = 100000
851+md.amr.fieldname = 'Vel'
852+md.amr.keepmetric = 1
853+md.amr.gradation = 1.2
854+md.amr.groundingline_resolution = 2000
855+md.amr.groundingline_distance = 0
856+md.amr.icefront_resolution = 1000
857+md.amr.icefront_distance = 0
858+md.amr.thicknesserror_resolution = 1000
859+md.amr.thicknesserror_threshold = 0
860+md.amr.deviatoricerror_resolution = 1000
861+md.amr.deviatoricerror_threshold = 0
862+md.transient.amr_frequency = 1
863+md.timestepping.start_time = 0
864+md.timestepping.final_time = 3
865+md.timestepping.time_step = 1
866+md = solve(md,'Transient')
867+
868+#Fields and tolerances to track changes
869+field_names = ['Vx','Vy','Vel','Pressure']
870+field_tolerances = [1e-13,1e-13,1e-13,1e-13]
871+field_values = [
872+ md.results.TransientSolution[2].Vx,
873+ md.results.TransientSolution[2].Vy,
874+ md.results.TransientSolution[2].Vel,
875+ md.results.TransientSolution[2].Pressure,
876+ ]
877Index: ../trunk-jpl/test/NightlyRun/test436.py
878===================================================================
879--- ../trunk-jpl/test/NightlyRun/test436.py (nonexistent)
880+++ ../trunk-jpl/test/NightlyRun/test436.py (revision 22267)
881@@ -0,0 +1,45 @@
882+#Test Name: SquareSheetShelfSteaEnthalpyRheologiesHO
883+import numpy as np
884+from model import *
885+from socket import gethostname
886+from triangle import *
887+from setmask import *
888+from parameterize import *
889+from setflowequation import *
890+from solve import *
891+
892+md = triangle(model(),'../Exp/Square.exp',150000.)
893+md = setmask(md,'../Exp/SquareShelf.exp','')
894+md = parameterize(md,'../Par/SquareSheetShelf.py')
895+md = md.extrude(3,2.)
896+md = setflowequation(md,'HO','all')
897+md.cluster = generic('name',gethostname(),'np',3)
898+md.timestepping.time_step = 0.
899+md.thermal.isenthalpy = 1
900+md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,))
901+md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,))
902+
903+#Go solve
904+field_names = []
905+field_tolerances = []
906+field_values = []
907+for i in ['LliboutryDuval', 'CuffeyTemperate']:
908+ print ' '
909+ print '====== Testing rheology law: ' + i + ' ====='
910+
911+ md.materials.rheology_law = i
912+ md = solve(md,'Steadystate')
913+ field_names += ['Vx'+i,'Vy'+i,'Vz'+i,'Vel'+i,'Pressure'+i,
914+ 'Temperature'+i,'Waterfraction'+i,'Enthalpy'+i]
915+ field_tolerances += [2e-09,1e-09,1e-09,1e-09,1e-13,1e-10,6e-10,5e-10]
916+ field_values += [
917+ md.results.SteadystateSolution.Vx,
918+ md.results.SteadystateSolution.Vy,
919+ md.results.SteadystateSolution.Vz,
920+ md.results.SteadystateSolution.Vel,
921+ md.results.SteadystateSolution.Pressure,
922+ md.results.SteadystateSolution.Temperature,
923+ md.results.SteadystateSolution.Waterfraction,
924+ md.results.SteadystateSolution.Enthalpy,
925+ ]
926+
927Index: ../trunk-jpl/test/NightlyRun/test463.py
928===================================================================
929--- ../trunk-jpl/test/NightlyRun/test463.py (nonexistent)
930+++ ../trunk-jpl/test/NightlyRun/test463.py (revision 22267)
931@@ -0,0 +1,49 @@
932+#Test Name: SquareSheetShelfAmrBamgGroundingline
933+import numpy as np
934+from model import *
935+from socket import gethostname
936+from triangle import *
937+from setmask import *
938+from parameterize import *
939+from setflowequation import *
940+from solve import *
941+
942+md = triangle(model(),'../Exp/Square.exp',150000.)
943+md = setmask(md,'../Exp/SquareShelf.exp','')
944+md = parameterize(md,'../Par/SquareSheetShelf.py')
945+md = setflowequation(md,'SSA','all')
946+md.cluster = generic('name',gethostname(),'np',3)
947+md.transient.isstressbalance = 1
948+md.transient.ismasstransport = 1
949+md.transient.issmb = 0
950+md.transient.isthermal = 0
951+md.transient.isgroundingline = 0
952+#amr bamg settings, just grounding line
953+md.amr.hmin = 10000
954+md.amr.hmax = 100000
955+md.amr.fieldname = 'None'
956+md.amr.keepmetric = 0
957+md.amr.gradation = 1.2
958+md.amr.groundingline_resolution = 12000
959+md.amr.groundingline_distance = 100000
960+md.amr.icefront_resolution = 1000
961+md.amr.icefront_distance = 0
962+md.amr.thicknesserror_resolution = 1000
963+md.amr.thicknesserror_threshold = 0
964+md.amr.deviatoricerror_resolution = 1000
965+md.amr.deviatoricerror_threshold = 0
966+md.transient.amr_frequency = 1
967+md.timestepping.start_time = 0
968+md.timestepping.final_time = 3
969+md.timestepping.time_step = 1
970+md = solve(md,'Transient')
971+
972+#Fields and tolerances to track changes
973+field_names = ['Vx','Vy','Vel','Pressure']
974+field_tolerances = [1e-8,1e-8,1e-8,1e-8]
975+field_values = [
976+ md.results.TransientSolution[2].Vx,
977+ md.results.TransientSolution[2].Vy,
978+ md.results.TransientSolution[2].Vel,
979+ md.results.TransientSolution[2].Pressure,
980+ ]
981Index: ../trunk-jpl/test/NightlyRun/test437.py
982===================================================================
983--- ../trunk-jpl/test/NightlyRun/test437.py (nonexistent)
984+++ ../trunk-jpl/test/NightlyRun/test437.py (revision 22267)
985@@ -0,0 +1,96 @@
986+#Test Name: ThermalEnthBasalcondsTrans
987+import numpy as np
988+from model import *
989+from socket import gethostname
990+from triangle import *
991+from setmask import *
992+from parameterize import *
993+from setflowequation import *
994+from solve import *
995+
996+md = triangle(model(),'../Exp/Square.exp',300000.)
997+md = setmask(md,'','')
998+md = parameterize(md,'../Par/SquareThermal.py')
999+
1000+h = 100.
1001+md.geometry.thickness = h * np.ones((md.mesh.numberofvertices,))
1002+md.geometry.base = -h * np.ones((md.mesh.numberofvertices,))
1003+md.geometry.surface = md.geometry.base + md.geometry.thickness
1004+
1005+md.extrude(41,2.)
1006+md = setflowequation(md,'HO','all')
1007+md.thermal.isenthalpy = True
1008+md.thermal.isdynamicbasalspc = True
1009+
1010+#Basal forcing
1011+Ts = 273.15-3.
1012+Tb = 273.15-1.
1013+Tsw = Tb
1014+qgeo = md.materials.thermalconductivity / max(md.geometry.thickness) * (Tb - Ts) #qgeo=kappa*(Tb-Ts)/H
1015+md.basalforcings.geothermalflux[np.where(md.mesh.vertexonbase)] = qgeo
1016+md.initialization.temperature = qgeo / md.materials.thermalconductivity * (md.geometry.surface - md.mesh.z) + Ts
1017+
1018+#Surface forcing
1019+pos = np.where(md.mesh.vertexonsurface)
1020+SPC_cold = float('NaN') * np.ones((md.mesh.numberofvertices,))
1021+SPC_warm = float('NaN') * np.ones((md.mesh.numberofvertices,))
1022+SPC_cold[pos] = Ts
1023+SPC_warm[pos] = Tsw
1024+md.thermal.spctemperature = SPC_cold
1025+md.timestepping.time_step = 5.
1026+t0 = 0.
1027+t1 = 10.
1028+t2 = 100.
1029+md.timestepping.final_time = 400.
1030+md.thermal.spctemperature = np.array([SPC_cold,SPC_cold,SPC_warm,SPC_warm,SPC_cold]).T
1031+md.thermal.spctemperature = np.vstack((md.thermal.spctemperature,[t0, t1-1, t1, t2-1, t2]))
1032+#print np.shape(md.thermal.spctemperature)
1033+#print md.thermal.spctemperature
1034+
1035+#Additional settings
1036+md.transient.ismasstransport = False
1037+md.transient.isstressbalance = False
1038+md.transient.issmb = True
1039+md.transient.isthermal = True
1040+md.thermal.stabilization = False
1041+
1042+#Go solve
1043+md.verbose = verbose(0)
1044+md.cluster = generic('name',gethostname(),'np',3)
1045+md = solve(md,'Transient')
1046+
1047+#Fields and tolerances to track changes
1048+field_names = ['Enthalpy1','Temperature1','Waterfraction1','BasalMeltingRate1','Watercolumn1',
1049+ 'Enthalpy2','Temperature2','Waterfraction2','BasalMeltingRate2','Watercolumn2',
1050+ 'Enthalpy3','Temperature3','Waterfraction3','BasalMeltingRate3','Watercolumn3',
1051+ 'Enthalpy4','Temperature4','Waterfraction4','BasalMeltingRate4','Watercolumn4']
1052+field_tolerances = [1.e-10,1.e-10,1.e-10,1.e-9,1.e-10,
1053+ 1.e-10,1.e-10,1.e-10,2.e-9,2.e-10,
1054+ 1.e-10,1.e-10,1.e-10,2.e-9,1.e-10,
1055+ 1.e-10,1.e-10,1.e-10,2.e-9,1.e-10]
1056+i1 = 0
1057+i2 = int(np.ceil(t2 / md.timestepping.time_step) + 2)-1
1058+i3 = int(np.ceil(md.timestepping.final_time / (2. * md.timestepping.time_step)))-1
1059+i4 = np.shape(md.results.TransientSolution)[0]-1
1060+field_values = [
1061+ md.results.TransientSolution[i1].Enthalpy,
1062+ md.results.TransientSolution[i1].Temperature,
1063+ md.results.TransientSolution[i1].Waterfraction,
1064+ md.results.TransientSolution[i1].BasalforcingsGroundediceMeltingRate,
1065+ md.results.TransientSolution[i1].Watercolumn,
1066+ md.results.TransientSolution[i2].Enthalpy,
1067+ md.results.TransientSolution[i2].Temperature,
1068+ md.results.TransientSolution[i2].Waterfraction,
1069+ md.results.TransientSolution[i2].BasalforcingsGroundediceMeltingRate,
1070+ md.results.TransientSolution[i2].Watercolumn,
1071+ md.results.TransientSolution[i3].Enthalpy,
1072+ md.results.TransientSolution[i3].Temperature,
1073+ md.results.TransientSolution[i3].Waterfraction,
1074+ md.results.TransientSolution[i3].BasalforcingsGroundediceMeltingRate,
1075+ md.results.TransientSolution[i3].Watercolumn,
1076+ md.results.TransientSolution[i4].Enthalpy,
1077+ md.results.TransientSolution[i4].Temperature,
1078+ md.results.TransientSolution[i4].Waterfraction,
1079+ md.results.TransientSolution[i4].BasalforcingsGroundediceMeltingRate,
1080+ md.results.TransientSolution[i4].Watercolumn,
1081+ ]
1082Index: ../trunk-jpl/test/NightlyRun/test464.py
1083===================================================================
1084--- ../trunk-jpl/test/NightlyRun/test464.py (nonexistent)
1085+++ ../trunk-jpl/test/NightlyRun/test464.py (revision 22267)
1086@@ -0,0 +1,49 @@
1087+#Test Name: SquareSheetShelfAmrBamgIceFront
1088+import numpy as np
1089+from model import *
1090+from socket import gethostname
1091+from triangle import *
1092+from setmask import *
1093+from parameterize import *
1094+from setflowequation import *
1095+from solve import *
1096+
1097+md = triangle(model(),'../Exp/Square.exp',150000.)
1098+md = setmask(md,'../Exp/SquareShelf.exp','')
1099+md = parameterize(md,'../Par/SquareSheetShelf.py')
1100+md = setflowequation(md,'SSA','all')
1101+md.cluster = generic('name',gethostname(),'np',3)
1102+md.transient.isstressbalance = 1
1103+md.transient.ismasstransport = 1
1104+md.transient.issmb = 0
1105+md.transient.isthermal = 0
1106+md.transient.isgroundingline = 0
1107+#amr bamg settings, just ice front
1108+md.amr.hmin = 10000
1109+md.amr.hmax = 100000
1110+md.amr.fieldname = 'None'
1111+md.amr.keepmetric = 0
1112+md.amr.gradation = 1.2
1113+md.amr.groundingline_resolution = 12000
1114+md.amr.groundingline_distance = 0
1115+md.amr.icefront_resolution = 12000
1116+md.amr.icefront_distance = 100000
1117+md.amr.thicknesserror_resolution = 1000
1118+md.amr.thicknesserror_threshold = 0
1119+md.amr.deviatoricerror_resolution = 1000
1120+md.amr.deviatoricerror_threshold = 0
1121+md.transient.amr_frequency = 1
1122+md.timestepping.start_time = 0
1123+md.timestepping.final_time = 3
1124+md.timestepping.time_step = 1
1125+md = solve(md,'Transient')
1126+
1127+#Fields and tolerances to track changes
1128+field_names = ['Vx','Vy','Vel','Pressure']
1129+field_tolerances = [1e-13,1e-13,1e-13,1e-13]
1130+field_values = [
1131+ md.results.TransientSolution[2].Vx,
1132+ md.results.TransientSolution[2].Vy,
1133+ md.results.TransientSolution[2].Vel,
1134+ md.results.TransientSolution[2].Pressure,
1135+ ]
1136Index: ../trunk-jpl/test/NightlyRun/test438.py
1137===================================================================
1138--- ../trunk-jpl/test/NightlyRun/test438.py (nonexistent)
1139+++ ../trunk-jpl/test/NightlyRun/test438.py (revision 22267)
1140@@ -0,0 +1,53 @@
1141+#Test Name: TransientFrictionWaterlayer2D
1142+import numpy as np
1143+from model import *
1144+from socket import gethostname
1145+from triangle import *
1146+from setmask import *
1147+from parameterize import *
1148+from setflowequation import *
1149+from solve import *
1150+from frictionwaterlayer import *
1151+
1152+md = triangle(model(),'../Exp/Square.exp',150000.)
1153+md = setmask(md,'../Exp/SquareShelf.exp','')
1154+md = parameterize(md,'../Par/SquareSheetShelf.py')
1155+md = setflowequation(md,'SSA','all')
1156+md.friction = frictionwaterlayer(md)
1157+md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2))
1158+md.friction.water_layer[:,1] = 1.
1159+md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.]
1160+md.friction.f = 0.8
1161+md.cluster = generic('name',gethostname(),'np',3)
1162+md = solve(md,'Transient')
1163+
1164+#Fields and tolerances to track changes
1165+field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',
1166+ 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',
1167+ 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3']
1168+field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,
1169+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,
1170+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13]
1171+field_values = [
1172+ md.results.TransientSolution[0].Vx,
1173+ md.results.TransientSolution[0].Vy,
1174+ md.results.TransientSolution[0].Vel,
1175+ md.results.TransientSolution[0].Pressure,
1176+ md.results.TransientSolution[0].Base,
1177+ md.results.TransientSolution[0].Surface,
1178+ md.results.TransientSolution[0].Thickness,
1179+ md.results.TransientSolution[1].Vx,
1180+ md.results.TransientSolution[1].Vy,
1181+ md.results.TransientSolution[1].Vel,
1182+ md.results.TransientSolution[1].Pressure,
1183+ md.results.TransientSolution[1].Base,
1184+ md.results.TransientSolution[1].Surface,
1185+ md.results.TransientSolution[1].Thickness,
1186+ md.results.TransientSolution[2].Vx,
1187+ md.results.TransientSolution[2].Vy,
1188+ md.results.TransientSolution[2].Vel,
1189+ md.results.TransientSolution[2].Pressure,
1190+ md.results.TransientSolution[2].Base,
1191+ md.results.TransientSolution[2].Surface,
1192+ md.results.TransientSolution[2].Thickness
1193+ ]
1194Index: ../trunk-jpl/test/NightlyRun/test465.py
1195===================================================================
1196--- ../trunk-jpl/test/NightlyRun/test465.py (nonexistent)
1197+++ ../trunk-jpl/test/NightlyRun/test465.py (revision 22267)
1198@@ -0,0 +1,49 @@
1199+#Test Name: SquareSheetShelfAmrBamgAll
1200+import numpy as np
1201+from model import *
1202+from socket import gethostname
1203+from triangle import *
1204+from setmask import *
1205+from parameterize import *
1206+from setflowequation import *
1207+from solve import *
1208+
1209+md = triangle(model(),'../Exp/Square.exp',150000.)
1210+md = setmask(md,'../Exp/SquareShelf.exp','')
1211+md = parameterize(md,'../Par/SquareSheetShelf.py')
1212+md = setflowequation(md,'SSA','all')
1213+md.cluster = generic('name',gethostname(),'np',3)
1214+md.transient.isstressbalance = 1
1215+md.transient.ismasstransport = 1
1216+md.transient.issmb = 0
1217+md.transient.isthermal = 0
1218+md.transient.isgroundingline = 0
1219+#amr bamg settings, field, grounding line and ice front
1220+md.amr.hmin = 20000
1221+md.amr.hmax = 100000
1222+md.amr.fieldname = 'Vel'
1223+md.amr.keepmetric = 0
1224+md.amr.gradation = 1.2
1225+md.amr.groundingline_resolution = 10000
1226+md.amr.groundingline_distance = 100000
1227+md.amr.icefront_resolution = 15000
1228+md.amr.icefront_distance = 100000
1229+md.amr.thicknesserror_resolution = 1000
1230+md.amr.thicknesserror_threshold = 0
1231+md.amr.deviatoricerror_resolution = 1000
1232+md.amr.deviatoricerror_threshold = 0
1233+md.transient.amr_frequency = 1
1234+md.timestepping.start_time = 0
1235+md.timestepping.final_time = 3
1236+md.timestepping.time_step = 1
1237+md = solve(md,'Transient')
1238+
1239+#Fields and tolerances to track changes
1240+field_names = ['Vx','Vy','Vel','Pressure']
1241+field_tolerances = [1e-8,1e-8,1e-8,1e-8]
1242+field_values = [
1243+ md.results.TransientSolution[2].Vx,
1244+ md.results.TransientSolution[2].Vy,
1245+ md.results.TransientSolution[2].Vel,
1246+ md.results.TransientSolution[2].Pressure,
1247+ ]
1248Index: ../trunk-jpl/test/NightlyRun/test439.py
1249===================================================================
1250--- ../trunk-jpl/test/NightlyRun/test439.py (nonexistent)
1251+++ ../trunk-jpl/test/NightlyRun/test439.py (revision 22267)
1252@@ -0,0 +1,54 @@
1253+#Test Name: TransientFrictionWaterlayer3D
1254+import numpy as np
1255+from model import *
1256+from socket import gethostname
1257+from triangle import *
1258+from setmask import *
1259+from parameterize import *
1260+from setflowequation import *
1261+from solve import *
1262+from frictionwaterlayer import *
1263+
1264+md = triangle(model(),'../Exp/Square.exp',150000.)
1265+md = setmask(md,'../Exp/SquareShelf.exp','')
1266+md = parameterize(md,'../Par/SquareSheetShelf.py')
1267+md = md.extrude(4,1.)
1268+md = setflowequation(md,'HO','all')
1269+md.friction = frictionwaterlayer(md)
1270+md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2))
1271+md.friction.water_layer[:,1] = 1.
1272+md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.]
1273+md.friction.f = 0.8
1274+md.cluster = generic('name',gethostname(),'np',3)
1275+md = solve(md,'Transient')
1276+
1277+#Fields and tolerances to track changes
1278+field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',
1279+ 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',
1280+ 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3']
1281+field_tolerances = [1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,
1282+ 1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,
1283+ 1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09]
1284+field_values = [
1285+ md.results.TransientSolution[0].Vx,
1286+ md.results.TransientSolution[0].Vy,
1287+ md.results.TransientSolution[0].Vel,
1288+ md.results.TransientSolution[0].Pressure,
1289+ md.results.TransientSolution[0].Base,
1290+ md.results.TransientSolution[0].Surface,
1291+ md.results.TransientSolution[0].Thickness,
1292+ md.results.TransientSolution[1].Vx,
1293+ md.results.TransientSolution[1].Vy,
1294+ md.results.TransientSolution[1].Vel,
1295+ md.results.TransientSolution[1].Pressure,
1296+ md.results.TransientSolution[1].Base,
1297+ md.results.TransientSolution[1].Surface,
1298+ md.results.TransientSolution[1].Thickness,
1299+ md.results.TransientSolution[2].Vx,
1300+ md.results.TransientSolution[2].Vy,
1301+ md.results.TransientSolution[2].Vel,
1302+ md.results.TransientSolution[2].Pressure,
1303+ md.results.TransientSolution[2].Base,
1304+ md.results.TransientSolution[2].Surface,
1305+ md.results.TransientSolution[2].Thickness
1306+ ]
1307Index: ../trunk-jpl/test/NightlyRun/test340.py
1308===================================================================
1309--- ../trunk-jpl/test/NightlyRun/test340.py (nonexistent)
1310+++ ../trunk-jpl/test/NightlyRun/test340.py (revision 22267)
1311@@ -0,0 +1,46 @@
1312+#Test Name: SquareSheetConstrainedSmbGradientsEla3d
1313+import numpy as np
1314+from model import *
1315+from socket import gethostname
1316+from triangle import *
1317+from setmask import *
1318+from parameterize import *
1319+from setflowequation import *
1320+from solve import *
1321+from taoinversion import *
1322+
1323+md = triangle(model(),'../Exp/Square.exp',200000.)
1324+md = setmask(md,'','')
1325+md = parameterize(md,'../Par/SquareSheetConstrained.py')
1326+md.extrude(3,1.)
1327+md = setflowequation(md,'HO','all')
1328+
1329+#control parameters
1330+md.inversion = taoinversion()
1331+md.inversion.iscontrol = 1
1332+md.inversion.control_parameters = ['FrictionCoefficient']
1333+md.inversion.min_parameters = 1. * np.ones((md.mesh.numberofvertices,))
1334+md.inversion.max_parameters = 200. * np.ones((md.mesh.numberofvertices,))
1335+md.inversion.maxsteps = 2
1336+md.inversion.maxiter = 6
1337+md.inversion.cost_functions = [102,501]
1338+md.inversion.cost_functions_coefficients = np.ones((md.mesh.numberofvertices,2))
1339+md.inversion.cost_functions_coefficients[:,1] = 2. * 1e-7
1340+md.inversion.vx_obs = md.initialization.vx
1341+md.inversion.vy_obs = md.initialization.vy
1342+
1343+md.cluster = generic('name',gethostname(),'np',3)
1344+md = solve(md,'Stressbalance')
1345+
1346+#Fields and tolerances to track changes
1347+field_names = ['Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy']
1348+field_tolerances = [3e-08,1e-07,5e-10,1e-10,1e-09,1e-09,1e-09]
1349+field_values = [
1350+ md.results.StressbalanceSolution.Gradient1,
1351+ md.results.StressbalanceSolution.J,
1352+ md.results.StressbalanceSolution.FrictionCoefficient,
1353+ md.results.StressbalanceSolution.Pressure,
1354+ md.results.StressbalanceSolution.Vel,
1355+ md.results.StressbalanceSolution.Vx,
1356+ md.results.StressbalanceSolution.Vy
1357+]
1358Index: ../trunk-jpl/test/NightlyRun/test430.py
1359===================================================================
1360--- ../trunk-jpl/test/NightlyRun/test430.py (nonexistent)
1361+++ ../trunk-jpl/test/NightlyRun/test430.py (revision 22267)
1362@@ -0,0 +1,95 @@
1363+#Test Name: MISMIP3D
1364+import numpy as np
1365+from model import *
1366+from socket import gethostname
1367+from triangle import *
1368+from setmask import *
1369+from parameterize import *
1370+from setflowequation import *
1371+from solve import *
1372+
1373+md = triangle(model(),'../Exp/Square.exp',100000.)
1374+md = setmask(md,'../Exp/SquareShelf.exp','')
1375+md = parameterize(md,'../Par/SquareSheetShelf.py')
1376+md.initialization.vx[:] = 1.
1377+md.initialization.vy[:] = 1.
1378+md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
1379+md.geometry.bed = -100. - md.mesh.x / 1000.
1380+md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
1381+md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
1382+pos = np.where(md.mask.groundedice_levelset >= 0.)
1383+md.geometry.base[pos] = md.geometry.bed[pos]
1384+md.geometry.surface = md.geometry.base + md.geometry.thickness
1385+md = setflowequation(md,'SSA','all')
1386+
1387+#Boundary conditions:
1388+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
1389+md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
1390+md.stressbalance.spcvx[:] = float('NaN')
1391+md.stressbalance.spcvy[:] = float('NaN')
1392+md.stressbalance.spcvz[:] = float('NaN')
1393+posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
1394+posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
1395+pos = np.unique(np.concatenate((posA,posB)))
1396+md.stressbalance.spcvy[pos] = 0.
1397+pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
1398+md.stressbalance.spcvx[pos2] = 0.
1399+md.stressbalance.spcvy[pos2] = 0.
1400+
1401+md.materials.rheology_B = 1. / ((10**-25)**(1. / 3.)) * np.ones((md.mesh.numberofvertices,))
1402+md.materials.rheology_law = 'None'
1403+md.friction.coefficient[:] = np.sqrt(10**7) * np.ones((md.mesh.numberofvertices,))
1404+md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
1405+md.smb.mass_balance[:] = 1.
1406+md.basalforcings.groundedice_melting_rate[:] = 0.
1407+md.basalforcings.floatingice_melting_rate[:] = 30.
1408+md.transient.isthermal = 0
1409+md.transient.isstressbalance = 1
1410+md.transient.isgroundingline = 1
1411+md.transient.ismasstransport = 1
1412+md.transient.issmb = 1
1413+md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
1414+md.groundingline.migration = 'SubelementMigration'
1415+md.timestepping.final_time = 30
1416+md.timestepping.time_step = 10
1417+
1418+md.cluster = generic('name',gethostname(),'np',3)
1419+md = solve(md,'Transient')
1420+#print md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate
1421+#print md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate
1422+#print md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate
1423+
1424+#Fields and tolerances to track changes
1425+field_names = [
1426+ 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Pressure1','FloatingiceMeltingrate1',
1427+ 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Pressure2','FloatingiceMeltingrate2',
1428+ 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Pressure3','FloatingiceMeltingrate3']
1429+field_tolerances = [2e-11,5e-12,2e-11,1e-11,5e-10,1e-08,1e-13,1e-13,
1430+ 3e-11,3e-11,9e-10,7e-11,1e-09,5e-08,1e-10,1e-13,
1431+ 1e-10,3e-11,1e-10,7e-11,1e-09,5e-08,1e-10,1e-13]
1432+field_values = [
1433+ md.results.TransientSolution[0].Base,
1434+ md.results.TransientSolution[0].Surface,
1435+ md.results.TransientSolution[0].Thickness,
1436+ md.results.TransientSolution[0].MaskGroundediceLevelset,
1437+ md.results.TransientSolution[0].Vx,
1438+ md.results.TransientSolution[0].Vy,
1439+ md.results.TransientSolution[0].Pressure,
1440+ md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate,
1441+ md.results.TransientSolution[1].Base,
1442+ md.results.TransientSolution[1].Surface,
1443+ md.results.TransientSolution[1].Thickness,
1444+ md.results.TransientSolution[1].MaskGroundediceLevelset,
1445+ md.results.TransientSolution[1].Vx,
1446+ md.results.TransientSolution[1].Vy,
1447+ md.results.TransientSolution[1].Pressure,
1448+ md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate,
1449+ md.results.TransientSolution[2].Base,
1450+ md.results.TransientSolution[2].Surface,
1451+ md.results.TransientSolution[2].Thickness,
1452+ md.results.TransientSolution[2].MaskGroundediceLevelset,
1453+ md.results.TransientSolution[2].Vx,
1454+ md.results.TransientSolution[2].Vy,
1455+ md.results.TransientSolution[2].Pressure,
1456+ md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate,
1457+ ]
1458Index: ../trunk-jpl/test/NightlyRun/test808.py
1459===================================================================
1460--- ../trunk-jpl/test/NightlyRun/test808.py (nonexistent)
1461+++ ../trunk-jpl/test/NightlyRun/test808.py (revision 22267)
1462@@ -0,0 +1,76 @@
1463+#Test Name: SquareShelfLevelsetCalvingSSA2dMinThickness
1464+from model import *
1465+from socket import gethostname
1466+from triangle import *
1467+from setmask import *
1468+from parameterize import *
1469+from setflowequation import *
1470+from solve import *
1471+import numpy as np
1472+from calvingminthickness import *
1473+
1474+md = triangle(model(),'../Exp/Square.exp',30000.)
1475+md = setmask(md,'all','')
1476+md = parameterize(md,'../Par/SquareShelf.py')
1477+md = setflowequation(md,'SSA','all')
1478+md.cluster = generic('name',gethostname(),'np',3)
1479+
1480+x = md.mesh.x
1481+xmin = min(x)
1482+xmax = max(x)
1483+Lx = (xmax - xmin)
1484+alpha = 2. / 3.
1485+md.mask.ice_levelset = -1 + 2 * (md.mesh.y > 9e5)
1486+
1487+md.timestepping.time_step = 1
1488+md.timestepping.final_time = 30
1489+
1490+#Transient
1491+md.transient.isstressbalance = 1
1492+md.transient.ismasstransport = 1
1493+md.transient.issmb = 1
1494+md.transient.isthermal = 0
1495+md.transient.isgroundingline = 0
1496+md.transient.isgia = 0
1497+md.transient.ismovingfront = 1
1498+
1499+md.calving = calvingminthickness()
1500+md.calving.min_thickness = 400
1501+md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,))
1502+md.levelset.spclevelset = float('NaN')* np.ones((md.mesh.numberofvertices,))
1503+md.levelset.reinit_frequency = 1
1504+
1505+md = solve(md,'Transient')
1506+
1507+#Fields and tolerances to track changes
1508+field_names = [
1509+ 'Vx1','Vy1','Vel1','Pressure1','Thickness1','Surface1','MaskIceLevelset1'
1510+ 'Vx2','Vy2','Vel2','Pressure2','Thickness2','Surface2','MaskIceLevelset2'
1511+ 'Vx3','Vy3','Vel3','Pressure3','Thickness3','Surface3','MaskIceLevelset3']
1512+field_tolerances = [
1513+ 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9,
1514+ 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9,
1515+ 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9]
1516+field_values = [
1517+ md.results.TransientSolution[0].Vx,
1518+ md.results.TransientSolution[0].Vy,
1519+ md.results.TransientSolution[0].Vel,
1520+ md.results.TransientSolution[0].Pressure,
1521+ md.results.TransientSolution[0].Thickness,
1522+ md.results.TransientSolution[0].Surface,
1523+ md.results.TransientSolution[0].MaskIceLevelset,
1524+ md.results.TransientSolution[1].Vx,
1525+ md.results.TransientSolution[1].Vy,
1526+ md.results.TransientSolution[1].Vel,
1527+ md.results.TransientSolution[1].Pressure,
1528+ md.results.TransientSolution[1].Thickness,
1529+ md.results.TransientSolution[1].Surface,
1530+ md.results.TransientSolution[1].MaskIceLevelset,
1531+ md.results.TransientSolution[2].Vx,
1532+ md.results.TransientSolution[2].Vy,
1533+ md.results.TransientSolution[2].Vel,
1534+ md.results.TransientSolution[2].Pressure,
1535+ md.results.TransientSolution[2].Thickness,
1536+ md.results.TransientSolution[2].Surface,
1537+ md.results.TransientSolution[2].MaskIceLevelset
1538+ ]
1539Index: ../trunk-jpl/test/NightlyRun/test2424.py
1540===================================================================
1541--- ../trunk-jpl/test/NightlyRun/test2424.py (nonexistent)
1542+++ ../trunk-jpl/test/NightlyRun/test2424.py (revision 22267)
1543@@ -0,0 +1,51 @@
1544+#Test Name: SquareSheetShelfGroundingLine2dAggressive. From test424, with sea level increasing.
1545+import numpy as np
1546+from model import *
1547+from socket import gethostname
1548+from triangle import *
1549+from setmask import *
1550+from parameterize import *
1551+from setflowequation import *
1552+from solve import *
1553+from newforcing import *
1554+
1555+md = triangle(model(),'../Exp/Square.exp',150000.)
1556+md = setmask(md,'../Exp/SquareShelf.exp','')
1557+md = parameterize(md,'../Par/SquareSheetShelf.py')
1558+md = setflowequation(md,'SSA','all')
1559+md.initialization.vx[:] = 0.
1560+md.initialization.vy[:] = 0.
1561+md.smb.mass_balance[:] = 0.
1562+
1563+md.geometry.base = -700. - np.abs(md.mesh.y-500000.) / 1000.
1564+md.geometry.bed = -700. - np.abs(md.mesh.y-500000.) / 1000.
1565+md.geometry.thickness[:] = 1000.
1566+md.geometry.surface = md.geometry.base + md.geometry.thickness
1567+
1568+md.transient.isstressbalance = 0
1569+md.transient.isgroundingline = 1
1570+md.transient.isthermal = 0
1571+md.groundingline.migration = 'AggressiveMigration'
1572+md.transient.requested_outputs = ['IceVolume','IceVolumeAboveFloatation','Sealevel']
1573+
1574+md.timestepping.time_step = .1
1575+md.slr.sealevel = newforcing(md.timestepping.start_time, md.timestepping.final_time,
1576+ md.timestepping.time_step, -200., 200., md.mesh.numberofvertices)
1577+
1578+md.cluster = generic('name',gethostname(),'np',3)
1579+md = solve(md,'Transient')
1580+
1581+#we are checking that the grounding line position is near the theorical one, which is the 0 contour level
1582+#of surface - sealevel - (1-di)* thickness
1583+
1584+nsteps = len(md.results.TransientSolution)
1585+field_names = []
1586+field_tolerances = []
1587+field_values = []
1588+#time is off by the year constant
1589+for i in range(nsteps):
1590+ field_names.append('Time-' + str(md.results.TransientSolution[i].time) +
1591+ '-yr-ice_levelset-S-sl-(1-di)*H')
1592+ field_tolerances.append(1e-12)
1593+ field_values.append(md.results.TransientSolution[i].MaskGroundediceLevelset.reshape(-1,) - (md.geometry.surface - md.results.TransientSolution[i].Sealevel.reshape(-1,) - (1 - md.materials.rho_ice / md.materials.rho_water) * md.geometry.thickness))
1594+
1595Index: ../trunk-jpl/test/NightlyRun/test260.py
1596===================================================================
1597--- ../trunk-jpl/test/NightlyRun/test260.py (nonexistent)
1598+++ ../trunk-jpl/test/NightlyRun/test260.py (revision 22267)
1599@@ -0,0 +1,31 @@
1600+#Test Name: SquareShelfStressSSA2dEnhanced
1601+import numpy as np
1602+from model import *
1603+from socket import gethostname
1604+from triangle import *
1605+from setmask import *
1606+from parameterize import *
1607+from setflowequation import *
1608+from solve import *
1609+from matenhancedice import *
1610+
1611+md = triangle(model(),'../Exp/Square.exp',150000.)
1612+md = setmask(md,'all','')
1613+md.materials = matenhancedice()
1614+md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,)
1615+md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,)
1616+md.materials.rheology_E = np.ones(md.mesh.numberofvertices,)
1617+md = parameterize(md,'../Par/SquareShelf.py')
1618+md = setflowequation(md,'SSA','all')
1619+md.cluster = generic('name',gethostname(),'np',3)
1620+md = solve(md,'Stressbalance')
1621+
1622+#Fields and tolerances to track changes
1623+field_names = ['Vx','Vy','Vel','Pressure']
1624+field_tolerances = [1e-13,1e-13,1e-13,1e-13]
1625+field_values = [
1626+ md.results.StressbalanceSolution.Vx,
1627+ md.results.StressbalanceSolution.Vy,
1628+ md.results.StressbalanceSolution.Vel,
1629+ md.results.StressbalanceSolution.Pressure,
1630+ ]
1631Index: ../trunk-jpl/test/NightlyRun/test350.py
1632===================================================================
1633--- ../trunk-jpl/test/NightlyRun/test350.py (nonexistent)
1634+++ ../trunk-jpl/test/NightlyRun/test350.py (revision 22267)
1635@@ -0,0 +1,94 @@
1636+#Test Name: SquareSheetHydrologySommers
1637+from operator import itemgetter
1638+import numpy as np
1639+from model import *
1640+from socket import gethostname
1641+from triangle import *
1642+from setmask import *
1643+from parameterize import *
1644+from setflowequation import *
1645+from solve import *
1646+from frictionsommers import *
1647+from hydrologysommers import *
1648+from transient import *
1649+
1650+md = triangle(model(),'../Exp/Square.exp',50000.)
1651+md.mesh.x = md.mesh.x / 1000
1652+md.mesh.y = md.mesh.y / 1000
1653+md = setmask(md,'','')
1654+md = parameterize(md,'../Par/SquareSheetConstrained.py')
1655+md.transient = transient().deactivateall()
1656+md.transient.ishydrology = 1
1657+md = setflowequation(md,'SSA','all')
1658+md.cluster = generic('name',gethostname(),'np',2)
1659+
1660+#Use hydroogy coupled friciton law
1661+md.friction = frictionsommers(md)
1662+
1663+#Change hydrology class to Sommers' model
1664+md.hydrology = hydrologysommers()
1665+
1666+#Change geometry
1667+md.geometry.base = -.02 * md.mesh.x + 20.
1668+md.geometry.thickness = 300. * np.ones((md.mesh.numberofvertices,))
1669+md.geometry.bed = md.geometry.base
1670+md.geometry.surface = md.geometry.bed + md.geometry.thickness
1671+
1672+#define the initial water head as being such that the water pressure is 50% of the ice overburden pressure
1673+md.hydrology.head = 0.5 * md.materials.rho_ice / md.materials.rho_freshwater * md.geometry.thickness + md.geometry.base
1674+md.hydrology.gap_height = 0.01 * np.ones((md.mesh.numberofelements,))
1675+md.hydrology.bump_spacing = 2 * np.ones((md.mesh.numberofelements,))
1676+md.hydrology.bump_height = 0.05 * np.ones((md.mesh.numberofelements,))
1677+md.hydrology.englacial_input = 0.5 * np.ones((md.mesh.numberofvertices,))
1678+md.hydrology.reynolds= 1000. * np.ones((md.mesh.numberofelements,))
1679+md.hydrology.spchead = float('NaN') * np.ones((md.mesh.numberofvertices,))
1680+pos = np.intersect1d(np.array(np.where(md.mesh.vertexonboundary)), np.array(np.where(md.mesh.x == 1000)))
1681+md.hydrology.spchead[pos] = md.geometry.base[pos]
1682+
1683+#Define velocity
1684+md.initialization.vx = 1e-6 * md.constants.yts * np.ones((md.mesh.numberofvertices,))
1685+md.initialization.vy = np.zeros((md.mesh.numberofvertices,))
1686+
1687+md.timestepping.time_step = 3. * 3600. / md.constants.yts
1688+md.timestepping.final_time = .5 / 365.
1689+md.materials.rheology_B = (5e-25)**(-1. / 3.) * np.ones((md.mesh.numberofvertices,))
1690+
1691+#Add one moulin and Neumann BC, varying in time
1692+a = np.sqrt((md.mesh.x - 500.)**2 + (md.mesh.y - 500.)**2)
1693+pos = min(enumerate(a), key=itemgetter(1))[0]
1694+time = np.arange(0,md.timestepping.final_time+1,md.timestepping.time_step)
1695+md.hydrology.moulin_input = np.zeros((md.mesh.numberofvertices+1,np.size(time)))
1696+md.hydrology.moulin_input[-1,:] = time
1697+md.hydrology.moulin_input[pos,:] = 5. * (1. - np.sin(2. * np.pi / (1. / 365.) * time))
1698+md.hydrology.neumannflux = np.zeros((md.mesh.numberofelements+1,np.size(time)))
1699+md.hydrology.neumannflux[-1,:] = time
1700+segx = md.mesh.x[md.mesh.segments[:,0]-1]
1701+segy = md.mesh.y[md.mesh.segments[:,0]-1]
1702+posA = np.intersect1d(np.intersect1d(np.array(np.where(segx < 1.)),np.array(np.where(segy > 400.))), np.array(np.where(segy < 600.)))
1703+pos = (md.mesh.segments[posA]-1)[:,2]
1704+md.hydrology.neumannflux[pos,:] = np.tile(0.05*(1.-np.sin(2.*np.pi/(1./365.)*time)),(len(pos),1))
1705+
1706+md = solve(md,'Transient')
1707+
1708+#Fields and tolerances to track changes
1709+field_names = [
1710+ 'HydrologyHead1','HydrologyGapHeight1',
1711+ 'HydrologyHead2','HydrologyGapHeight2',
1712+ 'HydrologyHead3','HydrologyGapHeight3',
1713+ 'HydrologyHead4','HydrologyGapHeight4']
1714+field_tolerances = [
1715+ 1e-13, 1e-13,
1716+ 1e-13, 1e-13,
1717+ 1e-13, 1e-13,
1718+ 1e-13, 1e-12]
1719+field_values = [
1720+ md.results.TransientSolution[0].HydrologyHead,
1721+ md.results.TransientSolution[0].HydrologyGapHeight,
1722+ md.results.TransientSolution[1].HydrologyHead,
1723+ md.results.TransientSolution[1].HydrologyGapHeight,
1724+ md.results.TransientSolution[2].HydrologyHead,
1725+ md.results.TransientSolution[2].HydrologyGapHeight,
1726+ md.results.TransientSolution[3].HydrologyHead,
1727+ md.results.TransientSolution[3].HydrologyGapHeight
1728+ ]
1729+
1730Index: ../trunk-jpl/test/NightlyRun/test243.py
1731===================================================================
1732--- ../trunk-jpl/test/NightlyRun/test243.py (nonexistent)
1733+++ ../trunk-jpl/test/NightlyRun/test243.py (revision 22267)
1734@@ -0,0 +1,72 @@
1735+#Test Name: SquareShelfSMBGemb
1736+import numpy as np
1737+import scipy.io as spio
1738+from model import *
1739+from socket import gethostname
1740+from triangle import *
1741+from setmask import *
1742+from parameterize import *
1743+from setflowequation import *
1744+from solve import *
1745+from SMBgemb import *
1746+
1747+md = triangle(model(),'../Exp/Square.exp',200000.)
1748+md = setmask(md,'all','')
1749+md = parameterize(md,'../Par/SquareShelf.py')
1750+md = setflowequation(md,'SSA','all')
1751+md.materials.rho_ice = 910
1752+md.cluster = generic('name',gethostname(),'np',3)
1753+
1754+#Use of Gemb method for SMB computation
1755+md.smb = SMBgemb()
1756+md.smb.setdefaultparameters(md.mesh,md.geometry)
1757+
1758+#load hourly surface forcing date from 1979 to 2009:
1759+inputs = spio.loadmat('../Data/gemb_input.mat',squeeze_me=True)
1760+
1761+#setup the inputs:
1762+md.smb.Ta = np.append(np.tile(np.conjugate(inputs['Ta0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1763+md.smb.V = np.append(np.tile(np.conjugate(inputs['V0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1764+md.smb.dswrf = np.append(np.tile(np.conjugate(inputs['dsw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1765+md.smb.dlwrf = np.append(np.tile(np.conjugate(inputs['dlw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1766+md.smb.P = np.append(np.tile(np.conjugate(inputs['P0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1767+md.smb.eAir = np.append(np.tile(np.conjugate(inputs['eAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1768+md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1769+md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
1770+md.smb.Vz = np.tile(np.conjugate(inputs['LP']['Vz']),(md.mesh.numberofelements,1)).flatten()
1771+md.smb.Tz = np.tile(np.conjugate(inputs['LP']['Tz']),(md.mesh.numberofelements,1)).flatten()
1772+md.smb.Tmean = np.tile(np.conjugate(inputs['LP']['Tmean']),(md.mesh.numberofelements,1)).flatten()
1773+md.smb.C = np.tile(np.conjugate(inputs['LP']['C']),(md.mesh.numberofelements,1)).flatten()
1774+
1775+#smb settings
1776+md.smb.requested_outputs = ['SmbDz','SmbT','SmbD','SmbRe','SmbGdn','SmbGsp','SmbEC','SmbA','SmbMassBalance']
1777+
1778+#only run smb core:
1779+md.transient.isstressbalance = 0
1780+md.transient.ismasstransport = 0
1781+md.transient.isthermal = 0
1782+
1783+#time stepping:
1784+md.timestepping.start_time = 1965.
1785+md.timestepping.final_time = 1966.
1786+md.timestepping.time_step = 1. / 365.0
1787+md.timestepping.interp_forcings = 0.
1788+
1789+#Run transient
1790+md = solve(md,'Transient')
1791+
1792+#Fields and tolerances to track changes
1793+field_names = ['SmbDz','SmbT' ,'SmbD' ,'SmbRe','SmbGdn','SmbGsp','SmbA' ,'SmbEC','SmbMassBalance']
1794+field_tolerances = [5e-4,5e-5,0.0006,0.0002,1e-5,0.0003,2e-5,2e-7,1e-7]
1795+#shape is different in python solution (fixed using reshape) which can cause test failure:
1796+field_values = [
1797+ md.results.TransientSolution[-1].SmbDz[0,0:240].reshape(1,-1),
1798+ md.results.TransientSolution[-1].SmbT[0,0:240].reshape(1,-1),
1799+ md.results.TransientSolution[-1].SmbD[0,0:240].reshape(1,-1),
1800+ md.results.TransientSolution[-1].SmbRe[0,0:240].reshape(1,-1),
1801+ md.results.TransientSolution[-1].SmbGdn[0,0:240].reshape(1,-1),
1802+ md.results.TransientSolution[-1].SmbGsp[0,0:240].reshape(1,-1),
1803+ md.results.TransientSolution[-1].SmbA[0,0:240].reshape(1,-1),
1804+ md.results.TransientSolution[-1].SmbEC[0],
1805+ md.results.TransientSolution[-1].SmbMassBalance[0],
1806+ ]
1807Index: ../trunk-jpl/src/m/solve/WriteData.py
1808===================================================================
1809--- ../trunk-jpl/src/m/solve/WriteData.py (revision 22266)
1810+++ ../trunk-jpl/src/m/solve/WriteData.py (revision 22267)
1811@@ -50,9 +50,9 @@
1812 if np.size(data) > 1 and np.size(data,0)==timeserieslength:
1813 yts = options.getfieldvalue('yts')
1814 if np.ndim(data) > 1:
1815- data[-1,:] = data[-1,:]*yts
1816+ data[-1,:] = yts*data[-1,:]
1817 else:
1818- data[-1] = data[-1]*yts
1819+ data[-1] = yts*data[-1]
1820
1821 #Step 1: write the enum to identify this record uniquely
1822 fid.write(struct.pack('i',len(name)))
1823Index: ../trunk-jpl/src/m/solve/parseresultsfromdisk.py
1824===================================================================
1825--- ../trunk-jpl/src/m/solve/parseresultsfromdisk.py (revision 22266)
1826+++ ../trunk-jpl/src/m/solve/parseresultsfromdisk.py (revision 22267)
1827@@ -174,8 +174,6 @@
1828 yts=md.constants.yts
1829 if fieldname=='BalancethicknessThickeningRate':
1830 field = field*yts
1831- elif fieldname=='Time':
1832- field = field/yts
1833 elif fieldname=='HydrologyWaterVx':
1834 field = field*yts
1835 elif fieldname=='HydrologyWaterVy':
1836@@ -190,17 +188,36 @@
1837 field = field*yts
1838 elif fieldname=='BasalforcingsGroundediceMeltingRate':
1839 field = field*yts
1840+ elif fieldname=='BasalforcingsFloatingiceMeltingRate':
1841+ field = field*yts
1842 elif fieldname=='TotalFloatingBmb':
1843- field = field/10.**12.*yts #(GigaTon/year)
1844+ field = field/10.**12*yts #(GigaTon/year)
1845 elif fieldname=='TotalGroundedBmb':
1846- field = field/10.**12.*yts #(GigaTon/year)
1847+ field = field/10.**12*yts #(GigaTon/year)
1848 elif fieldname=='TotalSmb':
1849- field = field/10.**12.*yts #(GigaTon/year)
1850+ field = field/10.**12*yts #(GigaTon/year)
1851 elif fieldname=='SmbMassBalance':
1852 field = field*yts
1853+ elif fieldname=='SmbPrecipitation':
1854+ field = field*yts
1855+ elif fieldname=='SmbRunoff':
1856+ field = field*yts
1857+ elif fieldname=='SmbEC':
1858+ field = field*yts
1859+ elif fieldname=='SmbAccumulation':
1860+ field = field*yts
1861+ elif fieldname=='SmbMelt':
1862+ field = field*yts
1863+ elif fieldname=='SmbDz_add':
1864+ field = field*yts
1865+ elif fieldname=='SmbM_add':
1866+ field = field*yts
1867 elif fieldname=='CalvingCalvingrate':
1868 field = field*yts
1869
1870+ if time !=-9999:
1871+ time = time/yts
1872+
1873 saveres=OrderedDict()
1874 saveres['fieldname']=fieldname
1875 saveres['time']=time
1876Index: ../trunk-jpl/src/m/geometry/NowickiProfile.py
1877===================================================================
1878--- ../trunk-jpl/src/m/geometry/NowickiProfile.py (nonexistent)
1879+++ ../trunk-jpl/src/m/geometry/NowickiProfile.py (revision 22267)
1880@@ -0,0 +1,44 @@
1881+import numpy as np
1882+
1883+def NowickiProfile(x):
1884+ """
1885+ NOWICKIPROFILE - Create profile at the transition zone based on Sophie Nowicki's thesis
1886+
1887+ Usage:
1888+ [b h] = NowickiProfile(x)
1889+
1890+ - h = ice thickness
1891+ - b = ice base
1892+ - x = along flow coordinate
1893+ """
1894+ #Constant for theoretical profile
1895+ delta = 0.1 #ratio of water density and ice density -1
1896+ hg = 1. #ice thickness at grounding line
1897+ sea = hg / (1+delta) #sea level
1898+ lamda = 0.1 #ration of deviatoric stress and water pressure
1899+ beta = 5. #friction coefficient
1900+ ms = 0.005 #surface accumulation rat
1901+ mu = 5. #viscosity
1902+ q = 0.801 #ice mass flux
1903+
1904+ #mesh parameters
1905+ b = np.zeros((np.size(x),))
1906+ h = np.zeros((np.size(x),))
1907+ s = np.zeros((np.size(x),))
1908+
1909+ #upstream of the GL
1910+ for i in range(np.size(x) / 2):
1911+ ss = np.roots([1, 4 * lamda * beta, 0, 0, 6 * lamda * ms * x[i]**2 +
1912+ 12 * lamda * q * x[i] - hg**4 - 4 * lamda * beta * hg**3])
1913+ for j in range(4):
1914+ if (np.isreal(ss[j]) > 0) and (np.imag(ss[j]) == 0):
1915+ s[i] = ss[j]
1916+ h[i] = s[i]
1917+ b[i] = 0.
1918+
1919+ #downstream of the GL
1920+ for i in range(np.size(x) / 2, np.size(x)):
1921+ h[i] = (x[i] / (4. * (delta+1) * q) + hg**(-2))**(-0.5) # ice thickness for ice shelf from (3.1)
1922+ b[i] = sea - h[i] * (1. / (1+delta))
1923+
1924+ return [b, h, sea]
1925Index: ../trunk-jpl/src/m/consistency/checkfield.py
1926===================================================================
1927--- ../trunk-jpl/src/m/consistency/checkfield.py (revision 22266)
1928+++ ../trunk-jpl/src/m/consistency/checkfield.py (revision 22267)
1929@@ -83,7 +83,7 @@
1930 #Check numel
1931 if options.exist('numel'):
1932 fieldnumel=options.getfieldvalue('numel')
1933- if np.size(field) not in fieldnumel:
1934+ if (type(fieldnumel) == int and np.size(field) != fieldnumel) or (type(fieldnumel) == list and np.size(field) not in fieldnumel):
1935 if len(fieldnumel)==1:
1936 md = md.checkmessage(options.getfieldvalue('message',\
1937 "field '%s' size should be %d" % (fieldname,fieldnumel)))
1938@@ -100,6 +100,7 @@
1939 md = md.checkmessage(options.getfieldvalue('message',\
1940 "NaN values found in field '%s'" % fieldname))
1941
1942+
1943 #check Inf
1944 if options.getfieldvalue('Inf',0):
1945 if np.any(np.isinf(field)):
1946@@ -106,6 +107,7 @@
1947 md = md.checkmessage(options.getfieldvalue('message',\
1948 "Inf values found in field '%s'" % fieldname))
1949
1950+
1951 #check cell
1952 if options.getfieldvalue('cell',0):
1953 if not isinstance(field,(tuple,list,dict)):
1954@@ -128,13 +130,28 @@
1955
1956 #check greater
1957 if options.exist('>='):
1958- lowerbound=options.getfieldvalue('>=')
1959- if np.any(field<lowerbound):
1960+ lowerbound = options.getfieldvalue('>=')
1961+ field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
1962+ if options.getfieldvalue('timeseries',0):
1963+ field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
1964+
1965+ if options.getfieldvalue('singletimeseries',0):
1966+ field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
1967+
1968+ if np.any(field2<lowerbound):
1969 md = md.checkmessage(options.getfieldvalue('message',\
1970 "field '%s' should have values above %d" % (fieldname,lowerbound)))
1971+
1972 if options.exist('>'):
1973 lowerbound=options.getfieldvalue('>')
1974- if np.any(field<=lowerbound):
1975+ field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
1976+ if options.getfieldvalue('timeseries',0):
1977+ field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
1978+
1979+ if options.getfieldvalue('singletimeseries',0):
1980+ field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
1981+
1982+ if np.any(field2<=lowerbound):
1983 md = md.checkmessage(options.getfieldvalue('message',\
1984 "field '%s' should have values above %d" % (fieldname,lowerbound)))
1985
1986@@ -141,12 +158,26 @@
1987 #check smaller
1988 if options.exist('<='):
1989 upperbound=options.getfieldvalue('<=')
1990- if np.any(field>upperbound):
1991+ field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
1992+ if options.getfieldvalue('timeseries',0):
1993+ field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
1994+
1995+ if options.getfieldvalue('singletimeseries',0):
1996+ field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
1997+
1998+ if np.any(field2>upperbound):
1999 md = md.checkmessage(options.getfieldvalue('message',\
2000 "field '%s' should have values below %d" % (fieldname,upperbound)))
2001 if options.exist('<'):
2002 upperbound=options.getfieldvalue('<')
2003- if np.any(field>=upperbound):
2004+ field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
2005+ if options.getfieldvalue('timeseries',0):
2006+ field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
2007+
2008+ if options.getfieldvalue('singletimeseries',0):
2009+ field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
2010+
2011+ if np.any(field2>=upperbound):
2012 md = md.checkmessage(options.getfieldvalue('message',\
2013 "field '%s' should have values below %d" % (fieldname,upperbound)))
2014
2015@@ -163,15 +194,15 @@
2016
2017 #Check forcings (size and times)
2018 if options.getfieldvalue('timeseries',0):
2019- if np.size(field,0)==md.mesh.numberofvertices:
2020+ if np.size(field,0)==md.mesh.numberofvertices or np.size(field,0)==md.mesh.numberofelements:
2021 if np.ndim(field)>1 and not np.size(field,1)==1:
2022 md = md.checkmessage(options.getfieldvalue('message',\
2023 "field '%s' should have only one column as there are md.mesh.numberofvertices lines" % fieldname))
2024- elif np.size(field,0)==md.mesh.numberofvertices+1 or np.size(field,0)==2:
2025- if not all(field[-1,:]==np.sort(field[-1,:])):
2026+ elif np.size(field,0)==md.mesh.numberofvertices+1 or np.size(field,0)==md.mesh.numberofelements+1:
2027+ if np.ndim(field) > 1 and not all(field[-1,:]==np.sort(field[-1,:])):
2028 md = md.checkmessage(options.getfieldvalue('message',\
2029 "field '%s' columns should be sorted chronologically" % fieldname))
2030- if any(field[-1,0:-1]==field[-1,1:]):
2031+ if np.ndim(field) > 1 and any(field[-1,0:-1]==field[-1,1:]):
2032 md = md.checkmessage(options.getfieldvalue('message',\
2033 "field '%s' columns must not contain duplicate timesteps" % fieldname))
2034 else:
2035@@ -197,3 +228,4 @@
2036
2037 return md
2038
2039+
2040Index: ../trunk-jpl/src/m/mech/newforcing.py
2041===================================================================
2042--- ../trunk-jpl/src/m/mech/newforcing.py (nonexistent)
2043+++ ../trunk-jpl/src/m/mech/newforcing.py (revision 22267)
2044@@ -0,0 +1,34 @@
2045+import numpy as np
2046+
2047+def newforcing(t0,t1,deltaT,f0,f1,nodes):
2048+ '''
2049+FUNCTION NEWFORCING Build forcing that extends temporally from t0 to t1, and in magnitude from f0 to f1. Equal time
2050+ and magnitude spacing.
2051+
2052+ Usage: forcing=newforcing(t0,t1,deltaT,f0,f1,nodes);
2053+ Where:
2054+ t0:t1: time interval.
2055+ deltaT: time step
2056+ f0:f1: magnitude interval.
2057+ nodes: number of vertices where we have a temporal forcing
2058+
2059+ Example:
2060+ md.smb.mass_balance=newforcing(md.timestepping.start_time,md.timestepping.final_time,
2061+ md.timestepping.time_step,-1,+2,md.mesh.numberofvertices)
2062+ '''
2063+ #Number of time steps:
2064+ nsteps = (t1 - t0) / deltaT + 1
2065+
2066+ #delta forcing:
2067+ deltaf = (f1 - f0) / (nsteps - 1)
2068+
2069+ #creates times:
2070+ times = np.arange(t0,t1+deltaT,deltaT) #Add deltaT to fix python/matlab discrepency
2071+
2072+ #create forcing:
2073+ forcing = np.arange(f0,f1+deltaf,deltaf)#Add deltaf to fix python/matlab discrepency
2074+
2075+ #replicate for all nodes
2076+ forcing = np.tile(forcing, (nodes+1,1))
2077+ forcing[-1,:] = times
2078+ return forcing
2079Index: ../trunk-jpl/src/m/dev/devpath.py
2080===================================================================
2081--- ../trunk-jpl/src/m/dev/devpath.py (revision 22266)
2082+++ ../trunk-jpl/src/m/dev/devpath.py (revision 22267)
2083@@ -30,6 +30,7 @@
2084
2085 #Manual imports for commonly used functions
2086 from plotmodel import plotmodel
2087+from runme import runme
2088
2089 #c = get_ipython().config
2090 #c.InteractiveShellApp.exec_lines = []
2091Index: ../trunk-jpl/src/m/print/printmodel.py
2092===================================================================
2093--- ../trunk-jpl/src/m/print/printmodel.py (nonexistent)
2094+++ ../trunk-jpl/src/m/print/printmodel.py (revision 22267)
2095@@ -0,0 +1,109 @@
2096+
2097+import numpy as np
2098+#from model import *
2099+#from socket import gethostname
2100+#from bamg import *
2101+#from setmask import *
2102+#from parameterize import *
2103+#from setflowequation import *
2104+#from solve import *
2105+from pairoptions import *
2106+
2107+def printmodel(filename,format,*args):
2108+''' PRINTMODEL - save an image of current figure
2109+
2110+ filename: output name of image file (no extension)
2111+ format: image format (ex: 'tiff','jpg','pdf')
2112+
2113+ List of options to printfmodel:
2114+
2115+ figure: number of figure to print (default: current figure)
2116+ resolution: use higher resolution to anti-alias (default 2)
2117+ margin: add margin around final image
2118+ marginsize: size of margin around final image (default 5)
2119+ frame: add frame around final image
2120+ framesize: size of frame around final image (default 5)
2121+ framecolor: color of frame around final image (default 'black')
2122+ trim: trim empty space around image (default 'off')
2123+ hardcopy: 'off' to impose MATLAB to use the same colors (default 'off')
2124+
2125+ Usage:
2126+ printmodel(filename,format,varargin);
2127+
2128+ Examples:
2129+ printmodel('image','tiff')
2130+ printmodel('image','eps','margin','on','frame','on','hardcopy','on')
2131+'''
2132+
2133+#get options:
2134+options = pairoptions(*args)
2135+
2136+#set defaults
2137+options = addfielddefault(options,'figure','gcf')
2138+options = addfielddefault(options,'format','tiff')
2139+options = addfielddefault(options,'resolution',1)
2140+options = addfielddefault(options,'margin','on')
2141+options = addfielddefault(options,'marginsize',25)
2142+options = addfielddefault(options,'frame','on')
2143+options = addfielddefault(options,'framesize',3)
2144+options = addfielddefault(options,'framecolor','black')
2145+options = addfielddefault(options,'trim','on')
2146+options = addfielddefault(options,'hardcopy','off')
2147+
2148+#get fig:
2149+fig = getfieldvalue(options,'figure')
2150+if len(fig) == 1:
2151+ fig=gcf
2152+else:
2153+ figure(fig)
2154+ fig=gcf
2155+
2156+#In auto mode, MATLAB prints the figure the same size as it appears on the computer screen, centered on the page
2157+set(fig, 'PaperPositionMode', 'auto');
2158+
2159+#InvertHardcopy off imposes MATLAB to use the same colors
2160+set(fig, 'InvertHardcopy', getfieldvalue(options,'hardcopy'));
2161+
2162+#we could have several formats, as a cell array of strings.
2163+formats=format;
2164+if ~iscell(formats),
2165+ formats={formats};
2166+end
2167+
2168+#loop on formats:
2169+for i=1:length(formats),
2170+ format=formats{i};
2171+
2172+ #Use higher resolution to anti-alias and use zbuffer to have smooth colors
2173+ print(fig, '-zbuffer','-dtiff',['-r' num2str(get(0,'ScreenPixelsPerInch')*getfieldvalue(options,'resolution'))],filename);
2174+
2175+ #some trimming involved?
2176+ if ~strcmpi(format,'pdf'),
2177+ if strcmpi(getfieldvalue(options,'trim'),'on'),
2178+ system(['convert -trim ' filename '.tif ' filename '.tif']);
2179+ end
2180+ end
2181+
2182+ #margin?
2183+ if ~strcmpi(format,'pdf'),
2184+ if strcmpi(getfieldvalue(options,'margin'),'on'),
2185+ marginsize=getfieldvalue(options,'marginsize');
2186+ system(['convert -border ' num2str(marginsize) 'x' num2str(marginsize) ' -bordercolor "white" ' filename '.tif ' filename '.tif']);
2187+ end
2188+ end
2189+
2190+ #frame?
2191+ if ~strcmpi(format,'pdf'),
2192+ if strcmpi(getfieldvalue(options,'frame'),'on'),
2193+ framesize=getfieldvalue(options,'framesize');
2194+ framecolor=getfieldvalue(options,'framecolor');
2195+ system(['convert -border ' num2str(framesize) 'x' num2str(framesize) ' -bordercolor "' framecolor '" ' filename '.tif ' filename '.tif']);
2196+ end
2197+ end
2198+
2199+ #convert image to correct format
2200+ if ~strcmpi(format,'tiff') & ~strcmpi(format,'tif'),
2201+ system(['convert ' filename '.tif ' filename '.' format]);
2202+ delete([ filename '.tif']);
2203+ end
2204+end
2205Index: ../trunk-jpl/src/m/classes/thermal.py
2206===================================================================
2207--- ../trunk-jpl/src/m/classes/thermal.py (revision 22266)
2208+++ ../trunk-jpl/src/m/classes/thermal.py (revision 22267)
2209@@ -100,14 +100,18 @@
2210 md = checkfield(md,'fieldname','thermal.requested_outputs','stringrow',1)
2211
2212 if 'EnthalpyAnalysis' in analyses and md.thermal.isenthalpy and md.mesh.dimension()==3:
2213- pos=np.where(~np.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices]))
2214+ TEMP = md.thermal.spctemperature[:-1].flatten(-1)
2215+ pos=np.where(~np.isnan(TEMP))
2216 try:
2217 spccol=np.size(md.thermal.spctemperature,1)
2218 except IndexError:
2219 spccol=1
2220- replicate=np.tile(md.geometry.surface-md.mesh.z,(spccol))
2221- control=md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate
2222- md = checkfield(md,'fieldname','thermal.spctemperature','field',md.thermal.spctemperature[pos],'<=',control[pos],'message',"spctemperature should be below the adjusted melting point")
2223+
2224+ replicate=np.tile(md.geometry.surface-md.mesh.z,(spccol)).flatten(-1)
2225+
2226+ control=md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate+10**-5
2227+
2228+ md = checkfield(md,'fieldname','thermal.spctemperature','field',md.thermal.spctemperature.flatten(-1)[pos],'<=',control[pos],'message',"spctemperature should be below the adjusted melting point")
2229 md = checkfield(md,'fieldname','thermal.isenthalpy','numel',[1],'values',[0,1])
2230 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel',[1],'values',[0,1]);
2231 if(md.thermal.isenthalpy):
2232Index: ../trunk-jpl/src/m/classes/calvingminthickness.py
2233===================================================================
2234--- ../trunk-jpl/src/m/classes/calvingminthickness.py (nonexistent)
2235+++ ../trunk-jpl/src/m/classes/calvingminthickness.py (revision 22267)
2236@@ -0,0 +1,52 @@
2237+from fielddisplay import fielddisplay
2238+from checkfield import checkfield
2239+from WriteData import WriteData
2240+
2241+class calvingminthickness(object):
2242+ """
2243+ CALVINGMINTHICKNESS class definition
2244+
2245+ Usage:
2246+ calvingminthickness=calvingminthickness()
2247+ """
2248+
2249+ def __init__(self): # {{{
2250+
2251+ self.min_thickness = 0.
2252+ self.meltingrate = float('NaN')
2253+
2254+ #set defaults
2255+ self.setdefaultparameters()
2256+
2257+ #}}}
2258+ def __repr__(self): # {{{
2259+ string=' Calving Minimum thickness:'
2260+ string="%s\n%s"%(string,fielddisplay(self,'min_thickness','minimum thickness below which no ice is allowed'))
2261+ string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]'))
2262+ return string
2263+ #}}}
2264+ def extrude(self,md): # {{{
2265+ self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node')
2266+ return self
2267+ #}}}
2268+ def setdefaultparameters(self): # {{{
2269+
2270+ #minimum thickness is 100 m by default
2271+ self.min_thickness = 100.
2272+ #}}}
2273+ def checkconsistency(self,md,solution,analyses): # {{{
2274+
2275+ #Early return
2276+ if solution == 'TransientSolution' or md.transient.ismovingfront == 0:
2277+ return
2278+
2279+ md = checkfield(md,'fieldname','calving.min_thickness','>',0,'NaN',1,'Inf',1)
2280+ md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices],'>=',0)
2281+ return md
2282+ # }}}
2283+ def marshall(self,prefix,md,fid): # {{{
2284+ yts=md.constants.yts
2285+ WriteData(fid,prefix,'name','md.calving.law','data',4,'format','Integer')
2286+ WriteData(fid,prefix,'object',self,'fieldname','min_thickness','format','Double')
2287+ WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'scale',1./yts)
2288+ # }}}
2289Index: ../trunk-jpl/src/m/classes/calvingdev.py
2290===================================================================
2291--- ../trunk-jpl/src/m/classes/calvingdev.py (nonexistent)
2292+++ ../trunk-jpl/src/m/classes/calvingdev.py (revision 22267)
2293@@ -0,0 +1,60 @@
2294+from fielddisplay import fielddisplay
2295+from project3d import project3d
2296+from checkfield import checkfield
2297+from WriteData import WriteData
2298+
2299+class calvingdev(object):
2300+ """
2301+ CALVINGDEV class definition
2302+
2303+ Usage:
2304+ calvingdev=calvingdev();
2305+ """
2306+
2307+ def __init__(self): # {{{
2308+
2309+ self.stress_threshold_groundedice = 0.
2310+ self.stress_threshold_floatingice = 0.
2311+ self.meltingrate = float('NaN')
2312+
2313+ #set defaults
2314+ self.setdefaultparameters()
2315+
2316+ #}}}
2317+ def __repr__(self): # {{{
2318+ string=' Calving Pi parameters:'
2319+ string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_groundedice','sigma_max applied to grounded ice only [Pa]'))
2320+ string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_floatingice','sigma_max applied to floating ice only [Pa]'))
2321+
2322+ string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]'))
2323+ return string
2324+ #}}}
2325+ def extrude(self,md): # {{{
2326+ self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node')
2327+ return self
2328+ #}}}
2329+ def setdefaultparameters(self): # {{{
2330+ #Default sigma max
2331+ self.stress_threshold_groundedice = 1e6
2332+ self.stress_threshold_floatingice = 150e3
2333+ return self
2334+ #}}}
2335+ def checkconsistency(self,md,solution,analyses): # {{{
2336+ #Early return
2337+ if solution == 'TransientSolution' or md.transient.ismovingfront == 0:
2338+ return
2339+
2340+ md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'nan',1,'Inf',1)
2341+ md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'nan',1,'Inf',1)
2342+ md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'timeseries',1,'>=',0)
2343+
2344+ return md
2345+ # }}}
2346+ def marshall(self,prefix,md,fid): # {{{
2347+ yts=md.constants.yts
2348+
2349+ WriteData(fid,prefix,'name','md.calving.law','data',2,'format','Integer')
2350+ WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1)
2351+ WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1)
2352+ WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts)
2353+ # }}}
2354Index: ../trunk-jpl/src/m/classes/mismipbasalforcings.py
2355===================================================================
2356--- ../trunk-jpl/src/m/classes/mismipbasalforcings.py (revision 22266)
2357+++ ../trunk-jpl/src/m/classes/mismipbasalforcings.py (revision 22267)
2358@@ -39,8 +39,11 @@
2359 #}}}
2360 def initialize(self,md): # {{{
2361 if np.all(np.isnan(self.groundedice_melting_rate)):
2362- self.groundedice_melting_rate=np.zeros(md.mesh.numberofvertices)
2363+ self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices))
2364 print ' no basalforcings.groundedice_melting_rate specified: values set as zero'
2365+ if np.all(np.isnan(self.geothermalflux)):
2366+ self.geothermalflux=np.zeros((md.mesh.numberofvertices))
2367+ print " no basalforcings.geothermalflux specified: values set as zero"
2368 return self
2369 #}}}
2370 def setdefaultparameters(self): # {{{
2371@@ -83,7 +86,7 @@
2372 print 'WARNING: value of yts for MISMIP+ runs different from ISSM default!'
2373
2374 floatingice_melting_rate = np.zeros((md.mesh.numberofvertices))
2375- floatingice_melting_rate = md.basalforcings.meltrate_factor*np.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)*np.amax(md.basalforcings.upperdepth_melt-md.geometry.base,0)
2376+ floatingice_melting_rate = md.basalforcings.meltrate_factor*np.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)*(md.basalforcings.upperdepth_melt-md.geometry.base)
2377
2378 WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
2379 WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
2380Index: ../trunk-jpl/src/m/classes/SMBgradientsela.py
2381===================================================================
2382--- ../trunk-jpl/src/m/classes/SMBgradientsela.py (revision 22266)
2383+++ ../trunk-jpl/src/m/classes/SMBgradientsela.py (revision 22267)
2384@@ -8,7 +8,7 @@
2385 SMBgradientsela Class definition
2386
2387 Usage:
2388- SMBgradientsela=SMBgradientsela();
2389+ SMBgradientsela=SMBgradientsela()
2390 """
2391
2392 def __init__(self): # {{{
2393@@ -18,11 +18,12 @@
2394 self.b_max = float('NaN')
2395 self.b_min = float('NaN')
2396 self.requested_outputs = []
2397+ self.setdefaultparameters()
2398 #}}}
2399 def __repr__(self): # {{{
2400- string=" surface forcings parameters:"
2401+ string = " surface forcings parameters:"
2402+ string+= '\n SMB gradients ela parameters:'
2403
2404- string="%s\n%s"%(string,fielddisplay(self,'issmbgradientsela','is smb gradients ela method activated (0 or 1, default is 0)'))
2405 string="%s\n%s"%(string,fielddisplay(self,'ela',' equilibrium line altitude from which deviation is used to calculate smb using the smb gradients ela method [m a.s.l.]'))
2406 string="%s\n%s"%(string,fielddisplay(self,'b_pos',' vertical smb gradient (dB/dz) above ela'))
2407 string="%s\n%s"%(string,fielddisplay(self,'b_neg',' vertical smb gradient (dB/dz) below ela'))
2408@@ -46,6 +47,11 @@
2409
2410 return self
2411 #}}}
2412+ def setdefaultparameters(self): # {{{
2413+ self.b_max=9999.
2414+ self.b_min=-9999.
2415+ return self
2416+ #}}}
2417 def checkconsistency(self,md,solution,analyses): # {{{
2418
2419 if 'MasstransportAnalysis' in analyses:
2420@@ -55,7 +61,7 @@
2421 md = checkfield(md,'fieldname','smb.b_max','timeseries',1,'NaN',1,'Inf',1)
2422 md = checkfield(md,'fieldname','smb.b_min','timeseries',1,'NaN',1,'Inf',1)
2423
2424- md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
2425+ md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1)
2426 return md
2427 # }}}
2428 def marshall(self,prefix,md,fid): # {{{
2429Index: ../trunk-jpl/src/m/classes/constants.py
2430===================================================================
2431--- ../trunk-jpl/src/m/classes/constants.py (revision 22266)
2432+++ ../trunk-jpl/src/m/classes/constants.py (revision 22267)
2433@@ -11,10 +11,10 @@
2434 """
2435
2436 def __init__(self): # {{{
2437- self.g = 0
2438- self.omega = 0
2439- self.yts = 0
2440- self.referencetemperature = 0
2441+ self.g = 0.
2442+ self.omega = 0.
2443+ self.yts = 0.
2444+ self.referencetemperature = 0.
2445
2446 #set defaults
2447 self.setdefaultparameters()
2448@@ -48,10 +48,10 @@
2449 #}}}
2450 def checkconsistency(self,md,solution,analyses): # {{{
2451
2452- md = checkfield(md,'fieldname','constants.g','>',0,'size',[1])
2453- md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1])
2454- md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1])
2455- md = checkfield(md,'fieldname','constants.referencetemperature','size',[1])
2456+ md = checkfield(md,'fieldname','constants.g','>=',0,'size',[1,1])
2457+ md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1,1])
2458+ md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1,1])
2459+ md = checkfield(md,'fieldname','constants.referencetemperature','size',[1,1])
2460
2461 return md
2462 # }}}
2463Index: ../trunk-jpl/src/m/classes/hydrologysommers.py
2464===================================================================
2465--- ../trunk-jpl/src/m/classes/hydrologysommers.py (nonexistent)
2466+++ ../trunk-jpl/src/m/classes/hydrologysommers.py (revision 22267)
2467@@ -0,0 +1,90 @@
2468+from fielddisplay import fielddisplay
2469+from checkfield import checkfield
2470+from WriteData import WriteData
2471+
2472+class hydrologysommers(object):
2473+ """
2474+ HYDROLOGYSOMMERS class definition
2475+
2476+ Usage:
2477+ hydrologysommers=hydrologysommers()
2478+ """
2479+
2480+ def __init__(self): # {{{
2481+ self.head = float('NaN')
2482+ self.gap_height = float('NaN')
2483+ self.bump_spacing = float('NaN')
2484+ self.bump_height = float('NaN')
2485+ self.englacial_input = float('NaN')
2486+ self.moulin_input = float('NaN')
2487+ self.reynolds = float('NaN')
2488+ self.spchead = float('NaN')
2489+ self.neumannflux = float('NaN')
2490+ self.relaxation = 0
2491+ self.storage = 0
2492+
2493+ #set defaults
2494+ self.setdefaultparameters()
2495+
2496+ #}}}
2497+ def __repr__(self): # {{{
2498+
2499+ string=' hydrologysommers solution parameters:'
2500+ string="%s\n%s"%(string,fielddisplay(self,'head','subglacial hydrology water head (m)'))
2501+ string="%s\n%s"%(string,fielddisplay(self,'gap_height','height of gap separating ice to bed (m)'))
2502+ string="%s\n%s"%(string,fielddisplay(self,'bump_spacing','characteristic bedrock bump spacing (m)'))
2503+ string="%s\n%s"%(string,fielddisplay(self,'bump_height','characteristic bedrock bump height (m)'))
2504+ string="%s\n%s"%(string,fielddisplay(self,'englacial_input','liquid water input from englacial to subglacial system (m/yr)'))
2505+ string="%s\n%s"%(string,fielddisplay(self,'moulin_input','liquid water input from moulins (at the vertices) to subglacial system (m^3/s)'))
2506+ string="%s\n%s"%(string,fielddisplay(self,'reynolds','Reynolds'' number'))
2507+ string="%s\n%s"%(string,fielddisplay(self,'neumannflux','water flux applied along the model boundary (m^2/s)'))
2508+ string="%s\n%s"%(string,fielddisplay(self,'spchead','water head constraints (NaN means no constraint) (m)'))
2509+ string="%s\n%s"%(string,fielddisplay(self,'relaxation','under-relaxation coefficient for nonlinear iteration'))
2510+ string="%s\n%s"%(string,fielddisplay(self,'storage','englacial storage coefficient (void ratio)'))
2511+ return string
2512+ #}}}
2513+ def extrude(self,md): # {{{
2514+ return self
2515+ #}}}
2516+ def setdefaultparameters(self): # {{{
2517+ # Set under-relaxation parameter to be 1 (no under-relaxation of nonlinear iteration)
2518+ self.relaxation=1
2519+ self.storage=0
2520+ return self
2521+ #}}}
2522+ def checkconsistency(self,md,solution,analyses): # {{{
2523+
2524+ #Early return
2525+ if 'HydrologySommersAnalysis' not in analyses:
2526+ return md
2527+
2528+ md = checkfield(md,'fieldname','hydrology.head','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
2529+ md = checkfield(md,'fieldname','hydrology.gap_height','>=',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1)
2530+ md = checkfield(md,'fieldname','hydrology.bump_spacing','>',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1)
2531+ md = checkfield(md,'fieldname','hydrology.bump_height','>=',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1)
2532+ md = checkfield(md,'fieldname','hydrology.englacial_input','>=',0,'NaN',1,'Inf',1,'timeseries',1)
2533+ md = checkfield(md,'fieldname','hydrology.moulin_input','>=',0,'NaN',1,'Inf',1,'timeseries',1)
2534+ md = checkfield(md,'fieldname','hydrology.reynolds','>',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1)
2535+ md = checkfield(md,'fieldname','hydrology.neumannflux','timeseries',1,'NaN',1,'Inf',1)
2536+ md = checkfield(md,'fieldname','hydrology.spchead','size',[md.mesh.numberofvertices])
2537+ md = checkfield(md,'fieldname','hydrology.relaxation','>=',0)
2538+ md = checkfield(md,'fieldname','hydrology.storage','>=',0)
2539+
2540+ return md
2541+ # }}}
2542+ def marshall(self,prefix,md,fid): # {{{
2543+ yts=md.constants.yts
2544+
2545+ WriteData(fid,prefix,'name','md.hydrology.model','data',3,'format','Integer')
2546+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','head','format','DoubleMat','mattype',1)
2547+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','gap_height','format','DoubleMat','mattype',2)
2548+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','bump_spacing','format','DoubleMat','mattype',2)
2549+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','bump_height','format','DoubleMat','mattype',2)
2550+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','englacial_input','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
2551+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','moulin_input','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
2552+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','reynolds','format','DoubleMat','mattype',2)
2553+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','neumannflux','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
2554+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','spchead','format','DoubleMat','mattype',1)
2555+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','relaxation','format','Double')
2556+ WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','storage','format','Double')
2557+ # }}}
2558Index: ../trunk-jpl/src/m/classes/flowequation.py
2559===================================================================
2560--- ../trunk-jpl/src/m/classes/flowequation.py (revision 22266)
2561+++ ../trunk-jpl/src/m/classes/flowequation.py (revision 22267)
2562@@ -91,7 +91,7 @@
2563 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0,1])
2564 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',['P1','P1bubble','P1bubblecondensed','P2','P2bubble'])
2565 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',['P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4'])
2566- md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart'])
2567+ md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','LATaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart','LACrouzeixRaviart'])
2568 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices],'values',[0,1])
2569 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1])
2570 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1])
2571@@ -103,6 +103,9 @@
2572 if m.strcmp(md.mesh.domaintype(),'2Dhorizontal'):
2573 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2])
2574 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2])
2575+ elif m.strcmp(md.mesh.domaintype(),'2Dvertical'):
2576+ md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[2,4,5])
2577+ md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[2,4,5])
2578 elif m.strcmp(md.mesh.domaintype(),'3D'):
2579 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',np.arange(0,8+1))
2580 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',np.arange(0,8+1))
2581Index: ../trunk-jpl/src/m/classes/basalforcings.py
2582===================================================================
2583--- ../trunk-jpl/src/m/classes/basalforcings.py (revision 22266)
2584+++ ../trunk-jpl/src/m/classes/basalforcings.py (revision 22267)
2585@@ -44,6 +44,9 @@
2586 if np.all(np.isnan(self.floatingice_melting_rate)):
2587 self.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices))
2588 print " no basalforcings.floatingice_melting_rate specified: values set as zero"
2589+ #if np.all(np.isnan(self.geothermalflux)):
2590+ #self.geothermalflux=np.zeros((md.mesh.numberofvertices))
2591+ #print " no basalforcings.geothermalflux specified: values set as zero"
2592
2593 return self
2594 #}}}
2595Index: ../trunk-jpl/src/m/classes/calvingvonmises.py
2596===================================================================
2597--- ../trunk-jpl/src/m/classes/calvingvonmises.py (nonexistent)
2598+++ ../trunk-jpl/src/m/classes/calvingvonmises.py (revision 22267)
2599@@ -0,0 +1,60 @@
2600+from fielddisplay import fielddisplay
2601+from project3d import project3d
2602+from checkfield import checkfield
2603+from WriteData import WriteData
2604+
2605+class calvingvonmises(object):
2606+ """
2607+ CALVINGVONMISES class definition
2608+
2609+ Usage:
2610+ calvingvonmises=calvingvonmises()
2611+ """
2612+
2613+ def __init__(self): # {{{
2614+
2615+ self.stress_threshold_groundedice = 0.
2616+ self.stress_threshold_floatingice = 0.
2617+ self.meltingrate = float('NaN')
2618+
2619+ #set defaults
2620+ self.setdefaultparameters()
2621+
2622+ #}}}
2623+ def __repr__(self): # {{{
2624+ string=' Calving VonMises parameters:'
2625+ string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_groundedice','sigma_max applied to grounded ice only [Pa]'))
2626+ string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_floatingice','sigma_max applied to floating ice only [Pa]'))
2627+
2628+ string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]'))
2629+ return string
2630+ #}}}
2631+ def extrude(self,md): # {{{
2632+ self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node')
2633+ return self
2634+ #}}}
2635+ def setdefaultparameters(self): # {{{
2636+ #Default sigma max
2637+ self.stress_threshold_groundedice = 1e6
2638+ self.stress_threshold_floatingice = 150e3
2639+ return self
2640+ #}}}
2641+ def checkconsistency(self,md,solution,analyses): # {{{
2642+ #Early return
2643+ if solution == 'TransientSolution' or md.transient.ismovingfront == 0:
2644+ return
2645+
2646+ md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'nan',1,'Inf',1)
2647+ md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'nan',1,'Inf',1)
2648+ md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'timeseries',1,'>=',0)
2649+
2650+ return md
2651+ # }}}
2652+ def marshall(self,prefix,md,fid): # {{{
2653+ yts=md.constants.yts
2654+
2655+ WriteData(fid,prefix,'name','md.calving.law','data',2,'format','Integer')
2656+ WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1)
2657+ WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1)
2658+ WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts)
2659+ # }}}
2660Index: ../trunk-jpl/src/m/classes/transient.py
2661===================================================================
2662--- ../trunk-jpl/src/m/classes/transient.py (revision 22266)
2663+++ ../trunk-jpl/src/m/classes/transient.py (revision 22267)
2664@@ -11,7 +11,7 @@
2665 """
2666
2667 def __init__(self): # {{{
2668- self.issmb = False
2669+ self.issmb = False
2670 self.ismasstransport = False
2671 self.isstressbalance = False
2672 self.isthermal = False
2673@@ -22,9 +22,9 @@
2674 self.ismovingfront = False
2675 self.ishydrology = False
2676 self.isslr = False
2677+ self.iscoupler = False
2678+ self.amr_frequency = 0
2679 self.isoceancoupling = False
2680- self.iscoupler = False
2681- amr_frequency = 0
2682 self.requested_outputs = []
2683
2684 #set defaults
2685@@ -80,6 +80,26 @@
2686 self.requested_outputs=[]
2687 return self
2688 #}}}
2689+ def deactivateall(self):#{{{
2690+ self.issmb = False
2691+ self.ismasstransport = False
2692+ self.isstressbalance = False
2693+ self.isthermal = False
2694+ self.isgroundingline = False
2695+ self.isgia = False
2696+ self.isesa = False
2697+ self.isdamageevolution = False
2698+ self.ismovingfront = False
2699+ self.ishydrology = False
2700+ self.isslr = False
2701+ self.isoceancoupling = False
2702+ self.iscoupler = False
2703+ self.amr_frequency = 0
2704+
2705+ #default output
2706+ self.requested_outputs=[]
2707+ return self
2708+ #}}}
2709 def setdefaultparameters(self): # {{{
2710
2711 #full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now
2712Index: ../trunk-jpl/src/m/classes/mesh2dvertical.py
2713===================================================================
2714--- ../trunk-jpl/src/m/classes/mesh2dvertical.py (nonexistent)
2715+++ ../trunk-jpl/src/m/classes/mesh2dvertical.py (revision 22267)
2716@@ -0,0 +1,130 @@
2717+import numpy as np
2718+from fielddisplay import fielddisplay
2719+from checkfield import checkfield
2720+import MatlabFuncs as m
2721+from WriteData import WriteData
2722+
2723+class mesh2dvertical(object):
2724+ """
2725+ MESH2DVERTICAL class definition
2726+
2727+ Usage:
2728+ mesh2dvertical=mesh2dvertical();
2729+ """
2730+
2731+ def __init__(self): # {{{
2732+ self.x = float('NaN')
2733+ self.y = float('NaN')
2734+ self.elements = float('NaN')
2735+ self.numberofelements = 0
2736+ self.numberofvertices = 0
2737+ self.numberofedges = 0
2738+
2739+ self.lat = float('NaN')
2740+ self.long = float('NaN')
2741+ self.epsg = float('NaN')
2742+
2743+ self.vertexonboundary = float('NaN')
2744+ self.vertexonbase = float('NaN')
2745+ self.vertexonsurface = float('NaN')
2746+
2747+ self.edges = float('NaN')
2748+ self.segments = float('NaN')
2749+ self.segmentmarkers = float('NaN')
2750+ self.vertexconnectivity = float('NaN')
2751+ self.elementconnectivity = float('NaN')
2752+ self.average_vertex_connectivity = 0
2753+
2754+ #set defaults
2755+ self.setdefaultparameters()
2756+
2757+ #}}}
2758+ def __repr__(self): # {{{
2759+ string=" 2D tria Mesh (vertical):"
2760+
2761+ string="%s\n%s"%(string,"\n Elements and vertices:")
2762+ string="%s\n%s"%(string,fielddisplay(self,"numberofelements","number of elements"))
2763+ string="%s\n%s"%(string,fielddisplay(self,"numberofvertices","number of vertices"))
2764+ string="%s\n%s"%(string,fielddisplay(self,"elements","vertex indices of the mesh elements"))
2765+ string="%s\n%s"%(string,fielddisplay(self,"x","vertices x coordinate [m]"))
2766+ string="%s\n%s"%(string,fielddisplay(self,"y","vertices y coordinate [m]"))
2767+ string="%s\n%s"%(string,fielddisplay(self,"edges","edges of the 2d mesh (vertex1 vertex2 element1 element2)"))
2768+ string="%s\n%s"%(string,fielddisplay(self,"numberofedges","number of edges of the 2d mesh"))
2769+
2770+ string="%s%s"%(string,"\n\n Properties:")
2771+ string="%s\n%s"%(string,fielddisplay(self,"vertexonboundary","vertices on the boundary of the domain flag list"))
2772+ string="%s\n%s"%(string,fielddisplay(self,'vertexonbase','vertices on the bed of the domain flag list'))
2773+ string="%s\n%s"%(string,fielddisplay(self,'vertexonsurface','vertices on the surface of the domain flag list'))
2774+ string="%s\n%s"%(string,fielddisplay(self,"segments","edges on domain boundary (vertex1 vertex2 element)"))
2775+ string="%s\n%s"%(string,fielddisplay(self,"segmentmarkers","number associated to each segment"))
2776+ string="%s\n%s"%(string,fielddisplay(self,"vertexconnectivity","list of vertices connected to vertex_i"))
2777+ string="%s\n%s"%(string,fielddisplay(self,"elementconnectivity","list of vertices connected to element_i"))
2778+ string="%s\n%s"%(string,fielddisplay(self,"average_vertex_connectivity","average number of vertices connected to one vertex"))
2779+
2780+ string="%s%s"%(string,"\n\n Projection:")
2781+ string="%s\n%s"%(string,fielddisplay(self,"lat","vertices latitude [degrees]"))
2782+ string="%s\n%s"%(string,fielddisplay(self,"long","vertices longitude [degrees]"))
2783+ string="%s\n%s"%(string,fielddisplay(self,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)"))
2784+ return string
2785+ #}}}
2786+ def setdefaultparameters(self): # {{{
2787+
2788+ #the connectivity is the averaged number of nodes linked to a
2789+ #given node through an edge. This connectivity is used to initially
2790+ #allocate memory to the stiffness matrix. A value of 16 seems to
2791+ #give a good memory/time ration. This value can be checked in
2792+ #trunk/test/Miscellaneous/runme.m
2793+ self.average_vertex_connectivity=25.
2794+
2795+ return self
2796+ #}}}
2797+ def checkconsistency(self,md,solution,analyses): # {{{
2798+ if(solution=='LoveSolution'):
2799+ return
2800+
2801+ md = checkfield(md,'fieldname','mesh.x','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
2802+ md = checkfield(md,'fieldname','mesh.y','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
2803+ md = checkfield(md,'fieldname','mesh.elements','NaN',1,'Inf',1,'>',0,'values',np.arange(1,md.mesh.numberofvertices+1))
2804+ md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements,3])
2805+ if np.any(np.logical_not(m.ismember(np.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
2806+ md.checkmessage("orphan nodes have been found. Check the mesh outline")
2807+ md = checkfield(md,'fieldname','mesh.numberofelements','>',0)
2808+ md = checkfield(md,'fieldname','mesh.numberofvertices','>',0)
2809+ md = checkfield(md,'fieldname','mesh.vertexonbase','size',[md.mesh.numberofvertices],'values',[0,1])
2810+ md = checkfield(md,'fieldname','mesh.vertexonsurface','size',[md.mesh.numberofvertices],'values',[0,1])
2811+ md = checkfield(md,'fieldname','mesh.average_vertex_connectivity','>=',9,'message',"'mesh.average_vertex_connectivity' should be at least 9 in 2d")
2812+
2813+ if solution=='ThermalSolution':
2814+ md.checkmessage("thermal not supported for 2d mesh")
2815+
2816+ return md
2817+ # }}}
2818+ def domaintype(self): # {{{
2819+ return "2Dvertical"
2820+ #}}}
2821+ def dimension(self): # {{{
2822+ return 2
2823+ #}}}
2824+ def elementtype(self): # {{{
2825+ return "Tria"
2826+ #}}}
2827+ def vertexflags(self,value): # {{{
2828+ flags = np.zeros((self.numberofvertices,))
2829+ pos = self.segments[np.where(self.segmentmarkers==value),0:2]-1
2830+ flags[pos] = 1
2831+ return flags
2832+ #}}}
2833+ def marshall(self,prefix,md,fid): # {{{
2834+ WriteData(fid,prefix,'name','md.mesh.domain_type','data',"Domain"+self.domaintype(),'format','String');
2835+ WriteData(fid,prefix,'name','md.mesh.domain_dimension','data',self.dimension(),'format','Integer');
2836+ WriteData(fid,prefix,'name','md.mesh.elementtype','data',self.elementtype(),'format','String');
2837+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1)
2838+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1)
2839+ WriteData(fid,prefix,'name','md.mesh.z','data',np.zeros(self.numberofvertices),'format','DoubleMat','mattype',1);
2840+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2)
2841+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','numberofelements','format','Integer')
2842+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer')
2843+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1)
2844+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1)
2845+ WriteData(fid,prefix,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer')
2846+ # }}}
2847Index: ../trunk-jpl/src/m/classes/matenhancedice.py
2848===================================================================
2849--- ../trunk-jpl/src/m/classes/matenhancedice.py (nonexistent)
2850+++ ../trunk-jpl/src/m/classes/matenhancedice.py (revision 22267)
2851@@ -0,0 +1,171 @@
2852+from fielddisplay import fielddisplay
2853+from project3d import project3d
2854+from checkfield import checkfield
2855+from WriteData import WriteData
2856+
2857+class matenhancedice(object):
2858+ """
2859+ MATICE class definition
2860+
2861+ Usage:
2862+ matenhancedice=matenhancedice();
2863+ """
2864+
2865+ def __init__(self): # {{{
2866+ self.rho_ice = 0.
2867+ self.rho_water = 0.
2868+ self.rho_freshwater = 0.
2869+ self.mu_water = 0.
2870+ self.heatcapacity = 0.
2871+ self.latentheat = 0.
2872+ self.thermalconductivity = 0.
2873+ self.temperateiceconductivity = 0.
2874+ self.meltingpoint = 0.
2875+ self.beta = 0.
2876+ self.mixed_layer_capacity = 0.
2877+ self.thermal_exchange_velocity = 0.
2878+ self.rheology_E = float('NaN')
2879+ self.rheology_B = float('NaN')
2880+ self.rheology_n = float('NaN')
2881+ self.rheology_law = ''
2882+
2883+ #giaivins:
2884+ self.lithosphere_shear_modulus = 0.
2885+ self.lithosphere_density = 0.
2886+ self.mantle_shear_modulus = 0.
2887+ self.mantle_density = 0.
2888+
2889+ #SLR
2890+ self.earth_density= 0 # average density of the Earth, (kg/m^3)
2891+
2892+ self.setdefaultparameters()
2893+ #}}}
2894+ def __repr__(self): # {{{
2895+ string=" Materials:"
2896+
2897+ string="%s\n%s"%(string,fielddisplay(self,"rho_ice","ice density [kg/m^3]"))
2898+ string="%s\n%s"%(string,fielddisplay(self,"rho_water","water density [kg/m^3]"))
2899+ string="%s\n%s"%(string,fielddisplay(self,"rho_freshwater","fresh water density [kg/m^3]"))
2900+ string="%s\n%s"%(string,fielddisplay(self,"mu_water","water viscosity [N s/m^2]"))
2901+ string="%s\n%s"%(string,fielddisplay(self,"heatcapacity","heat capacity [J/kg/K]"))
2902+ string="%s\n%s"%(string,fielddisplay(self,"thermalconductivity","ice thermal conductivity [W/m/K]"))
2903+ string="%s\n%s"%(string,fielddisplay(self,"temperateiceconductivity","temperate ice thermal conductivity [W/m/K]"))
2904+ string="%s\n%s"%(string,fielddisplay(self,"meltingpoint","melting point of ice at 1atm in K"))
2905+ string="%s\n%s"%(string,fielddisplay(self,"latentheat","latent heat of fusion [J/m^3]"))
2906+ string="%s\n%s"%(string,fielddisplay(self,"beta","rate of change of melting point with pressure [K/Pa]"))
2907+ string="%s\n%s"%(string,fielddisplay(self,"mixed_layer_capacity","mixed layer capacity [W/kg/K]"))
2908+ string="%s\n%s"%(string,fielddisplay(self,"thermal_exchange_velocity","thermal exchange velocity [m/s]"))
2909+ string="%s\n%s"%(string,fielddisplay(self,"rheology_E","enhancement factor"))
2910+ string="%s\n%s"%(string,fielddisplay(self,"rheology_B","flow law parameter [Pa/s^(1/n)]"))
2911+ string="%s\n%s"%(string,fielddisplay(self,"rheology_n","Glen's flow law exponent"))
2912+ string="%s\n%s"%(string,fielddisplay(self,"rheology_law","law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius' or 'LliboutryDuval'"))
2913+ string="%s\n%s"%(string,fielddisplay(self,"lithosphere_shear_modulus","Lithosphere shear modulus [Pa]"))
2914+ string="%s\n%s"%(string,fielddisplay(self,"lithosphere_density","Lithosphere density [g/cm^-3]"))
2915+ string="%s\n%s"%(string,fielddisplay(self,"mantle_shear_modulus","Mantle shear modulus [Pa]"))
2916+ string="%s\n%s"%(string,fielddisplay(self,"mantle_density","Mantle density [g/cm^-3]"))
2917+ string="%s\n%s"%(string,fielddisplay(self,"earth_density","Mantle density [kg/m^-3]"))
2918+
2919+ return string
2920+ #}}}
2921+ def extrude(self,md): # {{{
2922+ self.rheology_E=project3d(md,'vector',self.rheology_E,'type','node')
2923+ self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node')
2924+ self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element')
2925+ return self
2926+ #}}}
2927+ def setdefaultparameters(self): # {{{
2928+ #ice density (kg/m^3)
2929+ self.rho_ice=917.
2930+
2931+ #ocean water density (kg/m^3)
2932+ self.rho_water=1023.
2933+
2934+ #fresh water density (kg/m^3)
2935+ self.rho_freshwater=1000.
2936+
2937+ #water viscosity (N.s/m^2)
2938+ self.mu_water=0.001787
2939+
2940+ #ice heat capacity cp (J/kg/K)
2941+ self.heatcapacity=2093.
2942+
2943+ #ice latent heat of fusion L (J/kg)
2944+ self.latentheat=3.34*10**5
2945+
2946+ #ice thermal conductivity (W/m/K)
2947+ self.thermalconductivity=2.4
2948+
2949+ #temperate ice thermal conductivity (W/m/K)
2950+ self.temperateiceconductivity=0.24
2951+
2952+ #the melting point of ice at 1 atmosphere of pressure in K
2953+ self.meltingpoint=273.15
2954+
2955+ #rate of change of melting point with pressure (K/Pa)
2956+ self.beta=9.8*10**-8
2957+
2958+ #mixed layer (ice-water interface) heat capacity (J/kg/K)
2959+ self.mixed_layer_capacity=3974.
2960+
2961+ #thermal exchange velocity (ice-water interface) (m/s)
2962+ self.thermal_exchange_velocity=1.00*10**-4
2963+
2964+ #Rheology law: what is the temperature dependence of B with T
2965+ #available: none, paterson and arrhenius
2966+ self.rheology_law='Paterson'
2967+
2968+ # GIA:
2969+ self.lithosphere_shear_modulus = 6.7*10**10 # (Pa)
2970+ self.lithosphere_density = 3.32 # (g/cm^-3)
2971+ self.mantle_shear_modulus = 1.45*10**11 # (Pa)
2972+ self.mantle_density = 3.34 # (g/cm^-3)
2973+
2974+ #SLR
2975+ self.earth_density= 5512 #average density of the Earth, (kg/m^3)
2976+
2977+ return self
2978+ #}}}
2979+ def checkconsistency(self,md,solution,analyses): # {{{
2980+ md = checkfield(md,'fieldname','materials.rho_ice','>',0)
2981+ md = checkfield(md,'fieldname','materials.rho_water','>',0)
2982+ md = checkfield(md,'fieldname','materials.rho_freshwater','>',0)
2983+ md = checkfield(md,'fieldname','materials.mu_water','>',0)
2984+ md = checkfield(md,'fieldname','materials.rheology_E','>',0,'timeseries',1,'NaN',1,'Inf',1)
2985+ md = checkfield(md,'fieldname','materials.rheology_B','>',0,'timeseries',1,'NaN',1,'Inf',1)
2986+ md = checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements])
2987+ md = checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka','Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval'])
2988+
2989+ if 'GiaAnalysis' in analyses:
2990+ md = checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1)
2991+ md = checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1)
2992+ md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1)
2993+ md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1)
2994+ if 'SealevelriseAnalysis' in analyses:
2995+ md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1)
2996+ return md
2997+ # }}}
2998+ def marshall(self,prefix,md,fid): # {{{
2999+ WriteData(fid,prefix,'name','md.materials.type','data',4,'format','Integer')
3000+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_ice','format','Double')
3001+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_water','format','Double')
3002+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_freshwater','format','Double')
3003+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mu_water','format','Double')
3004+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','heatcapacity','format','Double')
3005+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','latentheat','format','Double')
3006+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermalconductivity','format','Double')
3007+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double')
3008+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','meltingpoint','format','Double')
3009+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','beta','format','Double')
3010+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double')
3011+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double')
3012+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_E','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
3013+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
3014+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2)
3015+ WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String')
3016+
3017+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double')
3018+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3)
3019+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double')
3020+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10^3)
3021+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','earth_density','format','Double')
3022+ # }}}
3023Index: ../trunk-jpl/src/m/classes/amr.py
3024===================================================================
3025--- ../trunk-jpl/src/m/classes/amr.py (revision 22266)
3026+++ ../trunk-jpl/src/m/classes/amr.py (revision 22267)
3027@@ -27,6 +27,7 @@
3028 self.deviatoricerror_resolution= 0.
3029 self.deviatoricerror_threshold = 0.
3030 self.deviatoricerror_maximum = 0.
3031+ self.restart=0.
3032 #set defaults
3033 self.setdefaultparameters()
3034 #}}}
3035@@ -47,6 +48,7 @@
3036 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_resolution","element length when deviatoric stress error estimator is used"))
3037 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_threshold","maximum threshold deviatoricstress error permitted"))
3038 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_maximum","maximum deviatoricstress error permitted"))
3039+ string="%s\n%s"%(string,fielddisplay(self,'restart',['indicates if ReMesh() will call before first time step']))
3040 return string
3041 #}}}
3042 def setdefaultparameters(self): # {{{
3043@@ -66,6 +68,7 @@
3044 self.deviatoricerror_resolution= 500.
3045 self.deviatoricerror_threshold = 0
3046 self.deviatoricerror_maximum = 0
3047+ self.restart = 0.
3048 return self
3049 #}}}
3050 def checkconsistency(self,md,solution,analyses): # {{{
3051@@ -83,6 +86,7 @@
3052 md = checkfield(md,'fieldname','amr.deviatoricerror_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1);
3053 md = checkfield(md,'fieldname','amr.deviatoricerror_threshold','numel',[1],'>=',0,'<=',1,'NaN',1);
3054 md = checkfield(md,'fieldname','amr.deviatoricerror_maximum','numel',[1],'>=',0,'NaN',1,'Inf',1);
3055+ md = checkfield(md,'fieldname','amr.restart','numel',[1],'>=',0,'<=',1,'NaN',1)
3056 return md
3057 # }}}
3058 def marshall(self,prefix,md,fid): # {{{
3059@@ -103,4 +107,5 @@
3060 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_resolution','format','Double');
3061 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_threshold','format','Double');
3062 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_maximum','format','Double');
3063+ WriteData(fid,prefix,'object',self,'class','amr','fieldname','restart','format','Integer')
3064 # }}}
3065Index: ../trunk-jpl/src/m/classes/matestar.py
3066===================================================================
3067--- ../trunk-jpl/src/m/classes/matestar.py (nonexistent)
3068+++ ../trunk-jpl/src/m/classes/matestar.py (revision 22267)
3069@@ -0,0 +1,175 @@
3070+import numpy as np
3071+from fielddisplay import fielddisplay
3072+from project3d import project3d
3073+from checkfield import checkfield
3074+from WriteData import WriteData
3075+
3076+class matestar(object):
3077+ """
3078+ matestar class definition
3079+
3080+ Usage:
3081+ matestar=matestar()
3082+ """
3083+
3084+ def __init__(self): # {{{
3085+
3086+ rho_ice = 0.
3087+ rho_water = 0.
3088+ rho_freshwater = 0.
3089+ mu_water = 0.
3090+ heatcapacity = 0.
3091+ latentheat = 0.
3092+ thermalconductivity = 0.
3093+ temperateiceconductivity = 0.
3094+ meltingpoint = 0.
3095+ beta = 0.
3096+ mixed_layer_capacity = 0.
3097+ thermal_exchange_velocity = 0.
3098+ rheology_B = float('NaN')
3099+ rheology_Ec = float('NaN')
3100+ rheology_Es = float('NaN')
3101+ rheology_law = ''
3102+
3103+ #giaivins:
3104+ lithosphere_shear_modulus = 0.
3105+ lithosphere_density = 0.
3106+ mantle_shear_modulus = 0.
3107+ mantle_density = 0.
3108+
3109+ #slr
3110+ earth_density = 0
3111+
3112+ #set default parameters:
3113+ self.setdefaultparameters()
3114+ #}}}
3115+ def __repr__(self): # {{{
3116+ string=" Materials:"
3117+
3118+ string="%s\n%s"%(string,fielddisplay(self,'rho_ice','ice density [kg/m^3]'))
3119+ string="%s\n%s"%(string,fielddisplay(self,'rho_water','ocean water density [kg/m^3]'))
3120+ string="%s\n%s"%(string,fielddisplay(self,'rho_freshwater','fresh water density [kg/m^3]'))
3121+ string="%s\n%s"%(string,fielddisplay(self,'mu_water','water viscosity [N s/m^2]'))
3122+ string="%s\n%s"%(string,fielddisplay(self,'heatcapacity','heat capacity [J/kg/K]'))
3123+ string="%s\n%s"%(string,fielddisplay(self,'thermalconductivity',['ice thermal conductivity [W/m/K]']))
3124+ string="%s\n%s"%(string,fielddisplay(self,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]'))
3125+ string="%s\n%s"%(string,fielddisplay(self,'meltingpoint','melting point of ice at 1atm in K'))
3126+ string="%s\n%s"%(string,fielddisplay(self,'latentheat','latent heat of fusion [J/kg]'))
3127+ string="%s\n%s"%(string,fielddisplay(self,'beta','rate of change of melting point with pressure [K/Pa]'))
3128+ string="%s\n%s"%(string,fielddisplay(self,'mixed_layer_capacity','mixed layer capacity [W/kg/K]'))
3129+ string="%s\n%s"%(string,fielddisplay(self,'thermal_exchange_velocity','thermal exchange velocity [m/s]'))
3130+ string="%s\n%s"%(string,fielddisplay(self,'rheology_B','flow law parameter [Pa/s^(1/3)]'))
3131+ string="%s\n%s"%(string,fielddisplay(self,'rheology_Ec','compressive enhancement factor'))
3132+ string="%s\n%s"%(string,fielddisplay(self,'rheology_Es','shear enhancement factor'))
3133+ string="%s\n%s"%(string,fielddisplay(self,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''BuddJacka'', ''Cuffey'', ''CuffeyTemperate'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']))
3134+ string="%s\n%s"%(string,fielddisplay(self,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]'))
3135+ string="%s\n%s"%(string,fielddisplay(self,'lithosphere_density','Lithosphere density [g/cm^-3]'))
3136+ string="%s\n%s"%(string,fielddisplay(self,'mantle_shear_modulus','Mantle shear modulus [Pa]'))
3137+ string="%s\n%s"%(string,fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]'))
3138+ string="%s\n%s"%(string,fielddisplay(self,'earth_density','Mantle density [kg/m^-3]'))
3139+
3140+ return string
3141+ #}}}
3142+ def extrude(self,md): # {{{
3143+ self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node')
3144+ self.rheology_Ec=project3d(md,'vector',self.rheology_Ec,'type','node')
3145+ self.rheology_Es=project3d(md,'vector',self.rheology_Es,'type','node')
3146+ return self
3147+ #}}}
3148+ def setdefaultparameters(self): # {{{
3149+ #ice density (kg/m^3)
3150+ self.rho_ice=917.
3151+
3152+ #ocean water density (kg/m^3)
3153+ self.rho_water=1023.
3154+
3155+ #fresh water density (kg/m^3)
3156+ self.rho_freshwater=1000.
3157+
3158+ #water viscosity (N.s/m^2)
3159+ self.mu_water=0.001787
3160+
3161+ #ice heat capacity cp (J/kg/K)
3162+ self.heatcapacity=2093.
3163+
3164+ #ice latent heat of fusion L (J/kg)
3165+ self.latentheat=3.34*10**5
3166+
3167+ #ice thermal conductivity (W/m/K)
3168+ self.thermalconductivity=2.4
3169+
3170+ #wet ice thermal conductivity (W/m/K)
3171+ self.temperateiceconductivity=.24
3172+
3173+ #the melting point of ice at 1 atmosphere of pressure in K
3174+ self.meltingpoint=273.15
3175+
3176+ #rate of change of melting point with pressure (K/Pa)
3177+ self.beta=9.8*10**-8
3178+
3179+ #mixed layer (ice-water interface) heat capacity (J/kg/K)
3180+ self.mixed_layer_capacity=3974.
3181+
3182+ #thermal exchange velocity (ice-water interface) (m/s)
3183+ self.thermal_exchange_velocity=1.00*10**-4
3184+
3185+ #Rheology law: what is the temperature dependence of B with T
3186+ #available: none, paterson and arrhenius
3187+ self.rheology_law='Paterson'
3188+
3189+ # GIA:
3190+ self.lithosphere_shear_modulus = 6.7*10**10 # (Pa)
3191+ self.lithosphere_density = 3.32 # (g/cm^-3)
3192+ self.mantle_shear_modulus = 1.45*10**11 # (Pa)
3193+ self.mantle_density = 3.34 # (g/cm^-3)
3194+
3195+ #SLR
3196+ self.earth_density= 5512 # average density of the Earth, (kg/m^3)
3197+
3198+ return self
3199+ #}}}
3200+ def checkconsistency(self,md,solution,analyses): # {{{
3201+ md = checkfield(md,'fieldname','materials.rho_ice','>',0)
3202+ md = checkfield(md,'fieldname','materials.rho_water','>',0)
3203+ md = checkfield(md,'fieldname','materials.rho_freshwater','>',0)
3204+ md = checkfield(md,'fieldname','materials.mu_water','>',0)
3205+ md = checkfield(md,'fieldname','materials.rheology_B','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
3206+ md = checkfield(md,'fieldname','materials.rheology_Ec','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
3207+ md = checkfield(md,'fieldname','materials.rheology_Es','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
3208+ md = checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka', 'Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval'])
3209+
3210+ if 'GiaAnalysis' in analyses:
3211+ md = checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1)
3212+ md = checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1)
3213+ md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1)
3214+ md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1)
3215+ if 'SealevelriseAnalysis' in analyses:
3216+ md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1)
3217+
3218+ return md
3219+ # }}}
3220+ def marshall(self,prefix,md,fid): # {{{
3221+ WriteData(fid,prefix,'name','md.materials.type','data',2,'format','Integer')
3222+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_ice','format','Double')
3223+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_water','format','Double')
3224+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_freshwater','format','Double')
3225+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mu_water','format','Double')
3226+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','heatcapacity','format','Double')
3227+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','latentheat','format','Double')
3228+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermalconductivity','format','Double')
3229+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double')
3230+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','meltingpoint','format','Double')
3231+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','beta','format','Double')
3232+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double')
3233+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double')
3234+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1)
3235+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Ec','format','DoubleMat','mattype',1)
3236+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Es','format','DoubleMat','mattype',1)
3237+ WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String')
3238+
3239+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double')
3240+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3)
3241+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double')
3242+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10**3)
3243+ WriteData(fid,prefix,'object',self,'class','materials','fieldname','earth_density','format','Double')
3244+ # }}}
3245Index: ../trunk-jpl/src/m/classes/frictionsommers.py
3246===================================================================
3247--- ../trunk-jpl/src/m/classes/frictionsommers.py (nonexistent)
3248+++ ../trunk-jpl/src/m/classes/frictionsommers.py (revision 22267)
3249@@ -0,0 +1,47 @@
3250+from fielddisplay import fielddisplay
3251+from project3d import project3d
3252+from checkfield import checkfield
3253+from WriteData import WriteData
3254+
3255+class frictionsommers(object):
3256+ """
3257+ FRICTIONSOMMERS class definition
3258+
3259+ Usage:
3260+ friction=frictionsommers()
3261+ """
3262+
3263+ def __init__(self,md): # {{{
3264+ self.coefficient = md.friction.coefficient
3265+ #set defaults
3266+ self.setdefaultparameters()
3267+
3268+ #}}}
3269+ def __repr__(self): # {{{
3270+ string="Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n(effective stress Neff=rho_ice*g*thickness+rho_water*g*(head-b))"
3271+
3272+ string="%s\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]"))
3273+ return string
3274+ #}}}
3275+ def extrude(self,md): # {{{
3276+ self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1)
3277+ return self
3278+ #}}}
3279+ def setdefaultparameters(self): # {{{
3280+ return self
3281+ #}}}
3282+ def checkconsistency(self,md,solution,analyses): # {{{
3283+
3284+ #Early return
3285+ if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
3286+ return md
3287+
3288+ md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1)
3289+ return md
3290+
3291+ # }}}
3292+ def marshall(self,prefix,md,fid): # {{{
3293+ yts=md.constants.yts
3294+ WriteData(fid,prefix,'name','md.friction.law','data',8,'format','Integer')
3295+ WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
3296+ # }}}
3297Index: ../trunk-jpl/src/m/classes/SMBgemb.py
3298===================================================================
3299--- ../trunk-jpl/src/m/classes/SMBgemb.py (nonexistent)
3300+++ ../trunk-jpl/src/m/classes/SMBgemb.py (revision 22267)
3301@@ -0,0 +1,368 @@
3302+import numpy as np
3303+from fielddisplay import fielddisplay
3304+from checkfield import checkfield
3305+from WriteData import WriteData
3306+from project3d import project3d
3307+
3308+class SMBgemb(object):
3309+ """
3310+ SMBgemb Class definition
3311+
3312+ Usage:
3313+ SMB = SMBgemb()
3314+ """
3315+
3316+ def __init__(self): # {{{
3317+ #each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived
3318+ #from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number
3319+ #of time steps. )
3320+
3321+ #solution choices
3322+ #check these:
3323+ #isgraingrowth
3324+ #isalbedo
3325+ #isshortwave
3326+ #isthermal
3327+ #isaccumulation
3328+ #ismelt
3329+ #isdensification
3330+ #isturbulentflux
3331+
3332+ #inputs:
3333+ Ta = float('NaN') #2 m air temperature, in Kelvin
3334+ V = float('NaN') #wind speed (m/s-1)
3335+ dswrf = float('NaN') #downward shortwave radiation flux [W/m^2]
3336+ dlwrf = float('NaN') #downward longwave radiation flux [W/m^2]
3337+ P = float('NaN') #precipitation [mm w.e. / m^2]
3338+ eAir = float('NaN') #screen level vapor pressure [Pa]
3339+ pAir = float('NaN') #surface pressure [Pa]
3340+
3341+ Tmean = float('NaN') #mean annual temperature [K]
3342+ C = float('NaN') #mean annual snow accumulation [kg m-2 yr-1]
3343+ Tz = float('NaN') #height above ground at which temperature (T) was sampled [m]
3344+ Vz = float('NaN') #height above ground at which wind (V) eas sampled [m]
3345+
3346+ # Initialization of snow properties
3347+ Dzini = float('NaN') #cell depth (m)
3348+ Dini = float('NaN') #snow density (kg m-3)
3349+ Reini = float('NaN') #effective grain size (mm)
3350+ Gdnini = float('NaN') #grain dricity (0-1)
3351+ Gspini = float('NaN') #grain sphericity (0-1)
3352+ ECini = float('NaN') #evaporation/condensation (kg m-2)
3353+ Wini = float('NaN') #Water content (kg m-2)
3354+ Aini = float('NaN') #albedo (0-1)
3355+ Tini = float('NaN') #snow temperature (K)
3356+ Sizeini = float('NaN') #Number of layers
3357+
3358+ #settings:
3359+ aIdx = float('NaN') #method for calculating albedo and subsurface absorption (default is 1)
3360+ # 1: effective grain radius [Gardner & Sharp, 2009]
3361+ # 2: effective grain radius [Brun et al., 2009]
3362+ # 3: density and cloud amount [Greuell & Konzelmann, 1994]
3363+ # 4: exponential time decay & wetness [Bougamont & Bamber, 2005]
3364+ swIdx = float('NaN') # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1)
3365+
3366+ denIdx = float('NaN') #densification model to use (default is 2):
3367+ # 1 = emperical model of Herron and Langway (1980)
3368+ # 2 = semi-emerical model of Anthern et al. (2010)
3369+ # 3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)
3370+ # 4 = DO NOT USE: emperical model of Li and Zwally (2004)
3371+ # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)
3372+
3373+ zTop = float('NaN') # depth over which grid length is constant at the top of the snopack (default 10) [m]
3374+ dzTop = float('NaN') # initial top vertical grid spacing (default .05) [m]
3375+ dzMin = float('NaN') # initial min vertical allowable grid spacing (default dzMin/2) [m]
3376+ zY = float('NaN') # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]
3377+ zMax = float('NaN') #initial max model depth (default is min(thickness,500)) [m]
3378+ zMin = float('NaN') #initial min model depth (default is min(thickness,30)) [m]
3379+ outputFreq = float('NaN') #output frequency in days (default is monthly, 30)
3380+
3381+ #specific albedo parameters:
3382+ #Method 1 and 2:
3383+ aSnow = float('NaN') # new snow albedo (0.64 - 0.89)
3384+ aIce = float('NaN') # range 0.27-0.58 for old snow
3385+ #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo
3386+ cldFrac = float('NaN') # average cloud amount
3387+ #Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005)
3388+ t0wet = float('NaN') # time scale for wet snow (15-21.9)
3389+ t0dry = float('NaN') # warm snow timescale (30)
3390+ K = float('NaN') # time scale temperature coef. (7)
3391+
3392+ #densities:
3393+ InitDensityScaling = float('NaN') #initial scaling factor multiplying the density of ice, which describes the density of the snowpack.
3394+
3395+ requested_outputs = []
3396+
3397+ #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM.
3398+ #dateN: that's the last row of the above fields.
3399+ #dt: included in dateN. Not an input.
3400+ #elev: this is taken from the ISSM surface itself.
3401+
3402+ #}}}
3403+ def __repr__(self): # {{{
3404+ #string = " surface forcings parameters:"
3405+ #string = "#s\n#s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'))
3406+ #string = "#s\n#s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
3407+ string = ' surface forcings for SMB GEMB model :'
3408+
3409+ string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
3410+ string = "%s\n%s"%(string,fielddisplay(self,'isgraingrowth','run grain growth module (default true)'))
3411+ string = "%s\n%s"%(string,fielddisplay(self,'isalbedo','run albedo module (default true)'))
3412+ string = "%s\n%s"%(string,fielddisplay(self,'isshortwave','run short wave module (default true)'))
3413+ string = "%s\n%s"%(string,fielddisplay(self,'isthermal','run thermal module (default true)'))
3414+ string = "%s\n%s"%(string,fielddisplay(self,'isaccumulation','run accumulation module (default true)'))
3415+ string = "%s\n%s"%(string,fielddisplay(self,'ismelt','run melting module (default true)'))
3416+ string = "%s\n%s"%(string,fielddisplay(self,'isdensification','run densification module (default true)'))
3417+ string = "%s\n%s"%(string,fielddisplay(self,'isturbulentflux','run turbulant heat fluxes module (default true)'))
3418+ string = "%s\n%s"%(string,fielddisplay(self,'Ta','2 m air temperature, in Kelvin'))
3419+ string = "%s\n%s"%(string,fielddisplay(self,'V','wind speed (m/s-1)'))
3420+ string = "%s\n%s"%(string,fielddisplay(self,'dlwrf','downward shortwave radiation flux [W/m^2]'))
3421+ string = "%s\n%s"%(string,fielddisplay(self,'dswrf','downward longwave radiation flux [W/m^2]'))
3422+ string = "%s\n%s"%(string,fielddisplay(self,'P','precipitation [mm w.e. / m^2]'))
3423+ string = "%s\n%s"%(string,fielddisplay(self,'eAir','screen level vapor pressure [Pa]'))
3424+ string = "%s\n%s"%(string,fielddisplay(self,'pAir','surface pressure [Pa]'))
3425+ string = "%s\n%s"%(string,fielddisplay(self,'Tmean','mean annual temperature [K]'))
3426+ string = "%s\n%s"%(string,fielddisplay(self,'C','mean annual snow accumulation [kg m-2 yr-1]'))
3427+ string = "%s\n%s"%(string,fielddisplay(self,'Tz','height above ground at which temperature (T) was sampled [m]'))
3428+ string = "%s\n%s"%(string,fielddisplay(self,'Vz','height above ground at which wind (V) eas sampled [m]'))
3429+ string = "%s\n%s"%(string,fielddisplay(self,'zTop','depth over which grid length is constant at the top of the snopack (default 10) [m]'))
3430+ string = "%s\n%s"%(string,fielddisplay(self,'dzTop','initial top vertical grid spacing (default .05) [m] '))
3431+ string = "%s\n%s"%(string,fielddisplay(self,'dzMin','initial min vertical allowable grid spacing (default dzMin/2) [m] '))
3432+ string = "%s\n%s"%(string,fielddisplay(self,'zMax','initial max model depth (default is min(thickness,500)) [m]'))
3433+ string = "%s\n%s"%(string,fielddisplay(self,'zMin','initial min model depth (default is min(thickness,30)) [m]'))
3434+ string = "%s\n%s"%(string,fielddisplay(self,'zY','strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]'))
3435+ string = "%s\n%s"%(string,fielddisplay(self,'InitDensityScaling',['initial scaling factor multiplying the density of ice','which describes the density of the snowpack.']))
3436+ string = "%s\n%s"%(string,fielddisplay(self,'outputFreq','output frequency in days (default is monthly, 30)'))
3437+ string = "%s\n%s"%(string,fielddisplay(self,'aIdx',['method for calculating albedo and subsurface absorption (default is 1)',
3438+ '1: effective grain radius [Gardner & Sharp, 2009]',
3439+ '2: effective grain radius [Brun et al., 2009]',
3440+ '3: density and cloud amount [Greuell & Konzelmann, 1994]',
3441+ '4: exponential time decay & wetness [Bougamont & Bamber, 2005]']))
3442+
3443+ #snow properties init
3444+ string = "%s\n%s"%(string,fielddisplay(self,'Dzini','Initial cel depth when restart [m]'))
3445+ string = "%s\n%s"%(string,fielddisplay(self,'Dini','Initial snow density when restart [kg m-3]'))
3446+ string = "%s\n%s"%(string,fielddisplay(self,'Reini','Initial grain size when restart [mm]'))
3447+ string = "%s\n%s"%(string,fielddisplay(self,'Gdnini','Initial grain dricity when restart [-]'))
3448+ string = "%s\n%s"%(string,fielddisplay(self,'Gspini','Initial grain sphericity when restart [-]'))
3449+ string = "%s\n%s"%(string,fielddisplay(self,'ECini','Initial evaporation/condensation when restart [kg m-2]'))
3450+ string = "%s\n%s"%(string,fielddisplay(self,'Wini','Initial snow water content when restart [kg m-2]'))
3451+ string = "%s\n%s"%(string,fielddisplay(self,'Aini','Initial albedo when restart [-]'))
3452+ string = "%s\n%s"%(string,fielddisplay(self,'Tini','Initial snow temperature when restart [K]'))
3453+ string = "%s\n%s"%(string,fielddisplay(self,'Sizeini','Initial number of layers when restart [K]'))
3454+
3455+ #additional albedo parameters:
3456+ if type(self.aIdx) == list or type(self.aIdx) == type(np.array([1,2])) and (self.aIdx == [1,2] or (1 in self.aIdx and 2 in self.aIdx)):
3457+ string = "%s\n%s"%(string,fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)'))
3458+ string = "%s\n%s"%(string,fielddisplay(self,'aIce','albedo of ice (0.27-0.58)'))
3459+ elif self.aIdx == 3:
3460+ string = "%s\n%s"%(string,fielddisplay(self,'cldFrac','average cloud amount'))
3461+ elif self.aIdx == 4:
3462+ string = "%s\n%s"%(string,fielddisplay(self,'t0wet','time scale for wet snow (15-21.9) [d]'))
3463+ string = "%s\n%s"%(string,fielddisplay(self,'t0dry','warm snow timescale (30) [d]'))
3464+ string = "%s\n%s"%(string,fielddisplay(self,'K','time scale temperature coef. (7) [d]'))
3465+
3466+ string = "%s\n%s"%(string,fielddisplay(self,'swIdx','apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1]'))
3467+ string = "%s\n%s"%(string,fielddisplay(self,'denIdx',['densification model to use (default is 2):',
3468+ '1 = emperical model of Herron and Langway (1980)',
3469+ '2 = semi-emerical model of Anthern et al. (2010)',
3470+ '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)',
3471+ '4 = DO NOT USE: emperical model of Li and Zwally (2004)',
3472+ '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)']))
3473+ string = "%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
3474+ return string
3475+ #}}}
3476+
3477+ def extrude(self,md): # {{{
3478+
3479+ self.Ta = project3d(md,'vector',self.Ta,'type','node')
3480+ self.V = project3d(md,'vector',self.V,'type','node')
3481+ self.dswrf = project3d(md,'vector',self.dswrf,'type','node')
3482+ self.dswrf = project3d(md,'vector',self.dswrf,'type','node')
3483+ self.P = project3d(md,'vector',self.P,'type','node')
3484+ self.eAir = project3d(md,'vector',self.eAir,'type','node')
3485+ self.pAir = project3d(md,'vector',self.pAir,'type','node')
3486+ return self
3487+ #}}}
3488+ def defaultoutputs(self,md): # {{{
3489+ return ['SmbMassBalance']
3490+ #}}}
3491+
3492+ def setdefaultparameters(self,mesh,geometry): # {{{
3493+ self.isgraingrowth = 1
3494+ self.isalbedo = 1
3495+ self.isshortwave = 1
3496+ self.isthermal = 1
3497+ self.isaccumulation = 1
3498+ self.ismelt = 1
3499+ self.isdensification = 1
3500+ self.isturbulentflux = 1
3501+
3502+ self.aIdx = 1
3503+ self.swIdx = 1
3504+ self.denIdx = 2
3505+ self.zTop = 10*np.ones((mesh.numberofelements,))
3506+ self.dzTop = .05* np.ones((mesh.numberofelements,))
3507+ self.dzMin = self.dzTop/2
3508+ self.InitDensityScaling = 1.0
3509+
3510+ self.zMax = 250*np.ones((mesh.numberofelements,))
3511+ self.zMin = 130*np.ones((mesh.numberofelements,))
3512+ self.zY = 1.10*np.ones((mesh.numberofelements,))
3513+ self.outputFreq = 30
3514+
3515+ #additional albedo parameters
3516+ self.aSnow = 0.85
3517+ self.aIce = 0.48
3518+ self.cldFrac = 0.1
3519+ self.t0wet = 15
3520+ self.t0dry = 30
3521+ self.K = 7
3522+
3523+ self.Dzini = 0.05*np.ones((mesh.numberofelements,2))
3524+ self.Dini = 910.0*np.ones((mesh.numberofelements,2))
3525+ self.Reini = 2.5*np.ones((mesh.numberofelements,2))
3526+ self.Gdnini = 0.0*np.ones((mesh.numberofelements,2))
3527+ self.Gspini = 0.0*np.ones((mesh.numberofelements,2))
3528+ self.ECini = 0.0*np.ones((mesh.numberofelements,))
3529+ self.Wini = 0.0*np.ones((mesh.numberofelements,2))
3530+ self.Aini = self.aSnow*np.ones((mesh.numberofelements,2))
3531+ self.Tini = 273.15*np.ones((mesh.numberofelements,2))
3532+# /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).
3533+# If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp
3534+ self.Sizeini = 2*np.ones((mesh.numberofelements,))
3535+ #}}}
3536+
3537+ def checkconsistency(self,md,solution,analyses): # {{{
3538+
3539+ md = checkfield(md,'fieldname','smb.isgraingrowth','values',[0,1])
3540+ md = checkfield(md,'fieldname','smb.isalbedo','values',[0,1])
3541+ md = checkfield(md,'fieldname','smb.isshortwave','values',[0,1])
3542+ md = checkfield(md,'fieldname','smb.isthermal','values',[0,1])
3543+ md = checkfield(md,'fieldname','smb.isaccumulation','values',[0,1])
3544+ md = checkfield(md,'fieldname','smb.ismelt','values',[0,1])
3545+ md = checkfield(md,'fieldname','smb.isdensification','values',[0,1])
3546+ md = checkfield(md,'fieldname','smb.isturbulentflux','values',[0,1])
3547+
3548+ md = checkfield(md,'fieldname','smb.Ta','timeseries',1,'NaN',1,'Inf',1,'>',273-100,'<',273+100) #-100/100 celsius min/max value
3549+ md = checkfield(md,'fieldname','smb.V','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'<',45) #max 500 km/h
3550+ md = checkfield(md,'fieldname','smb.dswrf','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'< = ',1400)
3551+ md = checkfield(md,'fieldname','smb.dlwrf','timeseries',1,'NaN',1,'Inf',1,'> = ',0)
3552+ md = checkfield(md,'fieldname','smb.P','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'< = ',100)
3553+ md = checkfield(md,'fieldname','smb.eAir','timeseries',1,'NaN',1,'Inf',1)
3554+
3555+ md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'>',273-100,'<',273+100) #-100/100 celsius min/max value
3556+ md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0)
3557+ md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000)
3558+ md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000)
3559+
3560+ md = checkfield(md,'fieldname','smb.aIdx','NaN',1,'Inf',1,'values',[1,2,3,4])
3561+ md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1])
3562+ md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5])
3563+
3564+ md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'> = ',0)
3565+ md = checkfield(md,'fieldname','smb.dzTop','NaN',1,'Inf',1,'>',0)
3566+ md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0)
3567+ md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'> = ',1)
3568+ md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365) #10 years max
3569+ md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1)
3570+
3571+ if type(self.aIdx) == list or type(self.aIdx) == type(np.array([1,2])) and (self.aIdx == [1,2] or (1 in self.aIdx and 2 in self.aIdx)):
3572+ md = checkfield(md,'fieldname','smb.aSnow','NaN',1,'Inf',1,'> = ',.64,'< = ',.89)
3573+ md = checkfield(md,'fieldname','smb.aIce','NaN',1,'Inf',1,'> = ',.27,'< = ',.58)
3574+ elif self.aIdx == 3:
3575+ md = checkfield(md,'fieldname','smb.cldFrac','NaN',1,'Inf',1,'> = ',0,'< = ',1)
3576+ elif self.aIdx == 4:
3577+ md = checkfield(md,'fieldname','smb.t0wet','NaN',1,'Inf',1,'> = ',15,'< = ',21.9)
3578+ md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'> = ',30,'< = ',30)
3579+ md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'> = ',7,'< = ',7)
3580+
3581+
3582+ #check zTop is < local thickness:
3583+ he = np.sum(md.geometry.thickness[md.mesh.elements-1],axis=1)/np.size(md.mesh.elements,1)
3584+ if np.any(he<self.zTop):
3585+ error('SMBgemb consistency check error: zTop should be smaller than local ice thickness')
3586+
3587+ md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1)
3588+ return md
3589+ # }}}
3590+
3591+ def marshall(self,prefix,md,fid): # {{{
3592+
3593+ yts = md.constants.yts
3594+
3595+ WriteData(fid,prefix,'name','md.smb.model','data',8,'format','Integer')
3596+
3597+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isgraingrowth','format','Boolean')
3598+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isalbedo','format','Boolean')
3599+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isshortwave','format','Boolean')
3600+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isthermal','format','Boolean')
3601+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isaccumulation','format','Boolean')
3602+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','ismelt','format','Boolean')
3603+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isdensification','format','Boolean')
3604+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','isturbulentflux','format','Boolean')
3605+
3606+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Ta','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3607+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','V','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3608+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','dswrf','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3609+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','dlwrf','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3610+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','P','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3611+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','eAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3612+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
3613+
3614+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tmean','format','DoubleMat','mattype',2)
3615+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','C','format','DoubleMat','mattype',2)
3616+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tz','format','DoubleMat','mattype',2)
3617+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vz','format','DoubleMat','mattype',2)
3618+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','zTop','format','DoubleMat','mattype',2)
3619+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','dzTop','format','DoubleMat','mattype',2)
3620+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','dzMin','format','DoubleMat','mattype',2)
3621+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','zY','format','DoubleMat','mattype',2)
3622+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMax','format','DoubleMat','mattype',2)
3623+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMin','format','DoubleMat','mattype',2)
3624+
3625+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIdx','format','Integer')
3626+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','swIdx','format','Integer')
3627+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','denIdx','format','Integer')
3628+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','InitDensityScaling','format','Double')
3629+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','outputFreq','format','Double')
3630+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','aSnow','format','Double')
3631+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIce','format','Double')
3632+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','cldFrac','format','Double')
3633+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','t0wet','format','Double')
3634+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','t0dry','format','Double')
3635+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','K','format','Double')
3636+
3637+ #snow properties init
3638+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dzini','format','DoubleMat','mattype',3)
3639+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dini','format','DoubleMat','mattype',3)
3640+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Reini','format','DoubleMat','mattype',3)
3641+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Gdnini','format','DoubleMat','mattype',3)
3642+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Gspini','format','DoubleMat','mattype',3)
3643+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','ECini','format','DoubleMat','mattype',2)
3644+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Wini','format','DoubleMat','mattype',3)
3645+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Aini','format','DoubleMat','mattype',3)
3646+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tini','format','DoubleMat','mattype',3)
3647+ WriteData(fid,prefix,'object',self,'class','smb','fieldname','Sizeini','format','IntMat','mattype',2)
3648+
3649+ #figure out dt from forcings:
3650+ time = self.Ta[-1] #assume all forcings are on the same time step
3651+ dtime = np.diff(time,n=1,axis=0)
3652+ dt = min(dtime) / yts
3653+
3654+ WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts)
3655+
3656+ # Check if smb_dt goes evenly into transient core time step
3657+ if (md.timestepping.time_step % dt >= 1e-10):
3658+ error('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt)
3659+
3660+ #process requested outputs
3661+ outputs = self.requested_outputs
3662+ indices = [i for i, x in enumerate(outputs) if x == 'default']
3663+ if len(indices) > 0:
3664+ outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
3665+ outputs =outputscopy
3666+
3667+ WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
3668+ # }}}
3669+
3670Index: ../trunk-jpl/src/m/classes/taoinversion.py
3671===================================================================
3672--- ../trunk-jpl/src/m/classes/taoinversion.py (revision 22266)
3673+++ ../trunk-jpl/src/m/classes/taoinversion.py (revision 22267)
3674@@ -5,31 +5,33 @@
3675 from fielddisplay import fielddisplay
3676 from IssmConfig import IssmConfig
3677 from marshallcostfunctions import marshallcostfunctions
3678+from supportedcontrols import *
3679+from supportedcostfunctions import *
3680
3681-
3682-class taoinversion:
3683+class taoinversion(object):
3684 def __init__(self):
3685- iscontrol = 0
3686- incomplete_adjoint = 0
3687- control_parameters = float('NaN')
3688- maxsteps = 0
3689- maxiter = 0
3690- fatol = 0
3691- frtol = 0
3692- gatol = 0
3693- grtol = 0
3694- gttol = 0
3695- algorithm = ''
3696- cost_functions = float('NaN')
3697- cost_functions_coefficients = float('NaN')
3698- min_parameters = float('NaN')
3699- max_parameters = float('NaN')
3700- vx_obs = float('NaN')
3701- vy_obs = float('NaN')
3702- vz_obs = float('NaN')
3703- vel_obs = float('NaN')
3704- thickness_obs = float('NaN')
3705- surface_obs = float('NaN')
3706+ self.iscontrol = 0
3707+ self.incomplete_adjoint = 0
3708+ self.control_parameters = float('NaN')
3709+ self.maxsteps = 0
3710+ self.maxiter = 0
3711+ self.fatol = 0
3712+ self.frtol = 0
3713+ self.gatol = 0
3714+ self.grtol = 0
3715+ self.gttol = 0
3716+ self.algorithm = ''
3717+ self.cost_functions = float('NaN')
3718+ self.cost_functions_coefficients = float('NaN')
3719+ self.min_parameters = float('NaN')
3720+ self.max_parameters = float('NaN')
3721+ self.vx_obs = float('NaN')
3722+ self.vy_obs = float('NaN')
3723+ self.vz_obs = float('NaN')
3724+ self.vel_obs = float('NaN')
3725+ self.thickness_obs = float('NaN')
3726+ self.surface_obs = float('NaN')
3727+ self.setdefaultparameters()
3728
3729 def __repr__(self):
3730 string = ' taoinversion parameters:'
3731@@ -97,7 +99,6 @@
3732
3733 #several responses can be used:
3734 self.cost_functions=101;
3735-
3736 return self
3737
3738 def extrude(self,md):
3739@@ -118,17 +119,17 @@
3740 return self
3741
3742 def checkconsistency(self,md,solution,analyses):
3743- if not self.control:
3744+ if not self.iscontrol:
3745 return md
3746 if not IssmConfig('_HAVE_TAO_')[0]:
3747 md = checkmessage(md,['TAO has not been installed, ISSM needs to be reconfigured and recompiled with TAO'])
3748
3749
3750- num_controls= np.numel(md.inversion.control_parameters)
3751- num_costfunc= np.size(md.inversion.cost_functions,2)
3752+ num_controls= np.size(md.inversion.control_parameters)
3753+ num_costfunc= np.size(md.inversion.cost_functions)
3754
3755 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0, 1])
3756- md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0, 1])
3757+ md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1])
3758 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols())
3759 md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0)
3760 md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0)
3761@@ -142,12 +143,12 @@
3762 PETSCMAJOR = IssmConfig('_PETSC_MAJOR_')[0]
3763 PETSCMINOR = IssmConfig('_PETSC_MINOR_')[0]
3764 if(PETSCMAJOR>3 or (PETSCMAJOR==3 and PETSCMINOR>=5)):
3765- md = checkfield(md,'fieldname','inversion.algorithm','values',{'blmvm','cg','lmvm'})
3766+ md = checkfield(md,'fieldname','inversion.algorithm','values',['blmvm','cg','lmvm'])
3767 else:
3768- md = checkfield(md,'fieldname','inversion.algorithm','values',{'tao_blmvm','tao_cg','tao_lmvm'})
3769+ md = checkfield(md,'fieldname','inversion.algorithm','values',['tao_blmvm','tao_cg','tao_lmvm'])
3770
3771
3772- md = checkfield(md,'fieldname','inversion.cost_functions','size',[1, num_costfunc],'values',supportedcostfunctions())
3773+ md = checkfield(md,'fieldname','inversion.cost_functions','size', [num_costfunc],'values',supportedcostfunctions())
3774 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices, num_costfunc],'>=',0)
3775 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices, num_controls])
3776 md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices, num_controls])
3777@@ -161,38 +162,38 @@
3778 md = checkfield(md,'fieldname','inversion.vx_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
3779 md = checkfield(md,'fieldname','inversion.vy_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
3780
3781- def marshall(self, md, fid):
3782+ def marshall(self,prefix,md,fid):
3783
3784- yts=md.constants.yts;
3785- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean')
3786- WriteData(fid,prefix,'name','md.inversion.type','data',1,'format','Integer')
3787- if not self.iscontrol:
3788- return
3789- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean')
3790- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxsteps','format','Integer')
3791- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxiter','format','Integer')
3792- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','fatol','format','Double')
3793- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','frtol','format','Double')
3794- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gatol','format','Double')
3795- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','grtol','format','Double')
3796- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gttol','format','Double')
3797- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','algorithm','format','String')
3798- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1)
3799- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3)
3800- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3)
3801- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3802- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3803- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3804- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1)
3805- WriteData(fid,prefix,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',1)
3806+ yts=md.constants.yts;
3807+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean')
3808+ WriteData(fid,prefix,'name','md.inversion.type','data',1,'format','Integer')
3809+ if not self.iscontrol:
3810+ return
3811+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean')
3812+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxsteps','format','Integer')
3813+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxiter','format','Integer')
3814+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','fatol','format','Double')
3815+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','frtol','format','Double')
3816+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gatol','format','Double')
3817+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','grtol','format','Double')
3818+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gttol','format','Double')
3819+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','algorithm','format','String')
3820+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1)
3821+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3)
3822+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3)
3823+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3824+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3825+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts)
3826+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1)
3827+ WriteData(fid,prefix,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',1)
3828
3829- #process control parameters
3830- num_control_parameters = np.numel(self.control_parameters)
3831- WriteData(fid,prefix,'object',self,'fieldname','control_parameters','format','StringArray')
3832- WriteData(fid,prefix,'data',num_control_parameters,'name','md.inversion.num_control_parameters','format','Integer')
3833+ #process control parameters
3834+ num_control_parameters = np.size(self.control_parameters)
3835+ WriteData(fid,prefix,'object',self,'fieldname','control_parameters','format','StringArray')
3836+ WriteData(fid,prefix,'data',num_control_parameters,'name','md.inversion.num_control_parameters','format','Integer')
3837
3838- #process cost functions
3839- num_cost_functions = np.size(self.cost_functions,2)
3840- data= marshallcostfunctions(self.cost_functions)
3841- WriteData(fid,prefix,'data',data,'name','md.inversion.cost_functions','format','StringArray')
3842- WriteData(fid,prefix,'data',num_cost_functions,'name','md.inversion.num_cost_functions','format','Integer')
3843+ #process cost functions
3844+ num_cost_functions = np.size(self.cost_functions)
3845+ data= marshallcostfunctions(self.cost_functions)
3846+ WriteData(fid,prefix,'data',data,'name','md.inversion.cost_functions','format','StringArray')
3847+ WriteData(fid,prefix,'data',num_cost_functions,'name','md.inversion.num_cost_functions','format','Integer')
3848Index: ../trunk-jpl/src/m/classes/SMBgemb.m
3849===================================================================
3850--- ../trunk-jpl/src/m/classes/SMBgemb.m (revision 22266)
3851+++ ../trunk-jpl/src/m/classes/SMBgemb.m (revision 22267)
3852@@ -357,7 +357,7 @@
3853 dt=min(dtime);
3854
3855 WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts);
3856-
3857+
3858 % Check if smb_dt goes evenly into transient core time step
3859 if (mod(md.timestepping.time_step,dt) >= 1e-10)
3860 error('smb_dt/dt = %f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt);
3861Index: ../trunk-jpl/src/m/classes/plumebasalforcings.py
3862===================================================================
3863--- ../trunk-jpl/src/m/classes/plumebasalforcings.py (nonexistent)
3864+++ ../trunk-jpl/src/m/classes/plumebasalforcings.py (revision 22267)
3865@@ -0,0 +1,126 @@
3866+from fielddisplay import fielddisplay
3867+from checkfield import checkfield
3868+from WriteData import WriteData
3869+from project3d import project3d
3870+
3871+class plumebasalforcings(object):
3872+ '''
3873+ PLUME BASAL FORCINGS class definition
3874+
3875+ Usage:
3876+ plumebasalforcings=plumebasalforcings()
3877+ '''
3878+
3879+ def __init__(self): # {{{
3880+ floatingice_melting_rate = float('NaN')
3881+ groundedice_melting_rate = float('NaN')
3882+ mantleconductivity = float('NaN')
3883+ nusselt = float('NaN')
3884+ dtbg = float('NaN')
3885+ plumeradius = float('NaN')
3886+ topplumedepth = float('NaN')
3887+ bottomplumedepth = float('NaN')
3888+ plumex = float('NaN')
3889+ plumey = float('NaN')
3890+ crustthickness = float('NaN')
3891+ uppercrustthickness = float('NaN')
3892+ uppercrustheat = float('NaN')
3893+ lowercrustheat = float('NaN')
3894+
3895+ self.setdefaultparameters()
3896+ #}}}
3897+
3898+ def __repr__(self): # {{{
3899+ print ' mantle plume basal melt parameterization:'
3900+
3901+ string="%s\n%s"%(string,fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]'))
3902+ string="%s\n%s"%(string,fielddisplay(self,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]'))
3903+ string="%s\n%s"%(string,fielddisplay(self,'mantleconductivity','mantle heat conductivity [W/m^3]'))
3904+ string="%s\n%s"%(string,fielddisplay(self,'nusselt','nusselt number, ratio of mantle to plume [1]'))
3905+ string="%s\n%s"%(string,fielddisplay(self,'dtbg','background temperature gradient [degree/m]'))
3906+ string="%s\n%s"%(string,fielddisplay(self,'plumeradius','radius of the mantle plume [m]'))
3907+ string="%s\n%s"%(string,fielddisplay(self,'topplumedepth','depth of the mantle plume top below the crust [m]'))
3908+ string="%s\n%s"%(string,fielddisplay(self,'bottomplumedepth','depth of the mantle plume base below the crust [m]'))
3909+ string="%s\n%s"%(string,fielddisplay(self,'plumex','x coordinate of the center of the plume [m]'))
3910+ string="%s\n%s"%(string,fielddisplay(self,'plumey','y coordinate of the center of the plume [m]'))
3911+ string="%s\n%s"%(string,fielddisplay(self,'crustthickness','thickness of the crust [m]'))
3912+ string="%s\n%s"%(string,fielddisplay(self,'uppercrustthickness','thickness of the upper crust [m]'))
3913+ string="%s\n%s"%(string,fielddisplay(self,'uppercrustheat','volumic heat of the upper crust [w/m^3]'))
3914+ string="%s\n%s"%(string,fielddisplay(self,'lowercrustheat','volumic heat of the lowercrust [w/m^3]'))
3915+
3916+ return string
3917+ #}}}
3918+
3919+ def initialize(self,md): #{{{
3920+ if np.all(np.isnan(self.groundedice_melting_rate)):
3921+ self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices,))
3922+ print ' no basalforcings.groundedice_melting_rate specified: values set as zero'
3923+ if np.all(np.isnan(self.floatingice_melting_rate)):
3924+ self.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices,))
3925+ print ' no basalforcings.floatingice_melting_rate specified: values set as zero'
3926+ return
3927+ #}}}
3928+
3929+ def extrude(self,md): # {{{
3930+ self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1);
3931+ self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1);
3932+ return self
3933+ #}}}
3934+
3935+ def setdefaultparameters(self): # {{{
3936+ #default values for melting parameterization
3937+ self.mantleconductivity = 2.2
3938+ self.nusselt = 300
3939+ self.dtbg = 11/1000.
3940+ self.plumeradius = 100000
3941+ self.topplumedepth = 10000
3942+ self.bottomplumedepth = 1050000
3943+ self.crustthickness = 30000
3944+ self.uppercrustthickness = 14000
3945+ self.uppercrustheat = 1.7*10**-6
3946+ self.lowercrustheat = 0.4*10**-6
3947+ return self
3948+ #}}}
3949+
3950+ def checkconsistency(self,md,solution,analyses): # {{{
3951+ if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.ismasstransport==0):
3952+ md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1)
3953+ md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1)
3954+ if 'BalancethicknessAnalysis' in analyses:
3955+ md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'size',[md.mesh.numberofvertices])
3956+ md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'size',[md.mesh.numberofvertices])
3957+ if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.isthermal==0):
3958+ md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1)
3959+ md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1)
3960+ md = checkfield(md,'fieldname','basalforcings.mantleconductivity','>=',0,'numel',1)
3961+ md = checkfield(md,'fieldname','basalforcings.nusselt','>',0,'numel',1)
3962+ md = checkfield(md,'fieldname','basalforcings.dtbg','>',0,'numel',1)
3963+ md = checkfield(md,'fieldname','basalforcings.topplumedepth','>',0,'numel',1)
3964+ md = checkfield(md,'fieldname','basalforcings.bottomplumedepth','>',0,'numel',1)
3965+ md = checkfield(md,'fieldname','basalforcings.plumex','numel',1)
3966+ md = checkfield(md,'fieldname','basalforcings.plumey','numel',1)
3967+ md = checkfield(md,'fieldname','basalforcings.crustthickness','>',0,'numel',1)
3968+ md = checkfield(md,'fieldname','basalforcings.uppercrustthickness','>',0,'numel',1)
3969+ md = checkfield(md,'fieldname','basalforcings.uppercrustheat','>',0,'numel',1)
3970+ md = checkfield(md,'fieldname','basalforcings.lowercrustheat','>',0,'numel',1)
3971+ return md
3972+ # }}}
3973+ def marshall(self,prefix,md,fid): # {{{
3974+ yts=md.constants.yts
3975+
3976+ WriteData(fid,prefix,'name','md.basalforcings.model','data',4,'format','Integer')
3977+ WriteData(fid,prefix,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
3978+ WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
3979+ WriteData(fid,prefix,'object',self,'fieldname','mantleconductivity','format','Double')
3980+ WriteData(fid,prefix,'object',self,'fieldname','nusselt','format','Double')
3981+ WriteData(fid,prefix,'object',self,'fieldname','dtbg','format','Double')
3982+ WriteData(fid,prefix,'object',self,'fieldname','plumeradius','format','Double')
3983+ WriteData(fid,prefix,'object',self,'fieldname','topplumedepth','format','Double')
3984+ WriteData(fid,prefix,'object',self,'fieldname','bottomplumedepth','format','Double')
3985+ WriteData(fid,prefix,'object',self,'fieldname','plumex','format','Double')
3986+ WriteData(fid,prefix,'object',self,'fieldname','plumey','format','Double')
3987+ WriteData(fid,prefix,'object',self,'fieldname','crustthickness','format','Double')
3988+ WriteData(fid,prefix,'object',self,'fieldname','uppercrustthickness','format','Double')
3989+ WriteData(fid,prefix,'object',self,'fieldname','uppercrustheat','format','Double')
3990+ WriteData(fid,prefix,'object',self,'fieldname','lowercrustheat','format','Double')
3991+ # }}}
3992Index: ../trunk-jpl/test/NightlyRun/test701.py
3993===================================================================
3994--- ../trunk-jpl/test/NightlyRun/test701.py (nonexistent)
3995+++ ../trunk-jpl/test/NightlyRun/test701.py (revision 22267)
3996@@ -0,0 +1,75 @@
3997+#Test Name: FlowbandFSshelf
3998+import numpy as np
3999+from scipy.interpolate import interp1d
4000+from model import *
4001+from solve import *
4002+from setflowequation import *
4003+from bamgflowband import *
4004+from paterson import *
4005+
4006+x = np.arange(1,3001,100).T
4007+h = np.linspace(1000,300,np.size(x)).T
4008+b = -917./1023.*h
4009+
4010+md = bamgflowband(model(),x,b+h,b,'hmax',80.)
4011+print md.mesh.numberofvertices
4012+
4013+#Geometry #interp1d returns a function to be called on md.mesh.x
4014+md.geometry.surface = interp1d(x,b+h)(md.mesh.x)
4015+md.geometry.base = interp1d(x,b)(md.mesh.x)
4016+md.geometry.thickness = md.geometry.surface-md.geometry.base
4017+
4018+#mask
4019+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
4020+md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0.
4021+md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5
4022+
4023+#materials
4024+md.initialization.temperature = (273.-20.)*np.ones((md.mesh.numberofvertices,))
4025+md.materials.rheology_B = paterson(md.initialization.temperature)
4026+md.materials.rheology_n = 3.*np.ones((md.mesh.numberofelements,))
4027+
4028+#friction
4029+md.friction.coefficient = np.zeros((md.mesh.numberofvertices,))
4030+md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20.
4031+md.friction.p = np.ones((md.mesh.numberofelements,))
4032+md.friction.q = np.ones((md.mesh.numberofelements,))
4033+
4034+#Boundary conditions
4035+md.stressbalance.referential = float('NaN')*np.ones((md.mesh.numberofvertices,6))
4036+md.stressbalance.loadingforce = 0. * np.ones((md.mesh.numberofvertices,3))
4037+md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,))
4038+md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,))
4039+md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,))
4040+md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 0.
4041+md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0.
4042+
4043+#Misc
4044+md = setflowequation(md,'FS','all')
4045+md.stressbalance.abstol = float('NaN')
4046+#md.stressbalance.reltol = 10**-16
4047+md.stressbalance.FSreconditioning = 1.
4048+md.stressbalance.maxiter = 20
4049+md.flowequation.augmented_lagrangian_r = 10000.
4050+md.miscellaneous.name = 'test701'
4051+md.verbose = verbose('convergence',True)
4052+md.cluster = generic('np',2)
4053+
4054+#Go solve
4055+field_names = []
4056+field_tolerances = []
4057+field_values = []
4058+#md.initialization.pressure = md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y)
4059+for i in ['MINI','MINIcondensed','TaylorHood','LATaylorHood','CrouzeixRaviart','LACrouzeixRaviart']:
4060+ print ' '
4061+ print '======Testing ' +i+ ' Full-Stokes Finite element====='
4062+ md.flowequation.fe_FS = i
4063+ md = solve(md,'Stressbalance')
4064+ field_names = field_names + [['Vx'+i],['Vy'+i],['Vel'+i],['Pressure'+i]]
4065+ field_tolerances = field_tolerances + [9e-5,9e-5,9e-5,1e-10]
4066+ field_values = field_values + [
4067+ md.results.StressbalanceSolution.Vx,
4068+ md.results.StressbalanceSolution.Vy,
4069+ md.results.StressbalanceSolution.Vel,
4070+ md.results.StressbalanceSolution.Pressure
4071+ ]
4072Index: ../trunk-jpl/test/NightlyRun/test703.py
4073===================================================================
4074--- ../trunk-jpl/test/NightlyRun/test703.py (nonexistent)
4075+++ ../trunk-jpl/test/NightlyRun/test703.py (revision 22267)
4076@@ -0,0 +1,160 @@
4077+#Test Name: FlowbandFSsheetshelfTrans
4078+import numpy as np
4079+from scipy.interpolate import interp1d
4080+import copy
4081+from model import *
4082+from socket import gethostname
4083+from triangle import *
4084+from meshconvert import *
4085+from setmask import *
4086+from parameterize import *
4087+from setflowequation import *
4088+from solve import *
4089+from NowickiProfile import *
4090+from bamgflowband import *
4091+from paterson import *
4092+
4093+#mesh parameters
4094+x = np.arange(-5,5.5,.5).T
4095+[b,h,sea] = NowickiProfile(x)
4096+x = x * 10**3
4097+h = h * 10**3
4098+b = (b-sea) * 10**3
4099+
4100+#mesh domain
4101+md = bamgflowband(model(),x,b+h,b,'hmax',150)
4102+print md.mesh.numberofvertices
4103+
4104+#geometry
4105+md.geometry.surface = interp1d(x,b+h)(md.mesh.x)
4106+md.geometry.base = interp1d(x,b)(md.mesh.x)
4107+md.geometry.thickness = md.geometry.surface - md.geometry.base
4108+
4109+#mask
4110+md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
4111+md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0
4112+md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5
4113+
4114+#materials
4115+md.initialization.temperature = (273. - 20.) * np.ones((md.mesh.numberofvertices,))
4116+md.materials.rheology_B = paterson(md.initialization.temperature)
4117+md.materials.rheology_n = 3 * np.ones((md.mesh.numberofelements,))
4118+
4119+#friction
4120+md.friction.coefficient = np.zeros((md.mesh.numberofvertices,))
4121+md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20
4122+md.friction.p = np.ones((md.mesh.numberofelements,))
4123+md.friction.q = np.ones((md.mesh.numberofelements,))
4124+
4125+#boundary conditions
4126+md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,))
4127+md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,))
4128+md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,))
4129+md.stressbalance.referential = float('NaN') * np.ones((md.mesh.numberofvertices,6))
4130+md.stressbalance.loadingforce = 0 * np.ones((md.mesh.numberofvertices,3))
4131+md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 800.
4132+md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0.
4133+
4134+#print md.stressbalance.referential
4135+#print md.stressbalance.loadingforce
4136+#print md.stressbalance.spcvx
4137+#print md.stressbalance.spcvy
4138+#print md.stressbalance.spcvz
4139+#print np.shape(md.stressbalance.referential)
4140+#print np.shape(md.stressbalance.loadingforce)
4141+#print np.shape(md.stressbalance.spcvx)
4142+#print np.shape(md.stressbalance.spcvy)
4143+#print np.shape(md.stressbalance.spcvz)
4144+
4145+#Misc
4146+md = setflowequation(md,'FS','all')
4147+md.flowequation.fe_FS = 'TaylorHood'
4148+md.stressbalance.abstol = float('NaN')
4149+md.miscellaneous.name = 'test703'
4150+
4151+#Transient settings
4152+md.timestepping.time_step = 0.000001
4153+md.timestepping.final_time = 0.000005
4154+md.stressbalance.shelf_dampening = 1.
4155+md.smb.mass_balance = np.zeros((md.mesh.numberofvertices,))
4156+md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,))
4157+md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,))
4158+md.basalforcings.geothermalflux = np.zeros((md.mesh.numberofvertices,))
4159+posb = np.intersect1d(np.where(md.mesh.x > 0.), np.where(md.mesh.vertexonbase))
4160+md.basalforcings.groundedice_melting_rate[posb] = 18.
4161+md.basalforcings.floatingice_melting_rate[posb] = 18.
4162+md.initialization.vx = np.zeros((md.mesh.numberofvertices,))
4163+md.initialization.vy = np.zeros((md.mesh.numberofvertices,))
4164+md.initialization.pressure = np.zeros((md.mesh.numberofvertices,))
4165+md.masstransport.spcthickness = float('NaN') * np.ones((md.mesh.numberofvertices,))
4166+md.thermal.spctemperature = float('NaN') * np.ones((md.mesh.numberofvertices,))
4167+md.transient.isthermal = 0
4168+md.masstransport.isfreesurface = 1
4169+
4170+#Go solve
4171+md.cluster = generic('np',3)
4172+md.stressbalance.shelf_dampening = 1
4173+md1 = solve(md,'Transient')
4174+
4175+md.stressbalance.shelf_dampening = 0
4176+md = solve(md,'Transient')
4177+
4178+#Fields and tolerances to track changes
4179+field_names = [
4180+ 'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',
4181+ 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',
4182+ 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3',
4183+ 'Vx1_damp','Vy1_damp','Vel1_damp','Pressure1_damp','Bed1_damp','Surface1_damp','Thickness1_damp',
4184+ 'Vx2_damp','Vy2_damp','Vel2_damp','Pressure2_damp','Bed2_damp','Surface2_damp','Thickness2_damp',
4185+ 'Vx3_damp','Vy3_damp','Vel3_damp','Pressure3_damp','Bed3_damp','Surface3_damp','Thickness3_damp']
4186+field_tolerances = [
4187+ 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10,
4188+ 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10,
4189+ 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10,
4190+ 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10,
4191+ 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10,
4192+ 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10]
4193+field_values = [
4194+ md.results.TransientSolution[0].Vx,
4195+ md.results.TransientSolution[0].Vy,
4196+ md.results.TransientSolution[0].Vel,
4197+ md.results.TransientSolution[0].Pressure,
4198+ md.results.TransientSolution[0].Base,
4199+ md.results.TransientSolution[0].Surface,
4200+ md.results.TransientSolution[0].Thickness,
4201+ md.results.TransientSolution[1].Vx,
4202+ md.results.TransientSolution[1].Vy,
4203+ md.results.TransientSolution[1].Vel,
4204+ md.results.TransientSolution[1].Pressure,
4205+ md.results.TransientSolution[1].Base,
4206+ md.results.TransientSolution[1].Surface,
4207+ md.results.TransientSolution[1].Thickness,
4208+ md.results.TransientSolution[2].Vx,
4209+ md.results.TransientSolution[2].Vy,
4210+ md.results.TransientSolution[2].Vel,
4211+ md.results.TransientSolution[2].Pressure,
4212+ md.results.TransientSolution[2].Base,
4213+ md.results.TransientSolution[2].Surface,
4214+ md.results.TransientSolution[2].Thickness,
4215+ md1.results.TransientSolution[0].Vx,
4216+ md1.results.TransientSolution[0].Vy,
4217+ md1.results.TransientSolution[0].Vel,
4218+ md1.results.TransientSolution[0].Pressure,
4219+ md1.results.TransientSolution[0].Base,
4220+ md1.results.TransientSolution[0].Surface,
4221+ md1.results.TransientSolution[0].Thickness,
4222+ md1.results.TransientSolution[1].Vx,
4223+ md1.results.TransientSolution[1].Vy,
4224+ md1.results.TransientSolution[1].Vel,
4225+ md1.results.TransientSolution[1].Pressure,
4226+ md1.results.TransientSolution[1].Base,
4227+ md1.results.TransientSolution[1].Surface,
4228+ md1.results.TransientSolution[1].Thickness,
4229+ md1.results.TransientSolution[2].Vx,
4230+ md1.results.TransientSolution[2].Vy,
4231+ md1.results.TransientSolution[2].Vel,
4232+ md1.results.TransientSolution[2].Pressure,
4233+ md1.results.TransientSolution[2].Base,
4234+ md1.results.TransientSolution[2].Surface,
4235+ md1.results.TransientSolution[2].Thickness,
4236+ ]
4237Index: ../trunk-jpl/test/NightlyRun/test293.py
4238===================================================================
4239--- ../trunk-jpl/test/NightlyRun/test293.py (nonexistent)
4240+++ ../trunk-jpl/test/NightlyRun/test293.py (revision 22267)
4241@@ -0,0 +1,60 @@
4242+#Test Name: SquareShelfTranSSA2dMismipFloatingMeltParam
4243+import numpy as np
4244+from model import *
4245+from socket import gethostname
4246+from triangle import *
4247+from setmask import *
4248+from parameterize import *
4249+from setflowequation import *
4250+from solve import *
4251+from mismipbasalforcings import *
4252+
4253+md = triangle(model(),'../Exp/Square.exp',150000.)
4254+md = setmask(md,'all','')
4255+md = parameterize(md,'../Par/SquareShelf.py')
4256+md = setflowequation(md,'SSA','all')
4257+md.cluster = generic('name',gethostname(),'np',3)
4258+md.constants.yts = 365.2422 * 24. * 3600.
4259+md.basalforcings = mismipbasalforcings()
4260+md.basalforcings = md.basalforcings.initialize(md)
4261+md.transient.isgroundingline = 1
4262+md.geometry.bed = min(md.geometry.base) * np.ones(md.mesh.numberofvertices,)
4263+md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
4264+print md.constants.yts
4265+
4266+md = solve(md,'Transient')
4267+
4268+#Fields and tolerances to track changes
4269+field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','BasalforcingsFloatingiceMeltingRate1',
4270+ 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','BasalforcingsFloatingiceMeltingRate2',
4271+ 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','BasalforcingsFloatingiceMeltingRate3']
4272+field_tolerances = [
4273+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13,
4274+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13,
4275+ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13]
4276+field_values = [
4277+ md.results.TransientSolution[0].Vx,
4278+ md.results.TransientSolution[0].Vy,
4279+ md.results.TransientSolution[0].Vel,
4280+ md.results.TransientSolution[0].Pressure,
4281+ md.results.TransientSolution[0].Base,
4282+ md.results.TransientSolution[0].Surface,
4283+ md.results.TransientSolution[0].Thickness,
4284+ md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate,
4285+ md.results.TransientSolution[1].Vx,
4286+ md.results.TransientSolution[1].Vy,
4287+ md.results.TransientSolution[1].Vel,
4288+ md.results.TransientSolution[1].Pressure,
4289+ md.results.TransientSolution[1].Base,
4290+ md.results.TransientSolution[1].Surface,
4291+ md.results.TransientSolution[1].Thickness,
4292+ md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate,
4293+ md.results.TransientSolution[2].Vx,
4294+ md.results.TransientSolution[2].Vy,
4295+ md.results.TransientSolution[2].Vel,
4296+ md.results.TransientSolution[2].Pressure,
4297+ md.results.TransientSolution[2].Base,
4298+ md.results.TransientSolution[2].Surface,
4299+ md.results.TransientSolution[2].Thickness,
4300+ md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate,
4301+ ]
4302Index: ../trunk-jpl/src/m/mesh/bamgflowband.py
4303===================================================================
4304--- ../trunk-jpl/src/m/mesh/bamgflowband.py (nonexistent)
4305+++ ../trunk-jpl/src/m/mesh/bamgflowband.py (revision 22267)
4306@@ -0,0 +1,47 @@
4307+import numpy as np
4308+from model import *
4309+from collections import OrderedDict
4310+from bamg import *
4311+from mesh2dvertical import *
4312+
4313+def bamgflowband(md,x,surf,base,*args):
4314+ """
4315+ BAMGFLOWBAND - create flowband mesh with bamg
4316+
4317+ Usage:
4318+ md=bamgflowband(md,x,surf,base,OPTIONS)
4319+
4320+ surf and bed are the surface elevation and base for each x provided
4321+ x must be increasing
4322+ OPTIONS are bamg options
4323+
4324+ Example:
4325+ x =np.arrange(1,3001,100)
4326+ h=linspace(1000,300,numel(x))
4327+ b=-917/1023*h
4328+ md=bamgflowband(model,b+h,b,'hmax',80,'vertical',1,'Markers',m)
4329+ """
4330+
4331+ #Write expfile with domain outline
4332+ A = OrderedDict()
4333+ A.x = np.concatenate((x,np.flipud(x),[x[0]]))
4334+ A.y = np.concatenate((base,np.flipud(surf),[base[0]]))
4335+ A.nods = np.size(A.x)
4336+
4337+ #markers:
4338+ m = np.ones((np.size(A.x)-1,)) # base = 1
4339+ m[np.size(x) - 1] = 2 # right side = 2
4340+ m[np.size(x):2 * np.size(x) - 1] = 3 # top surface = 3
4341+ m[2 * np.size(x) - 1] = 4 # left side = 4
4342+
4343+ #mesh domain
4344+ md = bamg(model(),'domain',[A],'vertical',1,'Markers',m,*args)
4345+ #print md.mesh.numberofvertices
4346+
4347+ #Deal with vertices on bed
4348+ md.mesh.vertexonbase = np.zeros((md.mesh.numberofvertices,))
4349+ md.mesh.vertexonbase[np.where(md.mesh.vertexflags(1))] = 1
4350+ md.mesh.vertexonsurface = np.zeros((md.mesh.numberofvertices,))
4351+ md.mesh.vertexonsurface[np.where(md.mesh.vertexflags(3))] = 1
4352+
4353+ return md
4354Index: ../trunk-jpl/src/m/mesh/bamg.py
4355===================================================================
4356--- ../trunk-jpl/src/m/mesh/bamg.py (revision 22266)
4357+++ ../trunk-jpl/src/m/mesh/bamg.py (revision 22267)
4358@@ -1,6 +1,6 @@
4359 import os.path
4360 import numpy as np
4361-from mesh2d import mesh2d
4362+from mesh2dvertical import *
4363 from collections import OrderedDict
4364 from pairoptions import pairoptions
4365 from bamggeom import bamggeom
4366@@ -79,9 +79,12 @@
4367
4368 #Check that file exists
4369 domainfile=options.getfieldvalue('domain')
4370- if not os.path.exists(domainfile):
4371- raise IOError("bamg error message: file '%s' not found" % domainfile)
4372- domain=expread(domainfile)
4373+ if type(domainfile) == str:
4374+ if not os.path.exists(domainfile):
4375+ raise IOError("bamg error message: file '%s' not found" % domainfile)
4376+ domain=expread(domainfile)
4377+ else:
4378+ domain=domainfile
4379
4380 #Build geometry
4381 count=0
4382@@ -88,18 +91,18 @@
4383 for i,domaini in enumerate(domain):
4384
4385 #Check that the domain is closed
4386- if (domaini['x'][0]!=domaini['x'][-1] or domaini['y'][0]!=domaini['y'][-1]):
4387+ if (domaini.x[0]!=domaini.x[-1] or domaini.y[0]!=domaini.y[-1]):
4388 raise RuntimeError("bamg error message: all contours provided in ''domain'' should be closed")
4389
4390 #Checks that all holes are INSIDE the principle domain outline
4391 if i:
4392- flags=ContourToNodes(domaini['x'],domaini['y'],domainfile,0)[0]
4393+ flags=ContourToNodes(domaini.x,domaini.y,domainfile,0)[0]
4394 if np.any(np.logical_not(flags)):
4395 raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
4396
4397 #Add all points to bamg_geometry
4398- nods=domaini['nods']-1 #the domain are closed 0=end
4399- bamg_geometry.Vertices=np.vstack((bamg_geometry.Vertices,np.vstack((domaini['x'][0:nods],domaini['y'][0:nods],np.ones((nods)))).T))
4400+ nods=domaini.nods-1 #the domain are closed 0=end
4401+ bamg_geometry.Vertices=np.vstack((bamg_geometry.Vertices,np.vstack((domaini.x[0:nods],domaini.y[0:nods],np.ones((nods)))).T))
4402 bamg_geometry.Edges =np.vstack((bamg_geometry.Edges,np.vstack((np.arange(count+1,count+nods+1),np.hstack((np.arange(count+2,count+nods+1),count+1)),1.*np.ones((nods)))).T))
4403 if i:
4404 bamg_geometry.SubDomains=np.vstack((bamg_geometry.SubDomains,[2,count+1,1,-subdomain_ref]))
4405@@ -115,6 +118,12 @@
4406 #update counter
4407 count+=nods
4408
4409+ if options.getfieldvalue('vertical',0):
4410+ if np.size(options.getfieldvalue('Markers',[]))!=np.size(bamg_geometry.Edges,0):
4411+ raise RuntimeError('for 2d vertical mesh, ''Markers'' option is required, and should be of size ' + str(np.size(bamg_geometry.Edges,0)))
4412+ if np.size(options.getfieldvalue('Markers',[]))==np.size(bamg_geometry.Edges,0):
4413+ bamg_geometry.Edges[:,2]=options.getfieldvalue('Markers')
4414+
4415 #take care of rifts
4416 if options.exist('rifts'):
4417
4418@@ -322,23 +331,64 @@
4419 bamgmesh_out,bamggeom_out=BamgMesher(bamg_mesh.__dict__,bamg_geometry.__dict__,bamg_options)
4420
4421 # plug results onto model
4422+ if options.getfieldvalue('vertical',0):
4423+ md.mesh=mesh2dvertical()
4424+ md.mesh.x=bamgmesh_out['Vertices'][:,0].copy()
4425+ md.mesh.y=bamgmesh_out['Vertices'][:,1].copy()
4426+ md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int)
4427+ md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int)
4428+ md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int)
4429+ md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int)
4430+
4431+ #Fill in rest of fields:
4432+ md.mesh.numberofelements=np.size(md.mesh.elements,axis=0)
4433+ md.mesh.numberofvertices=np.size(md.mesh.x)
4434+ md.mesh.numberofedges=np.size(md.mesh.edges,axis=0)
4435+ md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool)
4436+ md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True
4437+
4438+ #Now, build the connectivity tables for this mesh. Doubled in matlab for some reason
4439+ md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,)
4440+ md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=1
4441+
4442+ elif options.getfieldvalue('3dsurface',0):
4443+ md.mesh=mesh3dsurface()
4444+ md.mesh.x=bamgmesh_out['Vertices'][:,0].copy()
4445+ md.mesh.y=bamgmesh_out['Vertices'][:,1].copy()
4446+ md.mesh.z=md.mesh.x
4447+ md.mesh.z[:]=0
4448+ md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int)
4449+ md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int)
4450+ md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int)
4451+ md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int)
4452+
4453+ #Fill in rest of fields:
4454+ md.mesh.numberofelements=np.size(md.mesh.elements,axis=0)
4455+ md.mesh.numberofvertices=np.size(md.mesh.x)
4456+ md.mesh.numberofedges=np.size(md.mesh.edges,axis=0)
4457+ md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool)
4458+ md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True
4459+
4460+ else:
4461+ md.mesh=mesh2d()
4462+ md.mesh.x=bamgmesh_out['Vertices'][:,0].copy()
4463+ md.mesh.y=bamgmesh_out['Vertices'][:,1].copy()
4464+ md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int)
4465+ md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int)
4466+ md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int)
4467+ md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int)
4468+
4469+ #Fill in rest of fields:
4470+ md.mesh.numberofelements=np.size(md.mesh.elements,axis=0)
4471+ md.mesh.numberofvertices=np.size(md.mesh.x)
4472+ md.mesh.numberofedges=np.size(md.mesh.edges,axis=0)
4473+ md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool)
4474+ md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True
4475+
4476+ #Bamg private fields
4477 md.private.bamg=OrderedDict()
4478 md.private.bamg['mesh']=bamgmesh(bamgmesh_out)
4479 md.private.bamg['geometry']=bamggeom(bamggeom_out)
4480- md.mesh = mesh2d()
4481- md.mesh.x=bamgmesh_out['Vertices'][:,0].copy()
4482- md.mesh.y=bamgmesh_out['Vertices'][:,1].copy()
4483- md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int)
4484- md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int)
4485- md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int)
4486- md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int)
4487-
4488- #Fill in rest of fields:
4489- md.mesh.numberofelements=np.size(md.mesh.elements,axis=0)
4490- md.mesh.numberofvertices=np.size(md.mesh.x)
4491- md.mesh.numberofedges=np.size(md.mesh.edges,axis=0)
4492- md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool)
4493- md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True
4494 md.mesh.elementconnectivity=md.private.bamg['mesh'].ElementConnectivity
4495 md.mesh.elementconnectivity[np.nonzero(np.isnan(md.mesh.elementconnectivity))]=0
4496 md.mesh.elementconnectivity=md.mesh.elementconnectivity.astype(int)
Note: See TracBrowser for help on using the repository browser.