initial upload
This commit is contained in:
BIN
PyLaGriT/examples/arctic_w_ice_wedges/meshdoc_cabolt_v1.pdf
Executable file
BIN
PyLaGriT/examples/arctic_w_ice_wedges/meshdoc_cabolt_v1.pdf
Executable file
Binary file not shown.
160
PyLaGriT/examples/arctic_w_ice_wedges/transectNWSE.PY
Executable file
160
PyLaGriT/examples/arctic_w_ice_wedges/transectNWSE.PY
Executable file
@@ -0,0 +1,160 @@
|
||||
from pylagrit import PyLaGriT
|
||||
import numpy as np
|
||||
|
||||
lg = PyLaGriT()
|
||||
|
||||
# Create base layer, with x matching s from the csv file
|
||||
x = np.linspace(0.,29.75,(29.75-0.)/0.25+1)
|
||||
y = [0.,0.25]
|
||||
top = lg.gridder(x,y,elem_type='quad',connect=True)
|
||||
|
||||
# Create top of mesh
|
||||
# Collapse y values
|
||||
top.addatt('y_save',vtype='vdouble',rank='scalar')
|
||||
top.copyatt('yic','y_save')
|
||||
top.setatt('yic',0.)
|
||||
|
||||
# Read in top elevations
|
||||
d = np.genfromtxt("transectNWSE.csv", delimiter=",", names=True)
|
||||
coords = np.column_stack([d['s'],np.zeros_like(d['s']),d['z']])
|
||||
surf_pts = lg.points(coords,elem_type='quad')
|
||||
surf_pts.addatt('z_save',vtype='vdouble',rank='scalar')
|
||||
surf_pts.copyatt('zic','z_save')
|
||||
surf_pts.setatt('zic',0.)
|
||||
|
||||
# Interpolate surface elevations to top
|
||||
top.addatt('z_val',vtype='vdouble',rank='scalar')
|
||||
top.interpolate_voronoi('z_val',surf_pts,'z_save')
|
||||
top.copyatt('y_save','yic')
|
||||
top.copyatt('z_val','zic')
|
||||
|
||||
# Save top
|
||||
top.setatt('imt',1)
|
||||
top.setatt('itetclr',1)
|
||||
top.dump('tmp_lay_peat_top.inp')
|
||||
surf_pts.delete()
|
||||
|
||||
# Copy top to create intermediate layers
|
||||
layer = top.copy()
|
||||
|
||||
# Begin to construct stacked layer arrays
|
||||
# Names of layer files
|
||||
stack_files = ['tmp_lay_peat_top.inp']
|
||||
# Material id, should be same length as length of stack_files
|
||||
matids = [1]
|
||||
|
||||
# Add (2) 1 cm thick layers
|
||||
layer.math('sub',0.01*2,'zic')
|
||||
layer.dump('tmp_lay1.inp')
|
||||
stack_files.append('tmp_lay1.inp')
|
||||
nlayers = [1]
|
||||
matids.append(1)
|
||||
|
||||
# Add (6) 2 cm thick layers
|
||||
layer.math('sub',0.02*6,'zic')
|
||||
layer.dump('tmp_lay2.inp')
|
||||
stack_files.append('tmp_lay2.inp')
|
||||
nlayers.append(5)
|
||||
matids.append(2)
|
||||
|
||||
# Add (8) 2 cm thick layers
|
||||
layer.math('sub',0.02*8,'zic')
|
||||
layer.dump('tmp_lay3.inp')
|
||||
stack_files.append('tmp_lay3.inp')
|
||||
nlayers.append(7)
|
||||
matids.append(3)
|
||||
|
||||
# Add (15) 5 cm thick layers
|
||||
layer.math('sub',0.05*15,'zic')
|
||||
layer.dump('tmp_lay4.inp')
|
||||
stack_files.append('tmp_lay4.inp')
|
||||
nlayers.append(14)
|
||||
matids.append(3)
|
||||
|
||||
# Add (15) 10 cm thick layers
|
||||
layer.math('sub',0.1*15,'zic')
|
||||
layer.dump('tmp_lay5.inp')
|
||||
stack_files.append('tmp_lay5.inp')
|
||||
nlayers.append(14)
|
||||
matids.append(3)
|
||||
|
||||
# Add (15) 1 m thick layers
|
||||
layer.math('sub',1*15,'zic')
|
||||
layer.dump('tmp_lay6.inp')
|
||||
stack_files.append('tmp_lay6.inp')
|
||||
nlayers.append(14)
|
||||
matids.append(3)
|
||||
|
||||
# Add (15) 2 m thick layers
|
||||
layer.math('sub',2.*15.,'zic')
|
||||
layer.dump('tmp_lay7.inp')
|
||||
stack_files.append('tmp_lay7.inp')
|
||||
nlayers.append(14)
|
||||
matids.append(3)
|
||||
|
||||
# Add the bottom layer, and make the bottom boundary flat
|
||||
layer.setatt('zic',29.)
|
||||
layer.dump('tmp_lay_bot.inp')
|
||||
stack_files.append('tmp_lay_bot.inp')
|
||||
nlayers.append(0)
|
||||
matids.append(3)
|
||||
|
||||
# Create stacked layer mesh and fill
|
||||
# Reverse arrays so that order is from bottom to top!!!
|
||||
stack_files.reverse()
|
||||
nlayers.reverse()
|
||||
matids.reverse()
|
||||
stack = lg.create()
|
||||
stack.stack_layers(stack_files,nlayers=nlayers,matids=matids,flip_opt=True)
|
||||
stack_hex = stack.stack_fill()
|
||||
|
||||
# Define ice wedges
|
||||
def iceWedgePoints( vtxL, vtxB, vtxR, dx, dz ):
|
||||
xnodes = np.arange( vtxL[0], vtxR[0], dx )
|
||||
znodes = np.arange( vtxB[1], vtxR[1], dz )
|
||||
xg, zg = np.meshgrid(xnodes, znodes)
|
||||
xg = xg.flatten(); zg = zg.flatten()
|
||||
m1 = (vtxB[1] - vtxL[1])/(vtxB[0] - vtxL[0])
|
||||
b1 = vtxL[1] - m1*vtxL[0]
|
||||
m2 = (vtxR[1] - vtxB[1])/(vtxR[0] - vtxB[0])
|
||||
b2 = vtxR[1] - m2*vtxR[0]
|
||||
idx = [ (zg[i] > m1*xg[i]+b1) & (zg[i] > m2*xg[i]+b2) for i in range(len(zg)) ]
|
||||
iwx = xg[np.array(idx)]; iwz = zg[np.array(idx)]
|
||||
iwy = np.concatenate( (np.ones(iwx.size)*0.05, np.ones(iwx.size)*0.2) )
|
||||
iwx = np.tile(iwx, 2); iwz = np.tile(iwz, 2)
|
||||
|
||||
return iwx, iwy, iwz
|
||||
|
||||
iw1x, iw1y, iw1z = iceWedgePoints( [3.25, 78.3], [3.875, 75.0], [4.5, 78.3], 0.125, 0.01 )
|
||||
iw1pts = lg.points(np.column_stack([iw1x, iw1y, iw1z]), connect=True)
|
||||
iw1 = stack_hex.eltset_object(iw1pts)
|
||||
iw1.setatt('itetclr', 4)
|
||||
|
||||
iw2x, iw2y, iw2z = iceWedgePoints( [18.5, 78.4], [19.125, 75.1], [19.75,78.4], 0.125, 0.01 )
|
||||
iw2pts = lg.points(np.column_stack([iw2x, iw2y, iw2z]), connect=True)
|
||||
iw2 = stack_hex.eltset_object(iw2pts)
|
||||
iw2.setatt('itetclr', 4)
|
||||
|
||||
# Create boundary facesets, dictionary of PyLaGriT faceset objects is returned
|
||||
fs = stack_hex.create_boundary_facesets(base_name='faceset_bounds',stacked_layers=True,reorder=True)
|
||||
|
||||
# Should add this to PyLaGriT, but I'm feeling lazy ;-)
|
||||
stack_hex.sendline('quality volume itetclr')
|
||||
|
||||
# Write exo file with boundary facesets
|
||||
stack_hex.dump_exo('transectNWSE.exo',facesets=fs.values())
|
||||
|
||||
# Write region and faceset identifier file for ats_xml
|
||||
matnames = {10000:'computational domain moss',
|
||||
20000:'computational domain peat',
|
||||
30000:'computational domain mineral',
|
||||
40000:'computational domain ice wedge'}
|
||||
facenames = {1:'bottom face',
|
||||
2:'surface',
|
||||
3:'front',
|
||||
4:'right',
|
||||
5:'back',
|
||||
6:'left'}
|
||||
|
||||
stack_hex.dump_ats_xml('transectNWSE_mesh.xml','../../mesh/transectNWSE.exo',matnames=matnames,facenames=facenames)
|
||||
stack_hex.dump_ats_xml('transectNWSE_parmesh.xml','../../mesh/4/transectNWSE.par',matnames=matnames,facenames=facenames)
|
||||
121
PyLaGriT/examples/arctic_w_ice_wedges/transectNWSE.csv
Executable file
121
PyLaGriT/examples/arctic_w_ice_wedges/transectNWSE.csv
Executable file
@@ -0,0 +1,121 @@
|
||||
s,x,y,z
|
||||
0,431503.263849712,7748935.90919019,79.01
|
||||
0.25,431503.436233142,7748935.72812679,79.01
|
||||
0.5,431503.608616571,7748935.5470634,79.01
|
||||
0.75,431503.781,7748935.366,79.01
|
||||
1,431503.953383429,7748935.1849366,79.01
|
||||
1.25,431504.125766858,7748935.00387321,79.03
|
||||
1.5,431504.298150288,7748934.82280981,79.0733333333333
|
||||
1.75,431504.470533717,7748934.64174642,79.1166666666667
|
||||
2,431504.642917146,7748934.46068302,79.16
|
||||
2.25,431504.815300575,7748934.27961962,79.165
|
||||
2.5,431504.987684004,7748934.09855623,79.17
|
||||
2.75,431505.160067433,7748933.91749283,79.17
|
||||
3,431505.332450863,7748933.73642944,79.13
|
||||
3.25,431505.504834292,7748933.55536604,79.09
|
||||
3.5,431505.677217721,7748933.37430265,79.035
|
||||
3.75,431505.84960115,7748933.19323925,78.98
|
||||
4,431506.021984579,7748933.01217585,78.97
|
||||
4.25,431506.194368009,7748932.83111246,79.03
|
||||
4.5,431506.366751438,7748932.65004906,79.09
|
||||
4.75,431506.539134867,7748932.46898567,79.12
|
||||
5,431506.711518296,7748932.28792227,79.118
|
||||
5.25,431506.883901725,7748932.10685887,79.116
|
||||
5.5,431507.056285155,7748931.92579548,79.114
|
||||
5.75,431507.228668584,7748931.74473208,79.112
|
||||
6,431507.401052013,7748931.56366869,79.11
|
||||
6.25,431507.573435442,7748931.38260529,79.08
|
||||
6.5,431507.745818871,7748931.20154189,79.07
|
||||
6.75,431507.918202301,7748931.0204785,79.0661538461538
|
||||
7,431508.09058573,7748930.8394151,79.0623076923077
|
||||
7.25,431508.262969159,7748930.65835171,79.0584615384615
|
||||
7.5,431508.435352588,7748930.47728831,79.0546153846154
|
||||
7.75,431508.607736017,7748930.29622491,79.0507692307692
|
||||
8,431508.780119446,7748930.11516152,79.0469230769231
|
||||
8.25,431508.952502876,7748929.93409812,79.0430769230769
|
||||
8.5,431509.124886305,7748929.75303473,79.0392307692308
|
||||
8.75,431509.297269734,7748929.57197133,79.0353846153846
|
||||
9,431509.469653163,7748929.39090793,79.0315384615385
|
||||
9.25,431509.642036592,7748929.20984454,79.0276923076923
|
||||
9.5,431509.814420022,7748929.02878114,79.0238461538462
|
||||
9.75,431509.986803451,7748928.84771775,79.02
|
||||
10,431510.15918688,7748928.66665435,79.0242857142857
|
||||
10.25,431510.331570309,7748928.48559096,79.0285714285714
|
||||
10.5,431510.503953738,7748928.30452756,79.0328571428571
|
||||
10.75,431510.676337168,7748928.12346416,79.0371428571429
|
||||
11,431510.848720597,7748927.94240077,79.0414285714286
|
||||
11.25,431511.021104026,7748927.76133737,79.0457142857143
|
||||
11.5,431511.193487455,7748927.58027398,79.05
|
||||
11.75,431511.365870884,7748927.39921058,79.055
|
||||
12,431511.538254313,7748927.21814718,79.06
|
||||
12.25,431511.710637743,7748927.03708379,79.066
|
||||
12.5,431511.883021172,7748926.85602039,79.072
|
||||
12.75,431512.055404601,7748926.674957,79.078
|
||||
13,431512.22778803,7748926.4938936,79.084
|
||||
13.25,431512.400171459,7748926.3128302,79.09
|
||||
13.5,431512.572554889,7748926.13176681,79.0925
|
||||
13.75,431512.744938318,7748925.95070341,79.095
|
||||
14,431512.917321747,7748925.76964002,79.0975
|
||||
14.25,431513.089705176,7748925.58857662,79.1
|
||||
14.5,431513.262088605,7748925.40751322,79.106
|
||||
14.75,431513.434472035,7748925.22644983,79.112
|
||||
15,431513.606855464,7748925.04538643,79.118
|
||||
15.25,431513.779238893,7748924.86432304,79.124
|
||||
15.5,431513.951622322,7748924.68325964,79.13
|
||||
15.75,431514.124005751,7748924.50219624,79.135
|
||||
16,431514.29638918,7748924.32113285,79.14
|
||||
16.25,431514.46877261,7748924.14006945,79.1633333333333
|
||||
16.5,431514.641156039,7748923.95900606,79.1866666666667
|
||||
16.75,431514.813539468,7748923.77794266,79.21
|
||||
17,431514.985922897,7748923.59687927,79.205
|
||||
17.25,431515.158306326,7748923.41581587,79.2
|
||||
17.5,431515.330689756,7748923.23475247,79.195
|
||||
17.75,431515.503073185,7748923.05368908,79.19
|
||||
18,431515.675456614,7748922.87262568,79.155
|
||||
18.25,431515.847840043,7748922.69156229,79.12
|
||||
18.5,431516.020223472,7748922.51049889,79.08
|
||||
18.75,431516.192606901,7748922.32943549,79.084
|
||||
19,431516.364990331,7748922.1483721,79.088
|
||||
19.25,431516.53737376,7748921.9673087,79.092
|
||||
19.5,431516.709757189,7748921.78624531,79.096
|
||||
19.75,431516.882140618,7748921.60518191,79.1
|
||||
20,431517.054524047,7748921.42411851,79.17
|
||||
20.25,431517.226907477,7748921.24305512,79.18
|
||||
20.5,431517.399290906,7748921.06199172,79.19
|
||||
20.75,431517.571674335,7748920.88092833,79.19
|
||||
21,431517.744057764,7748920.69986493,79.17
|
||||
21.25,431517.916441193,7748920.51880154,79.11
|
||||
21.5,431518.088824623,7748920.33773814,79.092
|
||||
21.75,431518.261208052,7748920.15667474,79.074
|
||||
22,431518.433591481,7748919.97561135,79.056
|
||||
22.25,431518.60597491,7748919.79454795,79.038
|
||||
22.5,431518.778358339,7748919.61348456,79.02
|
||||
22.75,431518.950741768,7748919.43242116,79.01
|
||||
23,431519.123125198,7748919.25135776,79.01
|
||||
23.25,431519.295508627,7748919.07029437,79.01
|
||||
23.5,431519.467892056,7748918.88923097,79.01
|
||||
23.75,431519.640275485,7748918.70816758,79.0128571428571
|
||||
24,431519.812658914,7748918.52710418,79.0157142857143
|
||||
24.25,431519.985042344,7748918.34604078,79.0185714285714
|
||||
24.5,431520.157425773,7748918.16497739,79.0214285714286
|
||||
24.75,431520.329809202,7748917.98391399,79.0242857142857
|
||||
25,431520.502192631,7748917.8028506,79.0271428571428
|
||||
25.25,431520.67457606,7748917.6217872,79.03
|
||||
25.5,431520.84695949,7748917.4407238,79.0283333333333
|
||||
25.75,431521.019342919,7748917.25966041,79.0266666666667
|
||||
26,431521.191726348,7748917.07859701,79.025
|
||||
26.25,431521.364109777,7748916.89753362,79.0233333333333
|
||||
26.5,431521.536493206,7748916.71647022,79.0216666666667
|
||||
26.75,431521.708876635,7748916.53540683,79.02
|
||||
27,431521.881260065,7748916.35434343,79.0208333333333
|
||||
27.25,431522.053643494,7748916.17328003,79.0216666666667
|
||||
27.5,431522.226026923,7748915.99221664,79.0225
|
||||
27.75,431522.398410352,7748915.81115324,79.0233333333333
|
||||
28,431522.570793781,7748915.63008985,79.0241666666667
|
||||
28.25,431522.743177211,7748915.44902645,79.025
|
||||
28.5,431522.91556064,7748915.26796305,79.0258333333333
|
||||
28.75,431523.087944069,7748915.08689966,79.0266666666667
|
||||
29,431523.260327498,7748914.90583626,79.0275
|
||||
29.25,431523.432710927,7748914.72477287,79.0283333333333
|
||||
29.5,431523.605094357,7748914.54370947,79.0291666666667
|
||||
29.75,431523.777477786,7748914.36264607,79.03
|
||||
|
Reference in New Issue
Block a user