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" 56 #endif // LIBMESH_HAVE_SLEPC 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)
111 libmesh_assert_equal_to (trans_theta_expansion.
get_n_M_terms(), trans_assembly_expansion.get_n_M_terms());
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();
478 &trans_assembly_expansion.get_M_assembly(q),
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 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++)
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);
std::vector< std::vector< std::vector< Number > > > Mq_Mq_representor_innerprods
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
virtual void allocate_data_structures() override
Helper function that actually allocates all the data structures required by this class.
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.
virtual void load_rb_solution() override
Load the RB solution from the current time-level into the libMesh solution vector.
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
This is the EquationSystems class.
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
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 Number eval_A_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta_q_a at the current parameter.
Real get_POD_tol() const
Get/set POD_tol.
void set_max_truth_solves(int max_truth_solves_in)
virtual void zero() override final
Set every element in the vector to 0.
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
void assemble_mass_matrix(SparseMatrix< Number > *input_matrix)
Assemble the mass matrix at the current parameter and store it in input_matrix.
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.
virtual void assemble_all_affine_operators() override
Assemble and store all the affine operators.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true)
Train the reduced basis.
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...
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > *> &all_matrices)
Get a map that stores pointers to all of the matrices.
void process_temporal_parameters_file(const std::string ¶meters_filename)
Read in and initialize parameters from parameters_filename.
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override
Train the reduced basis.
This extends RBAssemblyExpansion to provide an assembly expansion for the case of time-dependent PDEs...
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 truth_assembly() override
Assemble the truth system in the transient linear case.
std::vector< DenseMatrix< Number > > RB_M_q_vector
Dense matrices for the RB mass matrices.
std::string get_timestamp()
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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...
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
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.
void resize(const unsigned int n)
Resize the vector.
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
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.
const EquationSystems & get_equation_systems() const
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
virtual Real truth_solve(int write_interval) override
Perform a truth solve at the current parameter.
NumericVector< Number > * rhs
The system matrix.
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
This class is part of the rbOOmit framework.
std::vector< std::vector< Number > > truth_outputs_all_k
The truth outputs for all time-levels from the most recent truth_solve.
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.
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
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 ...
virtual LinearSolver< Number > * get_linear_solver() const override
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
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
virtual Number eval_M_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta at the current parameter.
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh...
Real get_delta_t() const
Get/set delta_t, the time-step size.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
const MeshBase & get_mesh() const
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.
void get_principal_subvector(unsigned int sub_n, DenseVector< T > &dest) const
Puts the principal subvector of size sub_n (i.e.
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.
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
Real get_euler_theta() const
Get/set euler_theta, parameter that determines the temporal discretization.
dof_id_type n_dofs() const
virtual void zero()=0
Set all entries to zero.
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 add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
virtual void update_RB_system_matrices() override
Compute the reduced basis matrices for the current basis.
void set_time_step(const unsigned int k)
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.
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.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > M_q_representor
Vector storing the mass matrix representors.
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 ...
void assemble_L2_matrix(SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the L2 matrix.
void pull_temporal_discretization_data(RBTemporalDiscretization &other)
Pull the temporal discretization data from other.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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.
Real final_linear_residual() const
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
virtual void zero()=0
Set all entries to 0.
std::vector< Real > initial_L2_error_all_N
Vector storing initial L2 error for all 1 <= N <= RB_size.
virtual T el(const unsigned int i, const unsigned int j) const override final
unsigned int n_linear_iterations() const
void svd(DenseVector< Real > &sigma)
Compute the singular value decomposition of the matrix.
void set_L2_assembly(ElemAssembly &L2_assembly_in)
Set the L2 object.
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 enrich_RB_space() override
Add a new basis functions to the RB space.
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.
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 unsigned int get_n_M_terms() const
Get Q_m, the number of terms in the affine expansion for the mass operator.
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.
Number set_error_temporal_data()
Set column k (i.e.
virtual void clear() override
Clear all the data structures associated with the system.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
virtual Number eval_F_theta(unsigned int q, const RBParameters &mu) const
Evaluate theta_q_f at the current parameter.
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...
bool nonzero_initialization
Boolean flag to indicate whether we are using a non-zero initialization.
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...
const RBParameters & get_parameters() const
Get the current parameters.
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.
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.
unsigned int get_time_step() const
Get/set the current time-step.
ElemAssembly & get_L2_assembly()
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...
This class is part of the rbOOmit framework.
bool is_rb_eval_initialized() const
unsigned int delta_N
The number of basis functions that we add at each greedy step.
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.
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.
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.
std::vector< DenseVector< Number > > RB_initial_condition_all_N
The RB initial conditions (i.e.
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.
TransientRBConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
void set_POD_tol(const Real POD_tol_in)
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
virtual void update()
Update the local values to reflect the solution on neighboring processors.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
void lu_solve(const DenseVector< T > &b, DenseVector< T > &x)
Solve the system Ax=b given the input vector b.
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 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.
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
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...
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
virtual void process_parameters_file(const std::string ¶meters_filename) override
Read in the parameters from file and set up the system accordingly.
virtual void clear() override
Clear all the data structures associated with the system.
SparseMatrix< Number > * matrix
The system matrix.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
std::vector< DenseVector< Number > > RB_temporal_solution_data
Array storing the solution data at each time level from the most recent solve.
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
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 ...
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.
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...
void add_scaled_mass_matrix(Number scalar, SparseMatrix< Number > *input_matrix)
Add the scaled mass matrix (assembled for the current parameter) to input_matrix. ...
virtual ~TransientRBConstruction()
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
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...
const NumericVector< Number > & get_error_temporal_data()
Get the column of temporal_data corresponding to the current time level.
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
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...
std::vector< std::vector< std::vector< std::vector< Number > > > > Aq_Mq_representor_innerprods
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...
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...
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.
void add_IC_to_RB_space()
Initialize RB space by adding the truth initial condition as the first RB basis function.
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
SparseMatrix< Number > * get_non_dirichlet_M_q(unsigned int q)
Get a pointer to non_dirichlet_M_q.
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.
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 ...
const DofMap & get_dof_map() const
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
Real get_control(const unsigned int k) const
Get/set the RHS control.
DenseMatrix< Number > RB_L2_matrix
Dense RB L2 matrix.
virtual void assemble_misc_matrices() override
Override to assemble the L2 matrix as well.
virtual void update_system() override
Update the system after enriching the RB space.
virtual void print_info() const override
Print out info that describes the current setup of this RBConstruction.
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.
DenseVector< Number > RB_ic_proj_rhs_all_N
The vector that stores the right-hand side for the initial condition projections. ...
virtual void assemble_all_affine_operators()
Assemble and store all Q_a affine operators as well as the inner-product 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.