Module Nvector

module Nvector: sig .. end

Generic nvector types and operations.


type ('data, 'kind) t 

Represents an nvector of kind 'kind with underlying data of type 'data. The type argument 'kind is either Nvector_serial.kind, Nvector_parallel.kind, Nvector_custom.kind, Nvector_openmp.kind, or Nvector_pthreads.kind. It is needed because some linear solvers make additional assumptions about the underlying vector representation.

type ('data, 'kind) nvector = ('data, 'kind) t 

An alias for Nvector.t.

type [> `Serial ] serial = (Sundials.RealArray.t, [> `Serial ] as 'k) t 

The type of any nvector that can be used as a serial nvector.

val unwrap : ('data, 'kind) t -> 'data

unwrap nv returns the data underlying the nvector nv.

val context : ('data, 'kind) t -> Sundials.Context.t

Returns the context used to create the nvector.

exception IncompatibleNvector

Raised when an nvector argument is incompatible with a session. For example, when a solver session was initialized with an nvector having 10 elements, and a later call passes an nvector with only 9 elements. The exact details depend on the nvector instantiation.

val check : ('data, 'kind) t -> ('data, 'kind) t -> unit

check v1 v2 checks v1 and v2 for compatibility.

val clone : ('data, 'kind) t -> ('data, 'kind) t

Clone an nvector. Cloning duplicates the payload and preserves the status of fused and array operations.

type nvector_id = 
| Serial
| Parallel
| OpenMP
| Pthreads
| ParHyp
| PETSc
| CUDA
| RAJA
| OpenMPdev
| Trilinos
| ManyVector
| MpiManyVector
| MpiPlusX
| Custom

Vector type identifiers.

val get_id : ('data, 'kind) t -> nvector_id

Returns the vector type identifier.

Vector operations

module type NVECTOR_OPS = sig .. end

Basic operations underlying an nvector.

module type NVECTOR = sig .. end

Basic structure of a concrete nvector implementation module.

module Ops: sig .. end

Operations on any type of nvector.

Generic nvectors

The two arguments of the standard nvector type encode, respectively, the type of the data payload that is manipulated from OCaml and the type of the underlying implementation. This encoding has two advantages. First, callback functions have direct access to the data payload. Second, incorrect combinations of nvectors can be rejected at compile time (although dynamic checks are still required on payload dimensions). There are two main disadvantages to this encoding. First, type signatures and error messages become more complicated. Second, it is not possible to form lists or arrays of heterogeneous nvectors, despite the object-oriented style of the underlying implementation.

Generic nvectors are an alternative interface that inverses the advantages and disadvantages of standard nvectors. The data payload is now accessed through a constructor that otherwise hides the underlying type. Since all such nvectors have the same values for the two type arguments, they can be stored together in lists and arrays regardless of their underlying payloads and implementations. The price to pay is additional run-time checks and the fact that certain errors can no longer be detected statically.

type gdata = ..

Represents generic nvector data. This type is extensible so that other nvector modules can support the generic form.

type gdata += 
| RA of Sundials.RealArray.t

Generic wrapper for RealArray.

type gkind 

Represents an nvector whose data must be accessed through a constructor in Nvector.gdata.

type any = (gdata, gkind) t 

The type of a generic nvector.

exception BadGenericType

A Nvector.gdata value did not have the expected wrapper.

exception OperationNotProvided

The requested operation is not provided by the given nvector.

module MakeDataOps (* : sig
end: NVECTOR_OPS  with type t = gdata

Lifts a set of operations on a type t to a set of operations on a generic nvector payload.