Skip to content

Commit 1677c4c

Browse files
authored
Merge pull request #158 from ReactionMechanismGenerator/type_stable_func_in_struct
Type stability for function in struct
2 parents b721d61 + 24a3f11 commit 1677c4c

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/Domain.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ function ConstantPDomain(;phase::Z,initialconds::Dict{X,E},constantspecies::Arra
238238
end
239239
export ConstantPDomain
240240

241-
struct ParametrizedTPDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray} <: AbstractVariableKDomain
241+
struct ParametrizedTPDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray,FT<:Function,FP<:Function} <: AbstractVariableKDomain
242242
phase::N
243243
indexes::Q #assumed to be in ascending order
244244
parameterindexes::Q
245245
constantspeciesinds::Array{S,1}
246-
T::Function
247-
P::Function
246+
T::FT
247+
P::FP
248248
efficiencyinds::Array{I,1}
249249
rxnarray::Array{Int64,2}
250250
jacobian::Array{W,2}
@@ -319,12 +319,12 @@ function ParametrizedTPDomain(;phase::Z,initialconds::Dict{X,Any},constantspecie
319319
end
320320
export ParametrizedTPDomain
321321

322-
struct ParametrizedVDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray} <: AbstractVariableKDomain
322+
struct ParametrizedVDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray,FV<:Function} <: AbstractVariableKDomain
323323
phase::N
324324
indexes::Q #assumed to be in ascending order
325325
parameterindexes::Q
326326
constantspeciesinds::Array{S,1}
327-
V::Function
327+
V::FV
328328
efficiencyinds::Array{I,1}
329329
rxnarray::Array{Int64,2}
330330
jacobian::Array{W,2}
@@ -396,12 +396,12 @@ function ParametrizedVDomain(;phase::Z,initialconds::Dict{X,Any},constantspecies
396396
end
397397
export ParametrizedVDomain
398398

399-
struct ParametrizedPDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray} <: AbstractVariableKDomain
399+
struct ParametrizedPDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray,FP<:Function} <: AbstractVariableKDomain
400400
phase::N
401401
indexes::Q #assumed to be in ascending order
402402
parameterindexes::Q
403403
constantspeciesinds::Array{S,1}
404-
P::Function
404+
P::FP
405405
efficiencyinds::Array{I,1}
406406
rxnarray::Array{Int64,2}
407407
jacobian::Array{W,2}
@@ -556,12 +556,12 @@ function ConstantTVDomain(;phase::Z,initialconds::Dict{X,E},constantspecies::Arr
556556
end
557557
export ConstantTVDomain
558558

559-
struct ParametrizedTConstantVDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray} <: AbstractVariableKDomain
559+
struct ParametrizedTConstantVDomain{N<:AbstractPhase,S<:Integer,W<:Real,W2<:Real,I<:Integer,Q<:AbstractArray,FT<:Function} <: AbstractVariableKDomain
560560
phase::N
561561
indexes::Q #assumed to be in ascending order
562562
parameterindexes::Q
563563
constantspeciesinds::Array{S,1}
564-
T::Function
564+
T::FT
565565
V::W
566566
efficiencyinds::Array{I,1}
567567
rxnarray::Array{Int64,2}

src/Interface.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,16 @@ function stickingcoefficient2arrhenius(sc,sitedensity,N,mw;Tmin=300.0,Tmax=2000.
227227
return Arrhenius(;A=p[1],n=p[2],Ea=p[3])
228228
end
229229

230-
struct Inlet{Q<:Real,S,V<:AbstractArray,U<:Real,X<:Real} <: AbstractBoundaryInterface
230+
struct Inlet{Q<:Real,S,V<:AbstractArray,U<:Real,X<:Real,FF<:Function} <: AbstractBoundaryInterface
231231
domain::S
232232
y::V
233-
F::Function
233+
F::FF
234234
T::U
235235
P::X
236236
H::Q
237237
end
238238

239-
function Inlet(domain::V,conddict::Dict{String,X},F::Function) where {V,X<:Real,B<:Real}
239+
function Inlet(domain::V,conddict::Dict{String,X},F::FF) where {V,X<:Real,B<:Real,FF<:Function}
240240
y = makespcsvector(domain.phase,conddict)
241241
T = conddict["T"]
242242
P = conddict["P"]
@@ -247,8 +247,8 @@ end
247247

248248
export Inlet
249249

250-
struct Outlet{V} <: AbstractBoundaryInterface
250+
struct Outlet{V,FF<:Function} <: AbstractBoundaryInterface
251251
domain::V
252-
F::Function
252+
F::FF
253253
end
254254
export Outlet

0 commit comments

Comments
 (0)