GridapROMs.ParamDataStructures

GridapROMs.ParamDataStructures — Module
module ParamDataStructures

Data structures for parametric PDEs: parameter spaces, realisations, parametric arrays, sparse matrices, and solution snapshots.

Parameter spaces and sampling

Parametric arrays

  • AbstractParamArray — abstract supertype; concrete subtypes are ConsecutiveParamArray (contiguous data layout, most efficient) and GenericParamArray.
  • ParamSparseMatrix — sparse matrix with one entry per parameter.
  • BlockParamArray — block-structured parametric array for multi-field problems.

Snapshots

source
GridapROMs.ParamDataStructures.AbstractSnapshots — Type
abstract type AbstractSnapshots{T,N} <: AbstractParamData{T,N} end

Type representing N-dimensional arrays of snapshots. Subtypes must contain the following information:

  • data: a (parametric) array
  • realisation: a subtype of AbstractRealisation, representing the points in the parameter space used to compute the array data
  • dof map: a subtype of AbstractDofMap, representing a reindexing strategy for the array data

Subtypes:

source
GridapROMs.ParamDataStructures.BlockSnapshots — Type
struct BlockSnapshots{S<:Snapshots,N} <: AbstractSnapshots{S,N}
  array::Array{S,N}
end

Block container for Snapshots in a MultiField setting. Its param data is not stored separately; it is always derived from blocks(s) (mortared together), so that it stays consistent with the blocks under any operation (selecting, clustering, concatenating, ...) instead of needing to be kept in sync by hand alongside them.

source
GridapROMs.ParamDataStructures.ConsecutiveParamArray — Type
struct ConsecutiveParamArray{T,N,M,A<:AbstractArray{T,M}} <: ParamArray{T,N}
  data::A
end

Parametric array with entries stored consecutively in memory. It is characterized by an inner size equal to size(data)[1:N], and parametric length equal to size(data,N+1), where data is an AbstractArray of dimension M = N+1

source
GridapROMs.ParamDataStructures.ConsecutiveParamSparseMatrixCSC — Type
struct ConsecutiveParamSparseMatrixCSC{Tv,Ti<:Integer,A<:AbstractMatrix{Tv}} <: ParamSparseMatrixCSC{Tv,Ti}
  m::Int64
  n::Int64
  colptr::Vector{Ti}
  rowval::Vector{Ti}
  data::A
end

Represents a vector of sparse matrices in CSC format, with entries stored consecutively in memory. For sake of coherence, an instance of ConsecutiveParamSparseMatrixCSC inherits from AbstractMatrix{<:SparseMatrixCSC{Tv,Ti} rather than AbstractVector{<:SparseMatrixCSC{Tv,Ti}, but should conceptually be thought as an AbstractVector{<:SparseMatrixCSC{Tv,Ti}.

source
GridapROMs.ParamDataStructures.ConsecutiveParamSparseMatrixCSR — Type
struct ConsecutiveParamSparseMatrixCSR{Bi,Tv,Ti<:Integer,A<:AbstractMatrix{Tv}} <: ParamSparseMatrixCSR{Bi,Tv,Ti}
  m::Int64
  n::Int64
  rowptr::Vector{Ti}
  colval::Vector{Ti}
  data::A
end

Represents a vector of sparse matrices in CSR format, with entries stored consecutively in memory. For sake of coherence, an instance of ConsecutiveParamSparseMatrixCSR inherits from AbstractMatrix{<:SparseMatrixCSR{Bi,Tv,Ti} rather than AbstractVector{<:SparseMatrixCSR{Bi,Tv,Ti}, but should conceptually be thought as an AbstractVector{<:SparseMatrixCSR{Bi,Tv,Ti}.

source
GridapROMs.ParamDataStructures.GenericParamSparseMatrixCSC — Type
struct GenericParamSparseMatrixCSC{Tv,Ti<:Integer} <: ParamSparseMatrixCSC{Tv,Ti}
  m::Int64
  n::Int64
  colptr::Vector{Ti}
  rowval::Vector{Ti}
  data::Vector{Tv}
  ptrs::Vector{Ti}
end

Represents a vector of sparse matrices in CSC format, with entries stored non-consecutively in memory. For sake of coherence, an instance of GenericParamSparseMatrixCSC inherits from AbstractMatrix{<:SparseMatrixCSC{Tv,Ti} rather than AbstractVector{<:SparseMatrixCSC{Tv,Ti}, but should conceptually be thought as an AbstractVector{<:SparseMatrixCSC{Tv,Ti}.

source
GridapROMs.ParamDataStructures.GenericParamSparseMatrixCSR — Type
struct GenericParamSparseMatrixCSR{Bi,Tv,Ti<:Integer} <: ParamSparseMatrixCSR{Bi,Tv,Ti}
  m::Int64
  n::Int64
  rowptr::Vector{Ti}
  colval::Vector{Ti}
  data::Vector{Tv}
  ptrs::Vector{Ti}
end

Represents a vector of sparse matrices in CSR format, with entries stored non-consecutively in memory. For sake of coherence, an instance of GenericParamSparseMatrixCSR inherits from AbstractMatrix{<:SparseMatrixCSR{Bi,Tv,Ti} rather than AbstractVector{<:SparseMatrixCSR{Bi,Tv,Ti}, but should conceptually be thought as an AbstractVector{<:SparseMatrixCSR{Bi,Tv,Ti}.

source
GridapROMs.ParamDataStructures.HaltonSampling — Type
struct HaltonSampling <: SamplingStyle
  start::Int
end

Sampling according to a Halton sequence

Note

Halton is a sequence, not a distribution, hence this sampling strategy repeats realisations since the draws are not randomized; to draw different parameters, one needs to provide a starting point in the sequence (start = 1 by default)

source
GridapROMs.ParamDataStructures.ParamArray — Type
abstract type ParamArray{T,N} <: AbstractParamArray{T,N,Array{T,N}} end

Type representing parametric arrays of type A. Subtypes:

Also acts as a constructor according to the following rules:

  • ParamArray(A::AbstractArray{<:Number}) -> ParamNumber
  • ParamArray(A::AbstractArray{<:Number},plength::Int) -> TrivialParamArray
  • ParamArray(A::AbstractVector{<:AbstractArray}) -> ParamArray
  • ParamArray(A::AbstractVector{<:AbstractSparseMatrix}) -> ParamSparseMatrix
  • ParamArray(A::AbstractArray{<:ParamArray}) -> BlockParamArray
source
GridapROMs.ParamDataStructures.ParamFunction — Type
struct ParamFunction{F,P} <: AbstractParamFunction{P}
  fun::F
  params::P
end

Representation of parametric functions with domain a parametric space. Given a function f : Ω₁ × ... × Ωₙ × D, where D is a ParamSpace, the evaluation of f in μ ∈ D returns the restriction of f to Ω₁ × ... × Ωₙ

source
GridapROMs.ParamDataStructures.ParamSpace — Type
struct ParamSpace{P<:AbstractVector{<:AbstractVector},S<:SamplingStyle} <: AbstractSet{Realisation}
  param_domain::P
  sampling_style::S
end

Fields:

  • param_domain: domain of definition of the parameters
  • sampling_style: distribution on param_domain according to which we can sample the parameters (by default it is set to HaltonSampling)
source
GridapROMs.ParamDataStructures.ParamSpace — Method
ParamSpace(domain::Tuple;sampling=:halton) -> ParamSpace
ParamSpace(domain::AbstractVector{<:AbstractVector};sampling=:halton) -> ParamSpace

Parameter space with bounds domain, given either as a tuple (min₁,max₁,min₂,max₂,...) whose entries share the same type, or as a vector of intervals [[min₁,max₁],...]. sampling (:halton, :uniform, :normal, :latin_hypercube, :tensorial_uniform) sets the default distribution of realisation

source
GridapROMs.ParamDataStructures.Realisation — Type
struct Realisation{P<:AbstractVector} <: AbstractRealisation
  params::P
end

Represents standard parametric realisations, i.e. samples extracted from a given parameter space. The field params is most commonly a vector of vectors. When the parameters are scalars, they still need to be defined as vectors of vectors of unit length. In other words, we treat the case in which params is a vector of numbers as the case in which params is a vector of one vector.

source
GridapROMs.ParamDataStructures.Snapshots — Type
abstract type Snapshots{T,N,I,R} <: AbstractSnapshots{T,N} end

Type representing a collection of parametric abstract arrays of eltype T, that are associated with a realisation of type R. Unlike AbstractParamArray, which are arrays of arrays, subtypes of Snapshots are arrays of numbers.

source
GridapROMs.ParamDataStructures.TransientParamFunction — Type
struct TransientParamFunction{F,P,T} <: AbstractParamFunction{P}
  fun::F
  params::P
  times::T
end

Representation of parametric functions with domain a transient parametric space. Given a function f : Ω₁ × ... × Ωₙ × D × [t₁,t₂], where [t₁,t₂] is a temporal domain and D is a ParamSpace, or equivalently f : Ω₁ × ... × Ωₙ × D × [t₁,t₂], where D is a TransientParamSpace, the evaluation of f in (μ,t) ∈ D × [t₁,t₂] returns the restriction of f to Ω₁ × ... × Ωₙ

source
GridapROMs.ParamDataStructures.TransientParamSpace — Type
struct TransientParamSpace{P<:ParamSpace,T} <: AbstractSet{TransientRealisation}
  parametric_space::P
  temporal_domain::T
end

Fields:

  • parametric_space: underlying parameter space
  • temporal_domain: underlying temporal space

It represents, in essence, the set of tuples (p,t) in parametric_space × temporal_domain

source
GridapROMs.ParamDataStructures.TransientRealisation — Type
abstract type TransientRealisation{P<:Realisation,T<:Real} <: AbstractRealisation end

Represents temporal parametric realisations, i.e. samples extracted from a given parameter space for every time step in a temporal range. The most obvious application of this type are transient PDEs, where an initial condition is given. Following this convention, the initial time instant is kept separate from the other time steps.

source
GridapROMs.ParamDataStructures.TransientRealisationAt — Type
struct TransientRealisationAt{P,T} <: TransientRealisation{P,T}
  params::P
  t::Base.RefValue{T}
end

Represents a GenericTransientRealisation{P,T} at a certain time instant t. To avoid making it a mutable struct, the time instant t is stored as a Base.RefValue{T}.

source
GridapROMs.ParamDataStructures.change_mode — Method
change_mode(a::AbstractMatrix,np::Integer) -> AbstractMatrix

Converts the space-mode unfolding a of transient snapshots with np parameters into their time-mode unfolding (time steps × (space DOFs, parameters))

source
GridapROMs.ParamDataStructures.find_param_length — Method
find_param_length(a...) -> Int

Returns the parametric length of all parametric quantities. An error is thrown if there are no parametric quantities or if at least two quantities have different parametric length

source
GridapROMs.ParamDataStructures.get_param_entry — Method
get_param_entry(A::AbstractParamArray{T},i...) where T -> Vector{eltype(T)}

Returns a vector of the entries of A at index i, for every parameter. The length of the output is equals to param_length(A)

source
GridapROMs.ParamDataStructures.local_parameterise — Method
local_parameterise(a,plength::Integer) -> GenericParamBlock

Cell-wise parameterisation of a: a block storing plength independent copies of a (or the entries of a, if it is already a collection of plength arrays)

source
GridapROMs.ParamDataStructures.parameterise — Method
parameterise(a,plength::Integer) -> Any

Returns a quantity with parametric length plength from a. When a already possesses a parametric length, i.e. it is a parametrized quantity, it returns a

source
GridapROMs.ParamDataStructures.parameterise — Method
parameterise(f::Function,r::Realisation) -> ParamFunction
parameterise(f::Function,r::TransientRealisation) -> TransientParamFunction

Method that parameterises an input quantity by a realisation r

source
GridapROMs.ParamDataStructures.realisation — Method
realisation(p::ParamSpace;nparams=1,sampling=get_sampling_style(p),kwargs...) -> Realisation
realisation(p::TransientParamSpace;nparams=1,sampling=get_sampling_style(p),kwargs...) -> TransientRealisation

Extraction of a set of nparams parameters from a given parametric space, by default according to the sampling strategy specified in p.

source