Skip to content

Commit 10fa36d

Browse files
Remove CoordinateSystemCoefficient (#202)
1 parent 7eafcc1 commit 10fa36d

14 files changed

Lines changed: 32 additions & 41 deletions

docs/src/api-reference/models.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ FieldCoefficient
1212
AnalyticalCoefficient
1313
SpectralTensorCoefficient
1414
SpatiallyHomogeneousDataField
15-
CoordinateSystemCoefficient
1615
evaluate_coefficient
1716
```
1817

docs/src/literate-howto/custom-stimulation-protocols.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function (protocol::SimpleS1S2Protocol)(x,t)
2929
end
3030

3131
# It is now possible to use the protocol as follows
32-
coordinate_system_coefficient = CoordinateSystemCoefficient(CartesianCoordinateSystem{3}()) # Or some cardiac coordinate system
32+
coordinate_system_coefficient = CartesianCoordinateSystem{3}() # Or some cardiac coordinate system
3333
stimulus_around_zero(x,t) = max(1.0-norm(x),0.0)
3434
stimulus_around_one(x,t) = max(1.0-norm(x+one(x)),0.0)
3535
s1s2fun = SimpleS1S2Protocol(

docs/src/literate-tutorials/cm01_simple-active-stress.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function calcium_profile_function(x::LVCoordinate,t)
7474
end
7575
calcium_field = AnalyticalCoefficient(
7676
calcium_profile_function,
77-
CoordinateSystemCoefficient(coordinate_system),
77+
coordinate_system,
7878
);
7979

8080
# We will use for a very simple sarcomere model which is constant in the calcium concentration.

docs/src/literate-tutorials/cm03_3d0d-coupling.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function calcium_profile_function(x::LVCoordinate,t)
276276
end
277277
calcium_field = AnalyticalCoefficient(
278278
calcium_profile_function,
279-
CoordinateSystemCoefficient(coordinate_system),
279+
coordinate_system,
280280
)
281281
sarcomere_model = CaDrivenInternalSarcomereModel(ConstantStretchModel(), calcium_field)
282282
active_stress_model = ActiveStressModel(

docs/src/literate-tutorials/ep04_geselowitz-ecg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
protocol = Thunderbolt.AnalyticalTransmembraneStimulationProtocol(
5252
AnalyticalCoefficient(
5353
UniformEndocardialActivation(),
54-
CoordinateSystemCoefficient(CartesianCoordinateSystem{3}())
54+
CartesianCoordinateSystem{3}()
5555
),
5656
[SVector((-Inf, Inf))],
5757
)

src/Thunderbolt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export
103103
FieldCoefficient,
104104
AnalyticalCoefficient,
105105
FieldCoefficient,
106-
CoordinateSystemCoefficient,
107106
SpectralTensorCoefficient,
108107
SpatiallyHomogeneousDataField,
109108
evaluate_coefficient,
@@ -197,6 +196,7 @@ export
197196
# Coordinate system
198197
LVCoordinateSystem,
199198
LVCoordinate,
199+
BiVCoordinateSystem,
200200
BiVCoordinate,
201201
CartesianCoordinateSystem,
202202
compute_lv_coordinate_system,

src/modeling/core/coefficients.jl

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,8 @@ function duplicate_for_parallel(cache::ConductivityToDiffusivityCoefficientCache
105105
)
106106
end
107107

108-
"""
109-
CoordinateSystemCoefficient(coordinate_system)
110-
111-
Helper to obtain the location in some possibly problem-specific coordinate system, e.g. for analytical coefficients (see [`AnalyticalCoefficient`](@ref)).
112-
"""
113-
struct CoordinateSystemCoefficient{CS}
114-
cs::CS
115-
end
116-
117108
function compute_nodal_values(csc::CoordinateSystemCoefficient, dh::DofHandler, field_name::Symbol)
118-
Tv = value_type(csc.cs)
109+
Tv = value_type(csc)
119110
nodal_values = Vector{Tv}(UndefInitializer(), ndofs(dh))
120111
T = eltype(Tv)
121112
for sdh in dh.subdofhandlers
@@ -147,12 +138,12 @@ end
147138

148139
duplicate_for_parallel(cache::CartesianCoordinateSystemCache) = cache
149140

150-
function setup_coefficient_cache(coefficient::CoordinateSystemCoefficient{<:CartesianCoordinateSystem}, qr::QuadratureRule{<:Any, <:AbstractArray{T}}, sdh::SubDofHandler) where T
141+
function setup_coefficient_cache(cs::CartesianCoordinateSystem, qr::QuadratureRule{<:Any, <:AbstractArray{T}}, sdh::SubDofHandler) where T
151142
cell = get_first_cell(sdh)
152-
ip = getcoordinateinterpolation(coefficient.cs, cell)
143+
ip = getcoordinateinterpolation(cs, cell)
153144
fv = Ferrite.FunctionValues{0}(T, ip.ip, qr, ip) # We scalarize the interpolation again as an optimization step
154145
Nξs = size(fv.Nξ)
155-
return CartesianCoordinateSystemCache(coefficient.cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
146+
return CartesianCoordinateSystemCache(cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
156147
end
157148

158149
function evaluate_coefficient(coeff::CartesianCoordinateSystemCache{<:CartesianCoordinateSystem{sdim}}, geometry_cache::FerriteUtils.AnyCellCache, qp::QuadraturePoint{<:Any,T}, t) where {sdim, T}
@@ -172,13 +163,13 @@ end
172163

173164
duplicate_for_parallel(cache::LVCoordinateSystemCache) = cache
174165

175-
function setup_coefficient_cache(coefficient::CoordinateSystemCoefficient{<:LVCoordinateSystem}, qr::QuadratureRule{<:Any, <:AbstractArray{T}}, sdh::SubDofHandler) where T
166+
function setup_coefficient_cache(cs::LVCoordinateSystem, qr::QuadratureRule{<:Any, <:AbstractArray{T}}, sdh::SubDofHandler) where T
176167
cell = get_first_cell(sdh)
177-
ip = getcoordinateinterpolation(coefficient.cs, cell)
168+
ip = getcoordinateinterpolation(cs, cell)
178169
ip_geo = ip^3
179170
fv = Ferrite.FunctionValues{0}(T, ip, qr, ip_geo)
180171
Nξs = size(fv.Nξ)
181-
return LVCoordinateSystemCache(coefficient.cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
172+
return LVCoordinateSystemCache(cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
182173
end
183174

184175
function evaluate_coefficient(coeff::LVCoordinateSystemCache, geometry_cache::FerriteUtils.AnyCellCache, qp::QuadraturePoint{ref_shape,T}, t) where {ref_shape,T}
@@ -204,13 +195,13 @@ end
204195

205196
duplicate_for_parallel(cache::BiVCoordinateSystemCache) = cache
206197

207-
function setup_coefficient_cache(coefficient::CoordinateSystemCoefficient{<:BiVCoordinateSystem}, qr::QuadratureRule{<:Any,<:AbstractArray{T}}, sdh::SubDofHandler) where T
198+
function setup_coefficient_cache(cs::BiVCoordinateSystem, qr::QuadratureRule{<:Any,<:AbstractArray{T}}, sdh::SubDofHandler) where T
208199
cell = get_first_cell(sdh)
209-
ip = getcoordinateinterpolation(coefficient.cs, cell)
200+
ip = getcoordinateinterpolation(cs, cell)
210201
ip_geo = ip^3
211202
fv = Ferrite.FunctionValues{0}(T, ip, qr, ip_geo)
212203
Nξs = size(fv.Nξ)
213-
return BiVCoordinateSystemCache(coefficient.cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
204+
return BiVCoordinateSystemCache(cs, FerriteUtils.StaticInterpolationValues(fv.ip, SMatrix{Nξs[1], Nξs[2]}(fv.Nξ), nothing))
214205
end
215206

216207
function evaluate_coefficient(cc::BiVCoordinateSystemCache, cell_cache::FerriteUtils.AnyCellCache, qp::QuadraturePoint{<:Any,T}, t) where {T}

src/modeling/core/coordinate_systems.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
abstract type CoordinateSystemCoefficient end
2+
13
"""
24
CartesianCoordinateSystem(mesh)
35
46
Standard cartesian coordinate system.
57
"""
6-
struct CartesianCoordinateSystem{sdim,T}
8+
struct CartesianCoordinateSystem{sdim,T} <: CoordinateSystemCoefficient
79
function CartesianCoordinateSystem{sdim}() where sdim
810
return new{sdim,Float32}()
911
end
@@ -27,7 +29,7 @@ getcoordinateinterpolation(cs::CartesianCoordinateSystem{sdim}, cell::CellType)
2729
Simplified universal ventricular coordinate on LV only, containing the transmural, apicobasal and
2830
rotational coordinates. See [`compute_lv_coordinate_system`](@ref) to construct it.
2931
"""
30-
struct LVCoordinateSystem{T, DH <: AbstractDofHandler, IPC}
32+
struct LVCoordinateSystem{T, DH <: AbstractDofHandler, IPC} <: CoordinateSystemCoefficient
3133
dh::DH
3234
ip_collection::IPC # TODO special dof handler with type stable interpolation
3335
u_transmural::Vector{T}
@@ -307,7 +309,7 @@ end
307309
Universal ventricular coordinate, containing the transmural, apicobasal, rotational
308310
and transventricular coordinates.
309311
"""
310-
struct BiVCoordinateSystem{T, DH <: Ferrite.AbstractDofHandler}
312+
struct BiVCoordinateSystem{T, DH <: Ferrite.AbstractDofHandler} <: CoordinateSystemCoefficient
311313
dh::DH
312314
u_transmural::Vector{T}
313315
u_apicobasal::Vector{T}

test/gpu/test_coefficients.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ import Tensors: Vec
103103

104104
end
105105

106-
@testset "Cartesian CoordinateSystemCoefficient" begin
107-
ccsc = CoordinateSystemCoefficient(CartesianCoordinateSystem(grid))
106+
@testset "Cartesian Coordinate System" begin
107+
ccsc = CartesianCoordinateSystem(grid)
108108
coeff_cache = setup_coefficient_cache(ccsc, qr, sdh)
109109
correct_vals = [Vec((-0.5f0,)), Vec((-0.45f0,)), Vec((0.5f0,)), Vec((0.55f0,))]
110110
Vals = correct_vals |> similar |> cu
@@ -118,7 +118,7 @@ import Tensors: Vec
118118
@testset "AnalyticalCoefficient" begin
119119
ac = AnalyticalCoefficient(
120120
(x, t) -> norm(x) + t,
121-
CoordinateSystemCoefficient(CartesianCoordinateSystem(grid))
121+
CartesianCoordinateSystem(grid)
122122
)
123123
coeff_cache = Thunderbolt.setup_coefficient_cache(ac, qr, sdh)
124124
correct_vals = [0.5f0, 0.45f0, 0.5f0, 0.55f0]

test/gpu/test_operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cs = CartesianCoordinateSystem(grid)
1010

1111

1212
protocol = AnalyticalTransmembraneStimulationProtocol(
13-
AnalyticalCoefficient((x,t) -> cos(2π * t) * exp(-norm(x)^2), CoordinateSystemCoefficient(cs)),
13+
AnalyticalCoefficient((x,t) -> cos(2π * t) * exp(-norm(x)^2), cs),
1414
[SVector((0.f0, 1.f0))]
1515
)
1616

0 commit comments

Comments
 (0)