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"
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_dirichlet_operators(true),
79 store_non_dirichlet_operators(false),
80 store_untransformed_basis(false),
81 use_empty_rb_solve_in_greedy(true),
82 Fq_representor_innerprods_computed(false),
85 output_dual_innerprods_computed(false),
86 assert_convergence(true),
88 inner_product_assembly(nullptr),
89 use_energy_inner_product(false),
90 rel_training_tolerance(1.e-4),
91 abs_training_tolerance(1.e-12),
92 normalize_rb_bound_in_greedy(false),
93 RB_training_type(
"Greedy"),
94 _preevaluate_thetas_flag(false),
95 _preevaluate_thetas_completed(false)
106 LOG_SCOPE(
"clear()",
"RBConstruction");
134 return "RBConstruction";
155 const unsigned int maxits =
156 es.
parameters.
get<
unsigned int>(
"linear solver maximum iterations");
166 input_solver.
solve (input_matrix, *
solution, input_rhs, tol, maxits);
181 libmesh_error_msg_if(!
rb_eval,
"Error: RBEvaluation object hasn't been initialized yet");
188 libmesh_error_msg_if(!
rb_eval,
"Error: RBEvaluation object hasn't been initialized yet");
211 GetPot infile(parameters_filename);
213 const unsigned int n_training_samples = infile(
"n_training_samples",0);
214 const bool deterministic_training = infile(
"deterministic_training",
false);
215 unsigned int training_parameters_random_seed_in =
216 static_cast<unsigned int>(-1);
217 training_parameters_random_seed_in = infile(
"training_parameters_random_seed",
218 training_parameters_random_seed_in);
219 const bool quiet_mode_in = infile(
"quiet_mode",
quiet_mode);
220 const unsigned int Nmax_in = infile(
"Nmax",
Nmax);
221 const Real rel_training_tolerance_in = infile(
"rel_training_tolerance",
223 const Real abs_training_tolerance_in = infile(
"abs_training_tolerance",
227 const bool normalize_rb_bound_in_greedy_in = infile(
"normalize_rb_bound_in_greedy",
230 const std::string RB_training_type_in = infile(
"RB_training_type",
"Greedy");
233 unsigned int n_continuous_parameters = infile.vector_variable_size(
"parameter_names");
236 for (
unsigned int i=0; i<n_continuous_parameters; i++)
239 std::string param_name = infile(
"parameter_names",
"NONE", i);
242 Real min_val = infile(param_name, 0., 0);
243 mu_min_in.
set_value(param_name, min_val);
247 Real max_val = infile(param_name, 0., 1);
248 mu_max_in.
set_value(param_name, max_val);
252 std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
254 unsigned int n_discrete_parameters = infile.vector_variable_size(
"discrete_parameter_names");
255 for (
unsigned int i=0; i<n_discrete_parameters; i++)
257 std::string param_name = infile(
"discrete_parameter_names",
"NONE", i);
259 unsigned int n_vals_for_param = infile.vector_variable_size(param_name);
260 std::vector<Real> vals_for_param(n_vals_for_param);
261 for (
auto j :
make_range(vals_for_param.size()))
262 vals_for_param[j] = infile(param_name, 0., j);
264 discrete_parameter_values_in[param_name] = vals_for_param;
267 std::map<std::string,bool> log_scaling_in;
271 for (
const auto & pr : mu_min_in)
272 log_scaling_in[pr.first] =
false;
276 deterministic_training,
277 static_cast<int>(training_parameters_random_seed_in),
280 rel_training_tolerance_in,
281 abs_training_tolerance_in,
282 normalize_rb_bound_in_greedy_in,
286 discrete_parameter_values_in,
291 unsigned int n_training_samples_in,
292 bool deterministic_training_in,
293 int training_parameters_random_seed_in,
295 unsigned int Nmax_in,
296 Real rel_training_tolerance_in,
297 Real abs_training_tolerance_in,
298 bool normalize_rb_bound_in_greedy_in,
299 const std::string & RB_training_type_in,
302 const std::map<std::string, std::vector<Real>> & discrete_parameter_values_in,
303 const std::map<std::string,bool> & log_scaling_in,
304 std::map<std::string, std::vector<RBParameter>> * training_sample_list)
327 bool updated_deterministic_training = deterministic_training_in;
337 updated_deterministic_training =
false;
342 n_training_samples_in,
344 updated_deterministic_training);
346 if (training_sample_list)
357 libMesh::out << std::endl <<
"RBConstruction parameters:" << std::endl;
374 libMesh::out <<
"RBThetaExpansion member is not set yet" << std::endl;
393 std::unique_ptr<NumericVector<Number>> temp =
solution->clone();
416 libmesh_error_msg_if(!
rb_assembly_expansion,
"Error: RBAssemblyExpansion object hasn't been initialized yet");
430 "Error: inner_product_assembly not available since we're using energy inner-product");
433 "Error: inner_product_assembly hasn't been initialized yet");
446#ifdef LIBMESH_ENABLE_CONSTRAINTS
467 bool skip_vector_assembly)
469 if (!skip_matrix_assembly && !skip_vector_assembly)
497 bool skip_vector_assembly)
499 if (!skip_matrix_assembly)
506 if (!skip_vector_assembly)
638 return std::make_unique<DGFEMContext>(*
this);
646 bool apply_dof_constraints)
648 LOG_SCOPE(
"add_scaled_matrix_and_vector()",
"RBConstruction");
650 bool assemble_matrix = (input_matrix !=
nullptr);
651 bool assemble_vector = (input_vector !=
nullptr);
653 if (!assemble_matrix && !assemble_vector)
664 std::set<dof_id_type> nodes_with_nodesets;
665 for (
const auto & t :
mesh.get_boundary_info().build_node_list())
666 nodes_with_nodesets.insert(std::get<0>(t));
674 int nodal_assembly_threw = 0;
679 for (
const auto &
id : nodes_with_nodesets)
681 const Node & node =
mesh.node_ref(
id);
688 std::vector<dof_id_type> nodal_dof_indices;
708 if (!nodal_dof_indices.empty())
710 if (apply_dof_constraints)
721 nodal_matrix *= scalar;
725 input_vector->
add_vector(nodal_rhs, nodal_dof_indices);
728 input_matrix->
add_matrix(nodal_matrix, nodal_dof_indices);
735 nodal_assembly_threw = 1;
740 this->
comm().
max(nodal_assembly_threw);
742 if (nodal_assembly_threw)
743 libmesh_error_msg(
"Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
760 int assembly_threw = 0;
765 for (
const auto & elem :
mesh.active_local_element_ptr_range())
767 const ElemType elemtype = elem->type();
777 if (!apply_dof_constraints)
784 std::unique_ptr<QBase> qrule;
793 const int extraorder = 0;
794 FEBase * elem_fe =
nullptr;
816 for (context.
side = 0; context.
side != n_sides; ++context.
side)
866 if (apply_dof_constraints)
871 if (assemble_matrix && symmetrize)
881 if (apply_dof_constraints)
899 if (!coupling_matrix)
909 for (
unsigned int var1=0; var1<
n_vars(); var1++)
912 for (
const auto & var2 : ccr)
917 for (
unsigned int row=0; row<sub_m; row++)
918 for (
unsigned int col=0; col<sub_n; col++)
950 input_matrix->
close();
952 input_vector->
close();
956 this->
comm().
max(assembly_threw);
959 libmesh_error_msg(
"Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
972 LOG_SCOPE(
"truth_assembly()",
"RBConstruction");
1007 bool apply_dof_constraints)
1009 input_matrix->
zero();
1018 apply_dof_constraints);
1023 "Error: invalid number of entries in energy_inner_product_coeffs.");
1034 apply_dof_constraints);
1041 bool apply_dof_constraints)
1044 "Error: We must have q < Q_a in assemble_Aq_matrix.");
1046 input_matrix->
zero();
1053 apply_dof_constraints);
1061 LOG_SCOPE(
"add_scaled_Aq()",
"RBConstruction");
1064 "Error: We must have q < Q_a in add_scaled_Aq.");
1068 input_matrix->
add(scalar, *
get_Aq(q_a));
1069 input_matrix->
close();
1085 libMesh::out <<
"Assembling inner product matrix" << std::endl;
1091 libMesh::out <<
"Assembling non-Dirichlet inner product matrix" << std::endl;
1101 libMesh::out <<
"Assembling affine operator " << (q_a+1) <<
" of "
1110 libMesh::out <<
"Assembling non-Dirichlet affine operator " << (q_a+1) <<
" of "
1122 libMesh::out <<
"Assembling affine vector " << (q_f+1) <<
" of "
1131 libMesh::out <<
"Assembling non-Dirichlet affine vector " << (q_f+1) <<
" of "
1141 bool apply_dof_constraints)
1144 "Error: We must have q < Q_f in assemble_Fq_vector.");
1146 input_vector->
zero();
1153 apply_dof_constraints );
1162 libMesh::out <<
"Assembling output vector, (" << (n+1) <<
"," << (q_l+1)
1179 libMesh::out <<
"Assembling non-Dirichlet output vector, (" << (n+1) <<
"," << (q_l+1)
1214 LOG_SCOPE(
"train_reduced_basis_with_greedy()",
"RBConstruction");
1224 if (resize_rb_eval_data)
1233 Real training_greedy_error = 0.;
1241 libMesh::out <<
"Maximum number of basis functions reached: Nmax = "
1259 libMesh::out << std::endl <<
"---- Performing Greedy basis enrichment ----" << std::endl;
1260 Real initial_greedy_error = 0.;
1261 bool initial_greedy_error_initialized =
false;
1269 libMesh::out <<
"Performing RB solves on training set" << std::endl;
1272 libMesh::out <<
"Maximum error bound is " << training_greedy_error << std::endl << std::endl;
1275 if (!initial_greedy_error_initialized)
1277 initial_greedy_error = training_greedy_error;
1278 initial_greedy_error_initialized =
true;
1287 libMesh::out <<
"Performing truth solve at parameter:" << std::endl;
1298 libMesh::out <<
"Zero basis function encountered hence ending basis enrichment" << std::endl;
1313 libMesh::out <<
"Maximum number of basis functions reached: Nmax = "
1328 return training_greedy_error;
1333 LOG_SCOPE(
"enrich_basis_from_rhs_terms()",
"RBConstruction");
1339 if (resize_rb_eval_data)
1344 libMesh::out << std::endl <<
"---- Enriching basis from rhs terms ----" << std::endl;
1350 libMesh::out << std::endl <<
"Performing truth solve with rhs from rhs term " << q_f << std::endl;
1382 char temp_file[] =
"truth_rhs_XXXXXX.dat";
1383 int fd = mkstemps(temp_file, 4);
1386 libMesh::out <<
"Writing truth system rhs to file: " << temp_file << std::endl;
1394#ifdef LIBMESH_HAVE_EXODUS_API
1400 char temp_file[] =
"truth_XXXXXX.exo";
1401 int fd = mkstemps(temp_file, 4);
1404 libMesh::out <<
"Writing truth solution to file: " << temp_file << std::endl;
1406 std::set<std::string> system_names = {this->
name()};
1430 libmesh_error_msg_if(
get_rb_evaluation().get_n_basis_functions() > 0,
"Basis should not already be initialized");
1448 std::vector<std::unique_ptr<NumericVector<Number>>> POD_snapshots(n_snapshots);
1449 for (
unsigned int i=0; i<n_snapshots; i++)
1457 for (
unsigned int i=0; i<n_snapshots; i++)
1464 libMesh::out <<
"Truth solve " << (i+1) <<
" of " << n_snapshots << std::endl;
1474 libMesh::out <<
"Normalizing solution snapshots" << std::endl;
1475 for (
unsigned int i=0; i<n_snapshots; i++)
1482 POD_snapshots[i]->scale(1./norm);
1488 for (
unsigned int i=0; i<n_snapshots; i++)
1493 for (
unsigned int j=0; j<=i; j++)
1497 correlation_matrix(i,j) = inner_prod;
1509 correlation_matrix.
svd(sigma, U, VT );
1518 if (j >=
get_Nmax() || j >= n_snapshots)
1520 libMesh::out <<
"Maximum number of basis functions (" << j <<
") reached." << std::endl;
1527 const Real rel_err = std::sqrt(sigma(j)) / std::sqrt(sigma(0));
1530 <<
", POD error norm: " << rel_err << std::endl;
1534 libMesh::out <<
"Training tolerance reached." << std::endl;
1538 std::unique_ptr< NumericVector<Number> > v = POD_snapshots[j]->zero_clone();
1539 for (
unsigned int i=0; i<n_snapshots; ++i )
1541 v->add( U.
el(i, j), *POD_snapshots[i] );
1544 Real norm_v = std::sqrt(sigma(j));
1545 v->scale( 1./norm_v );
1571 libMesh::out <<
"Absolute error tolerance reached." << std::endl;
1575 Real rel_greedy_error = abs_greedy_error/initial_error;
1578 libMesh::out <<
"Relative error tolerance reached." << std::endl;
1586 libMesh::out <<
"Maximum number of basis functions reached: Nmax = "
1595 libMesh::out <<
"Exiting greedy because the same parameters were selected twice" << std::endl;
1610 "Error: Argument in RBConstruction::get_greedy_parameter is too large.");
1617 LOG_SCOPE(
"truth_solve()",
"RBConstruction");
1662#ifdef LIBMESH_HAVE_EXODUS_API
1663 if (plot_solution > 0)
1666 std::set<std::string> system_names = {this->
name()};
1683 return (RB_training_type_in ==
"POD");
1705 this->
Nmax = Nmax_in;
1710 LOG_SCOPE(
"load_basis_function()",
"RBConstruction");
1721 LOG_SCOPE(
"enrich_RB_space()",
"RBConstruction");
1725 std::unique_ptr<NumericVector<Number>> new_untransformed_bf;
1750 if (new_bf_norm == 0.)
1756 new_untransformed_bf->zero();
1761 new_bf->scale(1./new_bf_norm);
1765 new_untransformed_bf->scale(1./new_bf_norm);
1788 Real error_bound = 0.;
1812 error_bound /= error_bound_normalization;
1825 unsigned int saved_delta_N =
delta_N;
1835 LOG_SCOPE(
"compute_max_error_bound()",
"RBConstruction");
1841 if (std::numeric_limits<Real>::has_infinity)
1843 max_val = std::numeric_limits<Real>::infinity();
1847 max_val = std::numeric_limits<Real>::max();
1858 unsigned int max_err_index = 0;
1883 std::pair<numeric_index_type, Real> error_pair(first_index+max_err_index, max_err);
1895 unsigned int root_id=0;
1907 return error_pair.second;
1912 LOG_SCOPE(
"update_RB_system_matrices()",
"RBConstruction");
1921 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1927 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1936 for (
unsigned int j=0; j<RB_size; j++)
1981 LOG_SCOPE(
"update_residual_terms()",
"RBConstruction");
1983 libMesh::out <<
"Updating RB residual terms" << std::endl;
1994 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2019 libMesh::out <<
"Starting solve [q_a][i]=[" << q_a <<
"]["<< i <<
"] in RBConstruction::update_residual_terms() at "
2030 libMesh::out <<
"Finished solve [q_a][i]=[" << q_a <<
"]["<< i <<
"] in RBConstruction::update_residual_terms() at "
2042 if (compute_inner_products)
2051 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2064 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
2066 for (
unsigned int j=0; j<RB_size; j++)
2104 LOG_SCOPE(
"compute_output_dual_innerprods()",
"RBConstruction");
2106 libMesh::out <<
"Compute output dual inner products" << std::endl;
2109 unsigned int max_Q_l = 0;
2113 std::vector<std::unique_ptr<NumericVector<Number>>> L_q_representor(max_Q_l);
2114 for (
unsigned int q=0; q<max_Q_l; q++)
2128 libMesh::out <<
"Starting solve n=" << n <<
", q_l=" << q_l
2129 <<
" in RBConstruction::compute_output_dual_innerprods() at "
2146 libMesh::out <<
"Finished solve n=" << n <<
", q_l=" << q_l
2147 <<
" in RBConstruction::compute_output_dual_innerprods() at "
2151 <<
" iterations, final residual "
2193 LOG_SCOPE(
"compute_Fq_representor_innerprods()",
"RBConstruction");
2211 <<
" in RBConstruction::update_residual_terms() at "
2222 <<
" in RBConstruction::update_residual_terms() at "
2226 <<
" iterations, final residual "
2233 if (compute_inner_products)
2258 LOG_SCOPE(
"load_rb_solution()",
"RBConstruction");
2263 "ERROR: System contains " <<
get_rb_evaluation().get_n_basis_functions() <<
" basis functions."
2264 <<
" RB_solution vector contains " <<
get_rb_evaluation().RB_solution.size() <<
" entries."
2265 <<
" RB_solution in RBConstruction::load_rb_solution is too long!");
2277 LOG_SCOPE(
"compute_residual_dual_norm_slow()",
"RBConstruction");
2294 for (
unsigned int i=0; i<N; i++)
2318 return std::sqrt(
libmesh_real(slow_residual_norm_sq) );
2324 "Error: Must have store_dirichlet_operators==true to access inner_product_matrix.");
2331 "Error: Must have store_dirichlet_operators==true to access inner_product_matrix.");
2338 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2346 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2374 "Error: Must have store_dirichlet_operators==true to access non_dirichlet_Aq.");
2377 "Error: We must have q < Q_a in get_Aq.");
2385 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Aq.");
2388 "Error: We must have q < Q_a in get_Aq.");
2406 "Error: Must have store_dirichlet_operators==true to access non_dirichlet_Fq.");
2409 "Error: We must have q < Q_f in get_Fq.");
2417 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Fq.");
2420 "Error: We must have q < Q_f in get_Fq.");
2439 "Error: We must have n < n_outputs and "
2440 "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_output_vector.");
2449 "Error: We must have n < n_outputs and "
2450 "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_non_dirichlet_output_vector.");
2457 all_matrices.clear();
2467 std::stringstream matrix_name;
2468 matrix_name <<
"A" << q_a;
2471 all_matrices[matrix_name.str()] =
get_Aq(q_a);
2475 matrix_name <<
"_non_dirichlet";
2483 all_vectors.clear();
2489 std::stringstream F_vector_name;
2490 F_vector_name <<
"F" << q_f;
2493 all_vectors[F_vector_name.str()] =
get_Fq(q_f);
2497 F_vector_name <<
"_non_dirichlet";
2505 output_vectors.clear();
2510 std::stringstream output_name;
2513 output_name <<
"output_" << n <<
"_"<< q_l;
2519 output_name <<
"_non_dirichlet";
2525#ifdef LIBMESH_ENABLE_DIRICHLET
2531 std::set<boundary_id_type> dirichlet_ids;
2532 std::vector<unsigned int> variables;
2535 return std::make_unique<DirichletBoundary>(dirichlet_ids, variables, &zf);
2541 const bool write_binary_residual_representors)
2543 LOG_SCOPE(
"write_riesz_representors_to_files()",
"RBConstruction");
2549 libMesh::out <<
"Writing out the Fq_representors..." << std::endl;
2551 std::ostringstream file_name;
2552 const std::string riesz_representor_suffix = (write_binary_residual_representors ?
".xdr" :
".dat");
2553 struct stat stat_info;
2558 libMesh::out <<
"Skipping creating residual_representors directory: " << strerror(errno) << std::endl;
2565 file_name << riesz_representors_dir <<
"/Fq_representor" << i << riesz_representor_suffix;
2579 int stat_result = stat(file_name.str().c_str(), &stat_info);
2581 if ( (stat_result != 0) ||
2582 (stat_info.st_size == 0))
2590 Xdr fqr_data(file_name.str(),
2591 write_binary_residual_representors ?
ENCODE :
WRITE);
2609 libMesh::out <<
"Writing out the Aq_representors..." << std::endl;
2616 for (
unsigned int j=jstart; j<jstop; ++j)
2618 libMesh::out <<
"Writing out Aq_representor[" << i <<
"][" << j <<
"]..." << std::endl;
2622 file_name << riesz_representors_dir
2623 <<
"/Aq_representor" << i <<
"_" << j << riesz_representor_suffix;
2630 Xdr aqr_data(file_name.str(),
2631 write_binary_residual_representors ?
ENCODE :
WRITE);
2650 const bool read_binary_residual_representors)
2652 LOG_SCOPE(
"read_riesz_representors_from_files()",
"RBConstruction");
2654 libMesh::out <<
"Reading in the Fq_representors..." << std::endl;
2656 const std::string riesz_representor_suffix = (read_binary_residual_representors ?
".xdr" :
".dat");
2657 std::ostringstream file_name;
2658 struct stat stat_info;
2663 libmesh_error_msg_if(rep,
"Error, must delete existing Fq_representor before reading in from file.");
2668 file_name << riesz_representors_dir
2669 <<
"/Fq_representor" << i << riesz_representor_suffix;
2674 int stat_result = stat(file_name.str().c_str(), &stat_info);
2676 libmesh_error_msg_if(stat_result != 0,
"File does not exist: " << file_name.str());
2679 Xdr fqr_data(file_name.str(),
2680 read_binary_residual_representors ?
DECODE :
READ);
2697 libMesh::out <<
"Reading in the Aq_representors..." << std::endl;
2704 for (
const auto & rep : row)
2705 libmesh_error_msg_if(rep,
"Error, must delete existing Aq_representor before reading in from file.");
2712 file_name << riesz_representors_dir
2713 <<
"/Aq_representor" << i <<
"_" << j << riesz_representor_suffix;
2718 int stat_result = stat(file_name.str().c_str(), &stat_info);
2720 libmesh_error_msg_if(stat_result != 0,
"File does not exist: " << file_name.str());
2723 Xdr aqr_data(file_name.str(), read_binary_residual_representors ?
DECODE :
READ);
2742 libmesh_error_msg_if(conv_flag < 0,
"Convergence error. Error id: " << conv_flag);
2775const std::vector<Number> &
2789 LOG_SCOPE(
"preevaluate_thetas()",
"RBConstruction");
2801 const unsigned int n_A_terms = rb_theta_expansion.
get_n_A_terms();
2802 const unsigned int n_F_terms = rb_theta_expansion.get_n_F_terms();
2803 const unsigned int n_outputs = rb_theta_expansion.get_total_n_output_terms();
2823 for (
unsigned int q_a=0; q_a<n_A_terms; q_a++)
2825 const auto A_vals = rb_theta_expansion.eval_A_theta(q_a, mus);
2830 for (
unsigned int q_f=0; q_f<n_F_terms; q_f++)
2832 const auto F_vals = rb_theta_expansion.eval_F_theta(q_f, mus);
2838 unsigned int output_counter = 0;
2839 for (
unsigned int n=0; n<rb_theta_expansion.get_n_outputs(); n++)
2840 for (
unsigned int q_l=0; q_l<rb_theta_expansion.get_n_output_terms(n); q_l++)
2844 const auto output_vals = rb_theta_expansion.eval_output_theta(n, q_l, mus);
2851 "We currently only support single-sample RBParameters "
2852 "objects during the training stage.");
void max(const T &r, T &o, Request &req) const
processor_id_type rank() const
This proxy class acts like a container of indices from a single coupling row.
This class defines a coupling matrix.
This class extends FEMContext in order to provide extra data required to perform local element residu...
const std::vector< dof_id_type > & get_neighbor_dof_indices() const
Accessor for neighbor dof indices.
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.
const DenseMatrix< Number > & get_neighbor_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseMatrix< Number > & get_elem_elem_jacobian() const
Const accessor for element-element Jacobian.
bool dg_terms_are_active() const
Are the DG terms active, i.e.
const DenseMatrix< Number > & get_neighbor_elem_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseMatrix< Number > & get_elem_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
Defines a dense matrix for use in Finite Element-type computations.
void svd(DenseVector< Real > &sigma)
Compute the singular value decomposition of the matrix.
void get_transpose(DenseMatrix< T > &dest) const
Put the tranposed matrix into dest.
virtual T el(const unsigned int i, const unsigned int j) const override final
Defines a dense vector for use in Finite Element-type computations.
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const
This class handles the numbering of degrees of freedom on a mesh.
bool is_constrained_dof(const dof_id_type dof) const
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
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.
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
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.
processor_id_type processor_id() const
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
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.
virtual void interior_assembly(FEMContext &)
Perform the element interior assembly.
virtual void boundary_assembly(FEMContext &)
Perform the element boundary assembly.
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
virtual unsigned int n_sides() const =0
const Elem * neighbor_ptr(unsigned int i) const
This is the EquationSystems class.
Parameters parameters
Data structure holding arbitrary parameters.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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.
NumericVector< Number > * rhs
The system matrix.
virtual void attach_quadrature_rule(QBase *q)=0
Provides the class with the quadrature rule.
FEType get_fe_type() const
This class forms the foundation from which generic finite elements may be derived.
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
unsigned char side
Current side for side_* to examine.
const Elem & get_elem() const
Accessor for current Elem object.
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
unsigned char get_side() const
Accessor for current side of Elem object.
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.
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
SparseMatrix< Number > * matrix
The system matrix.
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...
Real final_linear_residual() const
virtual LinearSolver< Number > * get_linear_solver() const override
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
Real _final_linear_residual
The final residual for the linear system Ax=b.
unsigned int n_linear_iterations() const
This base class can be inherited from to provide interfaces to linear solvers from different packages...
virtual LinearConvergenceReason get_converged_reason() const =0
virtual void init(const char *name=nullptr)=0
Initialize data structures if not done so already.
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
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...
This is the MeshBase class.
A Node is like a Point, but with more information.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual T dot(const NumericVector< T > &v) const =0
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab's sparse matrix format.
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].
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...
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
virtual Real l2_norm() const =0
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
virtual void zero()=0
Set all entries to zero.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
const T & get(std::string_view) const
This class stores the set of ElemAssembly functor objects that define the "parameter-independent expa...
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
void set_training_random_seed(int seed)
Set the seed that is used to randomly generate training parameters.
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...
virtual void clear()
Clear all the data structures associated with the system.
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage.
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
numeric_index_type get_n_training_samples() const
Get the number of global training samples.
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...
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.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors.
bool is_quiet() const
Is the system in quiet mode?
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...
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 load_training_set(const std::map< std::string, std::vector< RBParameter > > &new_training_set)
Overwrite the training parameters with new_training_set.
virtual bool is_serial_training_type(const std::string &RB_training_type_in)
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 ...
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
bool _preevaluate_thetas_completed
Flag to indicate if the preevaluate_thetas function has been called, since this allows us to avoid ca...
ElemAssembly & get_inner_product_assembly()
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.
void enrich_basis_from_rhs_terms(const bool resize_rb_eval_data=true)
This function computes one basis function for each rhs term.
void set_convergence_assertion_flag(bool flag)
Setter for the flag determining if convergence should be checked after each solve.
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.
bool get_convergence_assertion_flag() const
Getter for the flag determining if convergence should be checked after each solve.
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
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.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
virtual void update_RB_system_matrices()
Compute the reduced basis matrices for the current basis.
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
void print_basis_function_orthogonality() const
Print out a matrix that shows the orthogonality of the RB basis functions.
bool get_preevaluate_thetas_flag() const
Get/set flag to pre-evaluate the theta functions.
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.
virtual void set_Nmax(unsigned int Nmax)
virtual Real compute_max_error_bound()
(i) Compute the a posteriori error bound for each set of parameters in the training set,...
bool skip_residual_in_train_reduced_basis
Boolean flag to indicate if we skip residual calculations in train_reduced_basis.
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...
virtual void assemble_all_affine_operators()
Assemble and store all Q_a affine operators as well as the inner-product matrix.
void update_greedy_param_list()
Update the list of Greedily chosen parameters with current_parameters.
void set_rb_evaluation(RBEvaluation &rb_eval_in)
Set the RBEvaluation object.
const RBParameters & get_greedy_parameter(unsigned int i)
Return the parameters chosen during the i^th step of the Greedy algorithm.
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
virtual std::string system_type() const override
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.
virtual Real truth_solve(int plot_solution)
Perform a "truth" solve, i.e.
virtual void print_info() const
Print out info that describes the current setup of this RBConstruction.
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 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.
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_context_solution_vec(NumericVector< Number > &vec)
Set current_local_solution = vec so that we can access vec from FEMContext during assembly.
virtual std::unique_ptr< DGFEMContext > build_context()
Builds a DGFEMContext object with enough information to do evaluations on each element.
RBConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
bool store_dirichlet_operators
Boolean flag to indicate whether we store affine operator matrices and vectors with constraints enfor...
Real get_rel_training_tolerance() const
virtual void assemble_misc_matrices()
Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and...
virtual void assemble_affine_expansion(bool skip_matrix_assembly, bool skip_vector_assembly)
Assemble the matrices and vectors for this system.
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
bool use_empty_rb_solve_in_greedy
A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves ...
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_vector
Vector storing the Q_f vectors in the affine decomposition of the right-hand side.
std::string RB_training_type
This string indicates the type of training that we will use.
virtual void post_process_truth_solution()
Similarly, provide an opportunity to post-process the truth solution after the solve is complete.
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
const std::vector< Number > & get_evaluated_thetas(unsigned int training_parameter_index) const
Return the evaluated theta functions at the given training parameter index.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
void train_reduced_basis_with_POD()
Train the reduced basis using Proper Orthogonal Decomposition (POD).
virtual void preevaluate_thetas()
virtual ~RBConstruction()
bool normalize_rb_bound_in_greedy
This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound...
virtual Real get_RB_error_bound()
std::vector< Number > energy_inner_product_coeffs
We may optionally want to use the "energy inner-product" rather than the inner-product assembly speci...
std::vector< std::unique_ptr< SparseMatrix< Number > > > Aq_vector
Vector storing the Q_a matrices from the affine expansion.
virtual void init_context(FEMContext &)
Initialize the FEMContext prior to performing an element loop.
virtual void compute_output_dual_innerprods()
Compute and store the dual norm of each output functional.
bool impose_internal_fluxes
Boolean flag to indicate whether we impose "fluxes" (i.e.
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.
Real train_reduced_basis_with_greedy(const bool resize_rb_eval_data)
Train the reduced basis using the "Greedy algorithm.".
SparseMatrix< Number > * get_non_dirichlet_Aq(unsigned int q)
Get a pointer to non_dirichlet_Aq.
Real get_abs_training_tolerance() const
void set_inner_product_assembly(ElemAssembly &inner_product_assembly_in)
Set the rb_assembly_expansion object.
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
bool skip_degenerate_sides
In some cases meshes are intentionally created with degenerate sides as a way to represent,...
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.
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.
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 ...
std::unique_ptr< NumericVector< Number > > _untransformed_solution
We also store a copy of the untransformed solution in order to create _untransformed_basis_functions.
bool output_dual_innerprods_computed
A boolean flag to indicate whether or not the output dual norms have already been computed — used to ...
void set_rb_assembly_expansion(RBAssemblyExpansion &rb_assembly_expansion_in)
Set the rb_assembly_expansion object.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > outputs_vector
The libMesh vectors that define the output functionals.
void set_current_training_parameter_index(unsigned int index)
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true)
Train the reduced basis.
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...
virtual void load_basis_function(unsigned int i)
Load the i^th RB function into the RBConstruction solution vector.
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.
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 ...
virtual bool check_if_zero_truth_solve() const
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.
RBAssemblyExpansion & get_rb_assembly_expansion()
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_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.
LinearSolver< Number > * extra_linear_solver
Also, we store a pointer to an extra linear solver.
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
std::vector< Real > training_error_bounds
Vector storing the values of the error bound for each parameter in the training set — the parameter g...
void set_abs_training_tolerance(Real new_training_tolerance)
Get/set the absolute tolerance for the basis training.
void reset_preevaluate_thetas_completed()
Reset the _preevaluate_thetas_completed flag to false.
void set_rel_training_tolerance(Real new_training_tolerance)
Get/set the relative tolerance for the basis training.
std::vector< Number > truth_outputs
Vector storing the truth output values from the most recent truth solve.
std::vector< std::vector< Number > > _evaluated_thetas
Storage of evaluated theta functions at a set of parameters.
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 assemble_all_affine_vectors()
Assemble and store the affine RHS vectors.
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.
bool use_energy_inner_product
Boolean to indicate whether we're using the energy inner-product.
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves()
Return the matrix for the output residual dual norm solves.
virtual void load_rb_solution()
Load the RB solution from the most recent solve with rb_eval into this system's solution vector.
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 enrich_RB_space()
Add a new basis function to the RB space.
const std::string & get_RB_training_type() const
bool store_untransformed_basis
Boolean flag to indicate whether we store a second copy of the basis without constraints or dof trans...
void set_RB_training_type(const std::string &RB_training_type_in)
Get/set the string that determines the training type.
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.
virtual void assemble_all_output_vectors()
Assemble and store the output vectors.
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.
bool Fq_representor_innerprods_computed
A boolean flag to indicate whether or not the Fq representor norms have already been computed — used ...
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix()
Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
std::vector< std::unique_ptr< NumericVector< Number > > > non_dirichlet_Fq_vector
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...
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.
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 set_preevaluate_thetas_flag(bool flag)
Real abs_training_tolerance
virtual void truth_assembly()
Assemble the truth matrix and right-hand side for current_parameters.
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...
bool get_normalize_rb_bound_in_greedy() const
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > non_dirichlet_outputs_vector
Real compute_residual_dual_norm_slow(const unsigned int N)
The slow (but simple, non-error prone) way to compute the residual dual norm.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
bool _preevaluate_thetas_flag
Flag to indicate if we preevaluate the theta functions.
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > * > &all_matrices)
Get a map that stores pointers to all of the matrices.
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...
bool is_rb_eval_initialized() const
unsigned int _current_training_parameter_index
The current training parameter index during reduced basis training.
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...
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
unsigned int delta_N
The number of basis functions that we add at each greedy step.
NumericVector< Number > * get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to non-Dirichlet output vector.
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...
virtual void clear() override
Clear all the data structures associated with the system.
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.
unsigned int get_current_training_parameter_index() const
Get/set the current training parameter index.
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
This class is part of the rbOOmit framework.
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
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 Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params,...
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
virtual Real get_error_bound_normalization()
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
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.
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
DenseVector< Number > RB_solution
The RB solution vector.
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
This class is part of the rbOOmit framework.
void set_value(const std::string ¶m_name, Real value)
Set the value of the specified parameter.
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
const RBParameters & get_parameters() const
Get the current parameters.
unsigned int get_n_params() const
Get the number of parameters.
bool set_parameters(const RBParameters ¶ms)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
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.
Real get_parameter_max(const std::string ¶m_name) const
Get maximum allowable value of parameter param_name.
void print_discrete_parameter_values() const
Print out all the discrete parameter values.
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
Real get_parameter_min(const std::string ¶m_name) const
Get minimum allowable value of parameter param_name.
void print_parameters() const
Print the current parameters.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
virtual Number eval_A_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta_q_a at the current parameter.
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
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.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
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.
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.
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.
virtual void zero()=0
Set all entries to 0.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
const std::string & name() const
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
dof_id_type n_dofs() const
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
dof_id_type n_local_dofs() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
const DofMap & get_dof_map() const
const EquationSystems & get_equation_systems() const
const MeshBase & get_mesh() const
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
The Tri3Subdivision element is a three-noded subdivision surface shell element used in mechanics calc...
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
ConstFunction that simply returns 0.
std::string get_timestamp()
int mkdir(const char *pathname)
Create a directory.
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
dof_id_type numeric_index_type
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)