GridapROMs.Utils
GridapROMs.Utils — Module
module UtilsFoundational utilities for GridapROMs, providing:
- Performance tracking —
CostTracker,RBPerformanceTracker,Speedup,compute_error,compute_relative_error. - Partial derivatives —
PartialDerivative,∂₁,∂₂,∂₃. - Contributions —
Contribution,ArrayContribution: values indexed by triangulation. - Integration domains —
FEDomains,Bundle,OperatorType,get_polynomial_order.
GridapROMs.Utils.ArrayContribution — Type
const ArrayContribution = Contribution{<:Union{AbstractArray,ArrayBlock}}GridapROMs.Utils.ArrayContributionTuple — Type
const ArrayContributionTuple = ContributionTuple{<:ArrayContribution,S} where SSpecifically allows to deal with tuples of Jacobians in unsteady settings. Left unparameterized by element type for the same reason as ArrayContribution: eltype is not defined for it
GridapROMs.Utils.Bundle — Type
struct Bundle{A,B}
linear::A
nonlinear::B
endPair of a linear and a nonlinear quantity (residuals, Jacobians, domains, reduced contributions) of a problem split into its linear and nonlinear parts. Calling a Bundle of functions returns the sum of the two parts
GridapROMs.Utils.Contribution — Type
struct Contribution{V,T}
values::Tuple{Vararg{V}}
trians::Tuple{Vararg{T}}
endCollection of values corresponding to a set of triangulations. Similarly to DomainContribution, the values can be accessed by indexing the corresponding triangulation.
GridapROMs.Utils.ContributionTuple — Type
struct ContributionTuple{A,T<:Tuple{Vararg{A}}}
tuple::T
endConcrete wrapper around a (possibly heterogeneous) tuple of Contributions (e.g. one per time derivative order in unsteady settings, as in ArrayContributionTuple). A is a common supertype of the elements of tuple, allowing e.g. different jacobian terms to have differently-shaped bases.
GridapROMs.Utils.CostTracker — Type
mutable struct CostTracker <: PerformanceTracker
name::String
time::Float64
nallocs::Float64
nruns::Int
endRecords the wall time (in seconds) and the memory allocations (in Mb) of nruns runs of an algorithm
GridapROMs.Utils.FEDomains — Type
struct FEDomains{A,B}
domains_res::A
domains_jac::B
endFields:
domains_res: triangulations relative to the residual (nothing by default)domains_jac: triangulations relative to the Jacobian (nothing by default)
GridapROMs.Utils.LinearEq — Type
struct LinearEq <: OperatorType endTrait indicating that a parametric FE operator is fully linear.
GridapROMs.Utils.NonlinearEq — Type
struct NonlinearEq <: OperatorType endTrait indicating that a parametric FE operator is nonlinear.
GridapROMs.Utils.OfflineCostTracker — Type
mutable struct OfflineCostTracker <: PerformanceTracker
subspace::CostTracker
jacobian::CostTracker
residual::CostTracker
endCosts of the offline phase of a RB method: construction of the reduced subspace, and hyper-reduction of the Jacobian and of the residual
GridapROMs.Utils.OperatorType — Type
abstract type OperatorType <: GridapType endTrait encoding the linearity structure of a parametric FE operator.
Subtypes:
GridapROMs.Utils.PartialDerivative — Type
struct PartialDerivative{N} <: Function endGridap Map that implements a partial derivative
GridapROMs.Utils.PerformanceTracker — Type
abstract type PerformanceTracker endSupertype of the structures recording the computational cost (and, for RBPerformanceTracker, the accuracy) of FE and RB solvers
GridapROMs.Utils.RBPerformanceTracker — Type
mutable struct RBPerformanceTracker <: PerformanceTracker
verbose::Bool
full_order::CostTracker
reduced_order::CostTracker
offline::OfflineCostTracker
error::Any
endCosts of the full order solver, of the online and offline phases of a RB solver, and error of the RB approximation (see rom_performance). When verbose, costs are printed as soon as they are recorded
GridapROMs.Utils.Speedup — Type
struct Speedup <: PerformanceTracker
name::String
speedup_time::Float64
speedup_memory::Float64
endSpeedup in time and memory of one algorithm with respect to another. See compute_speedup
GridapROMs.Utils.∂₁ — Type
const ∂₁ = PartialDerivative{1}GridapROMs.Utils.∂₂ — Type
const ∂₂ = PartialDerivative{2}GridapROMs.Utils.∂₃ — Type
const ∂₃ = PartialDerivative{3}GridapROMs.Utils.collect_cell_matrix_for_trian — Method
function collect_cell_matrix_for_trian(
trial::FESpace,
test::FESpace,
a::DomainContribution,
strian::Triangulation
) -> Tuple{Vector{<:Any},Vector{<:Any},Vector{<:Any}}Computes the cell-wise data needed to assemble a global sparse matrix for a given input triangulation strian
GridapROMs.Utils.collect_cell_vector_for_trian — Method
function collect_cell_vector_for_trian(
test::FESpace,
a::DomainContribution,
strian::Triangulation
) -> Tuple{Vector{<:Any},Vector{<:Any}}Computes the cell-wise data needed to assemble a global vector for a given input triangulation strian
GridapROMs.Utils.compute_error — Method
compute_error(sol::AbstractArray,sol_approx::AbstractArray,args...) -> NumberComputes the error between sol and sol_approx, by default in the Euclidean norm. A different norm (usually represented by a sparse matrix) can be provided as an argument.
GridapROMs.Utils.compute_relative_error — Method
compute_relative_error(sol::AbstractArray,sol_approx::AbstractArray,args...) -> NumberComputes the relative error between sol and sol_approx, by default in the Euclidean norm. A different norm (usually represented by a sparse matrix) can be provided as an argument.
GridapROMs.Utils.compute_speedup — Method
compute_speedup(t1::CostTracker,t2::CostTracker) -> SpeedupComputes the speedup the tracker t2 achieves with respect to t1, in time and in memory footprint
GridapROMs.Utils.contribution — Method
contribution(f,trians) -> ContributionConstructor of a Contribution that allows do-block syntax. f is a function such that
values[i] = f(trians[i]) for i...
This constructor first builds the tuple of values, then builds the Contribution object from values and trians
GridapROMs.Utils.get_contributions — Method
get_contributions(a::Contribution) -> TupleValues of a, one per triangulation
GridapROMs.Utils.get_domains_jac — Method
get_domains_jac(a) -> Tuple{Vararg{Triangulation}}Triangulations on which the Jacobian of a is integrated. a can be a FEDomains, a Bundle of them, or an operator
GridapROMs.Utils.get_domains_res — Method
get_domains_res(a) -> Tuple{Vararg{Triangulation}}Triangulations on which the residual of a is integrated. a can be a FEDomains, a Bundle of them, or an operator
GridapROMs.Utils.get_linear_part — Method
get_linear_part(a)Linear part of a Bundle, or of an operator built from Bundles. Returns a itself for any other input
GridapROMs.Utils.get_name — Function
get_name(t::PerformanceTracker) -> StringName of the tracker t
GridapROMs.Utils.get_nonlinear_part — Method
get_nonlinear_part(a)Nonlinear part of a Bundle, or of an operator built from Bundles. Returns a itself for any other input
GridapROMs.Utils.get_polynomial_order — Method
get_polynomial_order(f::FESpace) -> IntegerRetrieves the polynomial order of f
GridapROMs.Utils.get_polynomial_orders — Method
get_polynomial_orders(fs::FESpace) -> NTuple{D,Int}Retrieves the polynomial order of fs for every dimension d = 1,...,D of the underlying reference FE
GridapROMs.Utils.induced_norm — Method
induced_norm(v::AbstractVector[,X::AbstractMatrix]) -> Number
induced_norm(A::AbstractArray[,X::AbstractMatrix]) -> NumberNorm of v induced by the norm matrix X (Euclidean if not provided). For an array A, the mean of the (squared) norms of its columns
GridapROMs.Utils.set_fom_tracker! — Function
set_fom_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Overwrites the cost of the full order solver recorded in t with stats, the output of @timed
GridapROMs.Utils.set_jacobian_tracker! — Function
set_jacobian_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Overwrites the cost of the hyper-reduction of the Jacobian recorded in t with stats, the output of @timed
GridapROMs.Utils.set_residual_tracker! — Function
set_residual_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Overwrites the cost of the hyper-reduction of the residual recorded in t with stats, the output of @timed
GridapROMs.Utils.set_rom_tracker! — Function
set_rom_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Overwrites the cost of the online phase of the reduced solver recorded in t with stats, the output of @timed
GridapROMs.Utils.set_subspace_tracker! — Function
set_subspace_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Overwrites the cost of the construction of the reduced subspace recorded in t with stats, the output of @timed
GridapROMs.Utils.set_tracker! — Method
set_tracker!(t::CostTracker)Resets t
GridapROMs.Utils.sqrtabs — Method
sqrtabs(x) -> NumberSquare root of x, or of its modulus when x is complex
GridapROMs.Utils.unwrap_and_setsize! — Method
unwrap_and_setsize!(a,b[,c]) -> AbstractArrayResizes the cached array (or block of cached arrays) a to the size of b (or of b ⊗ c), and returns the underlying array
GridapROMs.Utils.update_fom_tracker! — Function
update_fom_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Adds stats, the output of @timed, to the cost of the full order solver recorded in t
GridapROMs.Utils.update_jacobian_tracker! — Function
update_jacobian_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Adds stats, the output of @timed, to the cost of the hyper-reduction of the Jacobian recorded in t
GridapROMs.Utils.update_residual_tracker! — Function
update_residual_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Adds stats, the output of @timed, to the cost of the hyper-reduction of the residual recorded in t
GridapROMs.Utils.update_rom_tracker! — Function
update_rom_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Adds stats, the output of @timed, to the cost of the online phase of the reduced solver recorded in t
GridapROMs.Utils.update_subspace_tracker! — Function
update_subspace_tracker!(t::PerformanceTracker,stats::NamedTuple;kwargs...)Adds stats, the output of @timed, to the cost of the construction of the reduced subspace recorded in t
GridapROMs.Utils.update_tracker! — Method
update_tracker!(t::CostTracker,stats::NamedTuple;msg="")Adds the time and allocations in stats, the output of @timed, to t. If msg is not empty, it is printed together with t