adamantine
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
adamantine::DataAssimilator Class Reference

#include <DataAssimilator.hh>

Public Member Functions

 DataAssimilator (MPI_Comm const &global_communicator, MPI_Comm const &local_communicator, int my_color, boost::property_tree::ptree const &database)
 
void update_ensemble (std::vector< dealii::LA::distributed::BlockVector< double >> &augmented_state_ensemble, std::vector< double > const &expt_data, dealii::SparseMatrix< double > const &R)
 
template<int dim>
void update_dof_mapping (std::pair< std::vector< int >, std::vector< int >> const &expt_to_dof_mapping)
 
template<int dim>
void update_covariance_sparsity_pattern (dealii::DoFHandler< dim > const &dof_handler, const unsigned int parameter_size)
 

Private Types

using block_size_type = dealii::LA::distributed::BlockVector< double >::size_type
 

Private Member Functions

void gather_ensemble_members (std::vector< dealii::LA::distributed::BlockVector< double >> &augmented_state_ensemble, std::vector< dealii::LA::distributed::BlockVector< double >> &global_augmented_state_ensemble, std::vector< unsigned int > &local_n_ensemble_members, std::vector< block_size_type > &block_sizes)
 
void scatter_ensemble_members (std::vector< dealii::LA::distributed::BlockVector< double >> &augmented_state_ensemble, std::vector< dealii::LA::distributed::BlockVector< double >> const &global_augmented_state_ensemble, std::vector< unsigned int > const &local_n_ensemble_members, std::vector< block_size_type > const &block_sizes)
 
std::vector< dealii::LA::distributed::BlockVector< double > > apply_kalman_gain (std::vector< dealii::LA::distributed::BlockVector< double >> &augmented_state_ensemble, dealii::SparseMatrix< double > const &R, std::vector< dealii::Vector< double >> const &perturbed_innovation)
 
dealii::SparseMatrix< double > calc_H (dealii::SparsityPattern &pattern) const
 
dealii::Vector< double > calc_Hx (dealii::LA::distributed::Vector< double > const &sim_ensemble_member) const
 
void fill_noise_vector (dealii::Vector< double > &vec, dealii::SparseMatrix< double > const &R, bool const R_is_diagonal)
 
double gaspari_cohn_function (double const r) const
 
dealii::TrilinosWrappers::SparseMatrix calc_sample_covariance_sparse (std::vector< dealii::LA::distributed::BlockVector< double >> const &vec_ensemble) const
 

Private Attributes

MPI_Comm _global_communicator
 
MPI_Comm _local_communicator
 
int _global_rank = -1
 
int _global_comm_size = -1
 
int _color = -1
 
unsigned int _num_ensemble_members = 0
 
unsigned int _sim_size = 0
 
unsigned int _parameter_size = 0
 
unsigned int _expt_size = 0
 
dealii::TrilinosWrappers::SparsityPattern _covariance_sparsity_pattern
 
std::map< const std::pair< unsigned int, unsigned int >, double > _covariance_distance_map
 
double _localization_cutoff_distance
 
LocalizationCutoff _localization_cutoff_function
 
std::mt19937 _prng
 
std::normal_distribution _normal_dist_generator
 
std::pair< std::vector< int >, std::vector< int > > _expt_to_dof_mapping
 
dealii::SolverControl _solver_control
 
dealii::SolverGMRES< dealii::Vector< double > >::AdditionalData _additional_data
 

Friends

class DataAssimilatorTester
 

Detailed Description

This class implements an ensemble Kalman filter (EnKF) for data assimilation. It updates an ensemble of solution vectors to be consistent with experimental observations.

The EnKF implementation here is largely based on Chapter 6 of Data Assimilation: Method and Applications by Asch, Bocquet, and Nodet.

Definition at line 57 of file DataAssimilator.hh.

Member Typedef Documentation

◆ block_size_type

using adamantine::DataAssimilator::block_size_type = dealii::LA::distributed::BlockVector<double>::size_type
private

Definition at line 110 of file DataAssimilator.hh.

Constructor & Destructor Documentation

◆ DataAssimilator()

adamantine::DataAssimilator::DataAssimilator ( MPI_Comm const &  global_communicator,
MPI_Comm const &  local_communicator,
int  my_color,
boost::property_tree::ptree const &  database 
)

Constructor.

Definition at line 31 of file DataAssimilator.cc.

Member Function Documentation

◆ apply_kalman_gain()

std::vector< dealii::LA::distributed::BlockVector< double > > adamantine::DataAssimilator::apply_kalman_gain ( std::vector< dealii::LA::distributed::BlockVector< double >> &  augmented_state_ensemble,
dealii::SparseMatrix< double > const &  R,
std::vector< dealii::Vector< double >> const &  perturbed_innovation 
)
private

This calculates the Kalman gain and applies it to the perturbed innovation.

Definition at line 399 of file DataAssimilator.cc.

◆ calc_H()

dealii::SparseMatrix< double > adamantine::DataAssimilator::calc_H ( dealii::SparsityPattern &  pattern) const
private

This calculates the observation matrix.

Definition at line 474 of file DataAssimilator.cc.

◆ calc_Hx()

dealii::Vector< double > adamantine::DataAssimilator::calc_Hx ( dealii::LA::distributed::Vector< double > const &  sim_ensemble_member) const
private

This calculates the application of the observation matrix on an unaugmented ensemble member from the simulation, avoiding explicit construction of a sparse matrix for H.

Definition at line 607 of file DataAssimilator.cc.

◆ calc_sample_covariance_sparse()

dealii::TrilinosWrappers::SparseMatrix adamantine::DataAssimilator::calc_sample_covariance_sparse ( std::vector< dealii::LA::distributed::BlockVector< double >> const &  vec_ensemble) const
private

This calculates the sample covariance for an input ensemble of vectors (vec_ensemble). Currently this is tied to the simulation ensemble, through the use of member variables inside. If needed, the interface could be redone to make it more generally applicable.

Definition at line 684 of file DataAssimilator.cc.

◆ fill_noise_vector()

void adamantine::DataAssimilator::fill_noise_vector ( dealii::Vector< double > &  vec,
dealii::SparseMatrix< double > const &  R,
bool const  R_is_diagonal 
)
private

This fills a vector (vec) with noise from a multivariate normal distribution defined by a covariance matrix (R). Note: For non-diagonal R this method currently uses full matrices, which substantially limits the allowable problem size.

Definition at line 623 of file DataAssimilator.cc.

◆ gaspari_cohn_function()

double adamantine::DataAssimilator::gaspari_cohn_function ( double const  r) const
private

A standard localization function, resembles a Gaussian, but with finite support. From Gaspari and Cohn, Quarterly Journal of the Royal Meteorological Society, 125, 1999.

Definition at line 665 of file DataAssimilator.cc.

◆ gather_ensemble_members()

void adamantine::DataAssimilator::gather_ensemble_members ( std::vector< dealii::LA::distributed::BlockVector< double >> &  augmented_state_ensemble,
std::vector< dealii::LA::distributed::BlockVector< double >> &  global_augmented_state_ensemble,
std::vector< unsigned int > &  local_n_ensemble_members,
std::vector< block_size_type > &  block_sizes 
)
private

Gather the augmented ensemble members on the global root node in order to apply the Kalman gain.

Definition at line 186 of file DataAssimilator.cc.

◆ scatter_ensemble_members()

void adamantine::DataAssimilator::scatter_ensemble_members ( std::vector< dealii::LA::distributed::BlockVector< double >> &  augmented_state_ensemble,
std::vector< dealii::LA::distributed::BlockVector< double >> const &  global_augmented_state_ensemble,
std::vector< unsigned int > const &  local_n_ensemble_members,
std::vector< block_size_type > const &  block_sizes 
)
private

Scatter the global_augmented_state_ensemble back into augmented_state_ensemble.

Definition at line 300 of file DataAssimilator.cc.

◆ update_covariance_sparsity_pattern()

template<int dim>
template void adamantine::DataAssimilator::update_covariance_sparsity_pattern< 3 > ( dealii::DoFHandler< dim > const &  dof_handler,
const unsigned int  parameter_size 
)

This updates the sparsity pattern for the sample covariance matrix for the simulation ensemble. This must be called before updateEnsemble whenever there are changes to the simulation mesh.

Definition at line 508 of file DataAssimilator.cc.

◆ update_dof_mapping()

template<int dim>
template void adamantine::DataAssimilator::update_dof_mapping< 3 > ( std::pair< std::vector< int >, std::vector< int >> const &  expt_to_dof_mapping)

This updates the internal mapping between the indices of the entries in expt_data and the indices of the entries in the sim_data ensemble members in updateEnsemble. This must be called before updateEnsemble whenever there are changes to the simulation mesh or the observation locations.

Definition at line 500 of file DataAssimilator.cc.

◆ update_ensemble()

void adamantine::DataAssimilator::update_ensemble ( std::vector< dealii::LA::distributed::BlockVector< double >> &  augmented_state_ensemble,
std::vector< double > const &  expt_data,
dealii::SparseMatrix< double > const &  R 
)

This is the main public interface for the class and is called to perform one assimilation process. It takes in an ensemble of simulation data (sim_data), experimental observation data (expt_data), and the covariance matrix for the experimental observations (R). This function updates sim_data using the EnKF method.

Overall it performs x = x + K (y + u - H x) for each ensemble member, where: x is the simulation solution K is the Kalman gain y is the observed solution u is a perturbation to the observed solution H is the observation matrix

Definition at line 90 of file DataAssimilator.cc.

Friends And Related Function Documentation

◆ DataAssimilatorTester

friend class DataAssimilatorTester
friend

Definition at line 59 of file DataAssimilator.hh.

Member Data Documentation

◆ _additional_data

dealii::SolverGMRES<dealii::Vector<double> >::AdditionalData adamantine::DataAssimilator::_additional_data
private

Additional settings for the GMRES solver needed for the matrix inversion in the Kalman gain calculation.

Definition at line 286 of file DataAssimilator.hh.

◆ _color

int adamantine::DataAssimilator::_color = -1
private

Color associated with the local

Definition at line 209 of file DataAssimilator.hh.

◆ _covariance_distance_map

std::map<const std::pair<unsigned int, unsigned int>, double> adamantine::DataAssimilator::_covariance_distance_map
private

Map between the indices in the covariance matrix and the distance between the support points for the associated dofs on the mesh. This is necessary for localization.

Definition at line 242 of file DataAssimilator.hh.

◆ _covariance_sparsity_pattern

dealii::TrilinosWrappers::SparsityPattern adamantine::DataAssimilator::_covariance_sparsity_pattern
private

The sparsity pattern for the localized covariance matrix.

Definition at line 234 of file DataAssimilator.hh.

◆ _expt_size

unsigned int adamantine::DataAssimilator::_expt_size = 0
private

The length of the data vector the experimental observations.

Definition at line 229 of file DataAssimilator.hh.

◆ _expt_to_dof_mapping

std::pair<std::vector<int>, std::vector<int> > adamantine::DataAssimilator::_expt_to_dof_mapping
private

The mapping between the index in the experimental observation data vector to the DoF in the simulation data vectors. This is simpler to use than the indices and offsets that are passed into updateEnsemble, and means that the simulation DoFHandler only needs to be used by updateDofMapping where this variable is set.

Definition at line 274 of file DataAssimilator.hh.

◆ _global_comm_size

int adamantine::DataAssimilator::_global_comm_size = -1
private

Number of processes in the gglbal MPI communicator.

Definition at line 204 of file DataAssimilator.hh.

◆ _global_communicator

MPI_Comm adamantine::DataAssimilator::_global_communicator
private

Global MPI communicator.

Definition at line 189 of file DataAssimilator.hh.

◆ _global_rank

int adamantine::DataAssimilator::_global_rank = -1
private

Rank of the process when using the global MPI communicator.

Definition at line 199 of file DataAssimilator.hh.

◆ _local_communicator

MPI_Comm adamantine::DataAssimilator::_local_communicator
private

Local MPI communicator split off the global MPI communicator.

Definition at line 194 of file DataAssimilator.hh.

◆ _localization_cutoff_distance

double adamantine::DataAssimilator::_localization_cutoff_distance
private

The distance at which the sample covariance is truncated.

Definition at line 247 of file DataAssimilator.hh.

◆ _localization_cutoff_function

LocalizationCutoff adamantine::DataAssimilator::_localization_cutoff_function
private

The function used to reduce the sample covariance entries based on the distance between the relevant points.

Definition at line 253 of file DataAssimilator.hh.

◆ _normal_dist_generator

std::normal_distribution adamantine::DataAssimilator::_normal_dist_generator
private

Random variate generator for a normal distribution, used for the perturbations to the innovation vectors.

Definition at line 265 of file DataAssimilator.hh.

◆ _num_ensemble_members

unsigned int adamantine::DataAssimilator::_num_ensemble_members = 0
private

The number of ensemble members in the simulation.

Definition at line 214 of file DataAssimilator.hh.

◆ _parameter_size

unsigned int adamantine::DataAssimilator::_parameter_size = 0
private

The length of the parameter vector for each simulation ensemble member.

Definition at line 224 of file DataAssimilator.hh.

◆ _prng

std::mt19937 adamantine::DataAssimilator::_prng
private

The pseudo-random number generator, used for the perturbations to the innovation vectors.

Definition at line 259 of file DataAssimilator.hh.

◆ _sim_size

unsigned int adamantine::DataAssimilator::_sim_size = 0
private

The length of the data vector for each simulation ensemble member.

Definition at line 219 of file DataAssimilator.hh.

◆ _solver_control

dealii::SolverControl adamantine::DataAssimilator::_solver_control
private

Standardized settings for the GMRES solver needed for the matrix inversion in the Kalman gain calculation.

Definition at line 280 of file DataAssimilator.hh.