SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar > Class Template Referencefinal

Build a non-owning view of a packed layout as a span. More...

#include <vector_view.hpp>

Collaboration diagram for serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >:
[legend]

Public Types

using LayoutType = std::remove_cvref_t<Layout>
 Alias for the layout type, e.g. SystemLayout<Values, Residuals>.
 

Public Member Functions

 BlockVectorView (const LayoutType &layout, std::span< Scalar > values)
 Construct one of these views from a layout and a span of coefficients.
 
 BlockVectorView (const LayoutType &&, std::span< Scalar >)=delete
 Reject temporary metadata whose offsets would dangle before the coefficients are accessed.
 
template<typename Range>
requires (!std::is_lvalue_reference_v<Range> && !std::ranges::borrowed_range<Range>)
 BlockVectorView (const LayoutType &, Range &&)=delete
 Prevent implicit const-span conversion from retaining a temporary owning container.
 
template<typename Coordinate>
requires utils::dependencies::ContainsKey<Coordinate, typename LayoutType::template Coordinates<Kind>>
std::span< Scalar > get () const
 Access the requested physical coordinate while retaining storage constness.
 

Private Attributes

const LayoutType & m_layout
 The layout to use for the view. The layout must remain unchanged while the view is used.
 
std::span< Scalar > m_values
 The span of coefficients to view.
 

Detailed Description

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
requires (Kind == RepresentedValueKind::value || Kind == RepresentedValueKind::residual)
class serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >

Build a non-owning view of a packed layout as a span.

Template Parameters
KindThe kind of represented values to select, e.g. RepresentedValueKind::values or RepresentedValueKind::residuals.
LayoutThe block layout type, e.g. SystemLayout.
ScalarThe scalar type of the coefficients, e.g. double.
Requirements
Note
The layout must remain unchanged while the view is used. Probably we want to, in the future, add some way to validate this; however, I am at the moment at a loss for how to do so.

Member Typedef Documentation

◆ LayoutType

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
using serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::LayoutType = std::remove_cvref_t<Layout>

Alias for the layout type, e.g. SystemLayout<Values, Residuals>.

Constructor & Destructor Documentation

◆ BlockVectorView() [1/3]

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::BlockVectorView ( const LayoutType & layout,
std::span< Scalar > values )
inline

Construct one of these views from a layout and a span of coefficients.

Parameters
layoutThe layout to use for the view.
valuesThe span of coefficients to view.
Exceptions
std::domain_errorIf the span of coefficients does not match the total size of the layout.
Todo
Really this could go in many places; however, I think we should move away from throwing std exceptions and introduce our own exception hierarchy.

◆ BlockVectorView() [2/3]

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::BlockVectorView ( const LayoutType && ,
std::span< Scalar >  )
delete

Reject temporary metadata whose offsets would dangle before the coefficients are accessed.

◆ BlockVectorView() [3/3]

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
template<typename Range>
requires (!std::is_lvalue_reference_v<Range> && !std::ranges::borrowed_range<Range>)
serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::BlockVectorView ( const LayoutType & ,
Range &&  )
delete

Prevent implicit const-span conversion from retaining a temporary owning container.

Member Function Documentation

◆ get()

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
template<typename Coordinate>
requires utils::dependencies::ContainsKey<Coordinate, typename LayoutType::template Coordinates<Kind>>
std::span< Scalar > serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::get ( ) const
inlinenodiscard

Access the requested physical coordinate while retaining storage constness.

Template Parameters
CoordinateThe coordinate tag to access
Requirements
  • A layout type with kind Kind must contain the requested coordinate tag.

Member Data Documentation

◆ m_layout

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
const LayoutType& serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::m_layout
private

The layout to use for the view. The layout must remain unchanged while the view is used.

◆ m_values

template<RepresentedValueKind Kind, SystemLayoutType Layout, typename Scalar = double>
std::span<Scalar> serif::discretization::blocks::BlockVectorView< Kind, Layout, Scalar >::m_values
private

The span of coefficients to view.


The documentation for this class was generated from the following file: