The solving_utils Module

stat_fem.solving_utils.interp_covariance_to_data(im_left, G, ls, im_right, ensemble_comm=<Mock name='mock.COMM_SELF' id='140051716830736'>)

Solve for the interpolated covariance matrix

Solve for the covariance matrix interpolated to the sensor data locations. Note that the arguments allow for two different interpolation matrices to be used, in the event that we wish to compute the covariance matrix for other locations to make predictions. Note that since the Covariance Matrix is symmetric, it is advantageous to put the matrix with fewer spatial locations on the right as it will lead to fewer FEM solves (simply take the transpose if the reverse order is desired)

This function solves \(\Phi_l^T A^{-1}GA^{-1}\Phi_r\), returning it as a 2D numpy array on the root process. This requires doing two FEM solves for each location provided in \(\Phi_r\) plus some sparse matrix multiplication. Non-root processes will return an empty 2D numpy array (shape (0,0)).

The solves can be done independently, so optionally a Firedrake Ensemble communicator can be provided for dividing up the solves. The solves are simply divided up among the processes, so it is up to the user to determine an appropriate number of processes given the number of sensor locations that are needed. If not provided, the solves will be done serially.

Parameters:
  • im_left (InterpolationMatrix) – Left side InterpolationMatrix
  • G (ForcingCovariance) – Forcing covariance matrix to be used in the solve.
  • ls (Firedrake LinearSolver) – Firedrake LinearSolver to be used for the FEM solution
  • im_right (InterpolationMatrix) – Right side Interpolation Matrix
  • ensemble_comm (MPI Communicator) – MPI Communicator over which to parallelize the FEM solves (optional, default is solve in series)
Returns:

Covariance matrix interpolated to sensor locations. If run in parallel, this is returned on the root process as a 2D numpy array, while all other processes return an empty array (shape (0,0))

Return type:

ndarray

stat_fem.solving_utils.solve_forcing_covariance(G, ls, rhs)

Solve the forcing covariance part of the stat FEM

This function performs the basic solve needed to determine the prior covariance matrix in the stat-fem method. Two solves of the FEM are required, in addition to a sparse matrix multiplication. The arguments provide the sparse Forcing Covariance matrix, the Firedrake Linear Solver object representing the FEM, and the RHS to be solved for this particular iteration.

Note that this solve function temporarily turns off the BCs for the stiffness matrix. This is because Dirichlet BCs will enforce strong boundary conditions on the FEM solves, which is not desired here.

Parameters:
  • G (ForcingCovariance) – Forcing covariance matrix to be used in the solve.
  • ls (Firedrake LinearSolver) – Firedrake Linear Solver to be used in the solve.
  • rhs (Firedrake Vector) – RHS vector to be used in the solve
Returns:

Solution to \(A^{-1}GA^{-1}b\) where \(A\) is the FEM stiffness matrix and \(b\) is the RHS vector.

Return type:

Firedrake Vector