-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-callback
- Loading branch information
Showing
32 changed files
with
708 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
ba = "ba" | ||
Shepard = "Shepard" | ||
shepard = "shepard" | ||
Strack = "Strack" | ||
Lok = "Lok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
BoundarySPHSystem | ||
``` | ||
|
||
```@docs | ||
BoundaryDEMSystem | ||
``` | ||
|
||
```@docs | ||
BoundaryMovement | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# [Discrete Element Method](@id dem) | ||
The Discrete Element Method (DEM) is a computational technique widely used in physics, engineering, | ||
and applied mathematics for simulating the mechanical behavior of granular materials, such as powders, | ||
sand, soil, or rock, as well as other discontinua. Unlike continuum mechanics that treats materials as | ||
continuous, DEM considers individual particles or elements and their interactions. This approach provides | ||
detailed insights into the micro-mechanical behavior of materials, making it particularly valuable | ||
in fields such as geomechanics, material science, and mechanical engineering. | ||
|
||
## Fundamental Principles | ||
The core idea behind DEM is the discretization of a material system into a finite set of distinct, | ||
interacting mass elements (particles). These elements (particles) can vary in shape, size, and properties, and | ||
they interact with each other and possibly with their boundaries through contact forces and potential fields. | ||
The motion and behavior of each mass element are governed by Newton's laws of motion, accounting for the forces | ||
and moments acting upon them. | ||
|
||
```@autodocs | ||
Modules = [TrixiParticles] | ||
Pages = [joinpath("schemes", "solid", "discrete_element_method", "system.jl")] | ||
``` | ||
|
||
## References | ||
- N. Bićanić. "Discrete element methods". | ||
In: Encyclopedia of Computational Mechanics (2007). | ||
[doi: 10.1002/0470091355.ecm006.pub2](https://doi.org/10.1002/0470091355.ecm006.pub2) | ||
|
||
- P. Cundall and O. Strack. "A discrete numerical model for granular assemblies". | ||
In: Géotechnique 29.1 (1979), pages 47--65. | ||
[doi: 10.1680/geot.1979.29.1.47](https://doi.org/10.1680/geot.1979.29.1.47) | ||
|
||
- A. Renzo and F. Maio. "Comparison of contact-force models for the simulation of collisions in DEM-based granular flow codes" | ||
In: Chemical Engineering Science 59.3 (2004), pages 525--541. | ||
[doi: 10.1016/j.ces.2003.09.037](https://doi.org/10.1016/j.ces.2003.09.037) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
gravity = -9.81 | ||
|
||
# ========================================================================================== | ||
# ==== Falling rocks | ||
|
||
particle_spacing = 0.1 | ||
|
||
rock_width = 2.0 | ||
rock_height = 2.0 | ||
rock_density = 3000.0 | ||
|
||
tank_width = 2.0 | ||
tank_height = 4.0 | ||
|
||
tank = RectangularTank(particle_spacing, (rock_width, rock_height), | ||
(tank_width, tank_height), rock_density, | ||
n_layers=2) | ||
|
||
# ========================================================================================== | ||
# ==== Systems | ||
|
||
# Move the rocks up to let them fall | ||
tank.fluid.coordinates[2, :] .+= 0.5 | ||
rock_system = DEMSystem(tank.fluid, 2 * 10e5, 10e9, 0.3, acceleration=(0.0, gravity)) | ||
boundary_system = BoundaryDEMSystem(tank.boundary, 10e7) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
|
||
semi = Semidiscretization(rock_system, boundary_system, | ||
neighborhood_search=GridNeighborhoodSearch) | ||
|
||
tspan = (0.0, 5.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=5000) | ||
saving_callback = SolutionSavingCallback(dt=0.02) | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback) | ||
|
||
# Use a Runge-Kutta method with automatic (error based) time step size control | ||
sol = solve(ode, RDPK3SpFSAL49(), | ||
abstol=1e-5, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration) | ||
reltol=1e-4, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration) | ||
dtmax=1e-3, # Limit stepsize to prevent crashing | ||
dt=1e-7, # Initial step size | ||
save_everystep=false, callback=callbacks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Adapt.jl provides a function `adapt(to, x)`, which adapts a value `x` to `to`. | ||
# In practice, this means that we can use `adapt(CuArray, system)` to adapt a system to | ||
# the `CuArray` type. | ||
# What this does is that it converts all `Array`s inside this system to `CuArray`s, | ||
# therefore copying them to the GPU. | ||
# In order to run a simulation on a GPU, we want to call `adapt(T, semi)` to adapt the | ||
# `Semidiscretization` `semi` to the GPU array type `T` (e.g. `CuArray`). | ||
# | ||
# `Adapt.@adapt_structure` automatically generates the `adapt` function for our custom types. | ||
Adapt.@adapt_structure Semidiscretization | ||
Adapt.@adapt_structure WeaklyCompressibleSPHSystem | ||
Adapt.@adapt_structure DensityDiffusionAntuono | ||
Adapt.@adapt_structure BoundarySPHSystem | ||
Adapt.@adapt_structure BoundaryModelDummyParticles | ||
Adapt.@adapt_structure BoundaryModelMonaghanKajtar | ||
|
||
# The initial conditions are only used for initialization, which happens before `adapt`ing | ||
# the semidiscretization, so we don't need to store `InitialCondition`s on the GPU. | ||
# To save precious GPU memory, we replace initial conditions by `nothing`. | ||
function Adapt.adapt_structure(to, ic::InitialCondition) | ||
return nothing | ||
end | ||
|
||
# `adapt(CuArray, ::SVector)::SVector`, but `adapt(Array, ::SVector)::Vector`. | ||
# We don't want to change the type of the `SVector` here. | ||
function Adapt.adapt_structure(to::typeof(Array), svector::SVector) | ||
return svector | ||
end | ||
|
||
# `adapt(CuArray, ::UnitRange)::UnitRange`, but `adapt(Array, ::UnitRange)::Vector`. | ||
# We don't want to change the type of the `UnitRange` here. | ||
function Adapt.adapt_structure(to::typeof(Array), range::UnitRange) | ||
return range | ||
end |
Oops, something went wrong.