1*44554ea0SWill Paznermutable struct Operator 2*44554ea0SWill Pazner ref::RefValue{C.CeedOperator} 3*44554ea0SWill Pazner qf::AbstractQFunction 4*44554ea0SWill Pazner dqf::AbstractQFunction 5*44554ea0SWill Pazner dqfT::AbstractQFunction 6*44554ea0SWill Pazner sub_ops::Vector{Operator} 7*44554ea0SWill Pazner function Operator(ref, qf, dqf, dqfT) 8*44554ea0SWill Pazner obj = new(ref, qf, dqf, dqfT, []) 9*44554ea0SWill Pazner finalizer(obj) do x 10*44554ea0SWill Pazner # ccall(:jl_safe_printf, Cvoid, (Cstring, Cstring), "Finalizing %s.\n", repr(x)) 11*44554ea0SWill Pazner destroy(x) 12*44554ea0SWill Pazner end 13*44554ea0SWill Pazner return obj 14*44554ea0SWill Pazner end 15*44554ea0SWill Paznerend 16*44554ea0SWill Paznerdestroy(op::Operator) = C.CeedOperatorDestroy(op.ref) # COV_EXCL_LINE 17*44554ea0SWill PaznerBase.getindex(op::Operator) = op.ref[] 18*44554ea0SWill PaznerBase.show(io::IO, ::MIME"text/plain", op::Operator) = ceed_show(io, op, C.CeedOperatorView) 19*44554ea0SWill Pazner 20*44554ea0SWill Pazner""" 21*44554ea0SWill Pazner Operator(ceed::Ceed; qf, dqf=QFunctionNone(), dqfT=QFunctionNone(), fields) 22*44554ea0SWill Pazner 23*44554ea0SWill PaznerCreates a libCEED `CeedOperator` object using the given Q-function `qf`, and optionally its 24*44554ea0SWill Paznerderivative and derivative transpose. 25*44554ea0SWill Pazner 26*44554ea0SWill PaznerAn array of fields must be provided, where each element of the array is a tuple containing 27*44554ea0SWill Paznerthe name of the field (as a string or symbol), the corresponding element restriction, basis, 28*44554ea0SWill Paznerand vector. 29*44554ea0SWill Pazner 30*44554ea0SWill Pazner# Examples 31*44554ea0SWill Pazner 32*44554ea0SWill PaznerCreate the operator that builds the Q-data associated with the mass matrix. 33*44554ea0SWill Pazner``` 34*44554ea0SWill Paznerbuild_oper = Operator( 35*44554ea0SWill Pazner ceed, 36*44554ea0SWill Pazner qf=build_qfunc, 37*44554ea0SWill Pazner fields=[ 38*44554ea0SWill Pazner (:J, mesh_restr, mesh_basis, CeedVectorActive()), 39*44554ea0SWill Pazner (:w, ElemRestrictionNone(), mesh_basis, CeedVectorNone()), 40*44554ea0SWill Pazner (:qdata, sol_restr_i, BasisCollocated(), CeedVectorActive()) 41*44554ea0SWill Pazner ] 42*44554ea0SWill Pazner) 43*44554ea0SWill Pazner``` 44*44554ea0SWill Pazner""" 45*44554ea0SWill Paznerfunction Operator(c::Ceed; qf, dqf=QFunctionNone(), dqfT=QFunctionNone(), fields) 46*44554ea0SWill Pazner op = Operator(c, qf, dqf, dqfT) 47*44554ea0SWill Pazner for f ∈ fields 48*44554ea0SWill Pazner set_field!(op, String(f[1]), f[2], f[3], f[4]) 49*44554ea0SWill Pazner end 50*44554ea0SWill Pazner op 51*44554ea0SWill Paznerend 52*44554ea0SWill Pazner 53*44554ea0SWill Paznerfunction Operator( 54*44554ea0SWill Pazner c::Ceed, 55*44554ea0SWill Pazner qf::AbstractQFunction, 56*44554ea0SWill Pazner dqf::AbstractQFunction, 57*44554ea0SWill Pazner dqfT::AbstractQFunction, 58*44554ea0SWill Pazner) 59*44554ea0SWill Pazner ref = Ref{C.CeedOperator}() 60*44554ea0SWill Pazner C.CeedOperatorCreate(c[], qf[], dqf[], dqfT[], ref) 61*44554ea0SWill Pazner Operator(ref, qf, dqf, dqfT) 62*44554ea0SWill Paznerend 63*44554ea0SWill Pazner 64*44554ea0SWill Pazner""" 65*44554ea0SWill Pazner create_composite_operator(c::Ceed, ops) 66*44554ea0SWill Pazner 67*44554ea0SWill PaznerCreate an [`Operator`](@ref) whose action represents the sum of the operators in the 68*44554ea0SWill Paznercollection `ops`. 69*44554ea0SWill Pazner""" 70*44554ea0SWill Paznerfunction create_composite_operator(c::Ceed, ops) 71*44554ea0SWill Pazner ref = Ref{C.CeedOperator}() 72*44554ea0SWill Pazner C.CeedCompositeOperatorCreate(c[], ref) 73*44554ea0SWill Pazner comp_op = Operator(ref, QFunctionNone(), QFunctionNone(), QFunctionNone()) 74*44554ea0SWill Pazner comp_op.sub_ops = ops 75*44554ea0SWill Pazner for op ∈ ops 76*44554ea0SWill Pazner C.CeedCompositeOperatorAddSub(comp_op[], op[]) 77*44554ea0SWill Pazner end 78*44554ea0SWill Pazner comp_op 79*44554ea0SWill Paznerend 80*44554ea0SWill Pazner 81*44554ea0SWill Paznerfunction set_field!( 82*44554ea0SWill Pazner op::Operator, 83*44554ea0SWill Pazner fieldname::AbstractString, 84*44554ea0SWill Pazner r::AbstractElemRestriction, 85*44554ea0SWill Pazner b::AbstractBasis, 86*44554ea0SWill Pazner v::AbstractCeedVector, 87*44554ea0SWill Pazner) 88*44554ea0SWill Pazner C.CeedOperatorSetField(op[], fieldname, r[], b[], v[]) 89*44554ea0SWill Paznerend 90*44554ea0SWill Pazner 91*44554ea0SWill Pazner""" 92*44554ea0SWill Pazner apply!(op::Operator, vin, vout; request=RequestImmediate()) 93*44554ea0SWill Pazner 94*44554ea0SWill PaznerApply the action of the operator `op` to the input vector `vin`, and store the result in the 95*44554ea0SWill Pazneroutput vector `vout`. 96*44554ea0SWill Pazner 97*44554ea0SWill PaznerFor non-blocking application, the user can specify a request object. By default, immediate 98*44554ea0SWill Pazner(synchronous) completion is requested. 99*44554ea0SWill Pazner""" 100*44554ea0SWill Paznerfunction apply!( 101*44554ea0SWill Pazner op::Operator, 102*44554ea0SWill Pazner vin::AbstractCeedVector, 103*44554ea0SWill Pazner vout::AbstractCeedVector; 104*44554ea0SWill Pazner request=RequestImmediate(), 105*44554ea0SWill Pazner) 106*44554ea0SWill Pazner C.CeedOperatorApply(op[], vin[], vout[], request[]) 107*44554ea0SWill Paznerend 108*44554ea0SWill Pazner 109*44554ea0SWill Pazner""" 110*44554ea0SWill Pazner apply_add!(op::Operator, vin, vout; request=RequestImmediate()) 111*44554ea0SWill Pazner 112*44554ea0SWill PaznerApply the action of the operator `op` to the input vector `vin`, and add the result to the 113*44554ea0SWill Pazneroutput vector `vout`. 114*44554ea0SWill Pazner 115*44554ea0SWill PaznerFor non-blocking application, the user can specify a request object. By default, immediate 116*44554ea0SWill Pazner(synchronous) completion is requested. 117*44554ea0SWill Pazner""" 118*44554ea0SWill Paznerfunction apply_add!( 119*44554ea0SWill Pazner op::Operator, 120*44554ea0SWill Pazner vin::AbstractCeedVector, 121*44554ea0SWill Pazner vout::AbstractCeedVector; 122*44554ea0SWill Pazner request=RequestImmediate(), 123*44554ea0SWill Pazner) 124*44554ea0SWill Pazner C.CeedOperatorApplyAdd(op[], vin[], vout[], request[]) 125*44554ea0SWill Paznerend 126*44554ea0SWill Pazner 127*44554ea0SWill Pazner""" 128*44554ea0SWill Pazner assemble_diagonal!(op::Operator, diag::CeedVector; request=RequestImmediate()) 129*44554ea0SWill Pazner 130*44554ea0SWill PaznerOverwrites a [`CeedVector`](@ref) with the diagonal of a linear [`Operator`](@ref). 131*44554ea0SWill Pazner 132*44554ea0SWill Pazner!!! note "Note:" 133*44554ea0SWill Pazner Currently only [`Operator`](@ref)s with a single field are supported. 134*44554ea0SWill Pazner""" 135*44554ea0SWill Paznerfunction assemble_diagonal!(op::Operator, diag::CeedVector; request=RequestImmediate()) 136*44554ea0SWill Pazner C.CeedOperatorLinearAssembleDiagonal(op[], diag[], request[]) 137*44554ea0SWill Paznerend 138*44554ea0SWill Pazner 139*44554ea0SWill Pazner""" 140*44554ea0SWill Pazner assemble_diagonal!(op::Operator, diag::CeedVector; request=RequestImmediate()) 141*44554ea0SWill Pazner 142*44554ea0SWill PaznerAdds the diagonal of a linear [`Operator`](@ref) to the given [`CeedVector`](@ref). 143*44554ea0SWill Pazner 144*44554ea0SWill Pazner!!! note "Note:" 145*44554ea0SWill Pazner Currently only [`Operator`](@ref)s with a single field are supported. 146*44554ea0SWill Pazner""" 147*44554ea0SWill Paznerfunction assemble_add_diagonal!(op::Operator, diag::CeedVector; request=RequestImmediate()) 148*44554ea0SWill Pazner C.CeedOperatorLinearAssembleAddDiagonal(op[], diag[], request[]) 149*44554ea0SWill Paznerend 150