Skip to content

Commit a920040

Browse files
committed
fixup! use adapt_structure macro where-ever possible
1 parent f6866b0 commit a920040

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

src/semidiscretization/semidiscretization_hyperbolic.jl

+12-30
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ mutable struct SemidiscretizationHyperbolic{Mesh, Equations, InitialCondition,
3737
source_terms::SourceTerms,
3838
solver::Solver,
3939
cache::Cache,
40-
performance_counter::PerformanceCounter) where {Mesh, Equations,
41-
InitialCondition,
42-
BoundaryConditions,
43-
SourceTerms,
44-
Solver,
45-
Cache}
40+
performance_counter::PerformanceCounter) where {
41+
Mesh,
42+
Equations,
43+
InitialCondition,
44+
BoundaryConditions,
45+
SourceTerms,
46+
Solver,
47+
Cache
48+
}
4649
new(mesh, equations, initial_condition, boundary_conditions, source_terms,
4750
solver, cache, performance_counter)
4851
end
@@ -83,7 +86,8 @@ function SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver
8386
initial_condition,
8487
_boundary_conditions,
8588
source_terms, solver,
86-
cache, performance_counter)
89+
cache,
90+
performance_counter)
8791
end
8892

8993
# Create a new semidiscretization but change some parameters compared to the input.
@@ -105,29 +109,7 @@ function remake(semi::SemidiscretizationHyperbolic; uEltype = real(semi.solver),
105109
source_terms, boundary_conditions, uEltype)
106110
end
107111

108-
function Adapt.adapt_structure(to, semi::SemidiscretizationHyperbolic)
109-
if !(typeof(semi.mesh) <: P4estMesh)
110-
error("Adapt.adapt is only supported for semidiscretizations based on P4estMesh")
111-
end
112-
113-
mesh = semi.mesh
114-
equations = Adapt.adapt_structure(to, semi.equations)
115-
initial_condition = Adapt.adapt_structure(to, semi.initial_condition)
116-
boundary_conditions = Adapt.adapt_structure(to, semi.boundary_conditions)
117-
source_terms = Adapt.adapt_structure(to, semi.source_terms)
118-
solver = Adapt.adapt_structure(to, semi.solver)
119-
cache = Adapt.adapt_structure(to, semi.cache)
120-
performance_counter = semi.performance_counter
121-
122-
SemidiscretizationHyperbolic{typeof(mesh), typeof(equations),
123-
typeof(initial_condition),
124-
typeof(boundary_conditions), typeof(source_terms),
125-
typeof(solver), typeof(cache)}(mesh, equations,
126-
initial_condition,
127-
boundary_conditions,
128-
source_terms, solver,
129-
cache, performance_counter)
130-
end
112+
Adapt.@adapt_structure(SemidiscretizationHyperbolic)
131113

132114
# general fallback
133115
function digest_boundary_conditions(boundary_conditions, mesh, solver, cache)

src/solvers/dgsem_p4est/containers.jl

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ end
447447
function KernelAbstractions.get_backend(boundaries::P4estBoundaryContainer)
448448
return KernelAbstractions.get_backend(boundaries.u)
449449
end
450+
#Adapt.@adapt_structure(P4estBoundaryContainer)
450451
function Adapt.adapt_structure(to, boundaries::P4estBoundaryContainer)
451452
_u = Adapt.adapt_structure(to, boundaries._u)
452453
u = unsafe_wrap_or_alloc(to, _u, size(boundaries.u))

0 commit comments

Comments
 (0)