| tvtk.jl - Granular.jl - Julia package for granular dynamics simulation | |
| git clone git://src.adamsgaard.dk/Granular.jl | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| tvtk.jl (3923B) | |
| --- | |
| 1 #!/usr/bin/env julia | |
| 2 | |
| 3 # Check the contact search and geometry of a two-particle interaction | |
| 4 | |
| 5 @info "Writing simple simulation to VTK file" | |
| 6 sim = Granular.createSimulation(id="test") | |
| 7 Granular.addGrainCylindrical!(sim, [ 0., 0.], 10., 1., verbose=false) | |
| 8 Granular.addGrainCylindrical!(sim, [18., 0.], 10., 1., verbose=false) | |
| 9 sim.ocean = Granular.createRegularOceanGrid([10, 20, 5], [10., 25., 2.])… | |
| 10 Granular.findContacts!(sim, method="all to all") | |
| 11 Granular.writeVTK(sim, verbose=false) | |
| 12 | |
| 13 cmd_post = "" | |
| 14 if Sys.islinux() | |
| 15 cmd = "sha256sum" | |
| 16 elseif Sys.isapple() | |
| 17 cmd = ["shasum", "-a", "256"] | |
| 18 elseif Sys.iswindows() | |
| 19 @info "checksum verification not yet implemented on Windows" | |
| 20 exit() | |
| 21 cmd = ["powershell", "-Command", "\"Get-FileHash", "-Algorithm", "SH… | |
| 22 cmd_post = "\"" | |
| 23 else | |
| 24 error("checksum verification of VTK file not supported on this platf… | |
| 25 end | |
| 26 | |
| 27 grainpath = "test/test.grains.1.vtu" | |
| 28 grainchecksum = | |
| 29 "b1748cb82e8270d951d9c1acaea0d151f0a5c48a1255e75de350bf9bcbc15fe9 " * | |
| 30 grainpath * "\n" | |
| 31 | |
| 32 graininteractionpath = "test/test.grain-interaction.1.vtp" | |
| 33 graininteractionchecksum = | |
| 34 "b8e49252a0ac87c2fce05e68ffab46589853429dc9f75d89818e4a37b953b137 " * | |
| 35 graininteractionpath * "\n" | |
| 36 | |
| 37 oceanpath = "test/test.ocean.1.vts" | |
| 38 oceanchecksum = | |
| 39 "b65f00942f1cbef7335921948c9eb73d137574eb806c33dea8b0e9b638665f3b " * | |
| 40 oceanpath * "\n" | |
| 41 | |
| 42 #@test read(`$(cmd) $(grainpath)$(cmd_post)`, String) == grainchecksum | |
| 43 #@test read(`$(cmd) $(graininteractionpath)$(cmd_post)`, String) == | |
| 44 #graininteractionchecksum | |
| 45 #@test read(`$(cmd) $(oceanpath)$(cmd_post)`, String) == oceanchecksum | |
| 46 | |
| 47 Granular.removeSimulationFiles(sim) | |
| 48 | |
| 49 @info "Testing VTK write during run!()" | |
| 50 Granular.setOutputFileInterval!(sim, 1e-9) | |
| 51 Granular.setTotalTime!(sim, 1.5) | |
| 52 Granular.setTimeStep!(sim) | |
| 53 sim.file_number = 0 | |
| 54 Granular.run!(sim, single_step=true) | |
| 55 @test Granular.readSimulationStatus(sim.id) == 1 | |
| 56 @test Granular.readSimulationStatus(sim) == 1 | |
| 57 Granular.setOutputFileInterval!(sim, 0.1) | |
| 58 Granular.run!(sim) | |
| 59 | |
| 60 @info "Testing status output" | |
| 61 Granular.status() | |
| 62 Granular.status(colored_output=false) | |
| 63 dir = "empty_directory" | |
| 64 isdir(dir) || mkdir(dir) | |
| 65 Granular.status(dir) | |
| 66 rm(dir) | |
| 67 | |
| 68 @info "Testing generation of Paraview Python script" | |
| 69 Granular.writeParaviewPythonScript(sim, | |
| 70 save_animation=true, | |
| 71 save_images=false) | |
| 72 @test isfile("$(sim.id)/$(sim.id).py") && filesize("$(sim.id)/$(sim.id).… | |
| 73 | |
| 74 #@info "Testing Paraview rendering if `pvpython` is present" | |
| 75 #try | |
| 76 # run(`pvpython $(sim.id)/$(sim.id).py`) | |
| 77 #catch return_signal | |
| 78 # if !isa(return_signal, Base.IOError) | |
| 79 # @test isfile("$(sim.id)/$(sim.id).avi") | |
| 80 # end | |
| 81 #end | |
| 82 | |
| 83 Granular.writeParaviewPythonScript(sim, | |
| 84 save_animation=false, | |
| 85 save_images=true) | |
| 86 #try | |
| 87 # run(`pvpython $(sim.id)/$(sim.id).py`) | |
| 88 #catch return_signal | |
| 89 # if !isa(return_signal, Base.IOError) | |
| 90 # @test isfile("$(sim.id)/$(sim.id).0000.png") | |
| 91 # @test isfile("$(sim.id)/$(sim.id).0014.png") | |
| 92 # Granular.render(sim) | |
| 93 # @test isfile("$(sim.id)/$(sim.id).0001.png") | |
| 94 # end | |
| 95 #end | |
| 96 | |
| 97 #@test read(`$(cmd) $(grainpath)$(cmd_post)`, String) == grainchecksum | |
| 98 #@test read(`$(cmd) $(graininteractionpath)$(cmd_post)`, String) == | |
| 99 #graininteractionchecksum | |
| 100 #@test read(`$(cmd) $(oceanpath)$(cmd_post)`, String) == oceanchecksum | |
| 101 | |
| 102 @info "Writing simple simulation to VTK file" | |
| 103 sim = Granular.createSimulation(id="test") | |
| 104 Granular.addGrainCylindrical!(sim, [ 0., 0.], 10., 1., youngs_modulus=0.… | |
| 105 Granular.addGrainCylindrical!(sim, [18., 0.], 10., 1., youngs_modulus=0.… | |
| 106 sim.ocean = Granular.createRegularOceanGrid([10, 20, 5], [10., 25., 2.]) | |
| 107 sim.atmosphere = Granular.createRegularAtmosphereGrid([10, 20, 5], [10.,… | |
| 108 Granular.findContacts!(sim, method="all to all") | |
| 109 Granular.writeVTK(sim, verbose=false) | |
| 110 | |
| 111 Granular.removeSimulationFiles(sim) |