Skip to content

Commit

Permalink
Introduce collections in spiral wave example.
Browse files Browse the repository at this point in the history
  • Loading branch information
termi-official committed Sep 26, 2023
1 parent 3e9efab commit 31016f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/spiral-wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,24 @@ function setup_initial_condition!(problem::SplitProblem, cache, initial_conditio
end

struct GalerkinDiscretization
# TODO interpolation collection instead of single interpolation
interpolations::Dict{Symbol, Interpolation}
interpolations::Dict{Symbol, Thunderbolt.InterpolationCollection}
end

"""
semidiscretize(model, discretization, mesh)
Transform a space-time model into a pure time-dependent problem.
"""
semidiscretize

function semidiscretize(split::ReactionDiffusionSplit{MonodomainModel{A,B,C,D,E}}, discretization::GalerkinDiscretization, grid::Thunderbolt.AbstractGrid) where {A,B,C,D,E}
epmodel = split.model

ets = elementtypes(grid)
@assert length(ets) == 1

# TODO get these from the interpolation collection in GalerkinDiscretization
ip = Lagrange{RefQuadrilateral, 1}()
ip = getinterpolation(discretization.interpolations[:φₘ], ets[1])
dh = DofHandler(grid)
push!(dh, :ϕₘ, ip)
close!(dh);
Expand Down
2 changes: 2 additions & 0 deletions src/Thunderbolt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ using JLD2
import Ferrite: AbstractDofHandler, AbstractGrid, AbstractRefShape, AbstractCell
import Ferrite: vertices, edges, faces, sortedge, sortface

include("collections.jl")

include("mesh/meshes.jl")
include("mesh/coordinate_systems.jl")
include("mesh/tools.jl")
Expand Down
8 changes: 8 additions & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export
# Collections
LagrangeCollection,
getinterpolation,
QuadratureRuleCollection,
getquadraturerule,
CellValueCollection,
FaceValueCollection,
# Mesh generators
generate_mesh,
generate_ring_mesh,
Expand Down Expand Up @@ -53,6 +60,7 @@ export
LoadDrivenSolver,
# Utils
calculate_volume_deformed_mesh,
elementtypes,
value,
# IO
ParaViewWriter,
Expand Down
6 changes: 6 additions & 0 deletions src/mesh/meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ num_faces(mgrid::SimpleMesh3D) = length(mgrid.mfaces)
num_edges(mgrid::SimpleMesh3D) = length(mgrid.medges)
num_vertices(mgrid::SimpleMesh3D) = length(mgrid.mvertices)

elementtypes(::SimpleMesh3D{Tetrahedron}) = @SVector [Tetrahedron]
elementtypes(::SimpleMesh3D{Hexahedron}) = @SVector [Hexahedron]

function to_mesh(grid::Grid{3,C,T}) where {C, T}
mfaces = OrderedDict{NTuple{3,Int}, Int}()
medges = OrderedDict{NTuple{2,Int}, Int}()
Expand Down Expand Up @@ -124,6 +127,9 @@ num_nodes(mgrid::SimpleMesh2D) = length(mgrid.grid.nodes)
num_faces(mgrid::SimpleMesh2D) = length(mgrid.mfaces)
num_vertices(mgrid::SimpleMesh2D) = length(mgrid.mvertices)

elementtypes(::SimpleMesh2D{Triangle}) = @SVector [Triangle]
elementtypes(::SimpleMesh2D{Quadrilateral}) = @SVector [Quadrilateral]

# Ferrite compat layer for the mesh
@inline Ferrite.getncells(mesh::Union{SimpleMesh2D,SimpleMesh3D}) = Ferrite.getncells(mesh.grid)
@inline Ferrite.getcells(mesh::Union{SimpleMesh2D,SimpleMesh3D}) = Ferrite.getcells(mesh.grid)
Expand Down

0 comments on commit 31016f9

Please sign in to comment.