Skip to content

Commit

Permalink
Start new project Tesserae.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
KeitaNakamura committed Jul 21, 2024
1 parent d0113e5 commit 34abba0
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 128 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ jobs:
shell: julia --project=docs --color=yes {0}
run: |
using Documenter: DocMeta, doctest
using Sequoia
DocMeta.setdocmeta!(Sequoia, :DocTestSetup, :(using Sequoia); recursive=true)
doctest(Sequoia)
using Tesserae
DocMeta.setdocmeta!(Tesserae, :DocTestSetup, :(using Tesserae); recursive=true)
doctest(Tesserae)
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "Sequoia"
uuid = "30a04e26-4a89-4862-aa00-4d71e820c402"
name = "Tesserae"
uuid = "fd374396-9d9c-4d88-9aa5-37a7f6105aca"
authors = ["Keita Nakamura <keita.nakamura.1109@gmail.com>"]
version = "0.3.0"

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sequoia.jl
# Tesserae.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://KeitaNakamura.github.io/Sequoia.jl/stable)
[![Develop](https://img.shields.io/badge/docs-dev-blue.svg)](https://KeitaNakamura.github.io/Sequoia.jl/dev)
[![CI](https://github.com/KeitaNakamura/Sequoia.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/KeitaNakamura/Sequoia.jl/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/KeitaNakamura/Sequoia.jl/graph/badge.svg?token=bD5urvSTeq)](https://codecov.io/gh/KeitaNakamura/Sequoia.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://KeitaNakamura.github.io/Tesserae.jl/stable)
[![Develop](https://img.shields.io/badge/docs-dev-blue.svg)](https://KeitaNakamura.github.io/Tesserae.jl/dev)
[![CI](https://github.com/KeitaNakamura/Tesserae.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/KeitaNakamura/Tesserae.jl/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/KeitaNakamura/Tesserae.jl/graph/badge.svg?token=H5BHWIIBTG)](https://codecov.io/gh/KeitaNakamura/Tesserae.jl)
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Sequoia = "30a04e26-4a89-4862-aa00-4d71e820c402"
Tesserae = "fd374396-9d9c-4d88-9aa5-37a7f6105aca"
8 changes: 4 additions & 4 deletions docs/literate/examples/dam_break.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ## Main function

using Sequoia
using Tesserae
using LinearAlgebra

abstract type Transfer end
Expand Down Expand Up @@ -115,7 +115,7 @@ function main(transfer::Transfer = FLIP(1.0))
fps = 30
savepoints = collect(LinRange(t, T, round(Int, T*fps)+1))

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

## Update interpolation values based on the nodes of active cells
## where the particles are located
Expand Down Expand Up @@ -257,8 +257,8 @@ function variational_multiscale_method(state)

## Solve nonlinear system
U = zeros(ndofs(dofmap)) # Initialize nodal dispacement and pressure with zero
solved = Sequoia.newton!(U, U->residual(U,state), U->J;
linsolve=(x,A,b)->ldiv!(x,A,b), atol=1e-10, rtol=1e-10)
solved = Tesserae.newton!(U, U->residual(U,state), U->J;
linsolve=(x,A,b)->ldiv!(x,A,b), atol=1e-10, rtol=1e-10)

## If the simulation fails to solve, retry with a smaller time step
solved || (Δt /= 2)
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/examples/elastic_impact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# [^4]: [Li, X., Fang, Y., Li, M. and Jiang, C., 2022. BFEMP: Interpenetration-free MPM–FEM coupling with barrier contact. Computer Methods in Applied Mechanics and Engineering, 390, p.114350.](https://doi.org/10.1016/j.cma.2021.114350)
#

using Sequoia
using Tesserae

abstract type Transfer end
struct FLIP <: Transfer α::Float64 end
Expand Down Expand Up @@ -106,7 +106,7 @@ function main(transfer::Transfer = FLIP(1.0))
fps = 120
savepoints = collect(LinRange(t, T, round(Int, T*fps)+1))

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

## Calculate timestep based on the wave speed
vmax = maximum(@. sqrt((λ+2μ) / (particles.m/particles.V)) + norm(particles.v))
Expand Down
8 changes: 4 additions & 4 deletions docs/literate/examples/implicit_jacobian_based.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# # Jacobian-based implicit method

using Sequoia
using Tesserae

function main()

Expand Down Expand Up @@ -56,7 +56,7 @@ function main()
grid = generate_grid(GridProp, CartesianMesh(h, (0.0,1.2), (0.0,2.0), (-0.2,0.2)))

## Particles
beam = Sequoia.Box((0,1), (0.85,1.15), (-0.15,0.15))
beam = Tesserae.Box((0,1), (0.85,1.15), (-0.15,0.15))
particles = generate_particles(ParticleProp, grid.X; domain=beam, alg=GridSampling())
particles.V⁰ .= volume(beam) / length(particles)
@. particles.m = ρ⁰ * particles.V⁰
Expand Down Expand Up @@ -87,7 +87,7 @@ function main()
t = 0.0
step = 0

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

for p in eachindex(particles, mpvalues)
update!(mpvalues[p], particles.x[p], grid.X)
Expand Down Expand Up @@ -122,7 +122,7 @@ function main()
U = copy(dofmap(grid.u)) # Convert grid data to plain vector data
compute_residual(U) = residual(U, state)
compute_jacobian(U) = jacobian(U, state)
Sequoia.newton!(U, compute_residual, compute_jacobian)
Tesserae.newton!(U, compute_residual, compute_jacobian)

## Grid dispacement, velocity and acceleration have been updated during Newton's iterations
@G2P grid=>i particles=>p mpvalues=>ip begin
Expand Down
8 changes: 4 additions & 4 deletions docs/literate/examples/implicit_jacobian_free.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# # Jacobian-free Newton--Krylov method

using Sequoia
using Tesserae

using IterativeSolvers: gmres!
using LinearMaps: LinearMap
Expand Down Expand Up @@ -59,7 +59,7 @@ function main()
grid = generate_grid(GridProp, CartesianMesh(h, (0.0,1.2), (0.0,2.0), (-0.2,0.2)))

## Particles
beam = Sequoia.Box((0,1), (0.85,1.15), (-0.15,0.15))
beam = Tesserae.Box((0,1), (0.85,1.15), (-0.15,0.15))
particles = generate_particles(ParticleProp, grid.X; domain=beam, alg=GridSampling())
particles.V⁰ .= volume(beam) / length(particles)
@. particles.m = ρ⁰ * particles.V⁰
Expand All @@ -86,7 +86,7 @@ function main()
t = 0.0
step = 0

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

for p in eachindex(particles, mpvalues)
update!(mpvalues[p], particles.x[p], grid.X)
Expand Down Expand Up @@ -121,7 +121,7 @@ function main()
U = copy(dofmap(grid.u)) # Convert grid data to plain vector data
compute_residual(U) = residual(U, state)
compute_jacobian(U) = jacobian(U, state)
Sequoia.newton!(U, compute_residual, compute_jacobian; linsolve = (x,A,b)->gmres!(x,A,b))
Tesserae.newton!(U, compute_residual, compute_jacobian; linsolve = (x,A,b)->gmres!(x,A,b))

## Grid dispacement, velocity and acceleration have been updated during Newton's iterations
@G2P grid=>i particles=>p mpvalues=>ip begin
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/examples/rigid_body_contact.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# # Frictional contact with rigid body

using Sequoia
using Tesserae

mutable struct Disk{dim, T}
x::Vec{dim, T}
Expand Down Expand Up @@ -109,7 +109,7 @@ function main()
fps = 20
savepoints = collect(LinRange(t, T, round(Int, T*fps)+1))

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

vmax = maximum(@. sqrt((λ+2G) / (particles.m/particles.V)) + norm(particles.v))
Δt = CFL * spacing(grid) / vmax
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/examples/tlmpm_vortex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# [^1]: [de Vaucorbeil, A., Nguyen, V.P. and Hutchinson, C.R., 2020. A Total-Lagrangian Material Point Method for solid mechanics problems involving large deformations. Computer Methods in Applied Mechanics and Engineering, 360, p.112783.](https://doi.org/10.1016/j.cma.2019.112783)

using Sequoia
using Tesserae

function main()

Expand Down Expand Up @@ -99,7 +99,7 @@ function main()
fps = 60
savepoints = collect(LinRange(t, T, round(Int, T*fps)+1))

Sequoia.@showprogress while t < T
Tesserae.@showprogress while t < T

## Calculate timestep based on the wave speed
vmax = maximum(@. sqrt((λ+2μ) / (particles.m/(particles.V⁰ * det(particles.F)))) + norm(particles.v))
Expand Down
10 changes: 5 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Documenter
using Sequoia
using Tesserae

ENV["PLOTS_TEST"] = "true"
ENV["GKSwstype"] = "100"

# Setup for doctests in docstrings
DocMeta.setdocmeta!(Sequoia, :DocTestSetup, :(using Sequoia); recursive=true)
DocMeta.setdocmeta!(Tesserae, :DocTestSetup, :(using Tesserae); recursive=true)

# generate documentation by Literate.jl
include("literate.jl")
Expand All @@ -14,8 +14,8 @@ makedocs(;
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
),
modules = [Sequoia],
sitename = "Sequoia.jl",
modules = [Tesserae],
sitename = "Tesserae.jl",
pages=[
"Home" => "index.md",
"getting_started.md",
Expand All @@ -33,6 +33,6 @@ makedocs(;
)

deploydocs(
repo = "github.com/KeitaNakamura/Sequoia.jl.git",
repo = "github.com/KeitaNakamura/Tesserae.jl.git",
devbranch = "main",
)
2 changes: 1 addition & 1 deletion docs/src/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Getting Started

```@example
using Sequoia
using Tesserae
import Plots
# Material constants
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Sequoia
# Tesserae
4 changes: 2 additions & 2 deletions src/Sequoia.jl → src/Tesserae.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Sequoia
module Tesserae

using Base: @propagate_inbounds, @_inline_meta, @_propagate_inbounds_meta
using Base.Broadcast: Broadcasted, ArrayStyle, DefaultArrayStyle
Expand Down Expand Up @@ -96,4 +96,4 @@ include("implicit.jl")

include("vtk.jl")

end # module Sequoia
end # module Tesserae
4 changes: 2 additions & 2 deletions src/blockspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ blocksize(gridsize::Tuple{Vararg{Int}}) = @. (gridsize-1)>>BLOCKFACTOR+1
blocksize(A::AbstractArray) = blocksize(size(A))

"""
Sequoia.whichblock(x::Vec, mesh::CartesianMesh)
Tesserae.whichblock(x::Vec, mesh::CartesianMesh)
Return block index where `x` locates.
The unit block size is `2^$BLOCKFACTOR` cells.
Expand All @@ -137,7 +137,7 @@ julia> mesh = CartesianMesh(1, (0,10), (0,10))
[9.0, 0.0] [9.0, 1.0] [9.0, 2.0] [9.0, 9.0] [9.0, 10.0]
[10.0, 0.0] [10.0, 1.0] [10.0, 2.0] … [10.0, 9.0] [10.0, 10.0]
julia> Sequoia.whichblock(Vec(8.5, 1.5), mesh)
julia> Tesserae.whichblock(Vec(8.5, 1.5), mesh)
CartesianIndex(2, 1)
```
"""
Expand Down
6 changes: 3 additions & 3 deletions src/implicit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ function P2G_Matrix_macro(schedule::QuoteNode, grid_pair, particles_pair, mpvalu
globalname = lhs.args[1]
localname = gensym(globalname)

Meta.isexpr(ex, :(=)) && push!(init_global_matrices, :(Sequoia.fillzero!($globalname)))
Meta.isexpr(ex, :(=)) && push!(init_global_matrices, :(Tesserae.fillzero!($globalname)))
push!(global_matrices, globalname)
push!(create_local_matrices, :($localname = Array{eltype($globalname)}(undef, length($localdofs), length($localdofs))))
push!(assemble_local_matrices, :(@inbounds $localname[$I,$J] .= $trySArray($rhs))) # converting `Tensor` to `SArray` is faster for setindex!
push!(add_local_to_global, :(Sequoia.add!($globalname, $dofs, $dofs, $localname)))
push!(add_local_to_global, :(Tesserae.add!($globalname, $dofs, $dofs, $localname)))
push!(assertions, :(@assert $globalname isa AbstractMatrix && size($globalname, 1) == size($globalname, 2)))
end
push!(assertions, :(@assert allequal($([:(size($m)) for m in global_matrices]...,))))
Expand All @@ -150,7 +150,7 @@ function P2G_Matrix_macro(schedule::QuoteNode, grid_pair, particles_pair, mpvalu
@assert Meta.isexpr(lhs, :ref) && all(lhs.args[2:end] .== i) # currently support only `A[i,i] = ...`
complete_parent_from_index!(ex.args[2], [grid=>i])
globalname = lhs.args[1]
push!(grid_sums, :(Sequoia.add!($globalname, $I, $I, $(ex.args[2]))))
push!(grid_sums, :(Tesserae.add!($globalname, $I, $I, $(ex.args[2]))))
end

body = quote
Expand Down
6 changes: 3 additions & 3 deletions src/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ end

function _generate_points(::Type{ParticleProp}, mesh::CartesianMesh{dim, T}, spacing::Real, alg::SamplingAlgorithm, ::Nothing) where {ParticleProp, dim, T}
domain = tuple.(Tuple(first(mesh)), Tuple(last(mesh)))
point_sampling(alg, Sequoia.spacing(mesh) * T(spacing), domain...)
point_sampling(alg, Tesserae.spacing(mesh) * T(spacing), domain...)
end
function _generate_points(::Type{ParticleProp}, mesh::CartesianMesh{dim, T}, spacing::Real, alg::GridSampling, box::Box) where {ParticleProp, dim, T}
domain = tuple.(Tuple(first(mesh)), Tuple(last(mesh)))
points = point_sampling(alg, Sequoia.spacing(mesh) * T(spacing), domain...)
points = point_sampling(alg, Tesserae.spacing(mesh) * T(spacing), domain...)
filter(x -> isinside(x, box), points)
end
function _generate_points(::Type{ParticleProp}, mesh::CartesianMesh{dim, T}, spacing::Real, alg::PoissonDiskSampling, box::Box) where {ParticleProp, dim, T}
points = point_sampling(alg, Sequoia.spacing(mesh) * T(spacing), box.domain...)
points = point_sampling(alg, Tesserae.spacing(mesh) * T(spacing), box.domain...)
end

function _reorder_particles!(particles::AbstractVector, mesh::CartesianMesh)
Expand Down
4 changes: 2 additions & 2 deletions src/sparray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ julia> A[1,1] # still zero
This is because the block where index `(1,1)` is located is not activated yet.
To activate the block, update sparsity pattern by `update_block_sparsity!(A, spy)`
where `spy` must have `Sequoia.blocksize(A)`.
where `spy` must have `Tesserae.blocksize(A)`.
```jldoctest sparray
julia> spy = trues(Sequoia.blocksize(A))
julia> spy = trues(Tesserae.blocksize(A))
1×1 BitMatrix:
1
Expand Down
10 changes: 5 additions & 5 deletions src/transfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function P2G_sum_macro(schedule::QuoteNode, grid_pair, particles_pair, mpvalues_
# `lhs` is, for example, `grid.m[i]`
lhs = ex.args[1]
if Meta.isexpr(ex, :(=))
push!(init_gridprops, :(Sequoia.fillzero!($(lhs.args[1]))))
push!(init_gridprops, :(Tesserae.fillzero!($(lhs.args[1]))))
end
push!(sum_names, lhs.args[1].args[2].value) # extract `m` for `grid.m[i]`
end
Expand Down Expand Up @@ -107,7 +107,7 @@ function P2G_expr(schedule::QuoteNode, grid, particles, mpvalues, space, p, body
if isnothing(space)
body = quote
$(schedule.value != :nothing) && @warn "@P2G: `BlockSpace` must be given for threaded computation" maxlog=1
for $p in Sequoia.eachparticleindex($particles, $mpvalues)
for $p in Tesserae.eachparticleindex($particles, $mpvalues)
$body
end
end
Expand All @@ -122,7 +122,7 @@ function P2G_expr(schedule::QuoteNode, grid, particles, mpvalues, space, p, body
body = :(@threaded $schedule $body)
end
body = quote
for $blocks in Sequoia.threadsafe_blocks($space)
for $blocks in Tesserae.threadsafe_blocks($space)
$body
end
end
Expand All @@ -140,7 +140,7 @@ function P2G_nosum_macro(schedule, grid_pair, nosum_equations::Vector)
foreach(ex->findarrays_from_index!(vars, i, ex), nosum_equations)

body = quote
Sequoia.foreach_gridindex(Val($schedule), Sequoia.GridIndexStyle($(vars...)), $grid) do $i
Tesserae.foreach_gridindex(Val($schedule), Tesserae.GridIndexStyle($(vars...)), $grid) do $i
Base.@_inline_meta
$(nosum_equations...)
end
Expand Down Expand Up @@ -244,7 +244,7 @@ function G2P_macro(schedule::QuoteNode, grid_pair, particles_pair, mpvalues_pair
if isallunderscore(mpvalues)
iterator = :(eachindex($particles))
else
iterator = :(Sequoia.eachparticleindex($particles, $mpvalues))
iterator = :(Tesserae.eachparticleindex($particles, $mpvalues))
end

if schedule.value == :nothing
Expand Down
2 changes: 1 addition & 1 deletion test/LocalPreferences.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Sequoia]
[Tesserae]
debug_mode = true
block_factor = 3
threaded_macro = true
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sequoia = "30a04e26-4a89-4862-aa00-4d71e820c402"
Tesserae = "fd374396-9d9c-4d88-9aa5-37a7f6105aca"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6 changes: 3 additions & 3 deletions test/blockspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
(x-1.5)^2 + (y-2)^2 < 1
end
blockspace = (@inferred BlockSpace(mesh))
@test size(blockspace) === Sequoia.blocksize(mesh)
@test size(blockspace) === Tesserae.blocksize(mesh)
@test all(isempty, blockspace)
@test typeof(blockspace[1]) === eltype(blockspace)
update!(blockspace, xₚ)
ptsinblks = map(_->Int[], CartesianIndices(Sequoia.blocksize(mesh)))
ptsinblks = map(_->Int[], CartesianIndices(Tesserae.blocksize(mesh)))
for p in eachindex(xₚ)
I = Sequoia.whichblock(xₚ[p], mesh)
I = Tesserae.whichblock(xₚ[p], mesh)
I === nothing || push!(ptsinblks[I], p)
end
@test blockspace == ptsinblks
Expand Down
Loading

0 comments on commit 34abba0

Please sign in to comment.