Skip to content

Commit 7f17845

Browse files
Merge branch 'main' into l1-gs-smoother
2 parents 457c110 + 10fa36d commit 7f17845

44 files changed

Lines changed: 1849 additions & 708 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
1010
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
1111
Ferrite = "c061ca5d-56c9-439f-9c0e-210fe06d3992"
1212
FerriteGmsh = "4f95f4f8-b27c-4ae5-9a39-ea55e634e36b"
13+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1314
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1415
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1516
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -44,6 +45,8 @@ BlockArrays = "1"
4445
DiffEqBase = "6"
4546
FastBroadcast = "0.3.5"
4647
Ferrite = "1"
48+
ForwardDiff = "0.10.38"
49+
JET = "0.9"
4750
LinearSolve = "2"
4851
Logging = "1.10"
4952
ModelingToolkit = "9"

bak/examples/Manifest.toml

Lines changed: 140 additions & 138 deletions
Large diffs are not rendered by default.

bak/examples/conduction-velocity-benchmark.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ odeform = semidiscretize(
6363
u₀ = zeros(Float32, OS.function_size(odeform))
6464
steady_state_initializer!(u₀, odeform)
6565

66-
# io = ParaViewWriter("spiral-wave-test")
67-
6866
timestepper = #Thunderbolt.ReactionTangentController(
6967
OS.LieTrotterGodunov((
7068
BackwardEulerSolver(
@@ -87,19 +85,20 @@ integrator = OS.init(problem, timestepper, dt=dt₀, verbose=true)
8785
TimerOutputs.enable_debug_timings(Thunderbolt)
8886
step!(integrator) # precompile for benchmark below
8987

88+
io = ParaViewWriter("Niederer-Test")
9089
TimerOutputs.reset_timer!()
9190
for (u, t) in OS.TimeChoiceIterator(integrator, tspan[1]:dtvis:tspan[2])
92-
# dh = odeform.functions[1].dh
93-
# φ = u[odeform.dof_ranges[1]]
94-
# @info t,norm(u)
91+
dh = odeform.functions[1].dh
92+
φ = u[odeform.solution_indices[1]]
93+
@info t,norm(u)
9594
# sflat = ....?
96-
# store_timestep!(io, t, dh.grid) do file
97-
# Thunderbolt.store_timestep_field!(file, t, dh, φ, :φₘ)
98-
# # s = reshape(sflat, (Thunderbolt.num_states(ionic_model),length(φ)))
99-
# # for sidx in 1:Thunderbolt.num_states(ionic_model)
100-
# # Thunderbolt.store_timestep_field!(io, t, dh, s[sidx,:], state_symbol(ionic_model, sidx))
101-
# # end
102-
# end
95+
store_timestep!(io, t, dh.grid) do file
96+
Thunderbolt.store_timestep_field!(file, t, dh, φ, :φₘ)
97+
# s = reshape(sflat, (Thunderbolt.num_states(ionic_model),length(φ)))
98+
# for sidx in 1:Thunderbolt.num_states(ionic_model)
99+
# Thunderbolt.store_timestep_field!(io, t, dh, s[sidx,:], state_symbol(ionic_model, sidx))
100+
# end
101+
end
103102
end
104103
TimerOutputs.print_timer()
105104
# TimerOutputs.disable_debug_timings(Thunderbolt)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Thunderbolt
2+
using Thunderbolt.TimerOutputs
3+
4+
TimerOutputs.enable_debug_timings(Thunderbolt)
5+
6+
mesh = generate_mesh(Hexahedron, (4,4,4))
7+
material = Thunderbolt.LinearMaxwellMaterial(
8+
E₀ = 70e3,
9+
E₁ = 20e3,
10+
μ = 1e3,
11+
η₁ = 1e3,
12+
ν = 0.3,
13+
)
14+
tspan = (0.0,1.0)
15+
Δt = 0.1
16+
17+
# Clamp three sides
18+
dbcs = [
19+
Dirichlet(:d, getfacetset(mesh, "left"), (x,t) -> (0.0, 0.0, 0.0), [1,2,3]),
20+
Dirichlet(:d, getfacetset(mesh, "right"), (x,t) -> (0.1, 0.0, 0.0), [1,2,3]),
21+
]
22+
23+
quasistaticform = semidiscretize(
24+
QuasiStaticModel(:d, material, ()),
25+
FiniteElementDiscretization(
26+
Dict(:d => (LagrangeCollection{1}()^3 => QuadratureRuleCollection(2))),
27+
dbcs,
28+
),
29+
mesh
30+
)
31+
problem = QuasiStaticProblem(quasistaticform, tspan)
32+
33+
# Create sparse matrix and residual vector
34+
timestepper = BackwardEulerSolver(;
35+
inner_solver=Thunderbolt.MultiLevelNewtonRaphsonSolver(;
36+
# global_newton=NewtonRaphsonSolver(),
37+
# local_newton=NewtonRaphsonSolver(),
38+
)
39+
)
40+
integrator = init(problem, timestepper, dt=Δt, verbose=true)
41+
42+
step!(integrator) # Precompile
43+
44+
TimerOutputs.reset_timer!()
45+
solve!(integrator)
46+
TimerOutputs.print_timer()
47+
48+
cc = first(CellIterator(mesh.grid))
49+
F = one(Tensor{2,3})
50+
coefficient = nothing
51+
qr = QuadratureRule{RefHexahedron}(2)
52+
element_cache = Thunderbolt.setup_element_cache(integrator.cache.stage.nlsolver.global_solver_cache.op.integrator.volume_model, qr, integrator.cache.stage.nlsolver.global_solver_cache.op.dh.subdofhandlers[1])
53+
state_cache = element_cache.internal_cache
54+
qp = QuadraturePoint(1, qr.points[1])
55+
56+
using BenchmarkTools
57+
@btime Thunderbolt.solve_local_constraint(F, coefficient, material, state_cache, cc, qp, 0.0)
58+
@btime Thunderbolt._query_local_state(state_cache, cc, qp)

0 commit comments

Comments
 (0)