rom.ecsw.linear_form_hyperrom_ecsw

Purpose: Implements ECSW-based hyperreduction for finite element linear forms, enabling fast reduced-order load vector assembly by projecting element-wise load contributions onto a reduced basis, clustering elements by free-DOF count after Dirichlet condensation, and assembling the global reduced load vector via vectorized weighted projections.

Summary: Provides the LinearFormHYPERROM_ecsw class, a reduced-order linear form that handles Dirichlet boundary conditions through full-to-free DOF mapping, applies element-wise ECSW weights during projection, and produces the final ( r )-dimensional reduced load vector. All operations are restricted to free DOFs, with Dirichlet and mean-field contributions reinserted during reconstruction. The broader ecsw package also includes:

  • Reduced-order bilinear forms (BilinearFormHYPERROM_ecsw) and linear forms (LinearFormHYPERROM_ecsw)
  • Routines for extracting element stiffness matrices and load vectors in a reduced basis
  • Utilities for efficient Dirichlet condition handling and element clustering
  • Support for weights, parallelization, and full-order data reconstruction

Author: Suparno Bhattacharyya


Classes

Name Description
LinearFormHYPERROM_ecsw Reduced-order linear form for ECSW hyperreduction of load vectors.

LinearFormHYPERROM_ecsw

rom.ecsw.linear_form_hyperrom_ecsw.LinearFormHYPERROM_ecsw(
    form,
    elem_weight,
    ubasis,
    lob,
    free_dofs=None,
    mean=None,
    nthreads=0,
    dtype=np.float64,
)

Summary: Assembles the hyperreduced load vector for ROM use by projecting element-level load contributions onto the reduced test basis and accumulating them with their corresponding ECSW weights. Dirichlet boundary conditions are handled via a mapping from global DOFs to free (non-Dirichlet) DOFs—all assembly operations are performed exclusively on free DOFs. Elements are clustered by their free-DOF count to enable vectorized batch projections, following the same clustering strategy as BilinearFormHYPERROM_ecsw. The mean field, if provided, is subtracted during basis construction and reinserted during full-order reconstruction.

The assembly operation performed is:

[ r = {e {}} w_e V_L^|{} e|{} ]

where ( w_e ) is the ECSW weight for element ( e ), ( V_L ) is the left reduced test basis lob, and ( _e ) is the local load vector restricted to free DOFs.


Parameters

Name Type Description Default
form callable Full-order linear form function evaluating local load contributions for each element. required
elem_weight scalar or ndarray Element-wise ECSW weights; either a scalar applied uniformly to all elements or an array of length equal to the number of elements. required
ubasis Basis FE basis object containing the full DOF count and element connectivity for the original mesh. required
lob ndarray, shape (N_free, r) or (N, r) Left (test) reduced basis matrix; shape (N_free, r) when free_dofs is provided, or (N, r) otherwise, where ( r ) is the reduced dimension. required
free_dofs ndarray of int or None Indices of global DOFs that are free (non-Dirichlet); if provided, all assembly operations are restricted to these DOFs. None
mean ndarray or None Mean snapshot vector of length N_full; subtracted during basis construction and reinserted during full-order reconstruction. None
nthreads int Number of threads for parallel element-wise load evaluation; 0 uses serial execution. 0
dtype numpy.dtype NumPy data type for assembled vectors and intermediate arrays. np.float64

Methods

Name Description
assemble_weighted_ecsw Assemble the ECSW-weighted reduced load vector.
extract_element_vector_rom Extract local element load vectors over the hyperreduced element set.

assemble_weighted_ecsw

rom.ecsw.linear_form_hyperrom_ecsw.LinearFormHYPERROM_ecsw.assemble_weighted_ecsw(**kwargs)

Summary: Assembles the global reduced load vector by iterating over active elements, scaling each element load vector by its ECSW weight, projecting the result onto the left reduced test basis restricted to free DOFs, and summing all contributions into the final vector of length ( r ). The method forwards additional keyword arguments (such as previous solution states or material parameters) to the underlying element extraction routine.

Parameters
Name Type Description Default
**kwargs dict Additional keyword arguments forwarded to extract_element_vector_rom, such as previous solution states or material parameters. {}
Returns
Name Type Description
f_reduced ndarray, shape (r,) Assembled ECSW-weighted reduced load vector, ready for use in ROM linear solves.

extract_element_vector_rom

rom.ecsw.linear_form_hyperrom_ecsw.LinearFormHYPERROM_ecsw.extract_element_vector_rom(
    basis,
    elem_indices=None,
    **kwargs,
)

Summary: Evaluates the full-order linear form over the specified elements and returns the resulting local load vectors as an array of shape (n_elem, Nbfun), where Nbfun is the number of local basis functions per element. The basis is restricted to the specified element subset via with_elements before evaluation. Supports both serial and parallel execution depending on nthreads.

Parameters
Name Type Description Default
basis Basis Basis object restricted via with_elements for the active element subset. required
elem_indices ndarray of int or None Subset of element indices to include in the extraction; forwarded to with_elements. Defaults to all active elements. None
**kwargs dict Additional keyword arguments forwarded to the low-level form evaluation. {}
Returns
Name Type Description
element_vectors ndarray, shape (n_elem, Nbfun) Local load vectors for each element in the restricted element set; Nbfun is the number of local basis functions per element.
Raises
Type Condition
ValueError Raised if basis is None or improperly configured.

Functions

Name Description
with_elements Return a restricted basis on a specified subset of element indices.

with_elements

rom.ecsw.linear_form_hyperrom_ecsw.with_elements(self, elements=None)

Summary: Returns a new basis instance restricted to the specified subset of element indices. Used internally to construct element-restricted basis objects before load vector extraction, and is also available for direct use when restricting any compatible basis to an arbitrary element subset.

Parameters

Name Type Description Default
elements array_like of int or None Indices of elements to retain in the restricted basis; if None, the full basis is returned unchanged. None

Returns

Name Type Description
restricted_basis Basis New basis instance covering only the specified elements, with mesh connectivity adjusted accordingly.