tdatatypes.jl - Granular.jl - Julia package for granular dynamics simulation
HTML git clone git://src.adamsgaard.dk/Granular.jl
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tdatatypes.jl (12039B)
---
1 ## Particle composite types
2 mutable struct GrainCylindrical
3
4 # Material properties
5 density::Float64
6
7 # Geometrical parameters
8 thickness::Float64
9 contact_radius::Float64
10 areal_radius::Float64
11 circumreference::Float64
12 horizontal_surface_area::Float64
13 side_surface_area::Float64
14 volume::Float64
15 mass::Float64
16 moment_of_inertia::Float64
17
18 # Linear kinematic degrees of freedom along horizontal plane
19 lin_pos::Vector{Float64}
20 lin_vel::Vector{Float64}
21 lin_acc::Vector{Float64}
22 force::Vector{Float64}
23 external_body_force::Vector{Float64}
24 lin_disp::Vector{Float64}
25
26 # Angular kinematic degrees of freedom for vertical rotation around center
27 ang_pos::Vector{Float64}
28 ang_vel::Vector{Float64}
29 ang_acc::Vector{Float64}
30 torque::Vector{Float64}
31
32 # Kinematic constraint flags
33 fixed::Bool
34 allow_x_acc::Bool
35 allow_y_acc::Bool
36 allow_z_acc::Bool
37 rotating::Bool
38 enabled::Bool
39
40 # Rheological parameters
41 contact_stiffness_normal::Float64
42 contact_stiffness_tangential::Float64
43 contact_viscosity_normal::Float64
44 contact_viscosity_tangential::Float64
45 contact_static_friction::Float64
46 contact_dynamic_friction::Float64
47
48 youngs_modulus::Float64
49 poissons_ratio::Float64
50 tensile_strength::Float64
51 shear_strength::Float64
52 strength_heal_rate::Float64
53 fracture_toughness::Float64
54
55 # Ocean/atmosphere interaction parameters
56 ocean_drag_coeff_vert::Float64
57 ocean_drag_coeff_horiz::Float64
58 atmosphere_drag_coeff_vert::Float64
59 atmosphere_drag_coeff_horiz::Float64
60
61 # Interaction
62 pressure::Float64
63 n_contacts::Int
64 ocean_grid_pos::Vector{Int}
65 atmosphere_grid_pos::Vector{Int}
66 contacts::Vector{Int}
67 position_vector::Vector{Vector{Float64}}
68 contact_parallel_displacement::Vector{Vector{Float64}}
69 contact_rotation::Vector{Vector{Float64}}
70 contact_age::Vector{Float64}
71 contact_area::Vector{Float64}
72 compressive_failure::Vector{Bool}
73
74 granular_stress::Vector{Float64}
75 ocean_stress::Vector{Float64}
76 atmosphere_stress::Vector{Float64}
77
78 thermal_energy::Float64
79
80 # Visualization parameters
81 color::Int
82 end
83
84 # Type for linear (flat) and frictionless dynamic walls
85 mutable struct WallLinearFrictionless
86 normal::Vector{Float64} # Wall-face normal vector
87 pos::Float64 # Position along axis parallel to normal vector
88 bc::String # Boundary condition
89 mass::Float64 # Mass, used when bc != "fixed"
90 thickness::Float64 # Wall thickness
91 surface_area::Float64 # Wall surface area
92 normal_stress::Float64 # Normal stress when bc == "normal stress"
93 vel::Float64 # Velocity (constant when bc == "normal stress")
94 acc::Float64 # Acceleration (zero when bc == "velocity")
95 force::Float64 # Sum of normal forces on wall
96 contact_viscosity_normal::Float64 # Wall-normal contact viscosity
97 end
98
99 # Type for gathering data from grain objects into single arrays
100 mutable struct GrainArrays
101
102 # Material properties
103 density::Vector{Float64}
104
105 # Geometrical parameters
106 thickness::Vector{Float64}
107 contact_radius::Vector{Float64}
108 areal_radius::Vector{Float64}
109 circumreference::Vector{Float64}
110 horizontal_surface_area::Vector{Float64}
111 side_surface_area::Vector{Float64}
112 volume::Vector{Float64}
113 mass::Vector{Float64}
114 moment_of_inertia::Vector{Float64}
115
116 # Linear kinematic degrees of freedom along horizontal plane
117 lin_pos::Array{Float64, 2}
118 lin_vel::Array{Float64, 2}
119 lin_acc::Array{Float64, 2}
120 force::Array{Float64, 2}
121 external_body_force::Array{Float64, 2}
122 lin_disp::Array{Float64, 2}
123
124 # Angular kinematic degrees of freedom for vertical rotation around center
125 ang_pos::Array{Float64, 2}
126 ang_vel::Array{Float64, 2}
127 ang_acc::Array{Float64, 2}
128 torque::Array{Float64, 2}
129
130 # Kinematic constraint flags
131 fixed::Vector{Int}
132 allow_x_acc::Vector{Int}
133 allow_y_acc::Vector{Int}
134 allow_z_acc::Vector{Int}
135 rotating::Vector{Int}
136 enabled::Vector{Int}
137
138 # Rheological parameters
139 contact_stiffness_normal::Vector{Float64}
140 contact_stiffness_tangential::Vector{Float64}
141 contact_viscosity_normal::Vector{Float64}
142 contact_viscosity_tangential::Vector{Float64}
143 contact_static_friction::Vector{Float64}
144 contact_dynamic_friction::Vector{Float64}
145
146 youngs_modulus::Vector{Float64}
147 poissons_ratio::Vector{Float64}
148 tensile_strength::Vector{Float64}
149 shear_strength::Vector{Float64}
150 strength_heal_rate::Vector{Float64}
151 fracture_toughness::Vector{Float64}
152
153 ocean_drag_coeff_vert::Vector{Float64}
154 ocean_drag_coeff_horiz::Vector{Float64}
155 atmosphere_drag_coeff_vert::Vector{Float64}
156 atmosphere_drag_coeff_horiz::Vector{Float64}
157
158 pressure::Vector{Float64}
159 n_contacts::Vector{Int}
160
161 granular_stress::Array{Float64, 2}
162 ocean_stress::Array{Float64, 2}
163 atmosphere_stress::Array{Float64, 2}
164
165 thermal_energy::Vector{Float64}
166
167 color::Vector{Int}
168 end
169
170 #=
171 Type containing all relevant data from MOM6 NetCDF files. The ocean grid is a
172 staggered of Arakawa-B type, with south-west convention centered on the
173 h-points. During read, the velocities are interpolated to the cell corners
174 (q-points).
175
176 q( i,j+1) ------------------ q(i+1,j+1)
177 | |
178 | |
179 | |
180 | |
181 | h( i, j) |
182 | |
183 | |
184 | |
185 | |
186 q( i, j) ------------------ q(i+1, j)
187
188 # Fields
189 * `input_file::String`: path to input NetCDF file
190 * `time::Array{Float64, 1}`: time in days
191 * `xq::Array{Float64, 2}`: nominal longitude of q-points [degrees_E]
192 * `yq::Array{Float64, 2}`: nominal latitude of q-points [degrees_N]
193 * `xh::Array{Float64, 2}`: nominal longitude of h-points [degrees_E]
194 * `yh::Array{Float64, 2}`: nominal latitude of h-points [degrees_N]
195 * `zl::Array{Float64, 1}`: layer target potential density [kg m^-3]
196 * `zi::Array{Float64, 1}`: interface target potential density [kg m^-3]
197 * `u::Array{Float64, Int}`: zonal velocity (positive towards west) [m/s],
198 dimensions correspond to placement in `[xq, yq, zl, time]`.
199 * `v::Array{Float64, Int}`: meridional velocity (positive towards north) [m/s],
200 dimensions correspond to placement in `[xq, yq, zl, time]`.
201 * `h::Array{Float64, Int}`: layer thickness [m], dimensions correspond to
202 placement in `[xh, yh, zl, time]`.
203 * `e::Array{Float64, Int}`: interface height relative to mean sea level [m],
204 dimensions correspond to placement in `[xh, yh, zi, time]`.
205 * `grain_list::Array{Float64, Int}`: indexes of grains contained in the
206 ocean grid cells.
207 * `bc_west::Integer`: Boundary condition type for the west edge of the grid.
208 1: inactive,
209 2: periodic
210 * `bc_south::Integer`: Boundary condition type for the south edge of the grid.
211 1: inactive,
212 2: periodic
213 * `bc_east::Integer`: Boundary condition type for the east edge of the grid.
214 1: inactive,
215 2: periodic
216 * `bc_north::Integer`: Boundary condition type for the north edge of the grid.
217 1: inactive,
218 2: periodic
219 =#
220 mutable struct Ocean
221 input_file::Any
222
223 time::Vector{Float64}
224
225 # q-point (cell corner) positions
226 xq::Array{Float64, 2}
227 yq::Array{Float64, 2}
228
229 # h-point (cell center) positions
230 xh::Array{Float64, 2}
231 yh::Array{Float64, 2}
232
233 # Vertical positions
234 zl::Vector{Float64}
235 zi::Vector{Float64}
236
237 # Field values
238 u::Array{Float64, 4}
239 v::Array{Float64, 4}
240 h::Array{Float64, 4}
241 e::Array{Float64, 4}
242
243 # Grains in grid cells
244 grain_list::Array{Vector{Int}, 2}
245 porosity::Array{Float64, 2}
246
247 # Boundary conditions for grains
248 bc_west::Integer
249 bc_south::Integer
250 bc_east::Integer
251 bc_north::Integer
252
253 # If the grid is regular, allow for simpler particle sorting
254 regular_grid::Bool
255
256 # Grid size when regular_grid == true
257 origo::Vector{Float64} # Grid origo
258 L::Vector{Float64} # Grid length
259 n::Vector{Integer} # Cell count
260 dx::Vector{Float64} # Cell size
261 end
262
263 #=
264 The atmosphere grid is a staggered of Arakawa-B type, with south-west convention
265 centered on the h-points. During read, the velocities are interpolated to the
266 cell corners (q-points).
267
268 q( i,j+1) ------------------ q(i+1,j+1)
269 | |
270 | |
271 | |
272 | |
273 | h( i, j) |
274 | |
275 | |
276 | |
277 | |
278 q( i, j) ------------------ q(i+1, j)
279
280 # Fields
281 * `input_file::String`: path to input NetCDF file
282 * `time::Vector{Float64}`: time in days
283 * `xq::Array{Float64, 2}`: nominal longitude of q-points [degrees_E]
284 * `yq::Array{Float64, 2}`: nominal latitude of q-points [degrees_N]
285 * `xh::Array{Float64, 2}`: nominal longitude of h-points [degrees_E]
286 * `yh::Array{Float64, 2}`: nominal latitude of h-points [degrees_N]
287 * `zl::Vector{Float64}`: vertical position [m]
288 * `u::Array{Float64, Int}`: zonal velocity (positive towards west) [m/s],
289 dimensions correspond to placement in `[xq, yq, zl, time]`.
290 * `v::Array{Float64, Int}`: meridional velocity (positive towards north) [m/s],
291 dimensions correspond to placement in `[xq, yq, zl, time]`.
292 * `grain_list::Array{Float64, Int}`: interface height relative to mean sea
293 level [m], dimensions correspond to placement in `[xh, yh, zi, time]`.
294 * `bc_west::Integer`: Boundary condition type for the west edge of the grid.
295 1: inactive,
296 2: periodic
297 * `bc_south::Integer`: Boundary condition type for the south edge of the grid.
298 1: inactive,
299 2: periodic
300 * `bc_east::Integer`: Boundary condition type for the east edge of the grid.
301 1: inactive,
302 2: periodic
303 * `bc_north::Integer`: Boundary condition type for the north edge of the grid.
304 1: inactive,
305 2: periodic
306 =#
307 mutable struct Atmosphere
308 input_file::Any
309
310 time::Vector{Float64}
311
312 # q-point (cell corner) positions
313 xq::Array{Float64, 2}
314 yq::Array{Float64, 2}
315
316 # h-point (cell center) positions
317 xh::Array{Float64, 2}
318 yh::Array{Float64, 2}
319
320 # Vertical positions
321 zl::Vector{Float64}
322
323 # Field values
324 u::Array{Float64, 4}
325 v::Array{Float64, 4}
326
327 # Grains in grid cells
328 grain_list::Array{Vector{Int}, 2}
329 porosity::Array{Float64, 2}
330
331 # Boundary conditions for grains
332 bc_west::Integer
333 bc_south::Integer
334 bc_east::Integer
335 bc_north::Integer
336
337 # If true the grid positions are identical to the ocean grid
338 collocated_with_ocean_grid::Bool
339
340 # If the grid is regular, allow for simpler particle sorting
341 regular_grid::Bool
342
343 # Grid size when regular_grid == true
344 origo::Vector{Float64} # Grid origo
345 L::Vector{Float64} # Grid length
346 n::Vector{Integer} # Cell count
347 dx::Vector{Float64} # Cell size
348 end
349
350 # Top-level simulation type
351 mutable struct Simulation
352 id::String
353
354 time_iteration::Int
355 time::Float64
356 time_total::Float64
357 time_step::Float64
358 file_time_step::Float64
359 file_number::Int
360 file_time_since_output_file::Float64
361
362 grains::Vector{GrainCylindrical}
363
364 ocean::Ocean
365 atmosphere::Atmosphere
366
367 Nc_max::Int
368
369 walls::Vector{WallLinearFrictionless}
370 end
371
372 # Mappings between boundary condition keys (Integers) and strings
373 const grid_bc_strings = ["inactive", "periodic", "impermeable"]
374 const grid_bc_flags = Dict(zip(grid_bc_strings, 1:length(grid_bc_strings)))