21#include "libmesh/transient_rb_construction.h"
22#include "libmesh/transient_rb_evaluation.h"
23#include "libmesh/transient_rb_theta_expansion.h"
24#include "libmesh/transient_rb_assembly_expansion.h"
27#include "libmesh/numeric_vector.h"
28#include "libmesh/sparse_matrix.h"
29#include "libmesh/dof_map.h"
30#include "libmesh/libmesh_logging.h"
31#include "libmesh/linear_solver.h"
32#include "libmesh/equation_systems.h"
33#include "libmesh/exodusII_io.h"
34#include "libmesh/getpot.h"
35#include "libmesh/dense_matrix.h"
36#include "libmesh/dense_vector.h"
37#include "libmesh/xdr_cxx.h"
38#include "libmesh/timestamp.h"
50#if defined(LIBMESH_HAVE_SLEPC)
52#include "libmesh/ignore_warnings.h"
54#include <slepcblaslapack.h>
55#include "libmesh/restore_warnings.h"
62 const std::string & name_in,
63 const unsigned int number_in)
64 :
Parent(es, name_in, number_in),
67 nonzero_initialization(false),
68 compute_truth_projection_error(false),
100 bool skip_vector_assembly)
121 GetPot infile(parameters_filename);
130 const Real POD_tol_in = infile(
"POD_tol",
POD_tol);
131 const int max_truth_solves_in = infile(
"max_truth_solves",
max_truth_solves);
132 const unsigned int delta_N_in = infile(
"delta_N",
delta_N);
147 libMesh::out << std::endl <<
"TransientRBConstruction parameters:" << std::endl;
152 auto & trans_theta_expansion =
154 libMesh::out <<
"Q_m: " << trans_theta_expansion.get_n_M_terms() << std::endl;
158 libMesh::out <<
"RBThetaExpansion member is not set yet" << std::endl;
167 libMesh::out <<
"delta_N (number of basis functions to add each POD-Greedy step): " <<
get_delta_N() << std::endl;
174 libMesh::out <<
"Using zero initial condition" << std::endl;
185 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
186 const unsigned int n_outputs = trans_theta_expansion.
get_n_outputs();
205 for (
unsigned int q=0; q<Q_m; q++)
222 for (
unsigned int q=0; q<Q_m; q++)
233 for (
unsigned int i=0; i<n_time_levels; i++)
241 for (
unsigned int n=0; n<n_outputs; n++)
253 bool skip_vector_assembly)
284 "POD RB training is not supported with TransientRBConstruction");
298 libmesh_error_msg_if(q >= trans_theta_expansion.
get_n_M_terms(),
299 "Error: We must have q < Q_m in get_M_q.");
307 "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_M_q.");
312 libmesh_error_msg_if(q >= trans_theta_expansion.
get_n_M_terms(),
313 "Error: We must have q < Q_m in get_M_q.");
322 all_matrices[
"L2_matrix"] =
L2_matrix.get();
329 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
331 for (
unsigned int q_m=0; q_m<Q_m; q_m++)
333 std::stringstream matrix_name;
334 matrix_name <<
"M" << q_m;
335 all_matrices[matrix_name.str()] =
get_M_q(q_m);
339 matrix_name <<
"_non_dirichlet";
347 input_matrix->
zero();
358 input_matrix->
zero();
369 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
371 for (
unsigned int q=0; q<Q_m; q++)
379 LOG_SCOPE(
"mass_matrix_scaled_matvec()",
"TransientRBConstruction");
388 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
393 for (
unsigned int q=0; q<Q_m; q++)
396 dest.
add(scalar * trans_theta_expansion.
eval_M_theta(q,mu), *temp_vec);
402 LOG_SCOPE(
"truth_assembly()",
"TransientRBConstruction");
414 const unsigned int Q_a = trans_theta_expansion.
get_n_A_terms();
415 const unsigned int Q_f = trans_theta_expansion.
get_n_F_terms();
431 for (
unsigned int q_a=0; q_a<Q_a; q_a++)
436 temp_vec->scale( -(1.-euler_theta)*trans_theta_expansion.
eval_A_theta(q_a,mu) );
440 for (
unsigned int q_f=0; q_f<Q_f; q_f++)
460 libmesh_error_msg_if(!
L2_assembly,
"Error: L2_assembly hasn't been initialized yet");
473 libmesh_error_msg_if(q >= trans_theta_expansion.
get_n_M_terms(),
474 "Error: We must have q < Q_m in assemble_Mq_matrix.");
476 input_matrix->
zero();
492 for (
unsigned int q=0; q<trans_theta_expansion.
get_n_M_terms(); q++)
497 for (
unsigned int q=0; q<trans_theta_expansion.
get_n_M_terms(); q++)
509 libMesh::out <<
"Assembling non-Dirichlet L2 matrix" << std::endl;
518 LOG_SCOPE(
"truth_solve()",
"TransientRBConstruction");
546 for (
unsigned int time_level=1; time_level<=n_time_steps; time_level++)
582 if ((write_interval > 0) && (time_level%write_interval == 0))
584 libMesh::out << std::endl <<
"Truth solve, plotting time step " << time_level << std::endl;
586 std::ostringstream file_name;
588 file_name <<
"truth.e.";
589 file_name << std::setw(3)
590 << std::setprecision(0)
595#ifdef LIBMESH_HAVE_EXODUS_API
597 this->get_equation_systems());
611 return final_truth_L2_norm;
616 Real initial_greedy_error,
621 libMesh::out <<
"Maximum number of truth solves reached: max = "
622 << count << std::endl;
631 LOG_SCOPE(
"set_error_temporal_data()",
"TransientRBConstruction");
661 for (
unsigned int i=0; i<RB_size; i++)
662 for (
unsigned int j=0; j<RB_size; j++)
669 for (
unsigned int i=0; i<RB_size; i++)
677 RB_inner_product_matrix_N.
lu_solve(RB_proj_rhs, RB_proj);
681 for (
unsigned int i=0; i<RB_size; i++)
700 LOG_SCOPE(
"get_error_temporal_data()",
"TransientRBConstruction");
727 LOG_SCOPE(
"add_IC_to_RB_space()",
"TransientRBConstruction");
730 "Error: Should not call TransientRBConstruction::add_IC_to_RB_space() "
731 "on a system that already contains basis functions.");
734 "Error: Should not call TransientRBConstruction::add_IC_to_RB_space() "
735 "when nonzero_initialization==false.");
749 current_bf.
scale(1./current_bf_norm);
760 LOG_SCOPE(
"enrich_RB_space()",
"TransientRBConstruction");
767 for (
unsigned int i=0; i<n_snapshots; i++)
772 for (
unsigned int j=0; j<=i; j++)
779 correlation_matrix(i,j) = inner_prod;
793 correlation_matrix.
svd(sigma, U, VT );
795 libMesh::out << std::endl <<
"POD singular values:" << std::endl;
796 for (
unsigned int i=0; i<=1; i++)
798 libMesh::out <<
"singular value " << i <<
" = " << sigma(i) << std::endl;
801 libMesh::out <<
"last singular value = " << sigma(n_snapshots-1) << std::endl;
817 for (
unsigned int i=0; i<n_snapshots; i++)
826 current_bf.
scale(1./current_bf_norm);
875 libMesh::out <<
"Updating RB initial conditions" << std::endl;
886 LOG_SCOPE(
"load_rb_solution()",
"TransientRBConstruction");
896 "ERROR: rb_eval object contains "
898 <<
" basis functions. RB_solution vector contains "
899 << RB_solution_vector_k.
size()
900 <<
" entries. RB_solution in TransientRBConstruction::load_rb_solution is too long!");
902 for (
unsigned int i=0; i<RB_solution_vector_k.
size(); i++)
910 LOG_SCOPE(
"update_RB_system_matrices()",
"TransientRBConstruction");
918 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
925 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
927 for (
unsigned int j=0; j<RB_size; j++)
942 for (
unsigned int q_m=0; q_m<Q_m; q_m++)
968 LOG_SCOPE(
"update_residual_terms()",
"TransientRBConstruction");
977 const unsigned int Q_m = trans_theta_expansion.
get_n_M_terms();
978 const unsigned int Q_a = trans_theta_expansion.
get_n_A_terms();
979 const unsigned int Q_f = trans_theta_expansion.
get_n_F_terms();
983 for (
unsigned int q_m=0; q_m<Q_m; q_m++)
985 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
995 trans_rb_eval.
M_q_representor[q_m][i]->local_size() == this->n_local_dofs() );
1002 << i <<
" in TransientRBConstruction::update_residual_terms() at "
1013 << i <<
" in TransientRBConstruction::update_residual_terms() at "
1017 <<
" iterations, final residual "
1026 if (compute_inner_products)
1028 for (
unsigned int q_f=0; q_f<Q_f; q_f++)
1032 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1034 for (
unsigned int q_m=0; q_m<Q_m; q_m++)
1043 for (
unsigned int q_m1=0; q_m1<Q_m; q_m1++)
1045 for (
unsigned int q_m2=q_m1; q_m2<Q_m; q_m2++)
1047 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1049 for (
unsigned int j=0; j<RB_size; j++)
1071 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1073 for (
unsigned int j=0; j<RB_size; j++)
1075 for (
unsigned int q_a=0; q_a<Q_a; q_a++)
1077 for (
unsigned int q_m=0; q_m<Q_m; q_m++)
1103 LOG_SCOPE(
"update_RB_initial_condition_all_N()",
"TransientRBConstruction");
1122 for (
unsigned int i=(RB_size-
delta_N); i<RB_size; i++)
1131 for (
unsigned int N=(RB_size-
delta_N); N<RB_size; N++)
1141 RB_L2_matrix_N.
lu_solve(RB_rhs_N, RB_ic_N);
1151 for (
unsigned int i=0; i<N+1; i++)
1245 const bool write_binary_residual_representors)
1247 LOG_SCOPE(
"write_riesz_representors_to_files()",
"TransientRBConstruction");
1252 libMesh::out <<
"Writing out the M_q_representors..." << std::endl;
1254 std::ostringstream file_name;
1255 const std::string riesz_representor_suffix = (write_binary_residual_representors ?
".xdr" :
".dat");
1263 for (
unsigned int i=istart; i<istop; ++i)
1265 libMesh::out <<
"Writing out M_q_representor[" << q <<
"][" << i <<
"]..." << std::endl;
1269 file_name << riesz_representors_dir <<
"/M_q_representor" << i << riesz_representor_suffix;
1276 Xdr mr_data(file_name.str(),
1277 write_binary_residual_representors ?
ENCODE :
WRITE);
1294 const bool read_binary_residual_representors)
1296 LOG_SCOPE(
"read_riesz_representors_from_files()",
"TransientRBConstruction");
1298 const std::string riesz_representor_suffix =
1299 (read_binary_residual_representors ?
".xdr" :
".dat");
1301 std::ostringstream file_name;
1302 struct stat stat_info;
1306 libMesh::out <<
"Reading in the M_q_representors..." << std::endl;
1311 for (std::size_t i=0; i<trans_rb_eval.M_q_representor.size(); ++i)
1312 for (std::size_t j=0; j<trans_rb_eval.M_q_representor[i].size(); ++j)
1313 libmesh_error_msg_if(trans_rb_eval.M_q_representor[i][j] !=
nullptr,
1314 "Error, must delete existing M_q_representor before reading in from file.");
1317 for (std::size_t i=0; i<trans_rb_eval.M_q_representor.size(); ++i)
1318 for (std::size_t j=0; j<trans_rb_eval.get_n_basis_functions(); ++j)
1321 file_name << riesz_representors_dir
1322 <<
"/M_q_representor" << i <<
"_" << j << riesz_representor_suffix;
1327 int stat_result = stat(file_name.str().c_str(), &stat_info);
1329 libmesh_error_msg_if(stat_result != 0,
"File does not exist: " << file_name.str());
1332 Xdr aqr_data(file_name.str(),
1333 read_binary_residual_representors ?
DECODE :
READ);
1343 trans_rb_eval.M_q_representor[i][j]->swap(*
solution);
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 lu_solve(const DenseVector< T > &b, DenseVector< T > &x)
Solve the system Ax=b given the input vector b.
void get_principal_submatrix(unsigned int sub_m, unsigned int sub_n, DenseMatrix< T > &dest) const
Put the sub_m x sub_n principal submatrix into dest.
virtual T el(const unsigned int i, const unsigned int j) const override final
virtual void zero() override final
Sets all elements of the matrix to 0 and resets any decomposition flag which may have been previously...
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual void zero() override final
Set every element in the vector to 0.
void get_principal_subvector(unsigned int sub_n, DenseVector< T > &dest) const
Puts the principal subvector of size sub_n (i.e.
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
virtual unsigned int size() const override final
This class handles the numbering of degrees of freedom on a mesh.
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
This is the EquationSystems class.
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.
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() const
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
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
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 init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
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
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...
bool is_quiet() const
Is the system in quiet mode?
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
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.
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.
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
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 void print_info() const
Print out info that describes the current setup of this RBConstruction.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
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.
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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 ...
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 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 ...
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...
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
const std::string & get_RB_training_type() const
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
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.
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > * > &all_matrices)
Get a map that stores pointers to all of the matrices.
bool is_rb_eval_initialized() const
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.
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
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< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
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 unsigned int get_n_basis_functions() const
Get the current number of basis functions.
This class is part of the rbOOmit framework.
const RBParameters & get_parameters() const
Get the current parameters.
Real get_control(const unsigned int k) const
Get/set the RHS control.
void pull_temporal_discretization_data(RBTemporalDiscretization &other)
Pull the temporal discretization data from other.
Real get_delta_t() const
Get/set delta_t, the time-step size.
Real get_euler_theta() const
Get/set euler_theta, parameter that determines the temporal discretization.
void process_temporal_parameters_file(const std::string ¶meters_filename)
Read in and initialize parameters from parameters_filename.
void set_time_step(const unsigned int k)
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
unsigned int get_time_step() const
Get/set the current time-step.
virtual Number eval_F_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta_q_f at the current parameter.
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 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).
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
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 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.
This extends RBAssemblyExpansion to provide an assembly expansion for the case of time-dependent PDEs...
ElemAssembly & get_M_assembly(unsigned int q)
Return a reference to the specified M_assembly object.
unsigned int get_n_M_terms() const
Get Q_m, the number of terms in the affine expansion for the bilinear form.
virtual void truth_assembly() override
Assemble the truth system in the transient linear case.
void assemble_Mq_matrix(unsigned int q, SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the q^th affine term of the mass matrix and store it in input_matrix.
virtual ~TransientRBConstruction()
void update_RB_initial_condition_all_N()
Compute the L2 projection of the initial condition onto the RB space for 1 <= N <= RB_size and store ...
void set_POD_tol(const Real POD_tol_in)
ElemAssembly & get_L2_assembly()
virtual void write_riesz_representors_to_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors) override
Write out all the Riesz representor data to files.
std::vector< std::vector< Number > > truth_outputs_all_k
The truth outputs for all time-levels from the most recent truth_solve.
std::vector< std::unique_ptr< SparseMatrix< Number > > > non_dirichlet_M_q_vector
We sometimes also need a second set of M_q matrices that do not have the Dirichlet boundary condition...
Real get_POD_tol() const
Get/set POD_tol.
const NumericVector< Number > & get_error_temporal_data()
Get the column of temporal_data corresponding to the current time level.
int get_max_truth_solves() const
Get/set max_truth_solves, the maximum number of RB truth solves we are willing to compute in the tran...
virtual Real truth_solve(int write_interval) override
Perform a truth solve at the current parameter.
virtual void update_residual_terms(bool compute_inner_products) override
Compute the terms that are combined ‘online’ to determine the dual norm of the residual.
Number set_error_temporal_data()
Set column k (i.e.
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves() override
Override to return the L2 product matrix for output dual norm solves for transient state problems.
TransientRBConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
virtual void read_riesz_representors_from_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors) override
Write out all the Riesz representor data to files.
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
virtual void initialize_rb_construction(bool skip_matrix_assembly=false, bool skip_vector_assembly=false) override
Allocate all the data structures necessary for the construction stage of the RB method.
virtual bool greedy_termination_test(Real abs_greedy_error, Real initial_greedy_error, int count) override
Function that indicates when to terminate the Greedy basis training.
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
SparseMatrix< Number > * get_non_dirichlet_M_q(unsigned int q)
Get a pointer to non_dirichlet_M_q.
void assemble_mass_matrix(SparseMatrix< Number > *input_matrix)
Assemble the mass matrix at the current parameter and store it in input_matrix.
void assemble_L2_matrix(SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the L2 matrix.
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.
virtual void clear() override
Clear all the data structures associated with the system.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override
Train the reduced basis.
virtual void print_info() const override
Print out info that describes the current setup of this RBConstruction.
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...
virtual void enrich_RB_space() override
Add a new basis functions to the RB space.
void add_IC_to_RB_space()
Initialize RB space by adding the truth initial condition as the first RB basis function.
void set_max_truth_solves(int max_truth_solves_in)
virtual void update_system() override
Update the system after enriching the RB space.
virtual void assemble_all_affine_operators() override
Assemble and store all the affine operators.
virtual void assemble_misc_matrices() override
Override to assemble the L2 matrix as well.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
bool nonzero_initialization
Boolean flag to indicate whether we are using a non-zero initialization.
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh.
virtual void update_RB_system_matrices() override
Compute the reduced basis matrices for the current basis.
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > * > &all_matrices) override
Get a map that stores pointers to all of the matrices.
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.
virtual void load_rb_solution() override
Load the RB solution from the current time-level into the libMesh solution vector.
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
DenseVector< Number > RB_ic_proj_rhs_all_N
The vector that stores the right-hand side for the initial condition projections.
void set_delta_N(const unsigned int new_delta_N)
Set delta_N, the number of basis functions we add to the RB space from each POD.
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
void mass_matrix_scaled_matvec(Number scalar, NumericVector< Number > &dest, NumericVector< Number > &arg)
Perform a matrix-vector multiplication with the current mass matrix and store the result in dest.
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
virtual void process_parameters_file(const std::string ¶meters_filename) override
Read in the parameters from file and set up the system accordingly.
void add_scaled_mass_matrix(Number scalar, SparseMatrix< Number > *input_matrix)
Add the scaled mass matrix (assembled for the current parameter) to input_matrix.
void set_L2_assembly(ElemAssembly &L2_assembly_in)
Set the L2 object.
virtual void allocate_data_structures() override
Helper function that actually allocates all the data structures required by this class.
virtual void assemble_affine_expansion(bool skip_matrix_assembly, bool skip_vector_assembly) override
Override assemble_affine_expansion to also initialize RB_ic_proj_rhs_all_N, if necessary.
This class is part of the rbOOmit framework.
std::vector< std::vector< std::vector< std::vector< Number > > > > Aq_Mq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Mq_Mq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Fq_Mq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
DenseMatrix< Number > RB_L2_matrix
Dense RB L2 matrix.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > M_q_representor
Vector storing the mass matrix representors.
std::vector< Real > initial_L2_error_all_N
Vector storing initial L2 error for all 1 <= N <= RB_size.
std::vector< DenseMatrix< Number > > RB_M_q_vector
Dense matrices for the RB mass matrices.
std::vector< DenseVector< Number > > RB_temporal_solution_data
Array storing the solution data at each time level from the most recent solve.
std::vector< DenseVector< Number > > RB_initial_condition_all_N
The RB initial conditions (i.e.
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
virtual unsigned int get_n_M_terms() const
Get Q_m, the number of terms in the affine expansion for the mass operator.
virtual Number eval_M_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta at the current parameter.
virtual void clear() override
Clear all the data structures associated with the system.
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
std::string get_timestamp()
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real