CeedVector

LibCEED.CeedVectorType
CeedVector(c::Ceed, len::Integer; allocate::Bool=true)

Creates a CeedVector of given length. If allocate is false, then no memory is allocated. Attemping to access the vector before calling setarray! will fail. By default, allocate is true, and libCEED will allocate (host) memory for the vector.

source
CeedVector(c::Ceed, v2::AbstractVector; mtype=MEM_HOST, cmode=COPY_VALUES)

Creates a new CeedVector using the contents of the given vector v2. By default, the contents of v2 will be copied to the new CeedVector, but this behavior can be changed by specifying a different cmode.

source
Base.setindex!Method
setindex!(v::CeedVector, v2::AbstractArray)
v[] = v2

Sets the values of CeedVector v equal to those of v2 using broadcasting.

source
Base.VectorMethod
Vector(v::CeedVector)

Create a new Vector by copying the contents of v.

source
LinearAlgebra.normMethod
norm(v::CeedVector, ntype::NormType)

Return the norm of the given CeedVector.

The norm type can either be specified as one of NORM_1, NORM_2, NORM_MAX.

source
LibCEED.@witharrayMacro
@witharray(v_arr=v, [size=(dims...)], [mtype=MEM_HOST], body)

Executes body, having extracted the contents of the CeedVector v as an array with name v_arr. If the memory type mtype is not provided, MEM_HOST will be used. If the size is not specified, a flat vector will be assumed.

Examples

Negate the contents of CeedVector v:

@witharray v_arr=v v_arr .*= -1.0
source
LibCEED.witharrayFunction
witharray(f, v::CeedVector, mtype=MEM_HOST)

Calls f with an array containing the data of the CeedVector v, using memory type mtype.

Because of performance issues involving closures, if f is a complex operation, it may be more efficient to use the macro version @witharray (cf. the section on "Performance of captured variable" in the Julia documentation and related GitHub issue.

Examples

Return the sum of a vector:

witharray(sum, v)
source
LibCEED.witharray_readFunction
witharray_read(f, v::CeedVector, mtype::MemType=MEM_HOST)

Same as witharray, but with read-only access to the data.

Examples

Display the contents of a vector:

witharray_read(display, v)
source
LibCEED.setarray!Function
setarray!(v::CeedVector, mtype::MemType, cmode::CopyMode, arr)

Set the array used by a CeedVector, freeing any previously allocated array if applicable. The backend may copy values to a different MemType. See also syncarray! and takearray!.

Avoid OWN_POINTER CopyMode

The CopyMode OWN_POINTER is not suitable for use with arrays that are allocated by Julia, since those cannot be properly freed from libCEED.

source
LibCEED.syncarray!Function
syncarray!(v::CeedVector, mtype::MemType)

Sync the CeedVector to a specified MemType. This function is used to force synchronization of arrays set with setarray!. If the requested memtype is already synchronized, this function results in a no-op.

source
LibCEED.takearray!Function
takearray!(v::CeedVector, mtype::MemType)

Take ownership of the CeedVector array and remove the array from the CeedVector. The caller is responsible for managing and freeing the array. The array is returns as a Ptr{CeedScalar}.

source
LibCEED.scale!Function
scale!(v::CeedVector, a::Real)

Overwrite v with a*v for scalar a. Returns v.

source
LinearAlgebra.axpy!Method
axpy!(a::Real, x::CeedVector, y::CeedVector)

Overwrite y with x*a + y, where a is a scalar. Returns y.

Different argument order

In order to be consistent with LinearAlgebra.axpy!, the arguments are passed in order: a, x, y. This is different than the order of arguments of the C function CeedVectorAXPY.

source
LibCEED.pointwisemult!Function
pointwisemult!(w::CeedVector, x::CeedVector, y::CeedVector)

Overwrite w with x .* y. Any subset of x, y, and w may be the same vector. Returns w.

source