21 #include "libmesh/rb_construction_base.h" 22 #include "libmesh/rb_construction.h" 23 #include "libmesh/rb_assembly_expansion.h" 24 #include "libmesh/rb_evaluation.h" 25 #include "libmesh/elem_assembly.h" 28 #include "libmesh/numeric_vector.h" 29 #include "libmesh/sparse_matrix.h" 30 #include "libmesh/dof_map.h" 31 #include "libmesh/libmesh_logging.h" 32 #include "libmesh/equation_systems.h" 33 #include "libmesh/exodusII_io.h" 34 #include "libmesh/gmv_io.h" 35 #include "libmesh/linear_solver.h" 36 #include "libmesh/getpot.h" 37 #include "libmesh/int_range.h" 38 #include "libmesh/mesh_base.h" 39 #include "libmesh/parallel.h" 40 #include "libmesh/xdr_cxx.h" 41 #include "libmesh/timestamp.h" 42 #include "libmesh/petsc_linear_solver.h" 43 #include "libmesh/dg_fem_context.h" 44 #include "libmesh/dirichlet_boundaries.h" 45 #include "libmesh/zero_function.h" 46 #include "libmesh/coupling_matrix.h" 47 #include "libmesh/face_tri3_subdivision.h" 48 #include "libmesh/quadrature.h" 49 #include "libmesh/utility.h" 52 #include <sys/types.h> 59 #ifdef LIBMESH_HAVE_UNISTD_H 67 const std::string & name_in,
68 const unsigned int number_in)
69 :
Parent(es, name_in, number_in),
71 extra_linear_solver(nullptr),
73 skip_residual_in_train_reduced_basis(false),
74 exit_on_repeated_greedy_parameters(true),
75 impose_internal_fluxes(false),
76 skip_degenerate_sides(true),
77 compute_RB_inner_product(false),
78 store_non_dirichlet_operators(false),
79 store_untransformed_basis(false),
80 use_empty_rb_solve_in_greedy(true),
81 Fq_representor_innerprods_computed(false),
84 output_dual_innerprods_computed(false),
85 assert_convergence(true),
87 inner_product_assembly(nullptr),
88 use_energy_inner_product(false),
89 rel_training_tolerance(1.e-4),
90 abs_training_tolerance(1.e-12),
91 normalize_rb_bound_in_greedy(false),
92 RB_training_type(
"Greedy"),
93 _preevaluate_thetas_flag(false),
94 _preevaluate_thetas_completed(false)
105 LOG_SCOPE(
"clear()",
"RBConstruction");
130 return "RBConstruction";
151 const unsigned int maxits =
152 es.
parameters.
get<
unsigned int>(
"linear solver maximum iterations");
162 input_solver.
solve (input_matrix, *
solution, input_rhs, tol, maxits);
177 libmesh_error_msg_if(!
rb_eval,
"Error: RBEvaluation object hasn't been initialized yet");
184 libmesh_error_msg_if(!
rb_eval,
"Error: RBEvaluation object hasn't been initialized yet");
207 GetPot infile(parameters_filename);
209 const unsigned int n_training_samples = infile(
"n_training_samples",0);
210 const bool deterministic_training = infile(
"deterministic_training",
false);
211 unsigned int training_parameters_random_seed_in =
212 static_cast<unsigned int>(-1);
213 training_parameters_random_seed_in = infile(
"training_parameters_random_seed",
214 training_parameters_random_seed_in);
215 const bool quiet_mode_in = infile(
"quiet_mode",
quiet_mode);
216 const unsigned int Nmax_in = infile(
"Nmax",
Nmax);
217 const Real rel_training_tolerance_in = infile(
"rel_training_tolerance",
219 const Real abs_training_tolerance_in = infile(
"abs_training_tolerance",
223 const bool normalize_rb_bound_in_greedy_in = infile(
"normalize_rb_bound_in_greedy",
226 const std::string RB_training_type_in = infile(
"RB_training_type",
"Greedy");
229 unsigned int n_continuous_parameters = infile.vector_variable_size(
"parameter_names");
232 for (
unsigned int i=0; i<n_continuous_parameters; i++)
235 std::string param_name = infile(
"parameter_names",
"NONE", i);
238 Real min_val = infile(param_name, 0., 0);
239 mu_min_in.
set_value(param_name, min_val);
243 Real max_val = infile(param_name, 0., 1);
244 mu_max_in.
set_value(param_name, max_val);
248 std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
250 unsigned int n_discrete_parameters = infile.vector_variable_size(
"discrete_parameter_names");
251 for (
unsigned int i=0; i<n_discrete_parameters; i++)
253 std::string param_name = infile(
"discrete_parameter_names",
"NONE", i);
255 unsigned int n_vals_for_param = infile.vector_variable_size(param_name);
256 std::vector<Real> vals_for_param(n_vals_for_param);
257 for (
auto j :
make_range(vals_for_param.size()))
258 vals_for_param[j] = infile(param_name, 0., j);
260 discrete_parameter_values_in[param_name] = vals_for_param;
263 std::map<std::string,bool> log_scaling_in;
267 for (
const auto & pr : mu_min_in)
268 log_scaling_in[pr.first] =
false;
272 deterministic_training,
273 static_cast<int>(training_parameters_random_seed_in),
276 rel_training_tolerance_in,
277 abs_training_tolerance_in,
278 normalize_rb_bound_in_greedy_in,
282 discrete_parameter_values_in,
287 unsigned int n_training_samples_in,
288 bool deterministic_training_in,
289 int training_parameters_random_seed_in,
291 unsigned int Nmax_in,
292 Real rel_training_tolerance_in,
293 Real abs_training_tolerance_in,
294 bool normalize_rb_bound_in_greedy_in,
295 const std::string & RB_training_type_in,
298 const std::map<std::string, std::vector<Real>> & discrete_parameter_values_in,
299 const std::map<std::string,bool> & log_scaling_in,
300 std::map<std::string, std::vector<RBParameter>> * training_sample_list)
323 bool updated_deterministic_training = deterministic_training_in;
333 updated_deterministic_training =
false;
338 n_training_samples_in,
340 updated_deterministic_training);
342 if (training_sample_list)
353 libMesh::out << std::endl <<
"RBConstruction parameters:" << std::endl;
370 libMesh::out <<
"RBThetaExpansion member is not set yet" << std::endl;
389 std::unique_ptr<NumericVector<Number>> temp =
solution->clone();
412 libmesh_error_msg_if(!
rb_assembly_expansion,
"Error: RBAssemblyExpansion object hasn't been initialized yet");
426 "Error: inner_product_assembly not available since we're using energy inner-product");
429 "Error: inner_product_assembly hasn't been initialized yet");
442 #ifdef LIBMESH_ENABLE_CONSTRAINTS 463 bool skip_vector_assembly)
465 if (!skip_matrix_assembly && !skip_vector_assembly)
493 bool skip_vector_assembly)
495 if (!skip_matrix_assembly)
502 if (!skip_vector_assembly)
628 return std::make_unique<DGFEMContext>(*this);
636 bool apply_dof_constraints)
638 LOG_SCOPE(
"add_scaled_matrix_and_vector()",
"RBConstruction");
640 bool assemble_matrix = (input_matrix !=
nullptr);
641 bool assemble_vector = (input_vector !=
nullptr);
643 if (!assemble_matrix && !assemble_vector)
654 std::set<dof_id_type> nodes_with_nodesets;
655 for (
const auto & t :
mesh.get_boundary_info().build_node_list())
656 nodes_with_nodesets.insert(std::get<0>(t));
664 int nodal_assembly_threw = 0;
669 for (
const auto &
id : nodes_with_nodesets)
671 const Node & node =
mesh.node_ref(
id);
678 std::vector<dof_id_type> nodal_dof_indices;
698 if (!nodal_dof_indices.empty())
700 if (apply_dof_constraints)
711 nodal_matrix *= scalar;
715 input_vector->
add_vector(nodal_rhs, nodal_dof_indices);
718 input_matrix->
add_matrix(nodal_matrix, nodal_dof_indices);
725 nodal_assembly_threw = 1;
730 this->
comm().
max(nodal_assembly_threw);
732 if (nodal_assembly_threw)
733 libmesh_error_msg(
"Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
750 int assembly_threw = 0;
755 for (
const auto & elem :
mesh.active_local_element_ptr_range())
757 const ElemType elemtype = elem->type();
767 if (!apply_dof_constraints)
774 std::unique_ptr<QBase> qrule;
783 const int extraorder = 0;
784 FEBase * elem_fe =
nullptr;
806 for (context.
side = 0; context.
side != n_sides; ++context.
side)
856 if (apply_dof_constraints)
861 if (assemble_matrix && symmetrize)
871 if (apply_dof_constraints)
889 if (!coupling_matrix)
899 for (
unsigned int var1=0; var1<
n_vars(); var1++)
902 for (
const auto & var2 : ccr)
907 for (
unsigned int row=0; row<sub_m; row++)
908 for (
unsigned int col=0; col<sub_n; col++)
940 input_matrix->
close();
942 input_vector->
close();
946 this->
comm().
max(assembly_threw);
949 libmesh_error_msg(
"Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
962 LOG_SCOPE(
"truth_assembly()",
"RBConstruction");
997 bool apply_dof_constraints)
999 input_matrix->
zero();
1008 apply_dof_constraints);
1013 "Error: invalid number of entries in energy_inner_product_coeffs.");
1024 apply_dof_constraints);
1031 bool apply_dof_constraints)
1034 "Error: We must have q < Q_a in assemble_Aq_matrix.");
1036 input_matrix->
zero();
1043 apply_dof_constraints);
1051 LOG_SCOPE(
"add_scaled_Aq()",
"RBConstruction");
1054 "Error: We must have q < Q_a in add_scaled_Aq.");
1058 input_matrix->
add(scalar, *
get_Aq(q_a));
1059 input_matrix->
close();
1073 libMesh::out <<
"Assembling inner product matrix" << std::endl;
1078 libMesh::out <<
"Assembling non-Dirichlet inner product matrix" << std::endl;
1087 libMesh::out <<
"Assembling affine operator " << (q_a+1) <<
" of " 1096 libMesh::out <<
"Assembling non-Dirichlet affine operator " << (q_a+1) <<
" of " 1107 libMesh::out <<
"Assembling affine vector " << (q_f+1) <<
" of " 1116 libMesh::out <<
"Assembling non-Dirichlet affine vector " << (q_f+1) <<
" of " 1126 bool apply_dof_constraints)
1129 "Error: We must have q < Q_f in assemble_Fq_vector.");
1131 input_vector->
zero();
1138 apply_dof_constraints );
1146 libMesh::out <<
"Assembling output vector, (" << (n+1) <<
"," << (q_l+1)
1163 libMesh::out <<
"Assembling non-Dirichlet output vector, (" << (n+1) <<
"," << (q_l+1)
1198 LOG_SCOPE(
"train_reduced_basis_with_greedy()",
"RBConstruction");
1208 if (resize_rb_eval_data)
1217 Real training_greedy_error = 0.;
1225 libMesh::out <<
"Maximum number of basis functions reached: Nmax = " 1243 libMesh::out << std::endl <<
"---- Performing Greedy basis enrichment ----" << std::endl;
1244 Real initial_greedy_error = 0.;
1245 bool initial_greedy_error_initialized =
false;
1253 libMesh::out <<
"Performing RB solves on training set" << std::endl;
1256 libMesh::out <<
"Maximum error bound is " << training_greedy_error << std::endl << std::endl;
1259 if (!initial_greedy_error_initialized)
1261 initial_greedy_error = training_greedy_error;
1262 initial_greedy_error_initialized =
true;
1271 libMesh::out <<
"Performing truth solve at parameter:" << std::endl;
1282 libMesh::out <<
"Zero basis function encountered hence ending basis enrichment" << std::endl;
1297 libMesh::out <<
"Maximum number of basis functions reached: Nmax = " 1312 return training_greedy_error;
1317 LOG_SCOPE(
"enrich_basis_from_rhs_terms()",
"RBConstruction");
1323 if (resize_rb_eval_data)
1328 libMesh::out << std::endl <<
"---- Enriching basis from rhs terms ----" << std::endl;
1334 libMesh::out << std::endl <<
"Performing truth solve with rhs from rhs term " << q_f << std::endl;
1366 char temp_file[] =
"truth_rhs_XXXXXX.dat";
1367 int fd = mkstemps(temp_file, 4);
1370 libMesh::out <<
"Writing truth system rhs to file: " << temp_file << std::endl;
1378 #ifdef LIBMESH_HAVE_EXODUS_API 1384 char temp_file[] =
"truth_XXXXXX.exo";
1385 int fd = mkstemps(temp_file, 4);
1388 libMesh::out <<
"Writing truth solution to file: " << temp_file << std::endl;
1390 std::set<std::string> system_names = {this->
name()};
1396 #endif // LIBMESH_HAVE_EXODUS_API 1414 libmesh_error_msg_if(
get_rb_evaluation().get_n_basis_functions() > 0,
"Basis should not already be initialized");
1432 std::vector<std::unique_ptr<NumericVector<Number>>> POD_snapshots(n_snapshots);
1433 for (
unsigned int i=0; i<n_snapshots; i++)
1441 for (
unsigned int i=0; i<n_snapshots; i++)
1448 libMesh::out <<
"Truth solve " << (i+1) <<
" of " << n_snapshots << std::endl;
1458 libMesh::out <<
"Normalizing solution snapshots" << std::endl;
1459 for (
unsigned int i=0; i<n_snapshots; i++)
1466 POD_snapshots[i]->scale(1./
norm);
1472 for (
unsigned int i=0; i<n_snapshots; i++)
1477 for (
unsigned int j=0; j<=i; j++)
1481 correlation_matrix(i,j) = inner_prod;
1493 correlation_matrix.
svd(sigma, U, VT );
1502 if (j >=
get_Nmax() || j >= n_snapshots)
1504 libMesh::out <<
"Maximum number of basis functions (" << j <<
") reached." << std::endl;
1511 const Real rel_err = std::sqrt(sigma(j)) / std::sqrt(sigma(0));
1514 <<
", POD error norm: " << rel_err << std::endl;
1518 libMesh::out <<
"Training tolerance reached." << std::endl;
1522 std::unique_ptr< NumericVector<Number> > v = POD_snapshots[j]->zero_clone();
1523 for (
unsigned int i=0; i<n_snapshots; ++i )
1525 v->add( U.
el(i, j), *POD_snapshots[i] );
1528 Real norm_v = std::sqrt(sigma(j));
1529 v->scale( 1./norm_v );
1555 libMesh::out <<
"Absolute error tolerance reached." << std::endl;
1559 Real rel_greedy_error = abs_greedy_error/initial_error;
1562 libMesh::out <<
"Relative error tolerance reached." << std::endl;
1570 libMesh::out <<
"Maximum number of basis functions reached: Nmax = " 1579 libMesh::out <<
"Exiting greedy because the same parameters were selected twice" << std::endl;
1594 "Error: Argument in RBConstruction::get_greedy_parameter is too large.");
1601 LOG_SCOPE(
"truth_solve()",
"RBConstruction");
1646 #ifdef LIBMESH_HAVE_EXODUS_API 1647 if (plot_solution > 0)
1650 std::set<std::string> system_names = {this->
name()};
1667 return (RB_training_type_in ==
"POD");
1689 this->
Nmax = Nmax_in;
1694 LOG_SCOPE(
"load_basis_function()",
"RBConstruction");
1705 LOG_SCOPE(
"enrich_RB_space()",
"RBConstruction");
1709 std::unique_ptr<NumericVector<Number>> new_untransformed_bf;
1734 if (new_bf_norm == 0.)
1740 new_untransformed_bf->zero();
1745 new_bf->scale(1./new_bf_norm);
1749 new_untransformed_bf->scale(1./new_bf_norm);
1772 Real error_bound = 0.;
1796 error_bound /= error_bound_normalization;
1809 unsigned int saved_delta_N =
delta_N;
1819 LOG_SCOPE(
"compute_max_error_bound()",
"RBConstruction");
1825 if (std::numeric_limits<Real>::has_infinity)
1827 max_val = std::numeric_limits<Real>::infinity();
1831 max_val = std::numeric_limits<Real>::max();
1842 unsigned int max_err_index = 0;
1867 std::pair<numeric_index_type, Real> error_pair(first_index+max_err_index, max_err);
1879 unsigned int root_id=0;
1891 return error_pair.second;
1896 LOG_SCOPE(
"update_RB_system_matrices()",
"RBConstruction");
1905 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1911 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1920 for (
unsigned int j=0; j<RB_size; j++)
1965 LOG_SCOPE(
"update_residual_terms()",
"RBConstruction");
1967 libMesh::out <<
"Updating RB residual terms" << std::endl;
1978 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2003 libMesh::out <<
"Starting solve [q_a][i]=[" << q_a <<
"]["<< i <<
"] in RBConstruction::update_residual_terms() at " 2014 libMesh::out <<
"Finished solve [q_a][i]=[" << q_a <<
"]["<< i <<
"] in RBConstruction::update_residual_terms() at " 2026 if (compute_inner_products)
2035 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2048 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2050 for (
unsigned int j=0; j<RB_size; j++)
2088 LOG_SCOPE(
"compute_output_dual_innerprods()",
"RBConstruction");
2090 libMesh::out <<
"Compute output dual inner products" << std::endl;
2093 unsigned int max_Q_l = 0;
2097 std::vector<std::unique_ptr<NumericVector<Number>>> L_q_representor(max_Q_l);
2098 for (
unsigned int q=0; q<max_Q_l; q++)
2112 libMesh::out <<
"Starting solve n=" << n <<
", q_l=" << q_l
2113 <<
" in RBConstruction::compute_output_dual_innerprods() at " 2130 libMesh::out <<
"Finished solve n=" << n <<
", q_l=" << q_l
2131 <<
" in RBConstruction::compute_output_dual_innerprods() at " 2135 <<
" iterations, final residual " 2177 LOG_SCOPE(
"compute_Fq_representor_innerprods()",
"RBConstruction");
2195 <<
" in RBConstruction::update_residual_terms() at " 2206 <<
" in RBConstruction::update_residual_terms() at " 2210 <<
" iterations, final residual " 2217 if (compute_inner_products)
2242 LOG_SCOPE(
"load_rb_solution()",
"RBConstruction");
2249 <<
" RB_solution in RBConstruction::load_rb_solution is too long!");
2261 LOG_SCOPE(
"compute_residual_dual_norm_slow()",
"RBConstruction");
2278 for (
unsigned int i=0; i<N; i++)
2302 return std::sqrt(
libmesh_real(slow_residual_norm_sq) );
2318 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2326 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2354 "Error: We must have q < Q_a in get_Aq.");
2362 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Aq.");
2365 "Error: We must have q < Q_a in get_Aq.");
2383 "Error: We must have q < Q_f in get_Fq.");
2391 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Fq.");
2394 "Error: We must have q < Q_f in get_Fq.");
2413 "Error: We must have n < n_outputs and " 2414 "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_output_vector.");
2423 "Error: We must have n < n_outputs and " 2424 "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_non_dirichlet_output_vector.");
2431 all_matrices.clear();
2442 std::stringstream matrix_name;
2443 matrix_name <<
"A" << q_a;
2444 all_matrices[matrix_name.str()] =
get_Aq(q_a);
2448 matrix_name <<
"_non_dirichlet";
2456 all_vectors.clear();
2462 std::stringstream F_vector_name;
2463 F_vector_name <<
"F" << q_f;
2464 all_vectors[F_vector_name.str()] =
get_Fq(q_f);
2468 F_vector_name <<
"_non_dirichlet";
2476 output_vectors.clear();
2481 std::stringstream output_name;
2482 output_name <<
"output_" << n <<
"_"<< q_l;
2487 output_name <<
"_non_dirichlet";
2493 #ifdef LIBMESH_ENABLE_DIRICHLET 2499 std::set<boundary_id_type> dirichlet_ids;
2500 std::vector<unsigned int> variables;
2503 return std::make_unique<DirichletBoundary>(dirichlet_ids, variables, &zf);
2509 const bool write_binary_residual_representors)
2511 LOG_SCOPE(
"write_riesz_representors_to_files()",
"RBConstruction");
2517 libMesh::out <<
"Writing out the Fq_representors..." << std::endl;
2519 std::ostringstream file_name;
2520 const std::string riesz_representor_suffix = (write_binary_residual_representors ?
".xdr" :
".dat");
2521 struct stat stat_info;
2526 libMesh::out <<
"Skipping creating residual_representors directory: " << strerror(errno) << std::endl;
2533 file_name << riesz_representors_dir <<
"/Fq_representor" << i << riesz_representor_suffix;
2547 int stat_result = stat(file_name.str().c_str(), &stat_info);
2549 if ( (stat_result != 0) ||
2550 (stat_info.st_size == 0))
2558 Xdr fqr_data(file_name.str(),
2559 write_binary_residual_representors ?
ENCODE :
WRITE);
2577 libMesh::out <<
"Writing out the Aq_representors..." << std::endl;
2584 for (
unsigned int j=jstart; j<jstop; ++j)
2586 libMesh::out <<
"Writing out Aq_representor[" << i <<
"][" << j <<
"]..." << std::endl;
2590 file_name << riesz_representors_dir
2591 <<
"/Aq_representor" << i <<
"_" << j << riesz_representor_suffix;
2598 Xdr aqr_data(file_name.str(),
2599 write_binary_residual_representors ?
ENCODE :
WRITE);
2618 const bool read_binary_residual_representors)
2620 LOG_SCOPE(
"read_riesz_representors_from_files()",
"RBConstruction");
2622 libMesh::out <<
"Reading in the Fq_representors..." << std::endl;
2624 const std::string riesz_representor_suffix = (read_binary_residual_representors ?
".xdr" :
".dat");
2625 std::ostringstream file_name;
2626 struct stat stat_info;
2631 libmesh_error_msg_if(rep,
"Error, must delete existing Fq_representor before reading in from file.");
2636 file_name << riesz_representors_dir
2637 <<
"/Fq_representor" << i << riesz_representor_suffix;
2642 int stat_result = stat(file_name.str().c_str(), &stat_info);
2644 libmesh_error_msg_if(stat_result != 0,
"File does not exist: " << file_name.str());
2647 Xdr fqr_data(file_name.str(),
2648 read_binary_residual_representors ?
DECODE :
READ);
2657 Fq_representor[i]->swap(*
solution);
2665 libMesh::out <<
"Reading in the Aq_representors..." << std::endl;
2672 for (
const auto & rep : row)
2673 libmesh_error_msg_if(rep,
"Error, must delete existing Aq_representor before reading in from file.");
2680 file_name << riesz_representors_dir
2681 <<
"/Aq_representor" << i <<
"_" << j << riesz_representor_suffix;
2686 int stat_result = stat(file_name.str().c_str(), &stat_info);
2688 libmesh_error_msg_if(stat_result != 0,
"File does not exist: " << file_name.str());
2691 Xdr aqr_data(file_name.str(), read_binary_residual_representors ?
DECODE :
READ);
2710 libmesh_error_msg_if(conv_flag < 0,
"Convergence error. Error id: " << conv_flag);
2743 const std::vector<Number> &
2757 LOG_SCOPE(
"preevaluate_thetas()",
"RBConstruction");
2769 const unsigned int n_A_terms = rb_theta_expansion.
get_n_A_terms();
2770 const unsigned int n_F_terms = rb_theta_expansion.get_n_F_terms();
2771 const unsigned int n_outputs = rb_theta_expansion.get_total_n_output_terms();
2791 for (
unsigned int q_a=0; q_a<n_A_terms; q_a++)
2793 const auto A_vals = rb_theta_expansion.eval_A_theta(q_a, mus);
2798 for (
unsigned int q_f=0; q_f<n_F_terms; q_f++)
2800 const auto F_vals = rb_theta_expansion.eval_F_theta(q_f, mus);
2806 unsigned int output_counter = 0;
2807 for (
unsigned int n=0; n<rb_theta_expansion.get_n_outputs(); n++)
2808 for (
unsigned int q_l=0; q_l<rb_theta_expansion.get_n_output_terms(n); q_l++)
2812 const auto output_vals = rb_theta_expansion.eval_output_theta(n, q_l, mus);
2819 "We currently only support single-sample RBParameters " 2820 "objects during the training stage.");
virtual void read_riesz_representors_from_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
Read in all the Riesz representor data from files.
Real compute_residual_dual_norm_slow(const unsigned int N)
The slow (but simple, non-error prone) way to compute the residual dual norm.
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
bool normalize_rb_bound_in_greedy
This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound...
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
virtual void initialize_rb_construction(bool skip_matrix_assembly=false, bool skip_vector_assembly=false)
Allocate all the data structures necessary for the construction stage of the RB method.
ElemType
Defines an enum for geometric element types.
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
dof_id_type end_dof(const processor_id_type proc) const
This is the EquationSystems class.
virtual Number eval_output_theta(unsigned int output_index, unsigned int q_l, const RBParameters &mu) const
Evaluate theta_q_l at the current parameter.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
std::vector< Real > training_error_bounds
Vector storing the values of the error bound for each parameter in the training set — the parameter ...
bool get_normalize_rb_bound_in_greedy() const
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage. ...
A Node is like a Point, but with more information.
virtual void truth_assembly()
Assemble the truth matrix and right-hand side for current_parameters.
void set_RB_training_type(const std::string &RB_training_type_in)
Get/set the string that determines the training type.
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online...
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
void zero_constrained_dofs_on_vector(NumericVector< Number > &vector) const
It is sometimes useful to be able to zero vector entries that correspond to constrained dofs...
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
void set_energy_inner_product(const std::vector< Number > &energy_inner_product_coeffs_in)
Specify the coefficients of the A_q operators to be used in the energy inner-product.
std::vector< std::vector< Number > > _evaluated_thetas
Storage of evaluated theta functions at a set of parameters.
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
virtual void post_process_elem_matrix_and_vector(DGFEMContext &)
This function is called from add_scaled_matrix_and_vector() before each element matrix and vector are...
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
ConstFunction that simply returns 0.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true)
Train the reduced basis.
virtual void resize_data_structures(const unsigned int Nmax, bool resize_error_bound_data=true)
Resize and clear the data vectors corresponding to the value of Nmax.
virtual ~RBConstruction()
bool _normalize_solution_snapshots
Set this boolean to true if we want to normalize solution snapshots used in training to have norm of ...
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > *> &all_matrices)
Get a map that stores pointers to all of the matrices.
std::vector< std::unique_ptr< NumericVector< Number > > > _untransformed_basis_functions
In cases where we have dof transformations such as a change of coordinates at some nodes we need to s...
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
DenseVector< Number > RB_solution
The RB solution vector.
void set_preevaluate_thetas_flag(bool flag)
virtual Real truth_solve(int plot_solution)
Perform a "truth" solve, i.e.
RBConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and stores the result in NumericVector dest...
const Elem & get_elem() const
Accessor for current Elem object.
std::string get_timestamp()
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Real get_parameter_min(const std::string ¶m_name) const
Get minimum allowable value of parameter param_name.
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
Real get_parameter_max(const std::string ¶m_name) const
Get maximum allowable value of parameter param_name.
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
virtual void side_fe_reinit() override
Override side_fe_reinit to set a boolean flag so that by default DG terms are assumed to be inactive...
virtual void set_context_solution_vec(NumericVector< Number > &vec)
Set current_local_solution = vec so that we can access vec from FEMContext during assembly...
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
const std::vector< dof_id_type > & get_neighbor_dof_indices() const
Accessor for neighbor dof indices.
virtual void interior_assembly(FEMContext &)
Perform the element interior assembly.
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
const EquationSystems & get_equation_systems() const
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
void enrich_basis_from_rhs_terms(const bool resize_rb_eval_data=true)
This function computes one basis function for each rhs term.
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
ElemAssembly & get_inner_product_assembly()
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
processor_id_type rank() const
NumericVector< Number > * rhs
The system matrix.
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
bool get_convergence_assertion_flag() const
Getter for the flag determining if convergence should be checked after each solve.
This proxy class acts like a container of indices from a single coupling row.
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
bool skip_degenerate_sides
In some cases meshes are intentionally created with degenerate sides as a way to represent, say, triangles using a hex-only mesh.
virtual bool greedy_termination_test(Real abs_greedy_error, Real initial_greedy_error, int count)
Function that indicates when to terminate the Greedy basis training.
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
void add_scaled_Aq(Number scalar, unsigned int q_a, SparseMatrix< Number > *input_matrix, bool symmetrize)
Add the scaled q^th affine matrix to input_matrix.
const RBParameters & get_greedy_parameter(unsigned int i)
Return the parameters chosen during the i^th step of the Greedy algorithm.
int mkdir(const char *pathname)
Create a directory.
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
std::string RB_training_type
This string indicates the type of training that we will use.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix()
Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix...
static void get_global_max_error_pair(const Parallel::Communicator &communicator, std::pair< numeric_index_type, Real > &error_pair)
Static function to return the error pair (index,error) that is corresponds to the largest error on al...
NumericVector< Number > * get_non_dirichlet_Fq_if_avail(unsigned int q)
Get a pointer to non_dirichlet_Fq if it's available, otherwise get Fq.
virtual std::unique_ptr< DGFEMContext > build_context()
Builds a DGFEMContext object with enough information to do evaluations on each element.
virtual LinearSolver< Number > * get_linear_solver() const override
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
virtual Real get_error_bound_normalization()
const DenseMatrix< Number > & get_neighbor_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
const std::string & get_RB_training_type() const
The libMesh namespace provides an interface to certain functionality in the library.
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
virtual T dot(const NumericVector< T > &v) const =0
dof_id_type n_local_dofs() const
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online...
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
unsigned int get_current_training_parameter_index() const
Get/set the current training parameter index.
virtual void get_nodal_values(std::vector< dof_id_type > &, DenseMatrix< Number > &, DenseVector< Number > &, const System &, const Node &)
Get values to add to the matrix or rhs vector based on node.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
Real get_rel_training_tolerance() const
unsigned char get_side() const
Accessor for current side of Elem object.
const MeshBase & get_mesh() const
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
void reset_preevaluate_thetas_completed()
Reset the _preevaluate_thetas_completed flag to false.
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
virtual void print_info() const
Print out info that describes the current setup of this RBConstruction.
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
static std::unique_ptr< DirichletBoundary > build_zero_dirichlet_boundary_object()
It's helpful to be able to generate a DirichletBoundary that stores a ZeroFunction in order to impose...
std::vector< Number > energy_inner_product_coeffs
We may optionally want to use the "energy inner-product" rather than the inner-product assembly speci...
dof_id_type n_dofs() const
virtual void init_context(FEMContext &)
Initialize the FEMContext prior to performing an element loop.
virtual Real compute_max_error_bound()
(i) Compute the a posteriori error bound for each set of parameters in the training set...
This is the MeshBase class.
virtual void zero()=0
Set all entries to zero.
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
std::unique_ptr< NumericVector< Number > > inner_product_storage_vector
We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary me...
void print_basis_function_orthogonality() const
Print out a matrix that shows the orthogonality of the RB basis functions.
std::vector< std::unique_ptr< NumericVector< Number > > > non_dirichlet_Fq_vector
virtual void get_output_vectors(std::map< std::string, NumericVector< Number > *> &all_vectors)
Get a map that stores pointers to all of the vectors.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
virtual void load_training_set(const std::map< std::string, std::vector< RBParameter >> &new_training_set)
Overwrite the training parameters with new_training_set.
void set_rb_construction_parameters(unsigned int n_training_samples_in, bool deterministic_training_in, int training_parameters_random_seed_in, bool quiet_mode_in, unsigned int Nmax_in, Real rel_training_tolerance_in, Real abs_training_tolerance_in, bool normalize_rb_error_bound_in_greedy_in, const std::string &RB_training_type_in, const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values_in, const std::map< std::string, bool > &log_scaling, std::map< std::string, std::vector< RBParameter >> *training_sample_list=nullptr)
Set the state of this RBConstruction object based on the arguments to this function.
void assemble_inner_product_matrix(SparseMatrix< Number > *input_matrix, bool apply_dof_constraints=true)
Assemble the inner product matrix and store it in input_matrix.
LinearSolver< Number > * extra_linear_solver
Also, we store a pointer to an extra linear solver.
FEType get_fe_type() const
virtual void boundary_assembly(FEMContext &)
Perform the element boundary assembly.
This class handles the numbering of degrees of freedom on a mesh.
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
virtual void recompute_all_residual_terms(const bool compute_inner_products=true)
This function computes all of the residual representors, can be useful when restarting a basis traini...
virtual void load_basis_function(unsigned int i)
Load the i^th RB function into the RBConstruction solution vector.
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
This base class can be inherited from to provide interfaces to linear solvers from different packages...
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
virtual void initialize_training_parameters(const RBParameters &mu_min, const RBParameters &mu_max, const unsigned int n_global_training_samples, const std::map< std::string, bool > &log_param_scale, const bool deterministic=true)
Initialize the parameter ranges and indicate whether deterministic or random training parameters shou...
virtual void solve_for_matrix_and_rhs(LinearSolver< Number > &input_solver, SparseMatrix< Number > &input_matrix, NumericVector< Number > &input_rhs)
Assembles & solves the linear system A*x=b for the specified matrix input_matrix and right-hand side ...
bool impose_internal_fluxes
Boolean flag to indicate whether we impose "fluxes" (i.e.
bool Fq_representor_innerprods_computed
A boolean flag to indicate whether or not the Fq representor norms have already been computed — used...
void set_training_random_seed(int seed)
Set the seed that is used to randomly generate training parameters.
bool use_empty_rb_solve_in_greedy
A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves ...
bool use_energy_inner_product
Boolean to indicate whether we're using the energy inner-product.
void libmesh_ignore(const Args &...)
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool get_preevaluate_thetas_flag() const
Get/set flag to pre-evaluate the theta functions.
const T & get(std::string_view) const
Real final_linear_residual() const
void set_rb_assembly_expansion(RBAssemblyExpansion &rb_assembly_expansion_in)
Set the rb_assembly_expansion object.
virtual Real l2_norm() const =0
virtual void zero()=0
Set all entries to 0.
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
dof_id_type numeric_index_type
virtual void init(const char *name=nullptr)=0
Initialize data structures if not done so already.
virtual T el(const unsigned int i, const unsigned int j) const override final
void update_greedy_param_list()
Update the list of Greedily chosen parameters with current_parameters.
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.
unsigned int _current_training_parameter_index
The current training parameter index during reduced basis training.
unsigned int n_linear_iterations() const
void svd(DenseVector< Real > &sigma)
Compute the singular value decomposition of the matrix.
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
RBAssemblyExpansion & get_rb_assembly_expansion()
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
Real abs_training_tolerance
void get_transpose(DenseMatrix< T > &dest) const
Put the tranposed matrix into dest.
virtual void update_RB_system_matrices()
Compute the reduced basis matrices for the current basis.
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
virtual void update_residual_terms(bool compute_inner_products=true)
Compute the terms that are combined ‘online’ to determine the dual norm of the residual.
bool store_untransformed_basis
Boolean flag to indicate whether we store a second copy of the basis without constraints or dof trans...
void assemble_Fq_vector(unsigned int q, NumericVector< Number > *input_vector, bool apply_dof_constraints=true)
Assemble the q^th affine vector and store it in input_matrix.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const std::vector< Number > & get_evaluated_thetas(unsigned int training_parameter_index) const
Return the evaluated theta functions at the given training parameter index.
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
Real get_abs_training_tolerance() const
This class extends FEMContext in order to provide extra data required to perform local element residu...
bool is_constrained_dof(const dof_id_type dof) const
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves()
Return the matrix for the output residual dual norm solves.
The Tri3Subdivision element is a three-noded subdivision surface shell element used in mechanics calc...
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
virtual Real get_RB_error_bound()
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
unsigned int get_delta_N() const
Get delta_N, the number of basis functions we add to the RB space per iteration of the greedy algorit...
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
const RBParameters & get_parameters() const
Get the current parameters.
void print_parameters() const
Print the current parameters.
SparseMatrix< Number > * get_non_dirichlet_Aq(unsigned int q)
Get a pointer to non_dirichlet_Aq.
void set_inner_product_assembly(ElemAssembly &inner_product_assembly_in)
Set the rb_assembly_expansion object.
std::vector< std::unique_ptr< SparseMatrix< Number > > > Aq_vector
Vector storing the Q_a matrices from the affine expansion.
void add_scaled_matrix_and_vector(Number scalar, ElemAssembly *elem_assembly, SparseMatrix< Number > *input_matrix, NumericVector< Number > *input_vector, bool symmetrize=false, bool apply_dof_constraints=true)
This function loops over the mesh and applies the specified interior and/or boundary assembly routine...
bool skip_residual_in_train_reduced_basis
Boolean flag to indicate if we skip residual calculations in train_reduced_basis. ...
void set_convergence_assertion_flag(bool flag)
Setter for the flag determining if convergence should be checked after each solve.
This class is part of the rbOOmit framework.
virtual std::pair< unsigned int, Real > solve(SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const std::optional< double > tol=std::nullopt, const std::optional< unsigned int > m_its=std::nullopt)=0
This function calls the solver _solver_type preconditioned with the _preconditioner_type precondition...
bool is_rb_eval_initialized() const
unsigned int delta_N
The number of basis functions that we add at each greedy step.
Real train_reduced_basis_with_greedy(const bool resize_rb_eval_data)
Train the reduced basis using the "Greedy algorithm.".
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...
std::unique_ptr< NumericVector< Number > > _untransformed_solution
We also store a copy of the untransformed solution in order to create _untransformed_basis_functions...
numeric_index_type get_n_training_samples() const
Get the number of global training samples.
const DenseMatrix< Number > & get_elem_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
bool dg_terms_are_active() const
Are the DG terms active, i.e.
Real _final_linear_residual
The final residual for the linear system Ax=b.
std::vector< std::vector< std::vector< Number > > > Fq_Aq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online...
void set_params_from_training_set(unsigned int global_index)
Set parameters to the RBParameters stored in index global_index of the global training set...
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params, where 0 <= N <= RB_size.
This class is part of the rbOOmit framework.
virtual void post_process_truth_solution()
Similarly, provide an opportunity to post-process the truth solution after the solve is complete...
virtual unsigned int n_sides() const =0
bool set_parameters(const RBParameters ¶ms)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
virtual LinearConvergenceReason get_converged_reason() const =0
const DenseMatrix< Number > & get_neighbor_elem_jacobian() const
Const accessor for element-neighbor Jacobian.
const Elem * neighbor_ptr(unsigned int i) const
void set_current_training_parameter_index(unsigned int index)
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
void set_abs_training_tolerance(Real new_training_tolerance)
Get/set the absolute tolerance for the basis training.
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab's sparse matrix format.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void clear() override
Clear all the data structures associated with the system.
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
unsigned char side
Current side for side_* to examine.
virtual std::string system_type() const override
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
void max(const T &r, T &o, Request &req) const
std::unique_ptr< LinearSolver< Number > > inner_product_solver
We store an extra linear solver object which we can optionally use for solving all systems in which t...
void set_value(const std::string ¶m_name, Real value)
Set the value of the specified parameter.
void set_normalize_rb_bound_in_greedy(bool normalize_rb_bound_in_greedy_in)
Get/set the boolean to indicate if we normalize the RB error in the greedy.
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_vector
Vector storing the Q_f vectors in the affine decomposition of the right-hand side.
This class stores the set of ElemAssembly functor objects that define the "parameter-independent expa...
virtual bool is_serial_training_type(const std::string &RB_training_type_in)
SparseMatrix< Number > * matrix
The system matrix.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
virtual void preevaluate_thetas()
std::vector< Number > truth_outputs
Vector storing the truth output values from the most recent truth solve.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it's available, otherwise get the inner-product matrix ...
virtual void compute_Fq_representor_innerprods(bool compute_inner_products=true)
Compute the terms that are combined ‘online’ to determine the dual norm of the residual.
virtual void set_Nmax(unsigned int Nmax)
std::vector< std::unique_ptr< SparseMatrix< Number > > > non_dirichlet_Aq_vector
We may also need a second set of matrices/vectors that do not have the Dirichlet boundary conditions ...
void set_rel_training_tolerance(Real new_training_tolerance)
Get/set the relative tolerance for the basis training.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > non_dirichlet_outputs_vector
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
virtual void write_riesz_representors_to_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
Write out all the Riesz representor data to files.
virtual void assemble_all_output_vectors()
Assemble and store the output vectors.
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Parameters parameters
Data structure holding arbitrary parameters.
virtual unsigned int size() const override final
bool _preevaluate_thetas_flag
Flag to indicate if we preevaluate the theta functions.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
void assemble_Aq_matrix(unsigned int q, SparseMatrix< Number > *input_matrix, bool apply_dof_constraints=true)
Assemble the q^th affine matrix and store it in input_matrix.
virtual void process_parameters_file(const std::string ¶meters_filename)
Read in from the file specified by parameters_filename and set the this system's member variables acc...
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh...
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
virtual bool check_if_zero_truth_solve() const
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
virtual void assemble_misc_matrices()
Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and...
virtual void get_all_vectors(std::map< std::string, NumericVector< Number > *> &all_vectors)
Get a map that stores pointers to all of the vectors.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
const DenseMatrix< Number > & get_elem_elem_jacobian() const
Const accessor for element-element Jacobian.
const std::string & name() const
dof_id_type first_dof(const processor_id_type proc) const
virtual void load_rb_solution()
Load the RB solution from the most recent solve with rb_eval into this system's solution vector...
void set_rb_evaluation(RBEvaluation &rb_eval_in)
Set the RBEvaluation object.
unsigned int n_vars() const
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual void compute_output_dual_innerprods()
Compute and store the dual norm of each output functional.
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
processor_id_type processor_id() const
void initialize_parameters(const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values)
Initialize the parameter ranges and set current_parameters.
bool exit_on_repeated_greedy_parameters
Boolean flag to indicate whether we exit the greedy if we select the same parameters twice in a row...
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...
bool output_dual_innerprods_computed
A boolean flag to indicate whether or not the output dual norms have already been computed — used to...
const DofMap & get_dof_map() const
processor_id_type processor_id() const
void train_reduced_basis_with_POD()
Train the reduced basis using Proper Orthogonal Decomposition (POD).
unsigned int get_n_params() const
Get the number of parameters.
virtual void enrich_RB_space()
Add a new basis function to the RB space.
virtual void assemble_all_affine_vectors()
Assemble and store the affine RHS vectors.
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
virtual void attach_quadrature_rule(QBase *q)=0
Provides the class with the quadrature rule.
NumericVector< Number > * get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to non-Dirichlet output vector.
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
bool _preevaluate_thetas_completed
Flag to indicate if the preevaluate_thetas function has been called, since this allows us to avoid ca...
This class forms the foundation from which generic finite elements may be derived.
SparseMatrix< Number > * get_non_dirichlet_Aq_if_avail(unsigned int q)
Get a pointer to non_dirichlet_Aq if it's available, otherwise get Aq.
virtual void clear()
Clear all the data structures associated with the system.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.
virtual void assemble_affine_expansion(bool skip_matrix_assembly, bool skip_vector_assembly)
Assemble the matrices and vectors for this system.
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
void print_discrete_parameter_values() const
Print out all the discrete parameter values.
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > outputs_vector
The libMesh vectors that define the output functionals.
This class defines a coupling matrix.
virtual void assemble_all_affine_operators()
Assemble and store all Q_a affine operators as well as the inner-product matrix.
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.