void RBEIMConstruction::initialize_parametrized_functions_in_training_set() { if(!serial_training_set) { libMesh::err << "Error: We must have serial_training_set==true in " << "RBEIMConstruction::initialize_parametrized_functions_in_training_set" << std::endl; libmesh_error(); } libMesh::out << "Initializing parametrized functions in training set..." << std::endl; // initialize rb_eval's parameters get_rb_evaluation().initialize_parameters(*this); _parametrized_functions_in_training_set.resize( get_n_training_samples() ); for(unsigned int i=0; i<get_n_training_samples(); i++) { set_params_from_training_set(i); truth_solve(-1); _parametrized_functions_in_training_set[i] = solution->clone().release(); libMesh::out << "Completed solve for training sample " << (i+1) << " of " << get_n_training_samples() << std::endl; } _parametrized_functions_in_training_set_initialized = true; libMesh::out << "Parametrized functions in training set initialized" << std::endl << std::endl; }
Real RBEIMConstruction::compute_best_fit_error() { START_LOG("compute_best_fit_error()", "RBEIMConstruction"); const unsigned int RB_size = get_rb_evaluation().get_n_basis_functions(); // load up the parametrized function for the current parameters truth_solve(-1); switch(best_fit_type_flag) { // Perform an L2 projection in order to find an approximation to solution (from truth_solve above) case(PROJECTION_BEST_FIT): { // compute the rhs by performing inner products DenseVector<Number> best_fit_rhs(RB_size); inner_product_matrix->vector_mult(*inner_product_storage_vector, *solution); for(unsigned int i=0; i<RB_size; i++) { best_fit_rhs(i) = inner_product_storage_vector->dot(get_rb_evaluation().get_basis_function(i)); } // Now compute the best fit by an LU solve get_rb_evaluation().RB_solution.resize(RB_size); DenseMatrix<Number> RB_inner_product_matrix_N(RB_size); get_rb_evaluation().RB_inner_product_matrix.get_principal_submatrix(RB_size, RB_inner_product_matrix_N); RB_inner_product_matrix_N.lu_solve(best_fit_rhs, get_rb_evaluation().RB_solution); break; } // Perform EIM solve in order to find the approximation to solution // (rb_solve provides the EIM basis function coefficients used below) case(EIM_BEST_FIT): { // Turn off error estimation for this rb_solve, we use the linfty norm instead get_rb_evaluation().evaluate_RB_error_bound = false; get_rb_evaluation().set_parameters( get_parameters() ); get_rb_evaluation().rb_solve(RB_size); get_rb_evaluation().evaluate_RB_error_bound = true; break; } default: libmesh_error_msg("Should not reach here"); } // load the error into solution for(unsigned int i=0; i<get_rb_evaluation().get_n_basis_functions(); i++) { solution->add(-get_rb_evaluation().RB_solution(i), get_rb_evaluation().get_basis_function(i)); } Real best_fit_error = solution->linfty_norm(); STOP_LOG("compute_best_fit_error()", "RBEIMConstruction"); return best_fit_error; }