|
| 1 | +Hyper-Reduction |
| 2 | +=============== |
| 3 | + |
| 4 | +This tutorial builds off of the information presented in |
| 5 | +:doc:`understand` to demonstrate how to set up and run a hyper-reduced |
| 6 | +reduced-order model (ROM) for the 1-D Burgers' equation using the Pressio library. |
| 7 | + |
| 8 | +If you have not completed that initial tutorial, please do so before proceeding. |
| 9 | + |
| 10 | +This page will follow the same structure as the previous tutorial, |
| 11 | +going through the enumerated steps but only highlighting the differences |
| 12 | +needed to implement hyper-reduction. |
| 13 | + |
| 14 | +First: Why use hyper-reduction? |
| 15 | +------------------------------- |
| 16 | + |
| 17 | +As discussed above, a typical ROM uses only the state snapshots |
| 18 | +to build the reduced basis. |
| 19 | + |
| 20 | +This reduces the dimensionality of the system, but |
| 21 | +we still evaluate the full-order RHS at each time step, |
| 22 | +which can be computationally expensive. **Hyper-reduction** |
| 23 | +addresses this issue by approximating the RHS using a |
| 24 | +reduced basis constructed from the RHS snapshots. |
| 25 | + |
| 26 | +So instead of a reduced state basis alone, we will |
| 27 | +also build a reduced basis for the RHS using the |
| 28 | +RHS snapshots we collected earlier. |
| 29 | + |
| 30 | +With this, we can begin the tutorial. |
| 31 | + |
| 32 | +Steps 0-1: As Before |
| 33 | +-------------------- |
| 34 | + |
| 35 | +Setting up Pressio and constructing your FOM is done exactly |
| 36 | +the same, regardless of the type of ROM you will build. |
| 37 | + |
| 38 | +Step 2: Run the FOM to generate snapshots |
| 39 | +----------------------------------------- |
| 40 | + |
| 41 | +In the original tutorial, we defined a ``SnapshotSet`` |
| 42 | +to collect snapshots for both the ``state`` and the |
| 43 | +right-hand side ``rhs`` of the full-order model (FOM). |
| 44 | + |
| 45 | +You may have noticed that the default ROM did not use |
| 46 | +the RHS snapshots at all. However, for hyper-reduction, |
| 47 | +we will need these RHS snapshots to build the |
| 48 | +hyper-reduction basis. |
| 49 | + |
| 50 | +We will explain this further in subsequent steps. |
| 51 | + |
| 52 | +If you are not implementing hyper-reduction, there is no |
| 53 | +need to store the RHS snapshots. You can simply return |
| 54 | +the state snapshots directly. |
| 55 | + |
| 56 | +Step 3: Build the ROM from the snapshot matrix |
| 57 | +---------------------------------------------- |
| 58 | + |
| 59 | +The process begins identically to before: we use the |
| 60 | +state snapshots to compute the trial space, and then use |
| 61 | +that to get the reduced state. We will also use the same |
| 62 | +``ForwardEuler`` time stepper as before. |
| 63 | + |
| 64 | +The key difference is in the definition of a **hyper-reducer**. |
| 65 | + |
| 66 | +The hyper-reducer is a functor that takes in a sampled |
| 67 | +FOM RHS vector and projects it into a reduced space. |
| 68 | + |
| 69 | +The process is similar to that of the trial space: we |
| 70 | +compute a POD basis from the RHS snapshots using SVD, |
| 71 | +and then use that basis to project the FOM RHS onto |
| 72 | +a lower-dimensional subspace. |
| 73 | + |
| 74 | +There are refined techniques for selecting which rows |
| 75 | +of the RHS to sample, such as the Discrete Empirical |
| 76 | +Interpolation Method (DEIM). For simplicity in this tutorial, |
| 77 | +we will use a basic sampling approach that selects rows at |
| 78 | +a uniform interval (or stride). |
| 79 | + |
| 80 | +Here is a general outline of how the hyper-reducer functor |
| 81 | +is defined: |
| 82 | + |
| 83 | +.. code-block:: cpp |
| 84 | +
|
| 85 | + auto svdRhs = /* compute SVD of RHS snapshot matrix */; |
| 86 | + auto rhsBasis = /* extract leading left singular vectors from SVD */; |
| 87 | +
|
| 88 | + auto sampleIndices = /* select sample indices uniformly */; |
| 89 | + auto sampledBasis = /* extract rows of rhsBasis at sampleIndices */; |
| 90 | +
|
| 91 | + auto trialBasis /* aka Phi */ = trialSpace.basisOfTranslatedSpace(); |
| 92 | + auto hypredMatrix = /* (Phi^T rhsBasis) * pinv(sampledBasis) */; |
| 93 | +
|
| 94 | + // Construct hyperreducer functor |
| 95 | + ExplicitGalerkinHyperReducer hyperReducer(hypredMatrix, sampleIndices); |
| 96 | +
|
| 97 | +This code is implemented fully in the ``hyperreduction.h`` file |
| 98 | +by the ``buildHyperReducer`` function. |
| 99 | + |
| 100 | +The ``ExplicitGalerkinHyperReducer`` above is a |
| 101 | +user-defined functor that implements an ``operator()`` method |
| 102 | +that takes in a sampled FOM RHS vector and outputs the reduced RHS vector. |
| 103 | + |
| 104 | +Like with the other Pressio interfaces, you can define your |
| 105 | +hyperreducer in any way you like, as long as it meets the API requirements. |
| 106 | + |
| 107 | +Now that we have defined the hyper-reducer, we can |
| 108 | +build the ROM almost identically to before, but passing |
| 109 | +the hyperreducer functor as an additional argument: |
| 110 | + |
| 111 | +.. code-block:: cpp |
| 112 | +
|
| 113 | + auto rom = pressio::rom::galerkin::create_default_problem_with_hyperreduction( |
| 114 | + stepScheme, |
| 115 | + trialSpace, |
| 116 | + fom, |
| 117 | + hyperReducer |
| 118 | + ); |
| 119 | +
|
| 120 | +Step 4-6: As Before |
| 121 | +------------------- |
| 122 | + |
| 123 | +The rest of the steps are identical regardless of whether |
| 124 | +you are using hyper-reduction or not. You can refer to the |
| 125 | +:doc:`understand` page for details on how to run the ROM, |
| 126 | +reconstruct the full-order solution, compare to the FOM, |
| 127 | +and examine the output files. |
0 commit comments