romtools.vector_space.utils.shifter#

Notes

The vector defining the affine offset for a linear subspace is viewed as a matrix of shape

\[\mathbf{u}_{\mathrm{shift}} \in \mathbb{R}^{N_{\mathrm{vars}} \times N_{\mathrm{x}} }\]

Theory#

What is a shift vector, and why would I use it? In ROMs, we restrict a state to belong to a low-dimensional affine vector space,

\[\mathbf{u} \approx \tilde{\mathbf{u}} \in \mathcal{V} + \mathbf{u}_{\mathrm{shift}}\]

where \(\mathcal{V} \equiv \mathrm{range}(\boldsymbol \Phi)\). Here \(\mathbf{u}_{\mathrm{shift}}\) defines an affine offset. Affine offsets can be useful for a variety of reasons, including satisfying boundary conditions, and satisfying initial conditions.

The Shifter protocol encapsulates the affine offset. The StreamingShifter protocol additionally supports initializing a data-derived shift vector from snapshot blocks loaded on demand.

API#

Functions

create_average_shifter(my_array)

Shifts the data by the average of a data matrix.

create_constant_shifter(shift_value, my_array)

Shifts the data by a constant value.

create_firstvec_shifter(my_array)

Shifts the data by the first vector of a data matrix.

create_noop_shifter(my_array)

No op implementation.

create_streaming_average_shifter()

Create a shifter initialized from the temporal average of streamed data.

create_streaming_firstvec_shifter()

Create a shifter initialized from the first streamed snapshot.

create_vector_shifter(shift_vector)

Shifts the data by a user-input vector.

Classes

Shifter(*args, **kwargs)

Interface for the Shifter class.

StreamingShifter(*args, **kwargs)

Shifter interface required by streaming POD vector spaces.

class romtools.vector_space.utils.shifter.Shifter(*args, **kwargs)[source]#

Bases: Protocol

Interface for the Shifter class.

apply_inverse_shift(my_array)[source]#

Shifts the snapshot matrix by adding a vector generated by the public-facing free functions.

Parameters:

my_array (ndarray)

Return type:

None

apply_shift(my_array)[source]#

Shifts the snapshot matrix by subtracting a vector generated by the public-facing free functions.

Parameters:

my_array (ndarray)

Return type:

None

get_shift_vector()[source]#

Returns the vector used to shift the data.

Return type:

ndarray

class romtools.vector_space.utils.shifter.StreamingShifter(*args, **kwargs)[source]#

Bases: Shifter, Protocol

Shifter interface required by streaming POD vector spaces.

initialize_shift_vector_from_loader(snapshot_loader, block_size, n_snapshots, comm=None)[source]#

Initialize a shift vector from snapshot blocks when required.

Parameters:
Return type:

None

romtools.vector_space.utils.shifter.create_average_shifter(my_array)[source]#

Shifts the data by the average of a data matrix.

Parameters:

my_array (ndarray)

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_constant_shifter(shift_value, my_array)[source]#

Shifts the data by a constant value.

Parameters:

my_array (ndarray)

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_firstvec_shifter(my_array)[source]#

Shifts the data by the first vector of a data matrix.

Parameters:

my_array (ndarray)

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_noop_shifter(my_array)[source]#

No op implementation.

Parameters:

my_array (ndarray)

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_streaming_average_shifter()[source]#

Create a shifter initialized from the temporal average of streamed data.

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_streaming_firstvec_shifter()[source]#

Create a shifter initialized from the first streamed snapshot.

Return type:

StreamingShifter

romtools.vector_space.utils.shifter.create_vector_shifter(shift_vector)[source]#

Shifts the data by a user-input vector.

Parameters:

shift_vector (ndarray)

Return type:

StreamingShifter