Skip to content

Commit

Permalink
run runic
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Oct 25, 2024
1 parent f6edc3f commit eb2b2a7
Show file tree
Hide file tree
Showing 94 changed files with 6,706 additions and 6,201 deletions.
42 changes: 21 additions & 21 deletions benchmark/benchmarks-assembly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ SUITE["assembly"] = BenchmarkGroup()
# Permute over common combinations for some commonly required local matrices.
SUITE["assembly"]["common-local"] = BenchmarkGroup()
COMMON_LOCAL_ASSEMBLY = SUITE["assembly"]["common-local"]
for spatial_dim 1:3
ξ_dummy = Vec{spatial_dim}(ntuple(x->0.0, spatial_dim))
COMMON_LOCAL_ASSEMBLY["spatial-dim",spatial_dim] = BenchmarkGroup()
for geo_type FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
COMMON_LOCAL_ASSEMBLY["spatial-dim",spatial_dim][string(geo_type)] = BenchmarkGroup()
for spatial_dim in 1:3
ξ_dummy = Vec{spatial_dim}(ntuple(x -> 0.0, spatial_dim))
COMMON_LOCAL_ASSEMBLY["spatial-dim", spatial_dim] = BenchmarkGroup()
for geo_type in FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
COMMON_LOCAL_ASSEMBLY["spatial-dim", spatial_dim][string(geo_type)] = BenchmarkGroup()

grid = generate_grid(geo_type, tuple(repeat([2], spatial_dim)...));
grid = generate_grid(geo_type, tuple(repeat([2], spatial_dim)...))
topology = ExclusiveTopology(grid)
ip_geo = Ferrite.geometric_interpolation(geo_type)
ref_type = FerriteBenchmarkHelper.getrefshape(geo_type)

# Nodal interpolation tests
for order 1:2, ip_type [Lagrange, Serendipity]
for order in 1:2, ip_type in [Lagrange, Serendipity]
ip_type == Serendipity && (order < 2 || ref_type (RefQuadrilateral, RefHexahedron)) && continue
ip = ip_type{ref_type, order}()
ip_vectorized = ip^spatial_dim

# Skip over elements which are not implemented
!applicable(Ferrite.shape_value, ip, ξ_dummy, 1) && continue

qr = QuadratureRule{ref_type}(2*order-1)
qr = QuadratureRule{ref_type}(2 * order - 1)

# Currently we just benchmark nodal Lagrange bases.
COMMON_LOCAL_ASSEMBLY["spatial-dim",spatial_dim][string(geo_type)][string(ip_type),string(order)] = BenchmarkGroup()
LAGRANGE_SUITE = COMMON_LOCAL_ASSEMBLY["spatial-dim",spatial_dim][string(geo_type)][string(ip_type),string(order)]
COMMON_LOCAL_ASSEMBLY["spatial-dim", spatial_dim][string(geo_type)][string(ip_type), string(order)] = BenchmarkGroup()
LAGRANGE_SUITE = COMMON_LOCAL_ASSEMBLY["spatial-dim", spatial_dim][string(geo_type)][string(ip_type), string(order)]
LAGRANGE_SUITE["fe-values"] = BenchmarkGroup()
LAGRANGE_SUITE["ritz-galerkin"] = BenchmarkGroup()
LAGRANGE_SUITE["petrov-galerkin"] = BenchmarkGroup()

# Note: at the time of writing this PR the ctor makes the heavy lifting and caches important values.
LAGRANGE_SUITE["fe-values"]["scalar"] = @benchmarkable CellValues($qr, $ip, $ip_geo);
LAGRANGE_SUITE["fe-values"]["vector"] = @benchmarkable CellValues($qr, $ip_vectorized, $ip_geo);
LAGRANGE_SUITE["fe-values"]["scalar"] = @benchmarkable CellValues($qr, $ip, $ip_geo)
LAGRANGE_SUITE["fe-values"]["vector"] = @benchmarkable CellValues($qr, $ip_vectorized, $ip_geo)

csv = CellValues(qr, ip, ip_geo);
csv2 = CellValues(qr, ip, ip_geo);
csv = CellValues(qr, ip, ip_geo)
csv2 = CellValues(qr, ip, ip_geo)

cvv = CellValues(qr, ip_vectorized, ip_geo);
cvv2 = CellValues(qr, ip_vectorized, ip_geo);
cvv = CellValues(qr, ip_vectorized, ip_geo)
cvv2 = CellValues(qr, ip_vectorized, ip_geo)

# Scalar shape φ and test ψ: ∫ φ ψ
LAGRANGE_SUITE["ritz-galerkin"]["mass"] = @benchmarkable FerriteAssemblyHelper._generalized_ritz_galerkin_assemble_local_matrix($grid, $csv, shape_value, shape_value, *)
Expand All @@ -61,16 +61,16 @@ for spatial_dim ∈ 1:3
LAGRANGE_SUITE["petrov-galerkin"]["pressure-velocity"] = @benchmarkable FerriteAssemblyHelper._generalized_petrov_galerkin_assemble_local_matrix($grid, $cvv, shape_divergence, $csv, shape_value, *)

if spatial_dim > 1
qr_facet = FacetQuadratureRule{ref_type}(2*order-1)
fsv = FacetValues(qr_facet, ip, ip_geo);
fsv2 = FacetValues(qr_facet, ip, ip_geo);
qr_facet = FacetQuadratureRule{ref_type}(2 * order - 1)
fsv = FacetValues(qr_facet, ip, ip_geo)
fsv2 = FacetValues(qr_facet, ip, ip_geo)

LAGRANGE_SUITE["ritz-galerkin"]["face-flux"] = @benchmarkable FerriteAssemblyHelper._generalized_ritz_galerkin_assemble_local_matrix($grid, $fsv, shape_gradient, shape_value, *)
LAGRANGE_SUITE["petrov-galerkin"]["face-flux"] = @benchmarkable FerriteAssemblyHelper._generalized_petrov_galerkin_assemble_local_matrix($grid, $fsv, shape_gradient, $fsv2, shape_value, *)

ip = DiscontinuousLagrange{ref_type, order}()
isv = InterfaceValues(qr_facet, ip, ip_geo);
isv2 = InterfaceValues(qr_facet, ip, ip_geo);
isv = InterfaceValues(qr_facet, ip, ip_geo)
isv2 = InterfaceValues(qr_facet, ip, ip_geo)
dh = DofHandler(grid)
add!(dh, :u, ip)
close!(dh)
Expand Down
30 changes: 15 additions & 15 deletions benchmark/benchmarks-boundary-conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ SUITE["boundary-conditions"] = BenchmarkGroup()
SUITE["boundary-conditions"]["Dirichlet"] = BenchmarkGroup()
DIRICHLET_SUITE = SUITE["boundary-conditions"]["Dirichlet"]
# span artificial scope...
for spatial_dim [2]
for spatial_dim in [2]
# Benchmark application on global system
DIRICHLET_SUITE["global"] = BenchmarkGroup()

geo_type = Quadrilateral
grid = generate_grid(geo_type, ntuple(x->2, spatial_dim));
grid = generate_grid(geo_type, ntuple(x -> 2, spatial_dim))
ref_type = FerriteBenchmarkHelper.getrefshape(geo_type)
ip_geo = Ferrite.geometric_interpolation(geo_type)
order = 2

# assemble a mass matrix to apply BCs on (because its cheap)
ip = Lagrange{ref_type, order}()
qr = QuadratureRule{ref_type}(2*order-1)
cellvalues = CellValues(qr, ip, ip_geo);
qr = QuadratureRule{ref_type}(2 * order - 1)
cellvalues = CellValues(qr, ip, ip_geo)
dh = DofHandler(grid)
push!(dh, :u, 1, ip)
close!(dh);
close!(dh)

ch = ConstraintHandler(dh);
∂Ω = union(getfacetset.((grid, ), ["left"])...);
ch = ConstraintHandler(dh)
∂Ω = union(getfacetset.((grid,), ["left"])...)
dbc = Dirichlet(:u, ∂Ω, (x, t) -> 0)
add!(ch, dbc);
close!(ch);
add!(ch, dbc)
close!(ch)

# Non-symmetric application
M, f = FerriteAssemblyHelper._assemble_mass(dh, cellvalues, false);
DIRICHLET_SUITE["global"]["apply!(M,f)"] = @benchmarkable apply!($M, $f, $ch);
M, f = FerriteAssemblyHelper._assemble_mass(dh, cellvalues, false)
DIRICHLET_SUITE["global"]["apply!(M,f)"] = @benchmarkable apply!($M, $f, $ch)
# Symmetric application
M, f = FerriteAssemblyHelper._assemble_mass(dh, cellvalues, true);
DIRICHLET_SUITE["global"]["apply!(M_sym,f)"] = @benchmarkable apply!($M, $f, $ch);
M, f = FerriteAssemblyHelper._assemble_mass(dh, cellvalues, true)
DIRICHLET_SUITE["global"]["apply!(M_sym,f)"] = @benchmarkable apply!($M, $f, $ch)

DIRICHLET_SUITE["global"]["apply!(f)"] = @benchmarkable apply!($f, $ch);
DIRICHLET_SUITE["global"]["apply_zero!(f)"] = @benchmarkable apply!($f, $ch);
DIRICHLET_SUITE["global"]["apply!(f)"] = @benchmarkable apply!($f, $ch)
DIRICHLET_SUITE["global"]["apply_zero!(f)"] = @benchmarkable apply!($f, $ch)
end
45 changes: 22 additions & 23 deletions benchmark/benchmarks-dofs.jl
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@

#----------------------------------------------------------------------#
# Benchmarks around the dof management
#----------------------------------------------------------------------#
SUITE["dof-management"] = BenchmarkGroup()
SUITE["dof-management"]["numbering"] = BenchmarkGroup()
# !!! NOTE close! must wrapped into a custom function, because consecutive calls to close!, since the dofs are already distributed.
NUMBERING_SUITE = SUITE["dof-management"]["numbering"]
for spatial_dim [3]# 1:3
NUMBERING_SUITE["spatial-dim",spatial_dim] = BenchmarkGroup()
for geo_type FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
NUMBERING_SUITE["spatial-dim",spatial_dim][string(geo_type)] = BenchmarkGroup()
for spatial_dim in [3] # 1:3
NUMBERING_SUITE["spatial-dim", spatial_dim] = BenchmarkGroup()
for geo_type in FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
NUMBERING_SUITE["spatial-dim", spatial_dim][string(geo_type)] = BenchmarkGroup()

ref_type = FerriteBenchmarkHelper.getrefshape(geo_type)

for grid_size [2]#[3, 6, 9] #multiple grid sized to estimate computational complexity...
NUMBERING_SUITE["spatial-dim",spatial_dim][string(geo_type)]["grid-size-",grid_size] = BenchmarkGroup()
NUMBERING_SUITE["spatial-dim",spatial_dim][string(geo_type)]["grid-size-",grid_size] = BenchmarkGroup()
for grid_size in [2] #[3, 6, 9] #multiple grid sized to estimate computational complexity...
NUMBERING_SUITE["spatial-dim", spatial_dim][string(geo_type)]["grid-size-", grid_size] = BenchmarkGroup()
NUMBERING_SUITE["spatial-dim", spatial_dim][string(geo_type)]["grid-size-", grid_size] = BenchmarkGroup()

grid = generate_grid(geo_type, ntuple(x->grid_size, spatial_dim));
grid = generate_grid(geo_type, ntuple(x -> grid_size, spatial_dim))

for field_dim [3]#1:3
NUMBERING_SUITE["spatial-dim",spatial_dim][string(geo_type)]["grid-size-",grid_size]["field-dim-", field_dim] = BenchmarkGroup()
NUMBERING_FIELD_DIM_SUITE = NUMBERING_SUITE["spatial-dim",spatial_dim][string(geo_type)]["grid-size-",grid_size]["field-dim-", field_dim]
for field_dim in [3] #1:3
NUMBERING_SUITE["spatial-dim", spatial_dim][string(geo_type)]["grid-size-", grid_size]["field-dim-", field_dim] = BenchmarkGroup()
NUMBERING_FIELD_DIM_SUITE = NUMBERING_SUITE["spatial-dim", spatial_dim][string(geo_type)]["grid-size-", grid_size]["field-dim-", field_dim]
# Lagrange tests
for order 1:2
for order in 1:2
ip = Lagrange{ref_type, order}()

# Skip over elements which are not implemented
ξ_dummy = Vec{spatial_dim}(ntuple(x->0.0, spatial_dim))
ξ_dummy = Vec{spatial_dim}(ntuple(x -> 0.0, spatial_dim))
!applicable(Ferrite.shape_value, ip, ξ_dummy, 1) && continue

NUMBERING_FIELD_DIM_SUITE["Lagrange",order] = BenchmarkGroup()
LAGRANGE_SUITE = NUMBERING_FIELD_DIM_SUITE["Lagrange",order]
order2 = max(order-1, 1)
NUMBERING_FIELD_DIM_SUITE["Lagrange", order] = BenchmarkGroup()
LAGRANGE_SUITE = NUMBERING_FIELD_DIM_SUITE["Lagrange", order]
order2 = max(order - 1, 1)
ip2 = Lagrange{ref_type, order2}()

LAGRANGE_SUITE["DofHandler"] = BenchmarkGroup()

close_helper = function(grid, ip)
dh = DofHandler(grid)
push!(dh, :u, field_dim, ip)
close!(dh)
return close!(dh)
end
LAGRANGE_SUITE["DofHandler"]["one-field"] = @benchmarkable $close_helper($grid, $ip)

close_helper = function(grid, ip, ip2)
dh = DofHandler(grid)
push!(dh, :u, field_dim, ip)
push!(dh, :p, 1, ip2)
close!(dh)
return close!(dh)
end
LAGRANGE_SUITE["DofHandler"]["two-fields"] = @benchmarkable $close_helper($grid, $ip, $ip2)

close_helper = function(grid)
dh = DofHandler(grid)
sdh = SubDofHandler(dh, Set(1:Int(round(getncells(grid)/2))))
sdh = SubDofHandler(dh, Set(1:Int(round(getncells(grid) / 2))))
add!(sdh, :u, ip^field_dim)
close!(dh)
return close!(dh)
end
LAGRANGE_SUITE["DofHandler"]["one-field-subdomain"] = @benchmarkable $close_helper($grid)

close_helper = function(grid)
dh = DofHandler(grid)
sdh = SubDofHandler(dh, Set(1:Int(round(getncells(grid)/2))))
sdh = SubDofHandler(dh, Set(1:Int(round(getncells(grid) / 2))))
add!(sdh, :u, ip^field_dim)
add!(sdh, :p, ip2)
close!(dh)
return close!(dh)
end
LAGRANGE_SUITE["DofHandler"]["two-fields-subdomain"] = @benchmarkable $close_helper($grid)
end
Expand Down
9 changes: 4 additions & 5 deletions benchmark/benchmarks-mesh.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#----------------------------------------------------------------------#
# Benchmarks for mesh functionality within Ferrite
#----------------------------------------------------------------------#
Expand All @@ -10,10 +9,10 @@ SUITE["mesh"]["generator"] = BenchmarkGroup()
# Structured hyperrectangle generators
SUITE["mesh"]["generator"]["hyperrectangle"] = BenchmarkGroup()
HYPERRECTANGLE_GENERATOR = SUITE["mesh"]["generator"]["hyperrectangle"]
for spatial_dim 1:3
HYPERRECTANGLE_GENERATOR["spatial-dim",spatial_dim] = BenchmarkGroup()
for geo_type FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
HYPERRECTANGLE_GENERATOR["spatial-dim",spatial_dim][string(geo_type)] = @benchmarkable generate_grid($geo_type, $(ntuple(x->4, spatial_dim)));
for spatial_dim in 1:3
HYPERRECTANGLE_GENERATOR["spatial-dim", spatial_dim] = BenchmarkGroup()
for geo_type in FerriteBenchmarkHelper.geo_types_for_spatial_dim(spatial_dim)
HYPERRECTANGLE_GENERATOR["spatial-dim", spatial_dim][string(geo_type)] = @benchmarkable generate_grid($geo_type, $(ntuple(x -> 4, spatial_dim)))
end
end

Expand Down
Loading

0 comments on commit eb2b2a7

Please sign in to comment.