@@ -2124,8 +2124,7 @@ TruncatedStacktraces.@truncate_stacktrace OptimizationFunction 1 2
21242124"""
21252125$(TYPEDEF)
21262126"""
2127- abstract type AbstractBVPFunction{iip} < :
2128- AbstractDiffEqFunction{iip} end
2127+ abstract type AbstractBVPFunction{iip, twopoint} <: AbstractDiffEqFunction{iip} end
21292128
21302129@doc doc"""
21312130 BVPFunction{iip,F,BF,TMM,Ta,Tt,TJ,BCTJ,JVP,VJP,JP,BCJP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV,BCTCV} <: AbstractBVPFunction{iip,specialize}
@@ -2230,11 +2229,9 @@ For more details on this argument, see the ODEFunction documentation.
22302229
22312230The fields of the BVPFunction type directly match the names of the inputs.
22322231"""
2233- struct BVPFunction{iip, specialize, F, BF, TMM, Ta, Tt, TJ, BCTJ, JVP, VJP, JP,
2234- BCJP, SP, TW, TWt,
2235- TPJ,
2236- S, S2, S3, O, TCV, BCTCV,
2237- SYS} <: AbstractBVPFunction{iip}
2232+ struct BVPFunction{iip, specialize, twopoint, F, BF, TMM, Ta, Tt, TJ, BCTJ, JVP, VJP,
2233+ JP, BCJP, BCRP, SP, TW, TWt, TPJ, S, S2, S3, O, TCV, BCTCV,
2234+ SYS} <: AbstractBVPFunction{iip, twopoint}
22382235 f:: F
22392236 bc:: BF
22402237 mass_matrix:: TMM
@@ -2246,6 +2243,7 @@ struct BVPFunction{iip, specialize, F, BF, TMM, Ta, Tt, TJ, BCTJ, JVP, VJP, JP,
22462243 vjp:: VJP
22472244 jac_prototype:: JP
22482245 bcjac_prototype:: BCJP
2246+ bcresid_prototype:: BCRP
22492247 sparsity:: SP
22502248 Wfact:: TW
22512249 Wfact_t:: TWt
@@ -3648,9 +3646,8 @@ function NonlinearFunction{iip, specialize}(f;
36483646 nothing ,
36493647 sys = __has_sys (f) ? f. sys : nothing ,
36503648 resid_prototype = __has_resid_prototype (f) ? f. resid_prototype : nothing ) where {
3651- iip,
3652- specialize,
3653- }
3649+ iip, specialize}
3650+
36543651 if mass_matrix === I && typeof (f) <: Tuple
36553652 mass_matrix = ((I for i in 1 : length (f)). .. ,)
36563653 end
@@ -3814,35 +3811,28 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD();
38143811 cons_expr, sys)
38153812end
38163813
3817- function BVPFunction {iip, specialize} (f, bc;
3818- mass_matrix = __has_mass_matrix (f) ? f. mass_matrix :
3819- I,
3814+ function BVPFunction {iip, specialize, twopoint} (f, bc;
3815+ mass_matrix = __has_mass_matrix (f) ? f. mass_matrix : I,
38203816 analytic = __has_analytic (f) ? f. analytic : nothing ,
38213817 tgrad = __has_tgrad (f) ? f. tgrad : nothing ,
38223818 jac = __has_jac (f) ? f. jac : nothing ,
38233819 bcjac = __has_jac (bc) ? bc. jac : nothing ,
38243820 jvp = __has_jvp (f) ? f. jvp : nothing ,
38253821 vjp = __has_vjp (f) ? f. vjp : nothing ,
3826- jac_prototype = __has_jac_prototype (f) ?
3827- f. jac_prototype :
3828- nothing ,
3829- bcjac_prototype = __has_jac_prototype (bc) ?
3830- bc. jac_prototype :
3831- nothing ,
3832- sparsity = __has_sparsity (f) ? f. sparsity :
3833- jac_prototype,
3822+ jac_prototype = __has_jac_prototype (f) ? f. jac_prototype : nothing ,
3823+ bcjac_prototype = __has_jac_prototype (bc) ? bc. jac_prototype : nothing ,
3824+ bcresid_prototype = nothing ,
3825+ sparsity = __has_sparsity (f) ? f. sparsity : jac_prototype,
38343826 Wfact = __has_Wfact (f) ? f. Wfact : nothing ,
38353827 Wfact_t = __has_Wfact_t (f) ? f. Wfact_t : nothing ,
38363828 paramjac = __has_paramjac (f) ? f. paramjac : nothing ,
38373829 syms = __has_syms (f) ? f. syms : nothing ,
38383830 indepsym = __has_indepsym (f) ? f. indepsym : nothing ,
3839- paramsyms = __has_paramsyms (f) ? f. paramsyms :
3840- nothing ,
3841- observed = __has_observed (f) ? f. observed :
3842- DEFAULT_OBSERVED,
3831+ paramsyms = __has_paramsyms (f) ? f. paramsyms : nothing ,
3832+ observed = __has_observed (f) ? f. observed : DEFAULT_OBSERVED,
38433833 colorvec = __has_colorvec (f) ? f. colorvec : nothing ,
38443834 bccolorvec = __has_colorvec (bc) ? bc. colorvec : nothing ,
3845- sys = __has_sys (f) ? f. sys : nothing ) where {iip, specialize}
3835+ sys = __has_sys (f) ? f. sys : nothing ) where {iip, specialize, twopoint }
38463836 if mass_matrix === I && typeof (f) <: Tuple
38473837 mass_matrix = ((I for i in 1 : length (f)). .. ,)
38483838 end
@@ -3882,7 +3872,7 @@ function BVPFunction{iip, specialize}(f, bc;
38823872 _bccolorvec = bccolorvec
38833873 end
38843874
3885- bciip = isinplace (bc, 4 , " bc" , iip)
3875+ bciip = ! twopoint ? isinplace (bc, 4 , " bc " , iip) : isinplace (bc, 3 , " bc" , iip)
38863876 jaciip = jac != = nothing ? isinplace (jac, 4 , " jac" , iip) : iip
38873877 bcjaciip = bcjac != = nothing ? isinplace (bcjac, 4 , " bcjac" , bciip) : bciip
38883878 tgradiip = tgrad != = nothing ? isinplace (tgrad, 4 , " tgrad" , iip) : iip
@@ -3892,66 +3882,62 @@ function BVPFunction{iip, specialize}(f, bc;
38923882 Wfact_tiip = Wfact_t != = nothing ? isinplace (Wfact_t, 5 , " Wfact_t" , iip) : iip
38933883 paramjaciip = paramjac != = nothing ? isinplace (paramjac, 4 , " paramjac" , iip) : iip
38943884
3895- nonconforming = (jaciip,
3896- tgradiip,
3897- jvpiip,
3898- vjpiip,
3899- Wfactiip,
3900- Wfact_tiip,
3885+ nonconforming = (bciip, jaciip, tgradiip, jvpiip, vjpiip, Wfactiip, Wfact_tiip,
39013886 paramjaciip) .!= iip
39023887 bc_nonconforming = bcjaciip .!= bciip
39033888 if any (nonconforming)
39043889 nonconforming = findall (nonconforming)
3905- functions = [" jac" , " bcjac" , " tgrad" , " jvp" , " vjp" , " Wfact" , " Wfact_t" , " paramjac" ][nonconforming]
3890+ functions = [" bc" , " jac" , " bcjac" , " tgrad" , " jvp" , " vjp" , " Wfact" , " Wfact_t" ,
3891+ " paramjac" ][nonconforming]
39063892 throw (NonconformingFunctionsError (functions))
39073893 end
39083894
3895+ if twopoint
3896+ if iip && (bcresid_prototype === nothing || length (bcresid_prototype) != 2 )
3897+ error (" bcresid_prototype must be a tuple / indexable collection of length 2 for a inplace TwoPointBVPFunction" )
3898+ end
3899+ if bcresid_prototype != = nothing && length (bcresid_prototype) == 2
3900+ bcresid_prototype = ArrayPartition (bcresid_prototype[1 ], bcresid_prototype[2 ])
3901+ end
3902+ end
3903+
39093904 if any (bc_nonconforming)
39103905 bc_nonconforming = findall (bc_nonconforming)
39113906 functions = [" bcjac" ][bc_nonconforming]
39123907 throw (NonconformingFunctionsError (functions))
39133908 end
39143909
39153910 if specialize === NoSpecialize
3916- BVPFunction{iip, specialize, Any, Any, Any, Any, Any,
3917- Any, Any, Any, Any, Any, Any, Any, Any, Any,
3911+ BVPFunction{iip, specialize, twopoint, Any, Any, Any, Any, Any,
3912+ Any, Any, Any, Any, Any, Any, Any, Any, Any, Any,
39183913 Any, typeof (syms), typeof (indepsym), typeof (paramsyms),
39193914 Any, typeof (_colorvec), typeof (_bccolorvec), Any}(f, bc, mass_matrix,
3920- analytic,
3921- tgrad,
3922- jac, bcjac, jvp, vjp,
3923- jac_prototype,
3924- bcjac_prototype,
3925- sparsity, Wfact,
3926- Wfact_t,
3927- paramjac, syms,
3928- indepsym, paramsyms,
3929- observed,
3915+ analytic, tgrad, jac, bcjac, jvp, vjp, jac_prototype,
3916+ bcjac_prototype, bcresid_prototype,
3917+ sparsity, Wfact, Wfact_t, paramjac, syms, indepsym, paramsyms, observed,
39303918 _colorvec, _bccolorvec, sys)
39313919 else
3932- BVPFunction{iip, specialize, typeof (f), typeof (bc), typeof (mass_matrix),
3933- typeof (analytic),
3934- typeof (tgrad),
3935- typeof (jac), typeof (bcjac), typeof (jvp), typeof (vjp), typeof (jac_prototype),
3936- typeof (bcjac_prototype),
3937- typeof (sparsity), typeof (Wfact), typeof (Wfact_t),
3938- typeof (paramjac), typeof (syms), typeof (indepsym), typeof (paramsyms),
3939- typeof (observed),
3920+ BVPFunction{iip, specialize, twopoint, typeof (f), typeof (bc), typeof (mass_matrix),
3921+ typeof (analytic), typeof (tgrad), typeof (jac), typeof (bcjac), typeof (jvp),
3922+ typeof (vjp), typeof (jac_prototype),
3923+ typeof (bcjac_prototype), typeof (bcresid_prototype), typeof (sparsity),
3924+ typeof (Wfact), typeof (Wfact_t), typeof (paramjac), typeof (syms),
3925+ typeof (indepsym), typeof (paramsyms), typeof (observed),
39403926 typeof (_colorvec), typeof (_bccolorvec), typeof (sys)}(f, bc, mass_matrix, analytic,
39413927 tgrad, jac, bcjac, jvp, vjp,
3942- jac_prototype, bcjac_prototype, sparsity,
3928+ jac_prototype, bcjac_prototype, bcresid_prototype, sparsity,
39433929 Wfact, Wfact_t, paramjac,
39443930 syms, indepsym, paramsyms, observed,
39453931 _colorvec, _bccolorvec, sys)
39463932 end
39473933end
39483934
3949- function BVPFunction {iip} (f, bc; kwargs... ) where {iip}
3950- BVPFunction {iip, FullSpecialize} (f, bc; kwargs... )
3935+ function BVPFunction {iip} (f, bc; twopoint :: Bool = false , kwargs... ) where {iip}
3936+ BVPFunction {iip, FullSpecialize, twopoint } (f, bc; kwargs... )
39513937end
39523938BVPFunction {iip} (f:: BVPFunction , bc; kwargs... ) where {iip} = f
3953- function BVPFunction (f, bc; kwargs... )
3954- BVPFunction {isinplace(f, 4), FullSpecialize} (f, bc; kwargs... )
3939+ function BVPFunction (f, bc; twopoint :: Bool = false , kwargs... )
3940+ BVPFunction {isinplace(f, 4), FullSpecialize, twopoint } (f, bc; kwargs... )
39553941end
39563942BVPFunction (f:: BVPFunction ; kwargs... ) = f
39573943
0 commit comments